Files
tutti/packages/agent/gui/agent-gui/agentGuiNode/composeAgentGUIMentionService.ts
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

56 lines
2.1 KiB
TypeScript

import type {
RichTextMentionService,
RichTextMentionInvalidationSelector
} from "@tutti-os/ui-rich-text/service";
import type { RichTextMentionIdentity } from "@tutti-os/ui-rich-text/types";
/**
* Exposes the Agent GUI provider catalog without replacing the workspace-owned
* resolution cache. Providers already owned by the inherited service keep its
* invalidation subscriptions; Agent GUI-only providers resolve through the
* surface service that introduced them.
*/
export function composeAgentGUIMentionService(input: {
inheritedService: RichTextMentionService;
surfaceService: RichTextMentionService;
}): RichTextMentionService {
const { inheritedService, surfaceService } = input;
const inheritedProviderIds = new Set(
inheritedService.listProviders().map((provider) => provider.id)
);
const serviceForIdentity = (
identity: RichTextMentionIdentity
): RichTextMentionService =>
inheritedProviderIds.has(identity.providerId)
? inheritedService
: surfaceService;
return {
listProviders: () => surfaceService.listProviders(),
getProvider: (providerId) => surfaceService.getProvider(providerId),
listTriggerConfigs: () => surfaceService.listTriggerConfigs(),
query: (queryInput) => surfaceService.query(queryInput),
resolve: (identity) => serviceForIdentity(identity).resolve(identity),
getSnapshot: (identity) =>
serviceForIdentity(identity).getSnapshot(identity),
invalidate(selector?: RichTextMentionInvalidationSelector) {
inheritedService.invalidate(selector);
surfaceService.invalidate(selector);
},
subscribe(listener, identity) {
if (identity) {
return serviceForIdentity(identity).subscribe(listener, identity);
}
const unsubscribeInherited = inheritedService.subscribe(listener);
const unsubscribeSurface = surfaceService.subscribe(listener);
return () => {
unsubscribeInherited();
unsubscribeSurface();
};
},
// The boundary does not own either service. Their creators retain disposal
// authority so composing a view cannot tear down workspace subscriptions.
dispose() {}
};
}