Skip to content

refactor(schema): inline the session message ID schema #33731

Description

@opencode-agent

@kitlangton

Problem

SessionMessage.ID is currently defined indirectly through a standalone session-message-id.ts module:

import { SessionMessageID } from "./session-message-id"

export const ID = SessionMessageID.ID
export type ID = SessionMessageID.ID

The schema package has the real ID module, and Core adds a second two-line wrapper for it. Unlike session-id.ts and workspace-id.ts, this split is not preventing a circular dependency: session-message.ts does not depend on session-event.ts or session-input.ts.

This leaves an extra module and forwarding aliases without a dependency-boundary benefit.

Proposed solution

  • Define the branded ID schema and its create() static directly in packages/schema/src/session-message.ts.
  • Update schema consumers (session-event.ts and session-input.ts) to use SessionMessage.ID.
  • Update Core's session/context-epoch.ts to use SessionMessage.ID.create().
  • Delete both wrappers:
    • packages/schema/src/session-message-id.ts
    • packages/core/src/session/message-id.ts

Keep session-id.ts and workspace-id.ts separate: those are shared leaf modules whose inlining would introduce dependency cycles.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions