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。

chore(plugins): 合入 main 并解决工具入口冲突

liugaowei7056870f6b8d
diff --cc apps/desktop/src/main/cindy-brain/index.ts
index 7f9003de00,8afd01d5eb..10ff9914e6
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@@ -8,8 -8,10 +8,11 @@@ import { RemotePluginManagement, type R
import { projectPluginWorkdir, resolvePluginWorkdir } from './remotePluginProjects.js';
import { takePeerAttachment } from '../device-link/peerAttachmentStore.js';
import { parsePeerAttachmentRef } from '@cindy/device-link';
+ import type { Session as MakerSession } from '@cindy/maker-core';
+ import { GhostHarnessSlot } from './harnessSlot.js';
+ import { redactToolInputForUntrustedBoundary } from '../messagePersistBroadcaster.js';
import { capturePluginOauthPeer } from '../plugin-oauth/runtime.js';
+import { projectPluginPublishingSource } from './pluginPublishingSource.js';
import { readMobilePreview } from './mobilePreview.js';
import { createMailReader, mailReaderRemoteProvider } from './mailReader.js';
import { resolveForgeInstallTarget, ghostInstallTargetContext } from './ghostInstallTarget.js';
diff --cc apps/desktop/src/main/mcp-integrations/ghost.ts
index f01ab7ffde,bf1a2ee92c..9583a4008f
--- a/apps/desktop/src/main/mcp-integrations/ghost.ts
+++ b/apps/desktop/src/main/mcp-integrations/ghost.ts
@@@ -1812,79 -1793,18 +1812,91 @@@ export function getCindyGhostsMcpDeps
searchMarket: (query: string) => marketTools.search(query),
installMarket: (request: { pluginId: string; releaseId: string }, signal?: AbortSignal) => marketTools.install(request, signal),
} : {}),
+ async communityContribution(input) {
+ try {
+ const authority = await contributionAuthority(['prepare', 'submit', 'cancel', 'cancel-review'].includes(input.action));
+ let result: unknown;
+ if (input.action === 'prepare') {
+ const resolved = resolveInstalledGhost(getGhostManager().list(), input.ghostId, input.namespace);
+ if (resolved.status !== 'unique') return { ok: false, errorCode: resolved.status === 'ambiguous' ? 'GHOST_AMBIGUOUS' : 'GHOST_NOT_FOUND' };
+ result = await community.prepareContribution(installedGhostStoragePart(resolved.ghost), 'ai');
+ } else if (input.action === 'submit' || input.action === 'cancel-review') {
+ const cancelTarget = input.action === 'cancel-review' ? await community.myPluginReviewTarget(input.pluginId, input.release.releaseId) : null;
+ if (input.action === 'cancel-review' && (!cancelTarget || cancelTarget.release.sha256 !== input.release.sha256 || cancelTarget.release.revision !== input.release.revision)) throwIpcError('CONTRIBUTION_REVISION_STALE', 'Refresh this version before cancelling its review');
+ if (input.action === 'cancel-review' && cancelTarget && ['approved', 'rejected', 'cancelled'].includes(cancelTarget.release.reviewStatus ?? '')) {
+ await authority.assert();
+ return { ok: true, result: cancelTarget.release };
+ }
+ const toolName = input.action === 'cancel-review' ? 'ghost_cancel_plugin_review' : 'ghost_contribution_submit';
+ const prepared = input.action === 'cancel-review' && cancelTarget ? { preparedId: cancelTarget.release.releaseId, ghostId: input.pluginId, version: cancelTarget.release.version, sha256: cancelTarget.release.sha256, name: cancelTarget.name, description: t('settings.ghosts.contribution.cancelReviewDescription').replaceAll('{{version}}', cancelTarget.release.version) } : input.action === 'submit' ? getPreparedContribution(input.id).summary : undefined;
+ if (!prepared) throwIpcError('PRECONDITION_FAILED', 'Contribution preparation is unavailable');
+ const context = authority.context;
+ const live = hostDeps.getLiveSessionGrantState!(context.sessionId!, context.sessionInstanceId!);
+ let allowed = live?.permissionMode === 'bypassPermissions';
+ if (!allowed && live?.permissionMode === 'auto' && live.reviewAction) {
+ const decision = await live.reviewAction(toolAutoReviewAction(toolName, {
+ prepared_id: prepared.preparedId, ghost_id: prepared.ghostId, version: prepared.version, sha256: prepared.sha256, public: true,
+ }));
+ await authority.assert();
+ if (decision.verdict === 'block') return {
+ ok: false,
+ errorCode: 'PERMISSION_DENIED',
+ message: decision.reason ?? 'Automatic review denied this action; no publishing or cancellation request was sent.',
+ };
+ allowed = decision.verdict === 'allow';
+ }
+ if (!allowed) {
+ if (!hostDeps.requestHostPermission) throwIpcError('PRECONDITION_FAILED', 'Contribution confirmation is unavailable');
+ const decision = await hostDeps.requestHostPermission(context.sessionId!, context.sessionInstanceId!, {
+ kind: 'permission', requestId: randomUUID(), toolName,
+ input: { prepared_id: prepared.preparedId, ghost_id: prepared.ghostId, version: prepared.version, sha256: prepared.sha256 },
+ title: t(input.action === 'cancel-review' ? 'settings.ghosts.contribution.cancelReview' : 'settings.ghosts.contribution.confirmSubmit'),
+ description: [
+ input.action === 'cancel-review' ? '' : t('settings.ghosts.contribution.confirmPublic'),
+ `${prepared.name} · ${prepared.version}`,
+ prepared.description,
+ ...('releaseNotes' in prepared && typeof prepared.releaseNotes === 'string' && prepared.releaseNotes.trim()
+ ? [t('settings.ghosts.contribution.releaseNotes'), prepared.releaseNotes] : []),
+ input.action === 'cancel-review' ? '' : t('settings.ghosts.contribution.versionConsumedHint'),
+ ].filter(Boolean).join('\n'),
+ metadata: { hostOwnedConfirmation: 'plugin_contribution' },
+ }, AbortSignal.timeout(10 * 60_000));
+ allowed = decision?.kind === 'permission' && decision.behavior === 'allow';
+ }
+ await authority.assert();
+ if (!allowed) return { ok: false, errorCode: 'MUTATION_CANCELLED' };
+ result = input.action === 'cancel-review' ? await community.cancelPluginReview(input.pluginId, input.release, authority.assert) : await community.submitContribution(input.id, authority.assertAccepted);
+ } else if (input.action === 'status') result = await community.contributionTransferStatus(input.id);
+ else if (input.action === 'cancel') result = community.cancelContribution(input.id);
+ else if (input.action === 'list') result = await community.listMyPlugins({ query: input.query ?? '', filter: input.filter ?? 'all', cursor: input.cursor });
+ else if (input.action === 'submission') result = await community.myPluginSubmission(input.pluginId, input.submissionId);
+ else if (input.action === 'detail') result = await community.myPluginDetail(input.pluginId, input.cursor);
+ await authority.assert();
+ return { ok: true, result };
+ } catch (error) {
+ try { community.mapContributionError(error); } catch (safe) {
+ return {
+ ok: false,
+ errorCode: isIpcError(safe) ? safe.code : 'INTERNAL',
+ message: isIpcError(safe) && safe.code !== 'INTERNAL'
+ ? safe.message
+ : 'Community contribution action could not complete; query the original operation before retrying.',
+ };
+ }
+ }
+ },
+ ...(sessionCtx?.agentKind === 'codex' ? {
+ nativeHarnessHook: async (input: unknown, metadata: unknown) => {
+ // Never fall back to the server factory's process-wide context.
+ // Only the existing opaque route for this live root instance may call
+ // the native adapter, which verifies the native Hook receipt as well.
+ const context = getLiziMcpSessionContext();
+ if (context?.agentKind !== 'codex' || !context.sessionInstanceId ||
+ context.mcpCallerAttested !== true || context.mcpCallerKind !== 'root' ||
+ !context.nativeHarnessHook) throw new Error('NATIVE_HOOK_UNAVAILABLE');
+ return context.nativeHarnessHook(input, metadata);
+ },
+ } : {}),
connectAccount: async (target, signal) => {
const context = resolveSessionContext();
const sessionId = ghostSetupInteractionSessionId(context);