@cotal-ai/registry 0.150.0 → 0.151.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/dist/host.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { type RegistryService, type RegistryServiceHandle, type RegistryServiceInputs } from "@cotal-ai/core";
2
+ /** Serve one auth-owned registry. The host retains every credential and connection's custody. */
3
+ export declare function startRegistryService(inputs: RegistryServiceInputs): Promise<RegistryServiceHandle>;
4
+ /** Loaded on demand by the binary's existing extension registry. */
5
+ export declare const registryService: RegistryService;
6
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAC7E,MAAM,gBAAgB,CAAC;AAKxB,iGAAiG;AACjG,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAgFxG;AAED,oEAAoE;AACpE,eAAO,MAAM,eAAe,EAAE,eAI7B,CAAC"}
package/dist/host.js ADDED
@@ -0,0 +1,104 @@
1
+ import { EpEnvelopeError, REGISTRY_ENDPOINT, registry, serveEndpoint, } from "@cotal-ai/core";
2
+ import { natsRegistryReads } from "./reads.js";
3
+ import { registryCommandDefs } from "./serve.js";
4
+ /** Serve one auth-owned registry. The host retains every credential and connection's custody. */
5
+ export async function startRegistryService(inputs) {
6
+ const { space, connection, reader, grant, signal, log } = inputs;
7
+ if (grant.endpoint !== REGISTRY_ENDPOINT || grant.space !== space)
8
+ throw new Error("the registry grant must name this space's registry endpoint");
9
+ if (reader === connection)
10
+ throw new Error("the registry reader and serving connection must be separate");
11
+ let refused = false, generation = 0;
12
+ let native;
13
+ const proofs = new Set();
14
+ const active = () => {
15
+ if (refused || signal.aborted)
16
+ throw new EpEnvelopeError("unavailable", "the registry's authority plane is unavailable");
17
+ };
18
+ const available = () => {
19
+ active();
20
+ if (!native)
21
+ throw new EpEnvelopeError("unavailable", "the registry reader is not currently bound and proved");
22
+ return native;
23
+ };
24
+ const guarded = async (read) => {
25
+ const bound = available();
26
+ const result = await read(bound);
27
+ if (available() !== bound)
28
+ throw new EpEnvelopeError("unavailable", "the registry reader rebound during this request");
29
+ return result;
30
+ };
31
+ const bind = async () => {
32
+ const epoch = ++generation;
33
+ native = undefined;
34
+ const proved = await natsRegistryReads(reader, space);
35
+ active();
36
+ if (epoch === generation)
37
+ native = proved;
38
+ };
39
+ active();
40
+ await bind();
41
+ const reads = {
42
+ observe: (ref) => guarded((r) => r.observe(ref)),
43
+ instances: () => guarded((r) => r.instances()),
44
+ clusterDigests: (endpoint, instance) => guarded((r) => r.clusterDigests(endpoint, instance)),
45
+ state: (endpoint, instance) => guarded((r) => r.state(endpoint, instance)),
46
+ artifact: (digest) => guarded((r) => r.artifact(digest)),
47
+ };
48
+ const commands = registryCommandDefs({ space, mode: "authed", reads, log }).map((def) => ({
49
+ ...def,
50
+ handler: async (ctx) => {
51
+ const bound = available();
52
+ const result = await def.handler(ctx);
53
+ if (available() !== bound)
54
+ throw new EpEnvelopeError("unavailable", "the registry reader rebound during this request");
55
+ return result;
56
+ },
57
+ }));
58
+ const handle = serveEndpoint(connection, space, grant, commands, {
59
+ view: () => { available(); return { commands: [...grant.commands] }; },
60
+ });
61
+ // The same native status stream the auth reader uses: a renewal reconnect invalidates its
62
+ // proof, and only a new bind makes it usable. Requests crossing a bind are refused above.
63
+ void (async () => {
64
+ for await (const status of reader.status()) {
65
+ if (refused || signal.aborted)
66
+ break;
67
+ if (status.type === "disconnect") {
68
+ native = undefined;
69
+ generation++;
70
+ }
71
+ else if (status.type === "reconnect") {
72
+ const proof = bind();
73
+ proofs.add(proof);
74
+ void proof.catch((error) => {
75
+ if (!refused && !signal.aborted)
76
+ inputs.onFailure(`registry reader rebind failed: ${error instanceof Error ? error.message : String(error)}`);
77
+ }).finally(() => proofs.delete(proof));
78
+ }
79
+ }
80
+ })().catch((error) => {
81
+ if (!refused && !signal.aborted)
82
+ inputs.onFailure(`registry reader supervision failed: ${error instanceof Error ? error.message : String(error)}`);
83
+ });
84
+ const refuse = () => { refused = true; native = undefined; generation++; };
85
+ let stopping;
86
+ return {
87
+ refuse,
88
+ stop: () => {
89
+ refuse();
90
+ return stopping ??= (async () => {
91
+ await handle.stop();
92
+ await Promise.allSettled([...proofs]);
93
+ })();
94
+ },
95
+ };
96
+ }
97
+ /** Loaded on demand by the binary's existing extension registry. */
98
+ export const registryService = {
99
+ kind: "registry-service",
100
+ name: "builtin",
101
+ start: startRegistryService,
102
+ };
103
+ registry.register(registryService);
104
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,GAE5D,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAA6B;IACtE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IACjE,IAAI,KAAK,CAAC,QAAQ,KAAK,iBAAiB,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK;QAC/D,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,IAAI,MAAM,KAAK,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC1G,IAAI,OAAO,GAAG,KAAK,EAAE,UAAU,GAAG,CAAC,CAAC;IACpC,IAAI,MAAiC,CAAC;IACtC,MAA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;IACH,MAAM,MAAM,GAAG,GAAS,EAAE,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,IAAI,QAAmC,CAAC;IACxC,OAAO;QACL,MAAM;QACN,IAAI,EAAE,GAAG,EAAE;YACT,MAAM,EAAE,CAAC;YACT,OAAO,QAAQ,KAAK,CAAC,KAAK,IAAI,EAAE;gBAC9B,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBACpB,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YACxC,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;KACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AACF,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./answer.js";
2
2
  export * from "./reads.js";
3
3
  export * from "./serve.js";
4
+ export * from "./host.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./answer.js";
2
2
  export * from "./reads.js";
3
3
  export * from "./serve.js";
4
+ export * from "./host.js";
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cotal-ai/registry",
3
3
  "description": "Cotal registry: the registered endpoint that answers discovery questions, starting with the endpoints a caller's recorded grants cover.",
4
- "version": "0.150.0",
4
+ "version": "0.151.1",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@cotal-ai/core": "0.150.0",
21
+ "@cotal-ai/core": "0.151.1",
22
22
  "@nats-io/jetstream": "^3.4.0",
23
23
  "@nats-io/transport-node": "^3.4.0",
24
24
  "@nats-io/kv": "^3.4.0"