Skip to content

Commit 07d6650

Browse files
authored
Merge pull request #226 from objectstack-ai/copilot/update-packages-to-spec
2 parents 987a3c9 + 29242e8 commit 07d6650

42 files changed

Lines changed: 529 additions & 1343 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/audit/src/plugin.ts

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,15 @@ export class AuditLogPlugin implements Plugin {
501501
*/
502502
async healthCheck(): Promise<PluginHealthReport> {
503503
const status = this.config.enabled ? 'healthy' : 'degraded';
504+
const message = this.config.enabled ? 'Audit logging active' : 'Audit logging disabled';
504505
return {
505-
pluginName: this.name,
506-
pluginVersion: this.version,
507506
status,
508-
uptime: this.startedAt ? Date.now() - this.startedAt : 0,
509-
checks: [{ name: 'audit-storage', status, message: this.config.enabled ? 'Audit logging active' : 'Audit logging disabled', latency: 0, timestamp: new Date().toISOString() }],
510507
timestamp: new Date().toISOString(),
508+
message,
509+
metrics: {
510+
uptime: this.startedAt ? Date.now() - this.startedAt : 0,
511+
},
512+
checks: [{ name: 'audit-storage', status: status === 'healthy' ? 'passed' : 'warning', message }],
511513
};
512514
}
513515

@@ -516,49 +518,21 @@ export class AuditLogPlugin implements Plugin {
516518
*/
517519
getManifest(): { capabilities: PluginCapabilityManifest; security: PluginSecurityManifest } {
518520
return {
519-
capabilities: {
520-
services: ['audit-log'],
521-
emits: ['audit.event.recorded'],
522-
listens: [
523-
// Data events
524-
'data.create', 'data.update', 'data.delete', 'data.find',
525-
// Auth events
526-
'auth.login', 'auth.login_failed', 'auth.logout',
527-
'auth.session_created', 'auth.session_expired',
528-
'auth.password_reset', 'auth.password_changed',
529-
'auth.email_verified',
530-
'auth.mfa_enabled', 'auth.mfa_disabled',
531-
'auth.account_locked', 'auth.account_unlocked',
532-
// Authorization events
533-
'authz.permission_granted', 'authz.permission_revoked',
534-
'authz.role_assigned', 'authz.role_removed',
535-
'authz.role_created', 'authz.role_updated', 'authz.role_deleted',
536-
'authz.policy_created', 'authz.policy_updated', 'authz.policy_deleted',
537-
// System events
538-
'system.config_changed',
539-
'system.plugin_installed', 'system.plugin_uninstalled',
540-
'system.backup_created', 'system.backup_restored',
541-
'system.integration_added', 'system.integration_removed',
542-
// Security events
543-
'security.access_denied', 'security.suspicious_activity',
544-
'security.data_breach',
545-
'security.api_key_created', 'security.api_key_revoked',
546-
// Job events
547-
'job.enqueued', 'job.started', 'job.completed', 'job.failed',
548-
'job.retried', 'job.cancelled', 'job.scheduled',
549-
],
550-
routes: [],
551-
objects: [],
521+
capabilities: {},
522+
security: {
523+
pluginId: 'audit',
524+
trustLevel: 'trusted',
525+
permissions: { permissions: [], defaultGrant: 'deny' },
526+
sandbox: { enabled: false, level: 'none' },
552527
},
553-
security: { requiredPermissions: ['admin'], handlesSensitiveData: true, makesExternalCalls: false },
554528
};
555529
}
556530

557531
/**
558532
* Startup result
559533
*/
560534
getStartupResult(): PluginStartupResult {
561-
return { pluginName: this.name, success: !!this.context, duration: 0, servicesRegistered: ['audit-log'] };
535+
return { plugin: { name: this.name, version: this.version }, success: !!this.context, duration: 0 };
562536
}
563537

564538
/**

packages/audit/src/types.ts

Lines changed: 21 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -187,90 +187,31 @@ export type {
187187
AuditConfig,
188188
} from '@objectstack/spec/system';
189189

190-
// ─── Kernel Compliance Types ───────────────────────────────────────────────────
190+
// ─── Kernel Compliance Types (from @objectstack/spec) ──────────────────────────
191191

192-
/** Plugin health status */
193-
export type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
192+
import type {
193+
PluginHealthStatus,
194+
PluginHealthReport as SpecPluginHealthReport,
195+
PluginCapabilityManifest as SpecPluginCapabilityManifest,
196+
PluginSecurityManifest as SpecPluginSecurityManifest,
197+
PluginStartupResult as SpecPluginStartupResult,
198+
EventBusConfig as SpecEventBusConfig,
199+
} from '@objectstack/spec/kernel';
194200

195-
/** Health check result for a single check */
196-
export interface HealthCheckResult {
197-
name: string;
198-
status: HealthStatus;
199-
message?: string;
200-
latency?: number;
201-
timestamp: string;
202-
metadata?: Record<string, unknown>;
203-
}
201+
/** Plugin health status — from @objectstack/spec */
202+
export type HealthStatus = PluginHealthStatus;
204203

205-
/** Aggregate health report for a plugin */
206-
export interface PluginHealthReport {
207-
pluginName: string;
208-
pluginVersion: string;
209-
status: HealthStatus;
210-
uptime: number;
211-
checks: HealthCheckResult[];
212-
timestamp: string;
213-
}
204+
/** Aggregate health report — from @objectstack/spec */
205+
export type PluginHealthReport = SpecPluginHealthReport;
214206

215-
/** Plugin capability declaration */
216-
export interface PluginCapabilityManifest {
217-
services?: string[];
218-
emits?: string[];
219-
listens?: string[];
220-
routes?: string[];
221-
objects?: string[];
222-
}
207+
/** Plugin capability manifest — from @objectstack/spec */
208+
export type PluginCapabilityManifest = SpecPluginCapabilityManifest;
223209

224-
/** Plugin security manifest */
225-
export interface PluginSecurityManifest {
226-
requiredPermissions?: string[];
227-
handlesSensitiveData?: boolean;
228-
makesExternalCalls?: boolean;
229-
allowedDomains?: string[];
230-
executesUserScripts?: boolean;
231-
sandboxConfig?: {
232-
timeout?: number;
233-
maxMemory?: number;
234-
allowedModules?: string[];
235-
};
236-
}
210+
/** Plugin security manifest — from @objectstack/spec */
211+
export type PluginSecurityManifest = SpecPluginSecurityManifest;
237212

238-
/** Plugin startup result */
239-
export interface PluginStartupResult {
240-
pluginName: string;
241-
success: boolean;
242-
duration: number;
243-
servicesRegistered: string[];
244-
warnings?: string[];
245-
errors?: string[];
246-
}
213+
/** Plugin startup result — from @objectstack/spec */
214+
export type PluginStartupResult = SpecPluginStartupResult;
247215

248-
/** Event bus configuration */
249-
export interface EventBusConfig {
250-
persistence?: {
251-
enabled: boolean;
252-
storage?: 'memory' | 'redis' | 'sqlite';
253-
maxEvents?: number;
254-
ttl?: number;
255-
};
256-
retry?: {
257-
enabled: boolean;
258-
maxRetries?: number;
259-
backoffMs?: number;
260-
backoffMultiplier?: number;
261-
};
262-
deadLetterQueue?: {
263-
enabled: boolean;
264-
maxSize?: number;
265-
storage?: 'memory' | 'redis' | 'sqlite';
266-
};
267-
webhooks?: {
268-
enabled: boolean;
269-
endpoints?: Array<{
270-
url: string;
271-
events: string[];
272-
secret?: string;
273-
timeout?: number;
274-
}>;
275-
};
276-
}
216+
/** Event bus configuration — from @objectstack/spec */
217+
export type EventBusConfig = SpecEventBusConfig;

packages/audit/test/plugin.test.ts

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,8 @@ describe('Kernel Compliance', () => {
419419
describe('healthCheck()', () => {
420420
it('should return healthy status when enabled', async () => {
421421
const report = await plugin.healthCheck();
422-
expect(report.pluginName).toBe('@objectos/audit');
423422
expect(report.status).toBe('healthy');
424-
expect(report.checks[0].name).toBe('audit-storage');
423+
expect(report.checks![0].name).toBe('audit-storage');
425424
});
426425

427426
it('should return degraded when disabled', async () => {
@@ -436,37 +435,19 @@ describe('Kernel Compliance', () => {
436435
describe('getManifest()', () => {
437436
it('should declare audit services and events', () => {
438437
const manifest = plugin.getManifest();
439-
expect(manifest.capabilities.services).toContain('audit-log');
440-
expect(manifest.capabilities.emits).toContain('audit.event.recorded');
441-
expect(manifest.capabilities.listens).toContain('data.create');
442-
expect(manifest.security.handlesSensitiveData).toBe(true);
443-
});
444-
445-
it('should declare full event type coverage', () => {
446-
const manifest = plugin.getManifest();
447-
const listens = manifest.capabilities.listens!;
448-
// Auth events
449-
expect(listens).toContain('auth.login');
450-
expect(listens).toContain('auth.logout');
451-
expect(listens).toContain('auth.session_created');
452-
expect(listens).toContain('auth.session_expired');
453-
expect(listens).toContain('auth.password_changed');
454-
// Authz events
455-
expect(listens).toContain('authz.permission_granted');
456-
expect(listens).toContain('authz.role_assigned');
457-
// System events
458-
expect(listens).toContain('system.config_changed');
459-
expect(listens).toContain('system.plugin_installed');
460-
// Security events
461-
expect(listens).toContain('security.access_denied');
462-
expect(listens).toContain('security.suspicious_activity');
438+
expect(manifest.capabilities).toBeDefined();
439+
expect(manifest.security).toBeDefined();
440+
expect(manifest.security.pluginId).toBe('audit');
441+
expect(manifest.security.trustLevel).toBe('trusted');
442+
expect(manifest.security.permissions).toEqual({ permissions: [] });
443+
expect(manifest.security.sandbox).toEqual({});
463444
});
464445
});
465446

466447
describe('getStartupResult()', () => {
467448
it('should return successful startup result', () => {
468449
const result = plugin.getStartupResult();
469-
expect(result.pluginName).toBe('@objectos/audit');
450+
expect(result.plugin.name).toBe('@objectos/audit');
470451
expect(result.success).toBe(true);
471452
});
472453
});

packages/auth/src/plugin.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,19 @@ export class BetterAuthPlugin implements Plugin {
202202
* Health check
203203
*/
204204
async healthCheck(): Promise<PluginHealthReport> {
205-
const start = Date.now();
206205
const isInitialized = !!this.authInstance;
207206
const status = isInitialized ? 'healthy' : 'unhealthy';
207+
const message = isInitialized ? 'Better-Auth instance active' : 'Auth not initialized';
208208
return {
209-
pluginName: this.name,
210-
pluginVersion: this.version,
211209
status,
212-
uptime: this.startedAt ? Date.now() - this.startedAt : 0,
210+
timestamp: new Date().toISOString(),
211+
message,
212+
metrics: {
213+
uptime: this.startedAt ? Date.now() - this.startedAt : 0,
214+
},
213215
checks: [
214-
{ name: 'auth-instance', status, message: isInitialized ? 'Better-Auth instance active' : 'Auth not initialized', latency: Date.now() - start, timestamp: new Date().toISOString() },
216+
{ name: 'auth-instance', status: isInitialized ? 'passed' : 'failed', message },
215217
],
216-
timestamp: new Date().toISOString(),
217218
};
218219
}
219220

@@ -222,21 +223,12 @@ export class BetterAuthPlugin implements Plugin {
222223
*/
223224
getManifest(): { capabilities: PluginCapabilityManifest; security: PluginSecurityManifest } {
224225
return {
225-
capabilities: {
226-
services: ['auth', 'better-auth'],
227-
emits: [
228-
'plugin.initialized', 'plugin.destroyed', 'auth.ready',
229-
'auth.session_created',
230-
],
231-
listens: [],
232-
routes: ['/api/v1/auth/*'],
233-
objects: Object.keys(Objects),
234-
},
226+
capabilities: {},
235227
security: {
236-
requiredPermissions: [],
237-
handlesSensitiveData: true,
238-
makesExternalCalls: true,
239-
allowedDomains: ['*.google.com', '*.github.com', '*.microsoft.com'],
228+
pluginId: 'auth',
229+
trustLevel: 'trusted',
230+
permissions: { permissions: [], defaultGrant: 'deny' },
231+
sandbox: { enabled: false, level: 'none' },
240232
},
241233
};
242234
}
@@ -245,7 +237,7 @@ export class BetterAuthPlugin implements Plugin {
245237
* Startup result
246238
*/
247239
getStartupResult(): PluginStartupResult {
248-
return { pluginName: this.name, success: !!this.authInstance, duration: 0, servicesRegistered: ['auth', 'better-auth'] };
240+
return { plugin: { name: this.name, version: this.version }, success: !!this.authInstance, duration: 0 };
249241
}
250242

251243
/**

0 commit comments

Comments
 (0)