@moltzap/protocol 2026.505.4 → 2026.505.5

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.
@@ -21,9 +21,33 @@ export declare const agentId: (value: string) => AgentId;
21
21
  * `HashMap<AgentId, Set<EndpointAddress>>` multimap keyed by agent.
22
22
  */
23
23
  export type EndpointAddress = BrandedString<"EndpointAddress">;
24
- /** Endpoint kinds that may appear at the address prefix. Extending this list
25
- * is the single edit point for new endpoint kinds. */
26
- export declare const ENDPOINT_ADDRESS_KINDS: readonly ["agent", "app"];
24
+ /**
25
+ * Endpoint kinds that may appear at the address prefix. Extending this list
26
+ * is the single edit point for new endpoint kinds.
27
+ *
28
+ * Phase 9 (plan §2.4.a + Phase 8 codex deferral): `agent` carries the
29
+ * durable agent-id form `tm:agent:<agentId>` minted by
30
+ * {@link makeEndpointAddress} for task-manager registration (column
31
+ * `tasks.tm_endpoint_address`). `agent-conn` carries the volatile
32
+ * per-WebSocket-connection form `tm:agent-conn:<connId>` used by
33
+ * `AgentEndpointResolver` to address one specific connection of an
34
+ * authenticated agent. `app` is reserved for app-TM registrations the
35
+ * Phase-9 topology dispatches via in-process loopback or real WS.
36
+ *
37
+ * The split exists because routing semantics differ — `agent` resolves
38
+ * to "any connection of agentId" via the resolver's forward map, while
39
+ * `agent-conn` resolves to exactly one connection via the reverse
40
+ * index. Without distinct kinds, durable TM-routed `network.send`
41
+ * collapses into the per-connection reverse lookup and silently fails
42
+ * with `RecipientNotResolved` for any address whose tail is an agent id
43
+ * rather than a connection id.
44
+ *
45
+ * Order matters: the longer prefix `agent-conn:` MUST appear before
46
+ * `agent:` in the loops below so `startsWith("agent:")` does not
47
+ * pre-empt the `agent-conn` match. The const tuple's declaration order
48
+ * is the sole source of truth for that ordering.
49
+ */
50
+ export declare const ENDPOINT_ADDRESS_KINDS: readonly ["agent-conn", "agent", "app"];
27
51
  export type EndpointAddressKind = (typeof ENDPOINT_ADDRESS_KINDS)[number];
28
52
  /**
29
53
  * Common prefix for every {@link EndpointAddress} on the wire — `tm:`.
@@ -66,10 +90,17 @@ export declare const makeEndpointAddress: (kind: EndpointAddressKind, uuid: stri
66
90
  /**
67
91
  * The kinds of endpoints the actor-model network resolves.
68
92
  *
69
- * - `"agent"` a per-WS-connection endpoint resolved by `AgentId` via the
70
- * resolver multimap. Volatile.
71
- * - `"taskManager"` — a registered TM endpoint, durable in the `tasks` row.
72
- * Persists across the TM's reconnect window.
93
+ * Disambiguation: this is the legacy registration-tag union used by
94
+ * {@link EndpointRegistration}, NOT the address-prefix-driven
95
+ * {@link EndpointAddressKind}. `EndpointAddressKind` (`"agent-conn"`,
96
+ * `"agent"`, `"app"`) parses the wire-format `tm:<kind>:<uuid>` string;
97
+ * `EndpointKind` here labels a registration record's discriminator.
98
+ *
99
+ * - `"agent"` — a registered agent-identity endpoint. The resolver
100
+ * multimap keys by `AgentId`; the matching wire address kinds are
101
+ * `agent-conn` (volatile per-WS) and `agent` (durable per-agent).
102
+ * - `"taskManager"` — a registered TM endpoint, durable in the `tasks`
103
+ * row. Persists across the TM's reconnect window.
73
104
  *
74
105
  * String-literal union: `switch` over `EndpointKind` is exhaustive at the
75
106
  * type level, so adding a third kind here forces every downstream switch to
@@ -1 +1 @@
1
- {"version":3,"file":"actor-model.d.ts","sourceRoot":"","sources":["../../src/network/actor-model.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMlD,qEAAqE;AACrE,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,KAAG,MAA4B,CAAC;AAEpE,iFAAiF;AACjF,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;AAE/C,2FAA2F;AAC3F,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,KAAG,OAA8B,CAAC;AAEvE;;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O,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;CACnC,CAAC;AAMN;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC"}
@@ -25,9 +25,33 @@ export const userId = (value) => UserIdBrand(value);
25
25
  const AgentIdBrand = Brand.nominal();
26
26
  /** Brand a raw string as an {@link AgentId}. See {@link userId} for boundary semantics. */
