@tutti-os/agent-gui 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AgentMentionSearchController-DqssJ2-b.d.ts → AgentMentionSearchController-2Vjvmzh3.d.ts} +0 -1
- package/dist/agent-conversation/index.d.ts +2 -2
- package/dist/agent-conversation/index.js +4 -4
- package/dist/agent-message-center/index.d.ts +1 -1
- package/dist/agent-message-center/index.js +3 -3
- package/dist/{agentConversationVM-BVe64P2E.d.ts → agentConversationVM-D09Aw-Ei.d.ts} +4 -0
- package/dist/{chunk-FEWMACBN.js → chunk-5H4ISRJQ.js} +3 -3
- package/dist/{chunk-4RUK7VPA.js → chunk-7IFIA3DC.js} +35 -13
- package/dist/chunk-7IFIA3DC.js.map +1 -0
- package/dist/{chunk-S5GS4GRM.js → chunk-7THDJWRR.js} +32 -48
- package/dist/chunk-7THDJWRR.js.map +1 -0
- package/dist/{chunk-DT4W5Z2A.js → chunk-DIBNU26G.js} +32 -11
- package/dist/chunk-DIBNU26G.js.map +1 -0
- package/dist/{chunk-O5TUTXHT.js → chunk-IEBWFP7O.js} +1 -1
- package/dist/chunk-IEBWFP7O.js.map +1 -0
- package/dist/{chunk-HIREVEZM.js → chunk-JM24HADP.js} +1 -1
- package/dist/chunk-JM24HADP.js.map +1 -0
- package/dist/{chunk-5Z5HILKT.js → chunk-XAQQN6MP.js} +50 -184
- package/dist/chunk-XAQQN6MP.js.map +1 -0
- package/dist/context-mention-palette/index.d.ts +2 -2
- package/dist/context-mention-palette/index.js +4 -4
- package/dist/context-mention-provider.d.ts +4 -40
- package/dist/context-mention-provider.js +1 -1
- package/dist/index.d.ts +38 -3
- package/dist/index.js +229 -50
- package/dist/index.js.map +1 -1
- package/dist/plan-decision-ops.d.ts +1 -1
- package/package.json +12 -12
- package/dist/chunk-4RUK7VPA.js.map +0 -1
- package/dist/chunk-5Z5HILKT.js.map +0 -1
- package/dist/chunk-DT4W5Z2A.js.map +0 -1
- package/dist/chunk-HIREVEZM.js.map +0 -1
- package/dist/chunk-O5TUTXHT.js.map +0 -1
- package/dist/chunk-S5GS4GRM.js.map +0 -1
- /package/dist/{chunk-FEWMACBN.js.map → chunk-5H4ISRJQ.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../agentActivityRuntime.tsx","../agentActivityHost.tsx","../host/agentHostApi.ts"],"sourcesContent":["import {\n createContext,\n useContext,\n useSyncExternalStore,\n type JSX,\n type PropsWithChildren\n} from \"react\";\nimport type {\n AgentActivityCancelSessionInput,\n AgentActivityCancelSessionResult,\n AgentActivityCreateSessionInput,\n AgentActivityDeleteSessionInput,\n AgentActivityDeleteSessionResult,\n AgentActivityMessageOrder,\n AgentActivityMessagePage,\n AgentActivitySendInput,\n AgentActivitySession,\n AgentActivitySnapshot,\n AgentActivitySnapshotListener,\n AgentActivitySubmitInteractiveInput\n} from \"@tutti-os/agent-activity-core\";\nimport type {\n AgentHostAgentSessionComposerSettings,\n AgentHostActivateAgentSessionResult,\n AgentHostRuntimeOpenclawGatewayWarmupResult,\n AgentHostUpdateAgentSessionSettingsResult,\n AgentHostUnactivateAgentSessionResult,\n AgentHostAgentSessionState\n} from \"./shared/contracts/dto\";\n\nexport interface AgentActivityRuntimeListSessionMessagesInput {\n afterVersion?: number;\n beforeVersion?: number;\n agentSessionId: string;\n limit?: number;\n order?: AgentActivityMessageOrder;\n signal?: AbortSignal;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeListGeneratedFilesInput {\n limit?: number;\n query?: string;\n sessionCwd?: string;\n signal?: AbortSignal;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGeneratedFile {\n label: string;\n path: string;\n}\n\nexport interface AgentActivityRuntimeGeneratedFileList {\n entries: AgentActivityRuntimeGeneratedFile[];\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeEnsureSessionSynchronizedInput {\n afterVersion?: number;\n agentSessionId: string;\n onError?: (error: unknown) => void;\n workspaceId: string;\n}\n\nexport type AgentActivityRuntimeRetainSessionEventsInput =\n AgentActivityRuntimeEnsureSessionSynchronizedInput;\n\nexport interface AgentActivityRuntimeSetSessionPinnedInput {\n agentSessionId: string;\n pinned: boolean;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeTrackSettingsProjectChangeInput {\n action: \"clear\" | \"create_new\" | \"select_existing\";\n agentSessionId: string;\n provider?: string | null;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGetSessionControlStateInput {\n agentSessionId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGetComposerOptionsInput {\n cwd?: string | null;\n force?: boolean;\n provider?: string;\n settings?: AgentHostAgentSessionComposerSettings | null;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUpdateSessionSettingsInput {\n agentSessionId: string;\n settings: AgentHostAgentSessionComposerSettings;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeTrackDraftComposerSettingsChangeInput {\n nextSettings: AgentHostAgentSessionComposerSettings;\n previousSettings: AgentHostAgentSessionComposerSettings;\n provider: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeWarmupOpenclawGatewayInput {\n workspaceId?: string | null;\n}\n\nexport interface AgentActivityRuntimeDiagnosticInput {\n details?: Record<string, unknown>;\n event: string;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\";\n source?: string;\n workspaceId?: string | null;\n}\n\nexport interface AgentActivityRuntimeActivateSessionInput {\n agentSessionId: string;\n cwd?: string;\n initialContent?: AgentActivitySendInput[\"content\"];\n /** 仅展示用首轮文本(bundle 折叠成一个 chip);initialContent 仍带展开后的文件。 */\n initialDisplayPrompt?: string | null;\n mode: \"existing\" | \"new\";\n openclawGatewayReady?: boolean;\n provider?: string;\n settings?: AgentHostAgentSessionComposerSettings;\n title?: string;\n visible?: boolean;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUnactivateSessionInput {\n agentSessionId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeReadSessionAttachmentInput {\n agentSessionId: string;\n attachmentId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeReadPromptAssetInput {\n agentSessionId?: string | null;\n assetId?: string | null;\n mimeType: string;\n name?: string | null;\n path?: string | null;\n sha256?: string | null;\n uploadStatus?: \"pending\" | \"uploaded\" | \"failed\" | string | null;\n uri?: string | null;\n workspaceId: string;\n}\n\nexport type AgentActivityRuntimePromptContentBlock =\n AgentActivitySendInput[\"content\"][number] & {\n assetId?: string;\n path?: string;\n uri?: string;\n uploadStatus?: \"pending\" | \"uploaded\" | \"failed\" | string;\n };\n\nexport interface AgentActivityRuntimeUploadPromptContentInput {\n content: AgentActivityRuntimePromptContentBlock[];\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUploadPromptContentResult {\n content: AgentActivityRuntimePromptContentBlock[];\n}\n\nexport interface AgentActivityRuntimeSessionAttachment {\n attachmentId: string;\n mimeType: string;\n name?: string;\n data: string;\n}\n\nexport interface AgentActivityRuntimePromptAsset {\n assetId?: string;\n mimeType: string;\n name?: string;\n path: string;\n uri?: string;\n uploadStatus?: \"pending\" | \"uploaded\" | \"failed\" | string;\n data: string;\n}\n\nexport interface AgentActivityRuntime {\n cancelSession(\n input: AgentActivityCancelSessionInput\n ): Promise<AgentActivityCancelSessionResult>;\n createSession(\n input: AgentActivityCreateSessionInput\n ): Promise<AgentActivitySession>;\n deleteSession(\n input: AgentActivityDeleteSessionInput\n ): Promise<AgentActivityDeleteSessionResult>;\n activateSession(\n input: AgentActivityRuntimeActivateSessionInput\n ): Promise<AgentHostActivateAgentSessionResult>;\n getSession(\n workspaceId: string,\n agentSessionId: string\n ): Promise<AgentActivitySession>;\n getComposerOptions(\n input: AgentActivityRuntimeGetComposerOptionsInput\n ): Promise<unknown>;\n updateSessionSettings(\n input: AgentActivityRuntimeUpdateSessionSettingsInput\n ): Promise<AgentHostUpdateAgentSessionSettingsResult>;\n warmupOpenclawGateway?(\n input?: AgentActivityRuntimeWarmupOpenclawGatewayInput\n ): Promise<AgentHostRuntimeOpenclawGatewayWarmupResult>;\n getSessionControlState(\n input: AgentActivityRuntimeGetSessionControlStateInput\n ): Promise<AgentHostAgentSessionState>;\n getSnapshot(workspaceId: string): AgentActivitySnapshot;\n listSessionMessages(\n input: AgentActivityRuntimeListSessionMessagesInput\n ): Promise<AgentActivityMessagePage>;\n listAgentGeneratedFiles?(\n input: AgentActivityRuntimeListGeneratedFilesInput\n ): Promise<AgentActivityRuntimeGeneratedFileList>;\n load(\n workspaceId: string,\n signal?: AbortSignal\n ): Promise<AgentActivitySnapshot>;\n ensureSessionSynchronized?(\n input: AgentActivityRuntimeEnsureSessionSynchronizedInput\n ): () => void;\n /** @deprecated Use ensureSessionSynchronized. */\n retainSessionEvents(\n input: AgentActivityRuntimeRetainSessionEventsInput\n ): () => void;\n sendInput(input: AgentActivitySendInput): Promise<AgentActivitySession>;\n uploadPromptContent?(\n input: AgentActivityRuntimeUploadPromptContentInput\n ): Promise<AgentActivityRuntimeUploadPromptContentResult>;\n readSessionAttachment?(\n input: AgentActivityRuntimeReadSessionAttachmentInput\n ): Promise<AgentActivityRuntimeSessionAttachment>;\n readPromptAsset?(\n input: AgentActivityRuntimeReadPromptAssetInput\n ): Promise<AgentActivityRuntimePromptAsset>;\n setSessionPinned(\n input: AgentActivityRuntimeSetSessionPinnedInput\n ): Promise<AgentActivitySession>;\n trackSettingsProjectChange?(\n input: AgentActivityRuntimeTrackSettingsProjectChangeInput\n ): Promise<void>;\n trackDraftComposerSettingsChange?(\n input: AgentActivityRuntimeTrackDraftComposerSettingsChangeInput\n ): Promise<void>;\n reportDiagnostic?(\n input: AgentActivityRuntimeDiagnosticInput\n ): Promise<void> | void;\n unactivateSession(\n input: AgentActivityRuntimeUnactivateSessionInput\n ): Promise<AgentHostUnactivateAgentSessionResult>;\n submitInteractive(\n input: AgentActivitySubmitInteractiveInput\n ): Promise<unknown>;\n subscribeSessionEvents(\n workspaceId: string,\n listener: (event: unknown) => void\n ): () => void;\n subscribe(\n workspaceId: string,\n listener: AgentActivitySnapshotListener\n ): () => void;\n}\n\nconst AgentActivityRuntimeContext = createContext<AgentActivityRuntime | null>(\n null\n);\n\nlet currentAgentActivityRuntime: AgentActivityRuntime | null = null;\n\nexport interface AgentActivityRuntimeProviderProps extends PropsWithChildren {\n runtime?: AgentActivityRuntime | null;\n}\n\nexport function AgentActivityRuntimeProvider({\n children,\n runtime\n}: AgentActivityRuntimeProviderProps): JSX.Element {\n currentAgentActivityRuntime = runtime ?? null;\n return (\n <AgentActivityRuntimeContext.Provider value={runtime ?? null}>\n {children}\n </AgentActivityRuntimeContext.Provider>\n );\n}\n\nexport function useAgentActivityRuntime(): AgentActivityRuntime {\n const runtime =\n useContext(AgentActivityRuntimeContext) ?? getTestAgentActivityRuntime();\n if (!runtime) {\n throw new Error(\n \"AgentActivityRuntimeProvider is missing an AgentActivityRuntime instance.\"\n );\n }\n return runtime;\n}\n\nexport function useOptionalAgentActivityRuntime(): AgentActivityRuntime | null {\n return (\n useContext(AgentActivityRuntimeContext) ?? getTestAgentActivityRuntime()\n );\n}\n\nexport function useAgentActivitySnapshot(\n workspaceId: string\n): AgentActivitySnapshot {\n const runtime = useAgentActivityRuntime();\n const normalizedWorkspaceId = workspaceId.trim();\n return useSyncExternalStore(\n (listener) => runtime.subscribe(normalizedWorkspaceId, listener),\n () => runtime.getSnapshot(normalizedWorkspaceId),\n () => runtime.getSnapshot(normalizedWorkspaceId)\n );\n}\n\nexport function getAgentActivityRuntime(): AgentActivityRuntime {\n const runtime =\n getExplicitWindowTestAgentActivityRuntime() ??\n currentAgentActivityRuntime ??\n getTestAgentActivityRuntime();\n if (!runtime) {\n throw new Error(\n \"AgentActivityRuntimeProvider is missing an AgentActivityRuntime instance.\"\n );\n }\n return runtime;\n}\n\nexport function getOptionalAgentActivityRuntime(): AgentActivityRuntime | null {\n return (\n getExplicitWindowTestAgentActivityRuntime() ??\n currentAgentActivityRuntime ??\n getTestAgentActivityRuntime()\n );\n}\n\nexport function resetAgentActivityRuntimeForTests(): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentActivityRuntime = null;\n }\n}\n\nexport function setAgentActivityRuntimeForTests(\n runtime: AgentActivityRuntime | null\n): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentActivityRuntime = runtime;\n }\n}\n\nfunction getTestAgentActivityRuntime(): AgentActivityRuntime | null {\n if (process.env.NODE_ENV !== \"test\") {\n return null;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n const explicitRuntime = getExplicitWindowTestAgentActivityRuntime();\n if (explicitRuntime) {\n return explicitRuntime;\n }\n if (currentAgentActivityRuntime) {\n return currentAgentActivityRuntime;\n }\n const testRuntime = (\n window as unknown as Window & {\n agentActivityRuntime?: AgentActivityRuntime;\n }\n ).agentActivityRuntime;\n return testRuntime ?? null;\n}\n\nfunction getExplicitWindowTestAgentActivityRuntime(): AgentActivityRuntime | null {\n if (process.env.NODE_ENV !== \"test\" || typeof window === \"undefined\") {\n return null;\n }\n const testDescriptor = Object.getOwnPropertyDescriptor(\n window,\n \"agentActivityRuntime\"\n );\n if (!testDescriptor || !(\"value\" in testDescriptor)) {\n return null;\n }\n return (testDescriptor.value as AgentActivityRuntime | undefined) ?? null;\n}\n","import {\n createContext,\n useContext,\n useMemo,\n type JSX,\n type PropsWithChildren\n} from \"react\";\nimport {\n toAgentHostRuntimeApi,\n type AgentHostInputApi,\n type AgentHostRuntimeApi\n} from \"./host/agentHostApi\";\nimport {\n AgentActivityRuntimeProvider,\n type AgentActivityRuntime\n} from \"./agentActivityRuntime\";\n\nconst AgentActivityHostContext = createContext<AgentHostRuntimeApi | null>(\n null\n);\n\nlet currentAgentHostApi: AgentHostRuntimeApi | null = null;\n\nexport interface AgentActivityHostProviderProps extends PropsWithChildren {\n agentActivityRuntime?: AgentActivityRuntime | null;\n agentHostApi?: AgentHostInputApi | null;\n}\n\nexport function AgentActivityHostProvider({\n agentActivityRuntime,\n agentHostApi,\n children\n}: AgentActivityHostProviderProps): JSX.Element {\n const resolvedAgentHostApi = useMemo(\n () => (agentHostApi ? toAgentHostRuntimeApi(agentHostApi) : null),\n [agentHostApi]\n );\n currentAgentHostApi = resolvedAgentHostApi;\n return (\n <AgentActivityRuntimeProvider runtime={agentActivityRuntime}>\n <AgentActivityHostContext.Provider value={resolvedAgentHostApi}>\n {children}\n </AgentActivityHostContext.Provider>\n </AgentActivityRuntimeProvider>\n );\n}\n\nexport function useAgentHostApi(): AgentHostRuntimeApi {\n const agentHostApi =\n useContext(AgentActivityHostContext) ?? getTestAgentHostApi();\n if (!agentHostApi) {\n throw new Error(\n \"AgentActivityHostProvider is missing an agentHostApi instance.\"\n );\n }\n return agentHostApi;\n}\n\nexport function useOptionalAgentHostApi(): AgentHostRuntimeApi | null {\n return useContext(AgentActivityHostContext) ?? getTestAgentHostApi();\n}\n\nexport function getAgentHostApi(): AgentHostRuntimeApi {\n const agentHostApi =\n getExplicitWindowTestAgentHostApi() ??\n currentAgentHostApi ??\n getTestAgentHostApi();\n if (!agentHostApi) {\n throw new Error(\n \"AgentActivityHostProvider is missing an agentHostApi instance.\"\n );\n }\n return agentHostApi;\n}\n\nexport function getOptionalAgentHostApi(): AgentHostRuntimeApi | null {\n return (\n getExplicitWindowTestAgentHostApi() ??\n currentAgentHostApi ??\n getTestAgentHostApi()\n );\n}\n\nexport function resetAgentHostApiForTests(): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentHostApi = null;\n }\n}\n\nexport function setAgentHostApiForTests(\n agentHostApi: AgentHostInputApi | AgentHostRuntimeApi | null\n): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentHostApi = agentHostApi\n ? toAgentHostRuntimeApi(agentHostApi)\n : null;\n }\n}\n\nfunction getTestAgentHostApi(): AgentHostRuntimeApi | null {\n if (process.env.NODE_ENV !== \"test\") {\n return null;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n const explicitAgentHostApi = getExplicitWindowTestAgentHostApi();\n if (explicitAgentHostApi) {\n return explicitAgentHostApi;\n }\n if (currentAgentHostApi) {\n return currentAgentHostApi;\n }\n const testAgentHostApi = (\n window as unknown as Window & {\n agentHostApi?: AgentHostInputApi | AgentHostRuntimeApi;\n }\n ).agentHostApi;\n return testAgentHostApi ? toAgentHostRuntimeApi(testAgentHostApi) : null;\n}\n\nfunction getExplicitWindowTestAgentHostApi(): AgentHostRuntimeApi | null {\n if (process.env.NODE_ENV !== \"test\" || typeof window === \"undefined\") {\n return null;\n }\n const testDescriptor = Object.getOwnPropertyDescriptor(\n window,\n \"agentHostApi\"\n );\n if (!testDescriptor || !(\"value\" in testDescriptor)) {\n return null;\n }\n const testAgentHostApi = testDescriptor.value as\n | AgentHostInputApi\n | AgentHostRuntimeApi\n | undefined;\n return testAgentHostApi ? toAgentHostRuntimeApi(testAgentHostApi) : null;\n}\n","import type {\n AgentHostBatchUserInfoInput,\n AgentHostBatchUserInfoResult,\n AgentHostDeleteWorkspaceAgentSessionInput,\n AgentHostWorkspaceAgentListInput as AgentHostListWorkspaceAgentsInput,\n AgentHostListWorkspaceAgentProbesInput,\n AgentHostWorkspaceAgentSessionMessages,\n AgentHostWorkspaceAgentSessionMessagesInput,\n AgentHostWorkspaceAgentSessionSummary,\n AgentHostWorkspaceAgentSessionSummaryInput,\n AgentHostWorkspaceAgentProbesResult,\n AgentHostWorkspaceAgentSnapshot,\n ReadWorkspaceFileResult as AgentHostReadWorkspaceFileResult\n} from \"../shared/contracts/dto\";\nimport type { WorkspaceUserProjectService } from \"@tutti-os/workspace-user-project/contracts\";\n\ntype AgentHostAsyncResult<T = any> = Promise<T>;\ntype AgentHostRecord = Record<string, unknown>;\ntype AgentHostUnsubscribe = () => void;\ntype AgentHostWorkspaceScopedInput<\n T extends {\n workspaceId?: string | null;\n }\n> = Omit<T, \"workspaceId\"> & {\n workspaceId: string;\n};\ntype AgentHostWorkspaceAgentsListInput =\n AgentHostWorkspaceScopedInput<AgentHostListWorkspaceAgentsInput>;\ntype AgentHostWorkspaceAgentSessionMessagesRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostWorkspaceAgentSessionMessagesInput>;\ntype AgentHostWorkspaceAgentSessionSummaryRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostWorkspaceAgentSessionSummaryInput>;\ntype AgentHostDeleteWorkspaceAgentSessionRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostDeleteWorkspaceAgentSessionInput>;\n\nexport type AgentHostClipboardApi = {\n writeText: (text: string) => AgentHostAsyncResult<void>;\n};\n\nexport type AgentHostDebugApi = {\n logRuntimeDiagnostics: (\n payload: unknown\n ) => AgentHostAsyncResult<void> | void;\n logTerminalDiagnostics?: (\n payload: unknown\n ) => AgentHostAsyncResult<void> | void;\n};\n\nexport type AgentHostFilesystemApi = AgentHostRecord & {\n readFileText: (payload: {\n path?: string;\n uri?: string;\n }) => AgentHostAsyncResult<{\n content: string;\n name?: string;\n path?: string;\n }>;\n};\n\nexport type AgentHostMetaApi = AgentHostRecord & {\n appVersion?: string | null;\n isPackaged?: boolean;\n isTest?: boolean;\n mainPid?: number | null;\n platform?: string;\n workspaceId?: string;\n};\n\nexport type AgentHostEnvironmentApi = AgentHostRecord & {\n getBaseUrl?: () => AgentHostAsyncResult<string>;\n warmupOpenclawGateway?: (input?: unknown) => AgentHostAsyncResult<unknown>;\n};\n\nexport interface AgentHostSelectedFile {\n name?: string;\n path: string;\n}\n\nexport type AgentHostWorkspaceApi = AgentHostRecord & {\n copyPath?: (input: { path: string }) => AgentHostAsyncResult<void>;\n ensureDirectory: (input: { path: string }) => AgentHostAsyncResult<void>;\n getPathForFile: (file: File) => string;\n readFile: (input: {\n path: string;\n }) => AgentHostAsyncResult<AgentHostReadWorkspaceFileResult>;\n selectContextEntries?: () => AgentHostAsyncResult<{ entries: unknown[] }>;\n selectDirectory: () => AgentHostAsyncResult<{ path: string } | null>;\n selectFiles: () => AgentHostAsyncResult<AgentHostSelectedFile[]>;\n writeFileText: (input: {\n content: string;\n path: string;\n }) => AgentHostAsyncResult<unknown>;\n};\n\nexport interface AgentHostInputApi {\n account?: AgentHostAccountApi;\n agentGuiBatch?: AgentHostAgentGuiBatchApi;\n agentSessions?: AgentHostAgentSessionsApi;\n clipboard: AgentHostClipboardApi;\n debug?: AgentHostDebugApi;\n filesystem: AgentHostFilesystemApi;\n meta?: AgentHostMetaApi;\n onHostEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n runtime?: AgentHostEnvironmentApi;\n userProjects?: AgentHostUserProjectsApi;\n workspace: AgentHostWorkspaceApi;\n workspaceAgentProbes?: AgentHostWorkspaceAgentProbesApi;\n workspaceAgents?: AgentHostWorkspaceAgentsApi;\n}\n\nexport type AgentHostApi = AgentHostInputApi;\n\nexport type AgentHostAccountApi = AgentHostRecord & {\n batchGetUserInfo: (\n input: AgentHostBatchUserInfoInput\n ) => AgentHostAsyncResult<AgentHostBatchUserInfoResult>;\n ensureProfiles?: (input: any) => AgentHostAsyncResult<any>;\n};\n\nexport type AgentHostAgentGuiBatchApi = AgentHostRecord & {\n exportRun: (input: any) => AgentHostAsyncResult<any>;\n};\n\nexport type AgentHostWorkspaceAgentProbesApi = AgentHostRecord & {\n list: (\n input: AgentHostListWorkspaceAgentProbesInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentProbesResult>;\n};\n\nexport type AgentProviderProbeListInput =\n AgentHostListWorkspaceAgentProbesInput;\nexport type AgentProviderProbeListResult = AgentHostWorkspaceAgentProbesResult;\n\nexport interface AgentHostUserProject {\n id: string;\n path: string;\n label: string;\n createdAtUnixMs?: number;\n updatedAtUnixMs?: number;\n lastUsedAtUnixMs?: number;\n}\n\nexport type AgentHostUserProjectsApi = AgentHostRecord & {\n service?: WorkspaceUserProjectService;\n checkPath?: (input: { path: string }) => AgentHostAsyncResult<{\n exists: boolean;\n isDirectory: boolean;\n path: string;\n }>;\n create?: (input: {\n name: string;\n }) => AgentHostAsyncResult<AgentHostUserProject>;\n getDefaultSelection?: () => AgentHostAsyncResult<{\n path: string | null;\n } | null>;\n list: () => AgentHostAsyncResult<{\n projects: AgentHostUserProject[];\n }>;\n subscribe?: (listener: () => void) => AgentHostUnsubscribe;\n prepareSelection?: (input: {\n projectLocked: boolean;\n selectedPath: string | null;\n }) => AgentHostAsyncResult<{\n isSelectedPathMissing: boolean;\n projects: AgentHostUserProject[];\n selection:\n | {\n kind: \"clear\";\n suppressedPath: string;\n }\n | {\n kind: \"none\";\n }\n | {\n kind: \"select\";\n path: string;\n };\n }>;\n remove?: (input: { path: string }) => AgentHostAsyncResult<void>;\n isNoProjectPath?: (input: { path: string }) => boolean;\n rememberDefaultSelection?: (input: {\n path: string | null;\n }) => AgentHostAsyncResult<void>;\n use: (input: { path: string }) => AgentHostAsyncResult<AgentHostUserProject>;\n};\n\nexport type AgentHostAgentSessionsApi = AgentHostRecord & {\n activate: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.cancelSession.\n */\n cancel: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.sendInput.\n */\n exec: (input: any) => AgentHostAsyncResult<any>;\n getComposerOptions?: (input: any) => AgentHostAsyncResult<any>;\n getState: (input: any) => AgentHostAsyncResult<any>;\n onEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.setSessionPinned.\n */\n pinSession?: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production sync must use AgentActivityRuntime.ensureSessionSynchronized.\n */\n releaseEventStream?: (input?: any) => AgentHostAsyncResult;\n /**\n * @deprecated AgentGUI production sync must use AgentActivityRuntime.ensureSessionSynchronized.\n */\n retainEventStream?: (input: any) => AgentHostAsyncResult;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.submitInteractive.\n */\n submitInteractive: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production UI must derive events from AgentActivityRuntime snapshots.\n */\n trackSettingsProjectChange?: (input: {\n action: \"clear\" | \"create_new\" | \"select_existing\";\n agentSessionId: string;\n provider?: string | null;\n }) => AgentHostAsyncResult<void>;\n subscribeEvents: (\n input: any,\n listener: (event: any) => void\n ) => AgentHostUnsubscribe;\n unactivate: (input: any) => AgentHostAsyncResult<any>;\n updateSettings: (input: any) => AgentHostAsyncResult<any>;\n};\n\n/**\n * @deprecated Legacy host DTO projection. AgentGUI production reads and writes\n * must use AgentActivityRuntime and AgentActivity* models.\n */\nexport type AgentHostWorkspaceAgentsApi = AgentHostRecord & {\n /**\n * @deprecated Use AgentActivityRuntime.deleteSession.\n */\n deleteSession: (\n input: AgentHostDeleteWorkspaceAgentSessionRuntimeInput\n ) => AgentHostAsyncResult<any>;\n /**\n * @deprecated Derive summaries from AgentActivitySnapshot/session messages.\n */\n getSessionSummary: (\n input: AgentHostWorkspaceAgentSessionSummaryRuntimeInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSessionSummary>;\n /**\n * @deprecated Use AgentActivityRuntime.load/getSnapshot.\n */\n list: (\n input: string | AgentHostWorkspaceAgentsListInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSnapshot>;\n /**\n * @deprecated Use AgentActivityRuntime.listSessionMessages.\n */\n listSessionMessages: (\n input: AgentHostWorkspaceAgentSessionMessagesRuntimeInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSessionMessages>;\n};\n\nexport interface AgentHostRuntimeApi {\n account?: AgentHostAccountApi;\n agentGuiBatch: AgentHostAgentGuiBatchApi;\n clipboard: AgentHostClipboardApi;\n debug?: AgentHostDebugApi;\n filesystem: AgentHostFilesystemApi;\n meta?: AgentHostMetaApi;\n onHostEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n runtime?: AgentHostEnvironmentApi;\n userProjects?: AgentHostUserProjectsApi;\n workspace: AgentHostWorkspaceApi;\n workspaceAgentProbes?: AgentHostWorkspaceAgentProbesApi;\n}\n\nexport function toAgentHostRuntimeApi(\n hostApi: AgentHostInputApi | AgentHostRuntimeApi\n): AgentHostRuntimeApi {\n return {\n account: hostApi.account,\n agentGuiBatch: hostApi.agentGuiBatch ?? ({} as AgentHostAgentGuiBatchApi),\n clipboard: hostApi.clipboard,\n debug: hostApi.debug,\n filesystem: hostApi.filesystem,\n meta: hostApi.meta,\n onHostEvent: hostApi.onHostEvent,\n runtime: hostApi.runtime,\n userProjects: hostApi.userProjects,\n workspace: hostApi.workspace,\n workspaceAgentProbes: hostApi.workspaceAgentProbes\n };\n}\n"],"mappings":"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","names":["createContext","useContext","jsx","createContext","useContext"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../agent-gui/agentGuiNode/agentContextMentionProvider.ts"],"sourcesContent":["import type {\n RichTextTriggerInsertResult,\n RichTextTriggerProvider,\n RichTextTriggerQueryInput\n} from \"@tutti-os/ui-rich-text/types\";\nimport {\n TUTTI_EXTERNAL_AT_PROVIDER_IDS,\n type TuttiExternalAtProviderId\n} from \"@tutti-os/workspace-external-core/contracts\";\n\nexport const AGENT_CONTEXT_MENTION_PROVIDER_IDS =\n TUTTI_EXTERNAL_AT_PROVIDER_IDS;\n\nexport type AgentContextMentionProviderId = TuttiExternalAtProviderId;\n\nexport type AgentContextMentionQueryInput = RichTextTriggerQueryInput & {\n trigger: \"@\";\n};\n\nexport type AgentContextMentionInsertResult = RichTextTriggerInsertResult;\n\nexport type AgentContextMentionProvider<TItem = any> = Omit<\n RichTextTriggerProvider<TItem>,\n \"trigger\"\n> & {\n trigger: \"@\";\n};\n"],"mappings":";AAKA;AAAA,EACE;AAAA,OAEK;AAEA,IAAM,qCACX;","names":[]}
|
|
@@ -13,6 +13,12 @@ import { PluginKey } from "@tiptap/pm/state";
|
|
|
13
13
|
import { ReactNodeViewRenderer } from "@tiptap/react";
|
|
14
14
|
import Suggestion, { exitSuggestion } from "@tiptap/suggestion";
|
|
15
15
|
import { isRichTextTriggerPrefixBoundary } from "@tutti-os/ui-rich-text/editor";
|
|
16
|
+
import {
|
|
17
|
+
createRichTextLinkMarkdown,
|
|
18
|
+
createRichTextMentionMarkdown,
|
|
19
|
+
isRichTextMentionHref,
|
|
20
|
+
parseRichTextMentionHref
|
|
21
|
+
} from "@tutti-os/ui-rich-text/core";
|
|
16
22
|
|
|
17
23
|
// agent-gui/agentGuiNode/agentRichText/AgentMentionNodeView.tsx
|
|
18
24
|
import { useEffect, useState } from "react";
|
|
@@ -49,54 +55,6 @@ function normalizeKind(value) {
|
|
|
49
55
|
}
|
|
50
56
|
return "file";
|
|
51
57
|
}
|
|
52
|
-
function buildMentionHref(resource, attrs) {
|
|
53
|
-
const workspaceId = attrString(attrs, "workspaceId").trim();
|
|
54
|
-
const targetId = attrString(attrs, "targetId").trim();
|
|
55
|
-
if (resource === "workspace-issue") {
|
|
56
|
-
return buildAgentGenericMentionHref(resource, targetId, {
|
|
57
|
-
topicId: attrString(attrs, "topicId").trim(),
|
|
58
|
-
workspaceId
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (resource === "workspace-reference") {
|
|
62
|
-
return buildAgentGenericMentionHref(resource, targetId, {
|
|
63
|
-
source: attrString(attrs, "source").trim(),
|
|
64
|
-
groupId: attrString(attrs, "groupId").trim(),
|
|
65
|
-
icon: attrString(attrs, "iconUrl").trim(),
|
|
66
|
-
count: attrString(attrs, "fileCount").trim(),
|
|
67
|
-
workspaceId
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (resource === "workspace-app") {
|
|
71
|
-
const appId = attrString(attrs, "appId").trim() || targetId;
|
|
72
|
-
return buildAgentGenericMentionHref(resource, appId, { workspaceId });
|
|
73
|
-
}
|
|
74
|
-
if (resource === "workspace-app-factory") {
|
|
75
|
-
const jobId = attrString(attrs, "jobId").trim() || targetId;
|
|
76
|
-
return buildAgentGenericMentionHref(resource, jobId || "create", {
|
|
77
|
-
action: attrString(attrs, "action").trim(),
|
|
78
|
-
contextPath: attrString(attrs, "contextPath").trim(),
|
|
79
|
-
workspaceId
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
return buildAgentGenericMentionHref(resource, targetId, { workspaceId });
|
|
83
|
-
}
|
|
84
|
-
function buildAgentGenericMentionHref(providerId, entityId, scope) {
|
|
85
|
-
const normalizedProviderId = providerId.trim();
|
|
86
|
-
const normalizedEntityId = entityId.trim();
|
|
87
|
-
if (!normalizedProviderId || !normalizedEntityId) {
|
|
88
|
-
return "";
|
|
89
|
-
}
|
|
90
|
-
const params = new URLSearchParams();
|
|
91
|
-
Object.entries(scope ?? {}).map(([key, value]) => [key.trim(), value?.trim() ?? ""]).filter(([key, value]) => key && value).sort(([left], [right]) => left.localeCompare(right)).forEach(([key, value]) => {
|
|
92
|
-
params.set(key, value);
|
|
93
|
-
});
|
|
94
|
-
const query = params.toString();
|
|
95
|
-
const href = `mention://${encodeURIComponent(
|
|
96
|
-
normalizedProviderId
|
|
97
|
-
)}/${encodeURIComponent(normalizedEntityId)}`;
|
|
98
|
-
return query ? `${href}?${query}` : href;
|
|
99
|
-
}
|
|
100
58
|
function normalizeSessionTitle(value) {
|
|
101
59
|
const trimmed = value.trim();
|
|
102
60
|
const withoutMentionPrefix = trimmed.replace(/^@+/, "").trim();
|
|
@@ -156,7 +114,7 @@ function mentionViewModel(attrs, t) {
|
|
|
156
114
|
ariaLabel: `${t("agentHost.agentGui.mentionKindSession")} ${primary}`.trim(),
|
|
157
115
|
directoryPath: "",
|
|
158
116
|
entryKind: "",
|
|
159
|
-
href
|
|
117
|
+
href,
|
|
160
118
|
kind,
|
|
161
119
|
label: presentation.label,
|
|
162
120
|
summary: presentation.summary
|
|
@@ -167,7 +125,7 @@ function mentionViewModel(attrs, t) {
|
|
|
167
125
|
ariaLabel: `${t("agentHost.agentGui.mentionKindIssue")} ${name}`.trim(),
|
|
168
126
|
directoryPath: "",
|
|
169
127
|
entryKind: "",
|
|
170
|
-
href
|
|
128
|
+
href,
|
|
171
129
|
kind,
|
|
172
130
|
label: name
|
|
173
131
|
};
|
|
@@ -177,7 +135,7 @@ function mentionViewModel(attrs, t) {
|
|
|
177
135
|
ariaLabel: `${t("agentHost.agentGui.mentionKindApp")} ${name}`.trim(),
|
|
178
136
|
directoryPath: "",
|
|
179
137
|
entryKind: "",
|
|
180
|
-
href
|
|
138
|
+
href,
|
|
181
139
|
iconUrl: attrString(attrs, "iconUrl").trim() || void 0,
|
|
182
140
|
kind,
|
|
183
141
|
label: name
|
|
@@ -188,7 +146,7 @@ function mentionViewModel(attrs, t) {
|
|
|
188
146
|
ariaLabel: `${t("agentHost.agentGui.mentionKindApp")} ${name}`.trim(),
|
|
189
147
|
directoryPath: "",
|
|
190
148
|
entryKind: "",
|
|
191
|
-
href
|
|
149
|
+
href,
|
|
192
150
|
iconUrl: attrString(attrs, "iconUrl").trim() || void 0,
|
|
193
151
|
kind,
|
|
194
152
|
label: name,
|
|
@@ -200,7 +158,7 @@ function mentionViewModel(attrs, t) {
|
|
|
200
158
|
ariaLabel: `${t("agentHost.agentGui.mentionKindAppFactory")} ${name}`.trim(),
|
|
201
159
|
directoryPath: "",
|
|
202
160
|
entryKind: "",
|
|
203
|
-
href
|
|
161
|
+
href,
|
|
204
162
|
kind,
|
|
205
163
|
label: name
|
|
206
164
|
};
|
|
@@ -725,63 +683,22 @@ function createAgentFileMentionExtension(options = {}) {
|
|
|
725
683
|
}
|
|
726
684
|
});
|
|
727
685
|
}
|
|
728
|
-
function buildAgentSessionMentionHref(workspaceId, agentSessionId, _provider) {
|
|
729
|
-
return buildAgentGenericMentionHref2("agent-session", agentSessionId, {
|
|
730
|
-
workspaceId
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
function buildAgentWorkspaceIssueMentionHref(workspaceId, issueId, input) {
|
|
734
|
-
return buildAgentGenericMentionHref2("workspace-issue", issueId, {
|
|
735
|
-
workspaceId,
|
|
736
|
-
topicId: input?.topicId ?? void 0
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
function buildAgentWorkspaceAppMentionHref(workspaceId, appId) {
|
|
740
|
-
return buildAgentGenericMentionHref2("workspace-app", appId, {
|
|
741
|
-
workspaceId
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
function buildAgentWorkspaceReferenceMentionHref(workspaceId, handle, options) {
|
|
745
|
-
return buildAgentGenericMentionHref2("workspace-reference", handle.id, {
|
|
746
|
-
workspaceId,
|
|
747
|
-
source: handle.source,
|
|
748
|
-
groupId: handle.groupId?.trim() || void 0,
|
|
749
|
-
icon: options?.iconUrl?.trim() || void 0,
|
|
750
|
-
count: options?.fileCount != null && options.fileCount > 0 ? String(options.fileCount) : void 0
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
function buildAgentWorkspaceAppFactoryMentionHref(workspaceId, jobId, input) {
|
|
754
|
-
const params = new URLSearchParams();
|
|
755
|
-
const trimmedWorkspaceId = workspaceId?.trim() ?? "";
|
|
756
|
-
const trimmedJobId = jobId?.trim() ?? "";
|
|
757
|
-
const action = input?.action?.trim() ?? "";
|
|
758
|
-
const contextPath = input?.contextPath?.trim() ?? "";
|
|
759
|
-
if (trimmedWorkspaceId) {
|
|
760
|
-
params.set("workspaceId", trimmedWorkspaceId);
|
|
761
|
-
}
|
|
762
|
-
if (trimmedJobId) {
|
|
763
|
-
params.set("jobId", trimmedJobId);
|
|
764
|
-
}
|
|
765
|
-
if (action) {
|
|
766
|
-
params.set("action", action);
|
|
767
|
-
}
|
|
768
|
-
if (contextPath) {
|
|
769
|
-
params.set("contextPath", contextPath);
|
|
770
|
-
}
|
|
771
|
-
return buildAgentGenericMentionHref2(
|
|
772
|
-
"workspace-app-factory",
|
|
773
|
-
trimmedJobId || "create",
|
|
774
|
-
Object.fromEntries(params)
|
|
775
|
-
);
|
|
776
|
-
}
|
|
777
686
|
function normalizeAgentSessionMentionTitle(value) {
|
|
778
687
|
const trimmed = value.trim();
|
|
779
688
|
const withoutMentionPrefix = trimmed.replace(/^@+/, "").trim();
|
|
780
689
|
return withoutMentionPrefix || trimmed;
|
|
781
690
|
}
|
|
782
691
|
function formatAgentMentionMarkdown(item) {
|
|
783
|
-
|
|
784
|
-
|
|
692
|
+
if (item.kind === "file") {
|
|
693
|
+
const label = item.name.trim().startsWith("@") ? item.name : `@${item.name}`;
|
|
694
|
+
return createRichTextLinkMarkdown({
|
|
695
|
+
kind: "file",
|
|
696
|
+
name: label,
|
|
697
|
+
path: item.href
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
const identity = parseRichTextMentionHref(item.href, item.name);
|
|
701
|
+
return identity ? createRichTextMentionMarkdown(identity) : "";
|
|
785
702
|
}
|
|
786
703
|
function parseMentionFileCount(value) {
|
|
787
704
|
const parsed = typeof value === "number" ? value : typeof value === "string" ? Number.parseInt(value.trim(), 10) : Number.NaN;
|
|
@@ -839,7 +756,7 @@ function parseAgentMentionMarkdown(value, start = 0) {
|
|
|
839
756
|
if (!item) {
|
|
840
757
|
return null;
|
|
841
758
|
}
|
|
842
|
-
if (item.kind !== "file" && !prefixedMention && !href
|
|
759
|
+
if (item.kind !== "file" && !prefixedMention && !isRichTextMentionHref(href)) {
|
|
843
760
|
return null;
|
|
844
761
|
}
|
|
845
762
|
return {
|
|
@@ -857,7 +774,8 @@ function parseMentionItemFromHref(input) {
|
|
|
857
774
|
if (!href) {
|
|
858
775
|
return null;
|
|
859
776
|
}
|
|
860
|
-
|
|
777
|
+
const mention = parseRichTextMentionHref(href, input.name);
|
|
778
|
+
if (!mention && !isRichTextMentionHref(href)) {
|
|
861
779
|
return {
|
|
862
780
|
kind: "file",
|
|
863
781
|
href,
|
|
@@ -867,21 +785,13 @@ function parseMentionItemFromHref(input) {
|
|
|
867
785
|
directoryPath: dirnameFromPath2(href)
|
|
868
786
|
};
|
|
869
787
|
}
|
|
870
|
-
|
|
871
|
-
try {
|
|
872
|
-
url = new URL(href);
|
|
873
|
-
} catch {
|
|
788
|
+
if (!mention) {
|
|
874
789
|
return null;
|
|
875
790
|
}
|
|
876
|
-
const resource =
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const targetId = decodeURIComponent(url.pathname.replace(/^\/+/, "")).trim();
|
|
881
|
-
if (!targetId) {
|
|
882
|
-
return null;
|
|
883
|
-
}
|
|
884
|
-
const workspaceId = workspaceIdFromMentionUrl(url);
|
|
791
|
+
const resource = mention.providerId.trim().toLowerCase();
|
|
792
|
+
const targetId = mention.entityId.trim();
|
|
793
|
+
const workspaceId = mention.scope?.workspaceId?.trim() ?? "";
|
|
794
|
+
const name = mention.label;
|
|
885
795
|
if (resource === "agent-session") {
|
|
886
796
|
if (!workspaceId) {
|
|
887
797
|
return null;
|
|
@@ -891,8 +801,8 @@ function parseMentionItemFromHref(input) {
|
|
|
891
801
|
href,
|
|
892
802
|
workspaceId,
|
|
893
803
|
targetId,
|
|
894
|
-
name
|
|
895
|
-
title:
|
|
804
|
+
name,
|
|
805
|
+
title: name,
|
|
896
806
|
scope: "collab_sessions",
|
|
897
807
|
initiatorName: "",
|
|
898
808
|
agentName: ""
|
|
@@ -907,9 +817,9 @@ function parseMentionItemFromHref(input) {
|
|
|
907
817
|
href,
|
|
908
818
|
workspaceId,
|
|
909
819
|
targetId,
|
|
910
|
-
topicId:
|
|
911
|
-
name
|
|
912
|
-
title:
|
|
820
|
+
topicId: mention.scope?.topicId?.trim() || void 0,
|
|
821
|
+
name,
|
|
822
|
+
title: name
|
|
913
823
|
};
|
|
914
824
|
}
|
|
915
825
|
if (resource === "workspace-app") {
|
|
@@ -922,14 +832,14 @@ function parseMentionItemFromHref(input) {
|
|
|
922
832
|
workspaceId,
|
|
923
833
|
targetId,
|
|
924
834
|
appId: targetId,
|
|
925
|
-
name
|
|
835
|
+
name
|
|
926
836
|
};
|
|
927
837
|
}
|
|
928
838
|
if (resource === "workspace-reference") {
|
|
929
839
|
if (!workspaceId) {
|
|
930
840
|
return null;
|
|
931
841
|
}
|
|
932
|
-
const source =
|
|
842
|
+
const source = mention.scope?.source?.trim();
|
|
933
843
|
if (source !== "app" && source !== "task") {
|
|
934
844
|
return null;
|
|
935
845
|
}
|
|
@@ -939,10 +849,10 @@ function parseMentionItemFromHref(input) {
|
|
|
939
849
|
workspaceId,
|
|
940
850
|
targetId,
|
|
941
851
|
source,
|
|
942
|
-
groupId:
|
|
943
|
-
name
|
|
944
|
-
iconUrl:
|
|
945
|
-
fileCount: parseMentionFileCount(
|
|
852
|
+
groupId: mention.scope?.groupId?.trim() || void 0,
|
|
853
|
+
name,
|
|
854
|
+
iconUrl: mention.scope?.icon?.trim() || void 0,
|
|
855
|
+
fileCount: parseMentionFileCount(mention.scope?.count)
|
|
946
856
|
};
|
|
947
857
|
}
|
|
948
858
|
if (resource === "workspace-app-factory") {
|
|
@@ -952,9 +862,9 @@ function parseMentionItemFromHref(input) {
|
|
|
952
862
|
workspaceId,
|
|
953
863
|
targetId,
|
|
954
864
|
jobId: targetId === "create" ? "" : targetId,
|
|
955
|
-
name:
|
|
956
|
-
action:
|
|
957
|
-
contextPath:
|
|
865
|
+
name: name || translate("agentHost.agentGui.workspaceAppFactoryMentionFallback"),
|
|
866
|
+
action: mention.scope?.action?.trim() || void 0,
|
|
867
|
+
contextPath: mention.scope?.contextPath?.trim() || void 0
|
|
958
868
|
};
|
|
959
869
|
}
|
|
960
870
|
return null;
|
|
@@ -1055,7 +965,7 @@ function attrsToMentionItem(attrs) {
|
|
|
1055
965
|
const targetId = typeof attrs.targetId === "string" ? attrs.targetId : "";
|
|
1056
966
|
return {
|
|
1057
967
|
kind,
|
|
1058
|
-
href
|
|
968
|
+
href,
|
|
1059
969
|
workspaceId,
|
|
1060
970
|
targetId,
|
|
1061
971
|
name,
|
|
@@ -1074,9 +984,7 @@ function attrsToMentionItem(attrs) {
|
|
|
1074
984
|
const topicId = typeof attrs.topicId === "string" && attrs.topicId.trim() ? attrs.topicId.trim() : void 0;
|
|
1075
985
|
return {
|
|
1076
986
|
kind,
|
|
1077
|
-
href
|
|
1078
|
-
topicId
|
|
1079
|
-
}),
|
|
987
|
+
href,
|
|
1080
988
|
workspaceId,
|
|
1081
989
|
targetId,
|
|
1082
990
|
topicId,
|
|
@@ -1092,7 +1000,7 @@ function attrsToMentionItem(attrs) {
|
|
|
1092
1000
|
const appId = typeof attrs.appId === "string" && attrs.appId.trim() ? attrs.appId.trim() : typeof attrs.targetId === "string" ? attrs.targetId.trim() : "";
|
|
1093
1001
|
return {
|
|
1094
1002
|
kind,
|
|
1095
|
-
href
|
|
1003
|
+
href,
|
|
1096
1004
|
workspaceId,
|
|
1097
1005
|
targetId: appId,
|
|
1098
1006
|
appId,
|
|
@@ -1110,11 +1018,7 @@ function attrsToMentionItem(attrs) {
|
|
|
1110
1018
|
const fileCount = parseMentionFileCount(attrs.fileCount);
|
|
1111
1019
|
return {
|
|
1112
1020
|
kind,
|
|
1113
|
-
href
|
|
1114
|
-
workspaceId,
|
|
1115
|
-
{ source, id: targetId, groupId },
|
|
1116
|
-
{ iconUrl, fileCount }
|
|
1117
|
-
),
|
|
1021
|
+
href,
|
|
1118
1022
|
workspaceId,
|
|
1119
1023
|
targetId,
|
|
1120
1024
|
source,
|
|
@@ -1131,10 +1035,7 @@ function attrsToMentionItem(attrs) {
|
|
|
1131
1035
|
const contextPath = typeof attrs.contextPath === "string" && attrs.contextPath.trim() ? attrs.contextPath.trim() : void 0;
|
|
1132
1036
|
return {
|
|
1133
1037
|
kind,
|
|
1134
|
-
href
|
|
1135
|
-
action,
|
|
1136
|
-
contextPath
|
|
1137
|
-
}),
|
|
1038
|
+
href,
|
|
1138
1039
|
workspaceId,
|
|
1139
1040
|
targetId: jobId,
|
|
1140
1041
|
jobId,
|
|
@@ -1182,30 +1083,6 @@ function parseAgentMentionHTMLElementAttrs(node) {
|
|
|
1182
1083
|
...fileCount ? { fileCount } : {}
|
|
1183
1084
|
};
|
|
1184
1085
|
}
|
|
1185
|
-
function workspaceIdFromMentionUrl(url) {
|
|
1186
|
-
return url.searchParams.get("workspaceId")?.trim() ?? "";
|
|
1187
|
-
}
|
|
1188
|
-
function buildAgentGenericMentionHref2(providerId, entityId, scope) {
|
|
1189
|
-
const normalizedProviderId = providerId.trim();
|
|
1190
|
-
const normalizedEntityId = entityId.trim();
|
|
1191
|
-
if (!normalizedProviderId || !normalizedEntityId) {
|
|
1192
|
-
return "";
|
|
1193
|
-
}
|
|
1194
|
-
const params = new URLSearchParams();
|
|
1195
|
-
Object.entries(scope ?? {}).map(([key, value]) => [key.trim(), value?.trim() ?? ""]).filter(([key, value]) => key && value).sort(([left], [right]) => left.localeCompare(right)).forEach(([key, value]) => {
|
|
1196
|
-
params.set(key, value);
|
|
1197
|
-
});
|
|
1198
|
-
const query = params.toString();
|
|
1199
|
-
const href = `mention://${encodeURIComponent(
|
|
1200
|
-
normalizedProviderId
|
|
1201
|
-
)}/${encodeURIComponent(normalizedEntityId)}`;
|
|
1202
|
-
return query ? `${href}?${query}` : href;
|
|
1203
|
-
}
|
|
1204
|
-
function hasLegacyMentionQueryParams(url) {
|
|
1205
|
-
return [...url.searchParams.keys()].some(
|
|
1206
|
-
(key) => key === "appId" || key === "id" || key === "kind" || key === "link" || key === "provider" || key === "v" || key === "version" || key.startsWith("meta.")
|
|
1207
|
-
);
|
|
1208
|
-
}
|
|
1209
1086
|
function normalizeMentionKind(value) {
|
|
1210
1087
|
if (value === "session" || value === "agent-session") {
|
|
1211
1088
|
return "session";
|
|
@@ -1304,26 +1181,15 @@ function dirnameFromPath2(path) {
|
|
|
1304
1181
|
}
|
|
1305
1182
|
return `/${parts.slice(0, -1).join("/")}`;
|
|
1306
1183
|
}
|
|
1307
|
-
function escapeMarkdownLinkLabel(value) {
|
|
1308
|
-
return value.replace(/([\\[\]])/g, "\\$1");
|
|
1309
|
-
}
|
|
1310
|
-
function escapeMarkdownLinkTarget(value) {
|
|
1311
|
-
return value.replace(/\\/g, "\\\\").replace(/\)/g, "\\)");
|
|
1312
|
-
}
|
|
1313
1184
|
|
|
1314
1185
|
export {
|
|
1315
1186
|
exitAgentFileMentionSuggestion,
|
|
1316
1187
|
createAgentFileMentionExtension,
|
|
1317
|
-
buildAgentSessionMentionHref,
|
|
1318
|
-
buildAgentWorkspaceIssueMentionHref,
|
|
1319
|
-
buildAgentWorkspaceAppMentionHref,
|
|
1320
|
-
buildAgentWorkspaceReferenceMentionHref,
|
|
1321
1188
|
normalizeAgentSessionMentionTitle,
|
|
1322
1189
|
formatAgentMentionMarkdown,
|
|
1323
1190
|
parseAgentMentionMarkdown,
|
|
1324
1191
|
parseMentionItemFromHref,
|
|
1325
1192
|
mentionItemToAttrs,
|
|
1326
|
-
attrsToMentionItem
|
|
1327
|
-
buildAgentGenericMentionHref2 as buildAgentGenericMentionHref
|
|
1193
|
+
attrsToMentionItem
|
|
1328
1194
|
};
|
|
1329
|
-
//# sourceMappingURL=chunk-
|
|
1195
|
+
//# sourceMappingURL=chunk-XAQQN6MP.js.map
|