Uh oh!
There was an error while loading. Please reload this page.
Core: Router Implementation - #21
Merged
Merged
Conversation
Adds the `@openthreads/core` package with: - **Data model types** (`types.ts`): Channel, Recipient, Route, RouteCriteria, InboundMessage, Thread, Turn — derived from VISION.md. - **Route matching engine** (`router.ts`): - `router(routes, message)` — filters enabled routes whose criteria all match the inbound message, then returns them sorted by descending priority (highest-priority first). - Glob/wildcard support via `globToRegex` / `matchGlob` (`*` = any chars, `?` = one char; regex metacharacters are escaped so literal dots in channel/user IDs behave correctly). - Per-field AND semantics; array criteria use OR (any pattern matches). - Boolean criteria (`isThread`, `isMention`, `isDM`) accept undefined as "match everything". - Disabled routes are always excluded. - Multiple recipients per route (fan-out) are preserved on each result. - Input array is never mutated (sort operates on a copy produced by filter). - **Unit tests** (`router.test.ts`): 40+ cases covering glob edge-cases, criterion matching, priority ordering, stable sort, fan-out, overlapping routes, disabled routes, no-match, and a realistic multi-route scenario. Co-authored-by: claude[bot] <claude[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes#3