27
27
  export const agentId = (value) => AgentIdBrand(value);
28
- /** Endpoint kinds that may appear at the address prefix. Extending this list
29
- * is the single edit point for new endpoint kinds. */
30
- export const ENDPOINT_ADDRESS_KINDS = ["agent", "app"];
28
+ /**
29
+ * Endpoint kinds that may appear at the address prefix. Extending this list
30
+ * is the single edit point for new endpoint kinds.
31
+ *
32
+ * Phase 9 (plan §2.4.a + Phase 8 codex deferral): `agent` carries the
33
+ * durable agent-id form `tm:agent:<agentId>` minted by
34
+ * {@link makeEndpointAddress} for task-manager registration (column
35
+ * `tasks.tm_endpoint_address`). `agent-conn` carries the volatile
36
+ * per-WebSocket-connection form `tm:agent-conn:<connId>` used by
37
+ * `AgentEndpointResolver` to address one specific connection of an
38
+ * authenticated agent. `app` is reserved for app-TM registrations the
39
+ * Phase-9 topology dispatches via in-process loopback or real WS.
40
+ *
41
+ * The split exists because routing semantics differ — `agent` resolves
42
+ * to "any connection of agentId" via the resolver's forward map, while
43
+ * `agent-conn` resolves to exactly one connection via the reverse
44
+ * index. Without distinct kinds, durable TM-routed `network.send`
45
+ * collapses into the per-connection reverse lookup and silently fails
46
+ * with `RecipientNotResolved` for any address whose tail is an agent id
47
+ * rather than a connection id.
48
+ *
49
+ * Order matters: the longer prefix `agent-conn:` MUST appear before
50
+ * `agent:` in the loops below so `startsWith("agent:")` does not
51
+ * pre-empt the `agent-conn` match. The const tuple's declaration order
52
+ * is the sole source of truth for that ordering.
53
+ */
54
+ export const ENDPOINT_ADDRESS_KINDS = ["agent-conn", "agent", "app"];
31
55
  /**
32
56
  * Common prefix for every {@link EndpointAddress} on the wire — `tm:`.
33
57
  * Exported so server-side code that mints addresses or routes by kind
@@ -43,6 +67,8 @@ export const isEndpointAddress = (value) => {
43
67
  if (!value.startsWith(ENDPOINT_ADDRESS_PREFIX))
44
68
  return false;
45
69
  const rest = value.slice(ENDPOINT_ADDRESS_PREFIX.length);
70
+ // Walk in declaration order so `agent-conn:` is tried before `agent:`.
71
+ // See ENDPOINT_ADDRESS_KINDS doc for the longest-prefix invariant.
46
72
  for (const kind of ENDPOINT_ADDRESS_KINDS) {
47
73
  const kindPrefix = `${kind}:`;
48
74
  if (rest.startsWith(kindPrefix)) {
@@ -74,6 +100,10 @@ export const endpointAddress = (value) => EndpointAddressBrand(value);
74
100
  export const endpointAddressKind = (address) => {
75
101
  const raw = address;
76
102
  const rest = raw.slice(ENDPOINT_ADDRESS_PREFIX.length);
103
+ // Walk in declaration order — `agent-conn:` must precede `agent:` so
104
+ // the longer prefix wins (a `tm:agent-conn:<uuid>` value would also
105
+ // satisfy `startsWith("agent:")` if `agent` came first, which would
106
+ // mis-classify the kind).
77
107
  for (const kind of ENDPOINT_ADDRESS_KINDS) {
78
108
  if (rest.startsWith(`${kind}:`))
79
109
  return kind;
@@ -1 +1 @@
1
- {"version":3,"file":"actor-model.js","sourceRoot":"","sources":["../../src/network/actor-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAS/B,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,EAAU,CAAC;AAC5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,WA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eG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAwB,EACH,EAAE;IACvB,MAAM,GAAG,GAAG,OAAiB,CAAC;IAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACvD,qEAAqE;IACrE,oEAAoE;IACpE,oEAAoE;IACpE,0BAA0B;IAC1B,KAAK,MAAM,IAAI,IAAI,sBAAsB,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;IAC/C,CAAC;IACD,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAAyB,EACzB,IAAY,EACK,EAAE,CACnB,eAAe,CAAC,GAAG,uBAAuB,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PROTOCOL_VERSION = "2026.505.4";
1
+ export declare const PROTOCOL_VERSION = "2026.505.5";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Auto-bumped by publish workflow
2
- export const PROTOCOL_VERSION = "2026.505.4";
2
+ export const PROTOCOL_VERSION = "2026.505.5";
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltzap/protocol",
3
- "version": "2026.505.4",
3
+ "version": "2026.505.5",
4
4
  "description": "Protocol types and validators for MoltZap messaging",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {