@chatpanel/events 0.22.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -18,6 +18,7 @@ export {
18
18
  export { REF_KINDS, RESOLUTION, makeRef, isRef, resolveRef } from './ref.js';
19
19
  export { linearize, compareEvents, causesAreWellFormed } from './order.js';
20
20
  export { pendingQueue, isQueued, dequeue, moveQueued, promoteQueued } from './queue.js';
21
+ export { REACH, reachRank, reachSatisfies } from './reach.js';
21
22
  export { UPCASTERS, upcast, upcastAll } from './upcast.js';
22
23
  export {
23
24
  validateCapability, validateInvocation, canSatisfy,
@@ -42,7 +43,7 @@ export { defineAdapter, createAdapterRegistry, AdapterError } from './adapters.j
42
43
  export { linkifyCitations, sourcesFromToolText } from './citations.js';
43
44
  export { buildTrajectory, phasesOf, lanesOf, filterEntries, displayName, ENTRY_KINDS, threadsOf, threadTitle, promptEntries, turnsOf, threadTree } from './trajectory.js';
44
45
  export { createTurnRunner, defineLoop, LOOP_KINDS, LoopError } from './loop.js';
45
- export { defineModel, defineMiddleware, defineRouteStrategy, createModelRouter, signalsFrom, requirementsFor, requirementsForStep, preferenceFor, failoverOrder, pinnedOrderOf, FAILOVER_CLASS_GAP, FAILOVER_CAPABILITY_GAP, sameModelKey, REACH, RouterError } from './router.js';
46
+ export { defineModel, defineMiddleware, defineRouteStrategy, createModelRouter, signalsFrom, requirementsFor, requirementsForStep, preferenceFor, failoverOrder, pinnedOrderOf, FAILOVER_CLASS_GAP, FAILOVER_CAPABILITY_GAP, sameModelKey, RouterError } from './router.js';
46
47
  export { makeSourceStore, manifestText, shortUrl, readSource, sourceId } from './sources-retrieval.js';
47
48
  export { classifySource, extractUrls, hostMatches, meetReach, sourcePolicyFor, DEFAULT_INTERNAL_PATTERNS, INTERNAL_PATTERN_CATALOG } from './sources.js';
48
49
  export { defineRule, createRuleEngine, SUPPRESSED, RuleError } from './rules.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/events",
3
- "version": "0.22.0",
3
+ "version": "0.23.1",
4
4
  "description": "The canonical ChatPanel event-log and capability contracts — typed durable facts, clock-free deterministic linearization, schema upcasting, and the invariants the replay harness asserts. Pure, dependency-free ESM shared by the ChatPanel extension, gateway and bridge.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -21,6 +21,7 @@
21
21
  "./memory.js": "./memory.js",
22
22
  "./order.js": "./order.js",
23
23
  "./queue.js": "./queue.js",
24
+ "./reach.js": "./reach.js",
24
25
  "./ref.js": "./ref.js",
25
26
  "./registry.js": "./registry.js",
26
27
  "./route-graph.js": "./route-graph.js",
@@ -70,6 +71,7 @@
70
71
  "observability.js",
71
72
  "order.js",
72
73
  "queue.js",
74
+ "reach.js",
73
75
  "ref.js",
74
76
  "registry.js",
75
77
  "route-graph.js",
package/reach.js ADDED
@@ -0,0 +1,23 @@
1
+ // reach.js — how far a request may travel, on its own so it can travel alone.
2
+ //
3
+ // One ordered vocabulary answers "how far may this go" for three very different callers: the
4
+ // model router ranks a model's reach against a turn's requirement, pairing gives a phone a
5
+ // ceiling, and the bridge maps that ceiling to a toolset. Three declarations, one vocabulary,
6
+ // or "how far may this reach" gets three answers that drift.
7
+ //
8
+ // A separate module rather than a constant inside router.js for the reason scopes.js exists:
9
+ // the consumers have wildly different weights. The bridge has zero runtime dependencies by
10
+ // design and vendors what it needs — pulling the 50 KB model router in to reach a
11
+ // three-element array is exactly the transitive-graph mistake that split DATA_SCOPES out of
12
+ // capability.js.
13
+ //
14
+ // ORDERED, least to most: a ceiling comparison is an index comparison.
15
+ export const REACH = Object.freeze(['device', 'trusted', 'any']);
16
+
17
+ /** Position in the ladder; an unknown tier ranks LOWEST, so a typo never widens reach. */
18
+ export const reachRank = (r) => Math.max(0, REACH.indexOf(r));
19
+
20
+ /** Does `have` satisfy `need`? Fails closed — an unknown `have` is treated as 'device'. */
21
+ export function reachSatisfies(have, need) {
22
+ return reachRank(have) >= reachRank(need);
23
+ }
package/router.js CHANGED
@@ -25,9 +25,11 @@ export class RouterError extends Error {
25
25
  }
26
26
 
27
27
  /** Where a request may go. Ordered: each level permits everything below it. */
28
- export const REACH = Object.freeze(['device', 'trusted', 'any']);
29
-
30
- const reachRank = (r) => Math.max(0, REACH.indexOf(r));
28
+ // The reach vocabulary lives in reach.js so a zero-dependency consumer (the bridge) can take
29
+ // the ladder without taking the router. Re-exported here because every existing caller reaches
30
+ // for it through the router — that import must keep working.
31
+ export { REACH, reachRank } from './reach.js';
32
+ import { REACH, reachRank } from './reach.js';
31
33
 
32
34
  /**
33
35
  * Declare a model a request can be routed to.