Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions src/core/plugins/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ export class PluginManager {
this.logger.info(`✅ Loaded: ${pluginPath}`);
}

// Register all namespaces with the state service
const namespaces = this.getAllNamespaces();
if (namespaces.length > 0) {
try {
this.coreApi.state.registerNamespaces(namespaces);
} catch (error) {
// Use centralized error handler for consistent error formatting
this.exitWithError('Failed to register plugin namespaces', error);
}
}

this.logger.info(`✅ Plugin system ready`);
}

Expand Down Expand Up @@ -183,23 +172,6 @@ export class PluginManager {
}));
}

/**
* Get all namespaces from loaded plugins
*/
getAllNamespaces(): string[] {
const namespaces = new Set<string>();

for (const plugin of this.loadedPlugins.values()) {
if (plugin.status === 'loaded' && plugin.manifest.stateSchemas) {
for (const schema of plugin.manifest.stateSchemas) {
namespaces.add(schema.namespace);
}
}
}

return Array.from(namespaces);
}

/**
* Exit with formatted error using the current output format
* Wrapper for formatAndExitWithError with automatic format detection
Expand Down
7 changes: 1 addition & 6 deletions src/core/plugins/plugin.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Plugin System Type Definitions
* Types specific to the plugin architecture
*/
import type { z } from 'zod';
import type { CoreApi } from '@/core/core-api/core-api.interface';
import type { ConfigService } from '@/core/services/config/config-service.interface';
import type { Logger } from '@/core/services/logger/logger-service.interface';
Expand All @@ -22,19 +23,13 @@ export interface PluginManifest {
core: string;
api: string;
};
capabilities: string[];
commands: CommandSpec[];
stateSchemas?: PluginStateSchema[];
init?: (context?: PluginContext) => void | Promise<void>;
teardown?: (context?: PluginContext) => void | Promise<void>;
}

/**
* Command output specification
* Defines the schema and optional human-readable template for command output
*/
import type { z } from 'zod';

export interface CommandOutputSpec {
/** Zod schema for the command's output */
schema: z.ZodTypeAny;
Expand Down
22 changes: 0 additions & 22 deletions src/plugins/account/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import {
viewAccount,
ViewAccountOutputSchema,
} from './commands/view';
import { ACCOUNT_JSON_SCHEMA, ACCOUNT_NAMESPACE } from './schema';

export const accountPluginManifest: PluginManifest = {
name: 'account',
version: '1.0.0',
Expand All @@ -53,12 +51,6 @@ export const accountPluginManifest: PluginManifest = {
core: '^1.0.0',
api: '^1.0.0',
},
capabilities: [
`state:namespace:${ACCOUNT_NAMESPACE}`,
'network:read',
'network:write',
'tx-execution:use',
],
commands: [
{
name: 'create',
Expand Down Expand Up @@ -274,20 +266,6 @@ export const accountPluginManifest: PluginManifest = {
},
},
],
stateSchemas: [
{
namespace: ACCOUNT_NAMESPACE,
version: 1,
jsonSchema: ACCOUNT_JSON_SCHEMA,
scope: 'profile',
},
],
init: () => {
console.log('[ACCOUNT PLUGIN] Initializing account plugin...');
},
teardown: () => {
console.log('[ACCOUNT PLUGIN] Tearing down account plugin...');
},
};

export default accountPluginManifest;
8 changes: 0 additions & 8 deletions src/plugins/config/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const configPluginManifest: PluginManifest = {
core: '^1.0.0',
api: '^1.0.0',
},
capabilities: ['config:read', 'config:write'],
commands: [
{
name: 'list',
Expand Down Expand Up @@ -91,13 +90,6 @@ export const configPluginManifest: PluginManifest = {
},
},
],
stateSchemas: [],
init: () => {
console.log('[CONFIG PLUGIN] Initializing config plugin...');
},
teardown: () => {
console.log('[CONFIG PLUGIN] Tearing down config plugin...');
},
};

export default configPluginManifest;
11 changes: 0 additions & 11 deletions src/plugins/credentials/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
removeCredentials,
RemoveCredentialsOutputSchema,
} from './commands/remove';
import { CREDENTIALS_JSON_SCHEMA, CREDENTIALS_NAMESPACE } from './schema';

