Skip to content

Function: createAdapterNamespace()

Makaio Framework


Makaio Framework / ai-adapters-core / createAdapterNamespace

createAdapterNamespace<N, Schemas>(domain, schemas, options?): BusNamespace<N, SubjectRecordFromSchemaRecord<Schemas>, { [KeyType in PropertyKey]: AllPropertiesOfUnion<FilterablePayload<SubjectRecordFromSchemaRecord<Schemas>[keyof Schemas & string]>>[KeyType] }, Schemas>

Defined in: ../../../adapters/core/src/factory/create-adapter-namespace.ts:50

Creates an adapter namespace with typed subject definitions.

Seam: Thin wrapper around MakaioBus.registerNamespace that:

  • Delegates to bus-core for namespace registration
  • Preserves FilterPayload type for type-safe withFilter()
  • Provides extension point for future adapter-specific features

N extends string

Schemas extends SchemaRecord

N

Namespace domain (e.g., ‘adapter:claudeCode’)

Schemas

Record of subject schemas (events and requests)

NamespaceRegistrationOptions

Registration options (e.g., skipBusValidation for Zod version conflicts)

BusNamespace<N, SubjectRecordFromSchemaRecord<Schemas>, { [KeyType in PropertyKey]: AllPropertiesOfUnion<FilterablePayload<SubjectRecordFromSchemaRecord<Schemas>[keyof Schemas & string]>>[KeyType] }, Schemas>

Adapter namespace with typed subjects and pre-computed FilterPayload

const ClaudeCodeNamespace = createAdapterNamespace('adapter:claudeCode', {
thinking: z.object({ content: z.string() }),
getContext: {
request: z.object({ path: z.string() }),
response: z.object({ content: z.string() }),
},
});
// Access typed subjects
ClaudeCodeNamespace.subjects.thinking;
// Get scoped bus with type-safe filtering
const bus = await ClaudeCodeNamespace.scopedBus();
bus.withFilter({ content: 'test' }); // ✅ Type-checked
// For adapters with bundled Zod v3 (e.g., @github/copilot/sdk):
const CopilotNamespace = createAdapterNamespace('adapter:copilot', schemas, {
skipBusValidation: true, // Skip validation due to Zod version conflict
});