feat(coding): add model tools and device packages

This commit is contained in:
brother7 committed 2026-09-02 18:46:21 +08:00
1 parent 841273b433
commit 664b8823a0
60 files changed
+3847 -2068

No files matched your search

+68
View File
@@ -19,6 +19,8 @@ import {
import { PiProductTools } from '../../electron/coding-runtime/pi/product-tools';
import { productToolDetails } from '../../electron/coding-runtime/product-tool-protocol';
import type { CodingCapabilityRegistry } from '../../electron/coding-plugins/registry';
import type { ModelToolRegistryPort } from '../../electron/coding-runtime/pi/model-tools/model-tool-registry';
import type { DevicePackageTools } from '../../electron/coding-packages/device-package-tools';
import { DATA_SERVICE_PLUGIN_DEFINITION } from '../../shared/coding-plugins';
const exec = promisify(execFile);
@@ -477,6 +479,72 @@ describe('PI-090 product tools', () => {
});
});
it('routes Web Search through the model tool registry before the Plugin registry', async () => {
const root = await temporaryRoot('makelore-pi-model-tool-');
const modelInvoke = vi.fn().mockResolvedValue({
content: [{ type: 'text', text: 'current answer' }],
details: {
schema: 'makelore-model-tool.v1', tool: 'web_search', status: 'succeeded',
modelId: 'deepseek-v4-pro', answer: 'current answer', sources: [],
sourceMode: 'inline-or-structured',
},
});
const pluginInvoke = vi.fn();
const tools = new PiProductTools({
browser: {} as AgentBrowserModule,
attachments: new CodingAttachmentStore(path.join(root, 'attachments')),
bundledSkillsDir: path.resolve('resources/coding-skills'),
modelToolRegistry: { invoke: modelInvoke } as unknown as ModelToolRegistryPort,
capabilityRegistry: { invoke: pluginInvoke } as unknown as CodingCapabilityRegistry,
});
const context = {
conversationId: 'conversation-a', workerGeneration: 4,
runId: 'run-a', resourceId: 'resource-a',
projectId: 'local-project-a', projectPath: root, skillIds: [],
};
await tools.execute('web_search', context, { query: 'current fact' });
expect(modelInvoke).toHaveBeenCalledWith(
'web_search',
{
conversationId: 'conversation-a', workerGeneration: 4,
runId: 'run-a', resourceId: 'resource-a',
},
{ query: 'current fact' },
);
expect(pluginInvoke).not.toHaveBeenCalled();
});
it('routes conversation-only package management before the Plugin registry', async () => {
const root = await temporaryRoot('makelore-pi-device-package-tool-');
const invoke = vi.fn().mockResolvedValue({
content: [{ type: 'text', text: '[]' }],
details: {
schema: 'makelore-device-package.v1', operation: 'list', success: true,
index: { schemaVersion: 1, generation: 0, packages: [] },
},
});
const pluginInvoke = vi.fn();
const tools = new PiProductTools({
browser: {} as AgentBrowserModule,
attachments: new CodingAttachmentStore(path.join(root, 'attachments')),
bundledSkillsDir: path.resolve('resources/coding-skills'),
devicePackageTools: { invoke } as unknown as DevicePackageTools,
capabilityRegistry: { invoke: pluginInvoke } as unknown as CodingCapabilityRegistry,
});
const context = {
conversationId: 'conversation-a', workerGeneration: 4,
runId: 'run-a', resourceId: 'resource-a',
projectId: 'local-project-a', projectPath: root, skillIds: [],
};
await tools.execute('local_package_list', context, {});
expect(invoke).toHaveBeenCalledWith('local_package_list', 'run-a', {});
expect(pluginInvoke).not.toHaveBeenCalled();
});
it('does not fabricate Data Service validation or billing without a registry', async () => {
const root = await temporaryRoot('makelore-pi-data-input-');
const tools = new PiProductTools({