Browse Source

fix: expose the projection registration async disposer

creatixchu 1 week ago
parent
commit
4e7193945d

+ 1 - 1
docs/subsystems/session.md

@@ -909,7 +909,7 @@ Persistence is intentionally not implemented here — the agent lifecycle attach
  * @returns the fiber-owned disposer.
  * @throws when another definition already owns this event type.
  */
-registerMessageProjection(projection: SessionMessageProjection): () => void
+registerMessageProjection(projection: SessionMessageProjection): () => Promise<void>
 
 /**
  * Create a session owned by the calling fiber: disposing that fiber stops

+ 1 - 1
packages/core/session/src/index.ts

@@ -922,7 +922,7 @@ export class SessionStore extends Service {
    * @returns the fiber-owned disposer.
    * @throws when another definition already owns this event type.
    */
-  registerMessageProjection(projection: SessionMessageProjection): () => void {
+  registerMessageProjection(projection: SessionMessageProjection): () => Promise<void> {
     if (this.projections.some(item => item.type === projection.type)) {
       throw new Error(`session message projection "${projection.type}" is already registered`)
     }

+ 1 - 1
packages/extensions/tool-cordis/src/api-catalog.ts

@@ -1870,7 +1870,7 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [
     description: 'In-memory session store (`ctx.sessions`).\n\nPersistence is intentionally not implemented here — the agent lifecycle attaches a session-log writer to each published session\'s write handle; a session published outside that lifecycle persists nothing.',
     methods: [
       {
-        signature: 'registerMessageProjection(projection: SessionMessageProjection): () => void',
+        signature: 'registerMessageProjection(projection: SessionMessageProjection): () => Promise<void>',
         description: 'Register one event interpreter for live creation, restore, and fork. Disposing the contribution makes sessions that used it refuse further derivation.',
         parameters: [{ name: 'projection', description: 'pure definition owned by the event\'s plugin.' }],
         returns: 'the fiber-owned disposer.',

+ 1 - 1
packages/session/session-format-catalog/tests/catalog.spec.ts

@@ -25,7 +25,7 @@ describe('first-party Session format catalog', () => {
       header: { ...session.header, delegationDepth: 0 }, inheritedEventCount: 0,
       events: [...session.snapshotEvents() as unknown as SessionFormatEvent[], { type: 'image/offload', seq: 1, time: 0, data: { targets: [{ seq: 0, imageIndexes: [0] }] } }],
     }
-    expect(() => validateInstalledCurrentSessionArtifact(artifact)).toThrow(/image index 0 does not exist/)
+    expect(() => { validateInstalledCurrentSessionArtifact(artifact) }).toThrow(/image index 0 does not exist/)
   })
   it('statically owns the complete adjacent v0 to v3 chain', () => {
     const header = {