feat: integrate marketplace plugins with coding runtime

This commit is contained in:
2026-08-28 18:02:51 +08:00
parent 1d64b89499
commit 05917a789a
21 changed files with 1921 additions and 29 deletions

View File

@@ -15,6 +15,10 @@ import {
import { DATA_SERVICE_PLUGIN_DEFINITION } from '../../shared/coding-plugins';
import { productToolDetailsOfResult } from '../../shared/coding-conversation-product-tool-protocol';
import type { DataServiceErrorContext, DataServiceHostResult } from '../../shared/data-service';
import type {
EffectivePluginResolver,
EffectivePluginSnapshot,
} from '../../electron/coding-plugins/effective-resolver';
const policy: PluginPolicyClientState = {
status: 'current',
@@ -199,6 +203,49 @@ describe('CodingCapabilityRegistry', () => {
expect(JSON.stringify(invalidIdentity)).not.toMatch(/[0-9a-f]{8}-[0-9a-f]{4}/i);
});
it('refuses a new plugin action from an old worker after lifecycle invalidation', async () => {
const frozenSnapshot: EffectivePluginSnapshot = {
accountSessionId: 'account-a\u00001',
projectId: context.projectId,
pluginReleaseIds: [],
effectiveSkillIds: ['data-service'],
skillEntries: [{ id: 'data-service', entryPath: 'skills/data-service/SKILL.md' }],
toolDefinitions: DATA_SERVICE_PLUGIN_DEFINITION.tools,
runtimePolicies: [],
unavailableReasons: [],
};
const currentSnapshot: EffectivePluginSnapshot = {
...frozenSnapshot,
effectiveSkillIds: [],
skillEntries: [],
toolDefinitions: [],
unavailableReasons: [{
pluginId: DATA_SERVICE_PLUGIN_DEFINITION.id,
code: 'project_disabled',
message: 'Plugin is not enabled for this project',
}],
};
const effectiveResolver = {
resolve: vi.fn(async () => currentSnapshot),
getSkillSources: vi.fn(async () => []),
getPolicyState: vi.fn(() => policy),
} as unknown as EffectivePluginResolver;
const result = await registry({ effectiveResolver }).invoke({
toolName: 'data_service_get_document',
context: { ...context, effectiveSnapshot: frozenSnapshot },
workerRole: 'parent',
effectiveSkillIds: frozenSnapshot.effectiveSkillIds,
value: { collection: 'todos', document_id: 'one' },
});
expect(result.details).toMatchObject({ success: false, code: 'plugin_not_enabled' });
expect(effectiveResolver.resolve).toHaveBeenCalledWith(expect.objectContaining({
projectId: context.projectId,
projectPath: context.projectPath,
role: 'parent',
}));
});
it('keeps the replay identity and parses bounded Data Service faults for all ten tools', async () => {
const fault = (
code: string,