export const credentialsManifest: PluginManifest = {
name: 'credentials',
version: '1.0.0',
Expand All @@ -27,7 +25,6 @@ export const credentialsManifest: PluginManifest = {
core: '>=1.0.0',
api: '>=1.0.0',
},
capabilities: ['credentials:manage', 'credentials:list'],
commands: [
{
name: 'list',
Expand Down Expand Up @@ -60,14 +57,6 @@ export const credentialsManifest: PluginManifest = {
},
},
],
stateSchemas: [
{
namespace: CREDENTIALS_NAMESPACE,
version: 1,
jsonSchema: CREDENTIALS_JSON_SCHEMA,
scope: 'profile',
},
],
};

export default credentialsManifest;
1 change: 0 additions & 1 deletion src/plugins/hbar/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const hbarPluginManifest: PluginManifest = {
core: '^1.0.0',
api: '^1.0.0',
},
capabilities: ['tx-execution:use', 'network:read'],
commands: [
{
name: 'transfer',
Expand Down
1 change: 0 additions & 1 deletion src/plugins/network/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const networkPluginManifest: PluginManifest = {
core: '^1.0.0',
api: '^1.0.0',
},
capabilities: ['state:read', 'state:write', 'config:read'],
commands: [
{
name: 'list',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ module.exports = {
displayName: 'Topic Plugin',
description: 'Manage Hedera topics',
commands: [{ name: 'list' }, { name: 'create' }],
capabilities: ['topic:list', 'topic:create'],
};
3 changes: 0 additions & 3 deletions src/plugins/plugin-management/__tests__/unit/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jest.mock(
displayName: 'Topic Plugin',
description: 'Manage Hedera topics',
commands: [{ name: 'list' }, { name: 'create' }],
capabilities: ['topic:list', 'topic:create'],
},
}),
{ virtual: true },
Expand Down Expand Up @@ -99,7 +98,6 @@ describe('plugin-management info command', () => {
expect(output.plugin.enabled).toBe(true);
expect(output.plugin.description).toContain('Manage Hedera topics');
expect(output.plugin.commands).toEqual(['list', 'create']);
expect(output.plugin.capabilities).toEqual(['topic:list', 'topic:create']);
});

it('should use fallback values when optional metadata missing', async () => {
Expand Down Expand Up @@ -127,7 +125,6 @@ describe('plugin-management info command', () => {
expect(output.plugin.displayName).toBe('custom-plugin');
expect(output.plugin.description).toContain('No description available');
expect(output.plugin.commands).toEqual([]);
expect(output.plugin.capabilities).toEqual([]);
});

it('should return failure when plugin does not exist', async () => {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/plugin-management/commands/info/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export async function getPluginInfo(
description:
manifest.description ?? 'No description available for this plugin.',
commands: manifest.commands?.map((command) => command.name) ?? [],
capabilities: manifest.capabilities ?? [],
enabled: entry.enabled,
};

Expand Down
1 change: 0 additions & 1 deletion src/plugins/plugin-management/commands/info/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const PLUGIN_INFO_TEMPLATE = `{{#if found}}
Enabled: {{plugin.enabled}}
Description: {{plugin.description}}
Commands: {{plugin.commands}}
Capabilities: {{plugin.capabilities}}
{{else}}
❌ {{message}}
{{/if}}`;
Expand Down
1 change: 0 additions & 1 deletion src/plugins/plugin-management/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const pluginManagementManifest: PluginManifest = {
core: '>=1.0.0',
api: '>=1.0.0',
},
capabilities: ['plugin:manage', 'plugin:list', 'plugin:info'],
commands: [
{
name: 'add',
Expand Down
1 change: 0 additions & 1 deletion src/plugins/plugin-management/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const PluginInfoSchema = z.object({
displayName: z.string().describe('Plugin display name'),
description: z.string().describe('Plugin description'),
commands: z.array(z.string()).describe('Available commands'),
capabilities: z.array(z.string()).describe('Plugin capabilities'),
enabled: z.boolean().describe('Whether plugin is enabled'),
});

Expand Down
10 changes: 0 additions & 10 deletions src/plugins/test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { PluginManifest } from '@/core';

import { createMemo, MEMO_TEST_TEMPLATE } from '@/plugins/test/commands/memo';
import { MemoTestOutputSchema } from '@/plugins/test/commands/memo/output';
import { MEMO_JSON_SCHEMA, MEMO_NAMESPACE } from '@/plugins/test/schema';

import {
FOO_TEST_TEMPLATE,
Expand All @@ -24,7 +23,6 @@ export const testPluginManifest: PluginManifest = {
core: '^1.0.0',
api: '^1.0.0',
},
capabilities: ['test:read', 'memo:create'],
commands: [
{
name: 'foo',
Expand Down Expand Up @@ -74,14 +72,6 @@ export const testPluginManifest: PluginManifest = {
},
},
],
stateSchemas: [
{
namespace: MEMO_NAMESPACE,
version: 1,
jsonSchema: MEMO_JSON_SCHEMA,
scope: 'profile',
},
],
};

export default testPluginManifest;
6 changes: 0 additions & 6 deletions src/plugins/token/__tests__/unit/helpers/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,6 @@ export const expectedPluginManifest = {
version: '1.0.0',
displayName: 'Token Plugin',
expectedCommands: ['create', 'associate', 'transfer', 'create-from-file'],
expectedCapabilities: [
'state:namespace:token-tokens',
'network:read',
'network:write',
'tx-execution:use',
],
};

/**
Expand Down
15 changes: 0 additions & 15 deletions src/plugins/token/__tests__/unit/plugin-structure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ describe('Token Plugin Structure', () => {
expect(commandNames).toContain('create-from-file');
});

test('manifest should have proper capabilities', () => {
expect(tokenPluginManifest.capabilities).toContain(
'state:namespace:token-tokens',
);
expect(tokenPluginManifest.capabilities).toContain('network:read');
expect(tokenPluginManifest.capabilities).toContain('network:write');
expect(tokenPluginManifest.capabilities).toContain('tx-execution:use');
});

test('manifest should have state schema', () => {
expect(tokenPluginManifest.stateSchemas).toBeDefined();
expect(tokenPluginManifest.stateSchemas).toHaveLength(1);
expect(tokenPluginManifest.stateSchemas![0].namespace).toBe('token-tokens');
});

test('command handlers should be exported', () => {
expect(transferToken).toBeDefined();
expect(createToken).toBeDefined();
Expand Down
23 changes: 0 additions & 23 deletions src/plugins/token/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
transferToken,
TransferTokenOutputSchema,
} from './commands/transfer';
import { TOKEN_JSON_SCHEMA, TOKEN_NAMESPACE } from './schema';

export const tokenPluginManifest: PluginManifest = {
name: 'token',
Expand All @@ -42,12 +41,6 @@ export const tokenPluginManifest: PluginManifest = {
core: '^1.0.0',
api: '^1.0.0',
},
capabilities: [
`state:namespace:${TOKEN_NAMESPACE}`,
'network:read',
'network:write',
'tx-execution:use',
],
commands: [
{
name: 'transfer',
Expand Down Expand Up @@ -289,22 +282,6 @@ export const tokenPluginManifest: PluginManifest = {
},
},
],
stateSchemas: [
{
namespace: TOKEN_NAMESPACE,
version: 1,
jsonSchema: TOKEN_JSON_SCHEMA,
scope: 'profile',
},
],
init: () => {
console.log('[TOKEN PLUGIN] Initializing token plugin...');
// Plugin initialization logic
},
teardown: () => {
console.log('[TOKEN PLUGIN] Tearing down token plugin...');
// Plugin cleanup logic
},
};

export default tokenPluginManifest;
16 changes: 0 additions & 16 deletions src/plugins/topic/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {
submitMessage,
SubmitMessageOutputSchema,
} from './commands/submit-message';
import { TOPIC_JSON_SCHEMA, TOPIC_NAMESPACE } from './schema';

export const topicPluginManifest: PluginManifest = {
name: 'topic',
version: '1.0.0',
Expand All @@ -37,12 +35,6 @@ export const topicPluginManifest: PluginManifest = {
core: '^1.0.0',
api: '^1.0.0',
},
capabilities: [
`state:namespace:${TOPIC_NAMESPACE}`,
'network:read',
'network:write',
'tx-execution:use',
],
commands: [
{
name: 'create',
Expand Down Expand Up @@ -212,14 +204,6 @@ export const topicPluginManifest: PluginManifest = {
},
},
],
stateSchemas: [
{
namespace: TOPIC_NAMESPACE,
version: 1,
jsonSchema: TOPIC_JSON_SCHEMA,
scope: 'profile',
},
],
};

export default topicPluginManifest;