@moltzap/identity 2026.902.0
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/LICENSE +202 -0
- package/NOTICE +19 -0
- package/README.md +31 -0
- package/bin/moltzap-registry +9 -0
- package/dist/agent-card.d.ts +69 -0
- package/dist/agent-card.d.ts.map +1 -0
- package/dist/agent-card.js +257 -0
- package/dist/agent-card.js.map +1 -0
- package/dist/agent-key.d.ts +77 -0
- package/dist/agent-key.d.ts.map +1 -0
- package/dist/agent-key.js +251 -0
- package/dist/agent-key.js.map +1 -0
- package/dist/authenticated-http.d.ts +44 -0
- package/dist/authenticated-http.d.ts.map +1 -0
- package/dist/authenticated-http.js +226 -0
- package/dist/authenticated-http.js.map +1 -0
- package/dist/canonical-json.d.ts +40 -0
- package/dist/canonical-json.d.ts.map +1 -0
- package/dist/canonical-json.js +399 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/http-errors.d.ts +115 -0
- package/dist/http-errors.d.ts.map +1 -0
- package/dist/http-errors.js +55 -0
- package/dist/http-errors.js.map +1 -0
- package/dist/http-signature.d.ts +60 -0
- package/dist/http-signature.d.ts.map +1 -0
- package/dist/http-signature.js +337 -0
- package/dist/http-signature.js.map +1 -0
- package/dist/identifiers.d.ts +32 -0
- package/dist/identifiers.d.ts.map +1 -0
- package/dist/identifiers.js +55 -0
- package/dist/identifiers.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/admission.d.ts +27 -0
- package/dist/registry/admission.d.ts.map +1 -0
- package/dist/registry/admission.js +107 -0
- package/dist/registry/admission.js.map +1 -0
- package/dist/registry/client.d.ts +20 -0
- package/dist/registry/client.d.ts.map +1 -0
- package/dist/registry/client.js +250 -0
- package/dist/registry/client.js.map +1 -0
- package/dist/registry/contract.d.ts +213 -0
- package/dist/registry/contract.d.ts.map +1 -0
- package/dist/registry/contract.js +132 -0
- package/dist/registry/contract.js.map +1 -0
- package/dist/registry/http.d.ts +27 -0
- package/dist/registry/http.d.ts.map +1 -0
- package/dist/registry/http.js +258 -0
- package/dist/registry/http.js.map +1 -0
- package/dist/registry/migrations/0001_registry.d.ts +6 -0
- package/dist/registry/migrations/0001_registry.d.ts.map +1 -0
- package/dist/registry/migrations/0001_registry.js +36 -0
- package/dist/registry/migrations/0001_registry.js.map +1 -0
- package/dist/registry/rpc.d.ts +138 -0
- package/dist/registry/rpc.d.ts.map +1 -0
- package/dist/registry/rpc.js +85 -0
- package/dist/registry/rpc.js.map +1 -0
- package/dist/registry/server.d.ts +52 -0
- package/dist/registry/server.d.ts.map +1 -0
- package/dist/registry/server.js +157 -0
- package/dist/registry/server.js.map +1 -0
- package/dist/registry/storage.d.ts +62 -0
- package/dist/registry/storage.d.ts.map +1 -0
- package/dist/registry/storage.js +341 -0
- package/dist/registry/storage.js.map +1 -0
- package/dist/registry.d.ts +34 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +13 -0
- package/dist/registry.js.map +1 -0
- package/dist/signed-message.d.ts +54 -0
- package/dist/signed-message.d.ts.map +1 -0
- package/dist/signed-message.js +289 -0
- package/dist/signed-message.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** @file Complete Registry-owned client, request, and representation contract. */
|
|
2
|
+
import { Data, Schema } from "effect";
|
|
3
|
+
import { AgentCard, verifiedAgentCardSchema, } from "../agent-card.js";
|
|
4
|
+
import { Ed25519PublicKey } from "../agent-key.js";
|
|
5
|
+
import { AgentId, AgentName, canonicalIdentifier, PrincipalId, } from "../identifiers.js";
|
|
6
|
+
/** Idempotency identity for a registration operation. */
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Effect Schemas share the public domain name they decode.
|
|
8
|
+
export const OperationId = canonicalIdentifier("OperationId", "opn_", 16);
|
|
9
|
+
/** The Registry connection could not be established or used. */
|
|
10
|
+
export class RegistryConnectionError extends Data.TaggedError("RegistryConnectionError") {
|
|
11
|
+
}
|
|
12
|
+
/** The configured complete Registry call deadline expired. */
|
|
13
|
+
export class RegistryRequestTimeoutError extends Data.TaggedError("RegistryRequestTimeoutError") {
|
|
14
|
+
}
|
|
15
|
+
/** A Registry response did not match the selected operation contract. */
|
|
16
|
+
export class RegistryInvalidResponseError extends Data.TaggedError("RegistryInvalidResponseError") {
|
|
17
|
+
}
|
|
18
|
+
const exactStruct = (fields) => Schema.Struct(fields).annotations({
|
|
19
|
+
parseOptions: {
|
|
20
|
+
exact: true,
|
|
21
|
+
onExcessProperty: "error",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
/** Closed Registry bootstrap registration request. */
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Effect Schemas share the public domain name they decode.
|
|
26
|
+
export const RegistryRegisterRequest = exactStruct({
|
|
27
|
+
operationId: OperationId,
|
|
28
|
+
principalId: PrincipalId,
|
|
29
|
+
agentName: AgentName,
|
|
30
|
+
publicKey: Ed25519PublicKey,
|
|
31
|
+
}).annotations({ identifier: "RegistryRegisterRequest" });
|
|
32
|
+
/** Closed Registry lookup selector. */
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Effect Schemas share the public domain name they decode.
|
|
34
|
+
export const RegistryLookupRequest = Schema.Union(exactStruct({ agentId: AgentId }), exactStruct({ agentName: AgentName })).annotations({
|
|
35
|
+
identifier: "RegistryLookupRequest",
|
|
36
|
+
parseOptions: {
|
|
37
|
+
exact: true,
|
|
38
|
+
onExcessProperty: "error",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
/** Closed Registry list continuation request. */
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Effect Schemas share the public domain name they decode.
|
|
43
|
+
export const RegistryListRequest = exactStruct({
|
|
44
|
+
afterAgentId: Schema.optional(AgentId),
|
|
45
|
+
}).annotations({ identifier: "RegistryListRequest" });
|
|
46
|
+
/** Package-private validated registration outcome. */
|
|
47
|
+
// eslint-disable-next-line agent-code-guard/no-exported-brand-constructor -- The private RPC descriptor consumes this verified in-process Schema; the package root does not export it.
|
|
48
|
+
export const registerResultSchema = Schema.Union(exactStruct({
|
|
49
|
+
kind: Schema.Literal("registered"),
|
|
50
|
+
agentCard: verifiedAgentCardSchema,
|
|
51
|
+
}), exactStruct({ kind: Schema.Literal("name_taken") }), exactStruct({ kind: Schema.Literal("key_already_registered") }), exactStruct({ kind: Schema.Literal("idempotency_conflict") }));
|
|
52
|
+
/** Package-private validated lookup outcome. */
|
|
53
|
+
// eslint-disable-next-line agent-code-guard/no-exported-brand-constructor -- The private RPC descriptor consumes this verified in-process Schema; the package root does not export it.
|
|
54
|
+
export const lookupResultSchema = Schema.Union(exactStruct({
|
|
55
|
+
kind: Schema.Literal("found"),
|
|
56
|
+
agentCard: verifiedAgentCardSchema,
|
|
57
|
+
}), exactStruct({ kind: Schema.Literal("not_found") }));
|
|
58
|
+
/** Package-private validated list outcome. */
|
|
59
|
+
export const listResultSchema = exactStruct({
|
|
60
|
+
kind: Schema.Literal("page"),
|
|
61
|
+
agentCards: Schema.Array(verifiedAgentCardSchema),
|
|
62
|
+
hasMore: Schema.Boolean,
|
|
63
|
+
});
|
|
64
|
+
/** Exact registration response representation used by both HTTP adapters. */
|
|
65
|
+
// eslint-disable-next-line agent-code-guard/no-exported-brand-constructor -- Private HTTP and storage adapters share this Schema; the package root does not export it.
|
|
66
|
+
export const registerResponseSchema = Schema.Union(exactStruct({
|
|
67
|
+
kind: Schema.Literal("registered"),
|
|
68
|
+
agentCard: AgentCard,
|
|
69
|
+
}), exactStruct({ kind: Schema.Literal("name_taken") }), exactStruct({ kind: Schema.Literal("key_already_registered") }), exactStruct({ kind: Schema.Literal("idempotency_conflict") }));
|
|
70
|
+
/** Exact lookup response representation used by both HTTP adapters. */
|
|
71
|
+
// eslint-disable-next-line agent-code-guard/no-exported-brand-constructor -- Private HTTP adapters share this Schema; the package root does not export it.
|
|
72
|
+
export const lookupResponseSchema = Schema.Union(exactStruct({
|
|
73
|
+
kind: Schema.Literal("found"),
|
|
74
|
+
agentCard: AgentCard,
|
|
75
|
+
}), exactStruct({ kind: Schema.Literal("not_found") }));
|
|
76
|
+
/** Exact list response representation used by both HTTP adapters. */
|
|
77
|
+
export const listResponseSchema = exactStruct({
|
|
78
|
+
kind: Schema.Literal("page"),
|
|
79
|
+
agentCards: Schema.Array(AgentCard),
|
|
80
|
+
hasMore: Schema.Boolean,
|
|
81
|
+
});
|
|
82
|
+
/** Exact bootstrap registration HTTP body. */
|
|
83
|
+
export const registrationBody = exactStruct({
|
|
84
|
+
request: RegistryRegisterRequest,
|
|
85
|
+
});
|
|
86
|
+
/** Exact bootstrap registration request path. */
|
|
87
|
+
export const REGISTER_PATH = "/v1/identities:register";
|
|
88
|
+
/** Exact public lookup request path. */
|
|
89
|
+
export const LOOKUP_PATH = "/v1/identities:lookup";
|
|
90
|
+
/** Exact public list request path. */
|
|
91
|
+
export const LIST_PATH = "/v1/identities:list";
|
|
92
|
+
/** Exact Registry readiness path. */
|
|
93
|
+
export const HEALTH_PATH = "/healthz";
|
|
94
|
+
/** Effect Router patterns escape the literal colon in Registry paths. */
|
|
95
|
+
export const REGISTER_ROUTE = "/v1/identities::register";
|
|
96
|
+
/** Effect Router pattern for the literal lookup path. */
|
|
97
|
+
export const LOOKUP_ROUTE = "/v1/identities::lookup";
|
|
98
|
+
/** Effect Router pattern for the literal list path. */
|
|
99
|
+
export const LIST_ROUTE = "/v1/identities::list";
|
|
100
|
+
/** Exact paths used to classify method mismatches at the fallback route. */
|
|
101
|
+
export const KNOWN_PATHS = new Set([
|
|
102
|
+
REGISTER_PATH,
|
|
103
|
+
LOOKUP_PATH,
|
|
104
|
+
LIST_PATH,
|
|
105
|
+
HEALTH_PATH,
|
|
106
|
+
]);
|
|
107
|
+
const maximumIdentifier = "agt_AAAAAAAAAAAAAAAAAAAAAA";
|
|
108
|
+
const maximumOperationId = "opn_AAAAAAAAAAAAAAAAAAAAAA";
|
|
109
|
+
const maximumPrincipalId = "prn_AAAAAAAAAAAAAAAAAAAAAA";
|
|
110
|
+
const maximumName = "a".repeat(32);
|
|
111
|
+
const maximumCoordinate = "A".repeat(43);
|
|
112
|
+
const byteLength = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
113
|
+
/** Derived exact maximum bootstrap registration body size. */
|
|
114
|
+
export const REGISTER_BODY_CAP = byteLength({
|
|
115
|
+
request: {
|
|
116
|
+
operationId: maximumOperationId,
|
|
117
|
+
principalId: maximumPrincipalId,
|
|
118
|
+
agentName: maximumName,
|
|
119
|
+
publicKey: {
|
|
120
|
+
crv: "Ed25519",
|
|
121
|
+
kty: "OKP",
|
|
122
|
+
x: maximumCoordinate,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
/** Derived exact maximum public lookup body size. */
|
|
127
|
+
export const LOOKUP_BODY_CAP = Math.max(byteLength({ agentId: maximumIdentifier }), byteLength({ agentName: maximumName }));
|
|
128
|
+
/** Derived exact maximum public list body size. */
|
|
129
|
+
export const LIST_BODY_CAP = byteLength({
|
|
130
|
+
afterAgentId: maximumIdentifier,
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/registry/contract.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,OAAO,EAAE,IAAI,EAA8B,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EACL,SAAS,EAET,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA8B,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EACL,OAAO,EACP,SAAS,EACT,mBAAmB,EACnB,WAA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BAAiB,EAAE,CAAC,EAC1C,UAAU,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CACvC,CAAC;AAEF,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;IACtC,YAAY,EAAE,iBAAiB;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @file Authenticated Registry HTTP routes, bounded framing, and exact envelopes. */
|
|
2
|
+
import { HttpRouter } from "@effect/platform";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import type { RegistryStorage } from "./storage.js";
|
|
5
|
+
import { verifyBootstrapRegistration } from "./admission.js";
|
|
6
|
+
import { type RegistryRpcClient } from "./rpc.js";
|
|
7
|
+
type RegistryHttpAppInput = Readonly<{
|
|
8
|
+
client: RegistryRpcClient;
|
|
9
|
+
storage: RegistryStorage;
|
|
10
|
+
admissionCredential: Parameters<typeof verifyBootstrapRegistration>[0]["admissionCredential"];
|
|
11
|
+
nonceCapacity: number;
|
|
12
|
+
requestSemaphore: Effect.Semaphore;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Builds the complete Registry HTTP application.
|
|
16
|
+
*
|
|
17
|
+
* @param input Complete Registry boundary dependencies.
|
|
18
|
+
* @param input.client In-process RPC client for domain operations.
|
|
19
|
+
* @param input.storage Durable registration nonce storage.
|
|
20
|
+
* @param input.admissionCredential Bootstrap admission secret.
|
|
21
|
+
* @param input.nonceCapacity Maximum live bootstrap nonces.
|
|
22
|
+
* @param input.requestSemaphore Immediate global request admission.
|
|
23
|
+
* @returns The complete Registry HTTP application.
|
|
24
|
+
*/
|
|
25
|
+
export declare function makeRegistryHttpApp(input: RegistryHttpAppInput): HttpRouter.HttpRouter<never, never>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/registry/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EACL,UAAU,EAGX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAS,MAAM,EAAkB,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAepD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAmB7D,OAAO,EAAE,KAAK,iBAAiB,EAA0B,MAAM,UAAU,CAAC;AAE1E,KAAK,oBAAoB,GAAG,QAAQ,CAAC;IACnC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,eAAe,CAAC;IACzB,mBAAmB,EAAE,UAAU,CAC7B,OAAO,2BAA2B,CACnC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC;CACpC,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,uCAQ9D"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/** @file Authenticated Registry HTTP routes, bounded framing, and exact envelopes. */
|
|
2
|
+
import { HttpRouter, HttpServerRequest, HttpServerResponse, } from "@effect/platform";
|
|
3
|
+
import { NodeHttpServerRequest } from "@effect/platform-node";
|
|
4
|
+
import { Cause, Effect, Option, Schema } from "effect";
|
|
5
|
+
import { decodeCanonicalJson, encodeCanonicalJson } from "../canonical-json.js";
|
|
6
|
+
import { httpEnvelope, InternalServerError, MalformedRequestError, MethodNotAllowedError, OverloadedError, PayloadTooLargeError, RouteNotFoundError, UnsupportedMediaTypeError, VersionMismatchError, } from "../http-errors.js";
|
|
7
|
+
import { MOLTZAP_VERSION } from "../version.js";
|
|
8
|
+
import { verifyBootstrapRegistration } from "./admission.js";
|
|
9
|
+
import { HEALTH_PATH, KNOWN_PATHS, LIST_BODY_CAP, LIST_PATH, LIST_ROUTE, listResponseSchema, LOOKUP_BODY_CAP, LOOKUP_PATH, LOOKUP_ROUTE, lookupResponseSchema, REGISTER_BODY_CAP, REGISTER_PATH, REGISTER_ROUTE, registerResponseSchema, RegistryListRequest, RegistryLookupRequest, } from "./contract.js";
|
|
10
|
+
import { withBootstrapAdmission } from "./rpc.js";
|
|
11
|
+
/**
|
|
12
|
+
* Builds the complete Registry HTTP application.
|
|
13
|
+
*
|
|
14
|
+
* @param input Complete Registry boundary dependencies.
|
|
15
|
+
* @param input.client In-process RPC client for domain operations.
|
|
16
|
+
* @param input.storage Durable registration nonce storage.
|
|
17
|
+
* @param input.admissionCredential Bootstrap admission secret.
|
|
18
|
+
* @param input.nonceCapacity Maximum live bootstrap nonces.
|
|
19
|
+
* @param input.requestSemaphore Immediate global request admission.
|
|
20
|
+
* @returns The complete Registry HTTP application.
|
|
21
|
+
*/
|
|
22
|
+
export function makeRegistryHttpApp(input) {
|
|
23
|
+
return HttpRouter.empty.pipe(HttpRouter.post(REGISTER_ROUTE, registerHandler(input)), lookupRoute(input), listRoute(input), healthRoute(input.storage), fallbackRoute());
|
|
24
|
+
}
|
|
25
|
+
const JSON_CONTENT_TYPE = "application/json";
|
|
26
|
+
const SIGNATURE_HEADERS = [
|
|
27
|
+
"content-digest",
|
|
28
|
+
"signature-input",
|
|
29
|
+
"signature",
|
|
30
|
+
"authorization",
|
|
31
|
+
];
|
|
32
|
+
const SINGLE_VALUE_HEADERS = [
|
|
33
|
+
"host",
|
|
34
|
+
"content-type",
|
|
35
|
+
"content-encoding",
|
|
36
|
+
"content-length",
|
|
37
|
+
"transfer-encoding",
|
|
38
|
+
"moltzap-version",
|
|
39
|
+
...SIGNATURE_HEADERS,
|
|
40
|
+
];
|
|
41
|
+
function lookupRoute(input) {
|
|
42
|
+
return HttpRouter.post(LOOKUP_ROUTE, publicReadHandler({
|
|
43
|
+
path: LOOKUP_PATH,
|
|
44
|
+
bodyCap: LOOKUP_BODY_CAP,
|
|
45
|
+
requestSchema: RegistryLookupRequest,
|
|
46
|
+
resultSchema: lookupResponseSchema,
|
|
47
|
+
invoke: (request) => input.client.lookup(request),
|
|
48
|
+
requestSemaphore: input.requestSemaphore,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
function listRoute(input) {
|
|
52
|
+
return HttpRouter.post(LIST_ROUTE, publicReadHandler({
|
|
53
|
+
path: LIST_PATH,
|
|
54
|
+
bodyCap: LIST_BODY_CAP,
|
|
55
|
+
requestSchema: RegistryListRequest,
|
|
56
|
+
resultSchema: listResponseSchema,
|
|
57
|
+
invoke: (request) => input.client.list(request),
|
|
58
|
+
requestSemaphore: input.requestSemaphore,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
function healthRoute(storage) {
|
|
62
|
+
return HttpRouter.get(HEALTH_PATH, Effect.gen(function* () {
|
|
63
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
64
|
+
if (request.url !== HEALTH_PATH) {
|
|
65
|
+
return errorResponse(new RouteNotFoundError());
|
|
66
|
+
}
|
|
67
|
+
return yield* storage.checkReadiness().pipe(Effect.match({
|
|
68
|
+
onFailure: () => HttpServerResponse.empty({ status: 503 }),
|
|
69
|
+
onSuccess: () => HttpServerResponse.empty({ status: 204 }),
|
|
70
|
+
}), Effect.catchAllCause(() => Effect.succeed(HttpServerResponse.empty({ status: 503 }))));
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
function fallbackRoute() {
|
|
74
|
+
return HttpRouter.all("*", Effect.gen(function* () {
|
|
75
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
76
|
+
if (request.url.includes("?")) {
|
|
77
|
+
return errorResponse(new RouteNotFoundError());
|
|
78
|
+
}
|
|
79
|
+
const path = request.url.split("?", 1)[0] ?? "";
|
|
80
|
+
return KNOWN_PATHS.has(path)
|
|
81
|
+
? errorResponse(new MethodNotAllowedError())
|
|
82
|
+
: errorResponse(new RouteNotFoundError());
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
function registerHandler(input) {
|
|
86
|
+
return recoverHttpResponse(Effect.gen(function* () {
|
|
87
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
88
|
+
if (request.url !== REGISTER_PATH) {
|
|
89
|
+
return yield* new RouteNotFoundError();
|
|
90
|
+
}
|
|
91
|
+
yield* validateRequestFraming({
|
|
92
|
+
request,
|
|
93
|
+
maximumBytes: REGISTER_BODY_CAP,
|
|
94
|
+
profile: "registration",
|
|
95
|
+
});
|
|
96
|
+
return yield* executeWithPermit(input.requestSemaphore, Effect.gen(function* () {
|
|
97
|
+
const bodyBytes = yield* readBoundedBody(request, REGISTER_BODY_CAP);
|
|
98
|
+
const registration = yield* verifyBootstrapRegistration({
|
|
99
|
+
httpRequest: request,
|
|
100
|
+
bodyBytes,
|
|
101
|
+
admissionCredential: input.admissionCredential,
|
|
102
|
+
nonceCapacity: input.nonceCapacity,
|
|
103
|
+
storage: input.storage,
|
|
104
|
+
});
|
|
105
|
+
const result = yield* withBootstrapAdmission(input.client.register(registration));
|
|
106
|
+
return yield* resultResponse(registerResponseSchema, result);
|
|
107
|
+
}));
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
function publicReadHandler(input) {
|
|
111
|
+
return recoverHttpResponse(Effect.gen(function* () {
|
|
112
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
113
|
+
if (request.url !== input.path) {
|
|
114
|
+
return yield* new RouteNotFoundError();
|
|
115
|
+
}
|
|
116
|
+
yield* validateRequestFraming({
|
|
117
|
+
request,
|
|
118
|
+
maximumBytes: input.bodyCap,
|
|
119
|
+
profile: "public-read",
|
|
120
|
+
});
|
|
121
|
+
return yield* executeWithPermit(input.requestSemaphore, Effect.gen(function* () {
|
|
122
|
+
const bodyBytes = yield* readBoundedBody(request, input.bodyCap);
|
|
123
|
+
if (request.headers["moltzap-version"] !== MOLTZAP_VERSION) {
|
|
124
|
+
return yield* new VersionMismatchError();
|
|
125
|
+
}
|
|
126
|
+
const decoded = yield* decodeCanonicalJson(input.requestSchema, bodyBytes).pipe(
|
|
127
|
+
// eslint-disable-next-line agent-code-guard/no-effect-error-coalescing -- Every canonical body or request-schema failure has the same public malformed-request meaning.
|
|
128
|
+
Effect.mapError(() => new MalformedRequestError()));
|
|
129
|
+
const result = yield* input.invoke(decoded);
|
|
130
|
+
return yield* resultResponse(input.resultSchema, result);
|
|
131
|
+
}));
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
function recoverHttpResponse(effect) {
|
|
135
|
+
return effect.pipe(Effect.catchAll((error) => Effect.succeed(errorResponse(error))), Effect.catchAllCause((cause) => Effect.logError("Registry request failed", Cause.squash(cause)).pipe(Effect.as(errorResponse(new InternalServerError())))));
|
|
136
|
+
}
|
|
137
|
+
function executeWithPermit(semaphore, effect) {
|
|
138
|
+
return semaphore
|
|
139
|
+
.withPermitsIfAvailable(1)(effect)
|
|
140
|
+
.pipe(Effect.flatMap(Option.match({
|
|
141
|
+
onNone: () => Effect.fail(new OverloadedError()),
|
|
142
|
+
onSome: Effect.succeed,
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
function validateRequestFraming(input) {
|
|
146
|
+
if (requestFramingIsMalformed(input)) {
|
|
147
|
+
return rejectBeforeBodyRead(input.request, new MalformedRequestError());
|
|
148
|
+
}
|
|
149
|
+
if (mediaTypeIsUnsupported(input.request)) {
|
|
150
|
+
return rejectBeforeBodyRead(input.request, new UnsupportedMediaTypeError());
|
|
151
|
+
}
|
|
152
|
+
return validateDeclaredLength(input.request, input.maximumBytes);
|
|
153
|
+
}
|
|
154
|
+
function requestFramingIsMalformed(input) {
|
|
155
|
+
if (SINGLE_VALUE_HEADERS.some((name) => rawHeaderCount(input.request, name) > 1)) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (input.request.headers["content-length"] !== undefined &&
|
|
159
|
+
input.request.headers["transfer-encoding"] !== undefined) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
return (input.profile === "public-read" &&
|
|
163
|
+
SIGNATURE_HEADERS.some((name) => rawHeaderCount(input.request, name) !== 0));
|
|
164
|
+
}
|
|
165
|
+
function rawHeaderCount(request, name) {
|
|
166
|
+
const incoming = NodeHttpServerRequest.toIncomingMessage(request);
|
|
167
|
+
let count = 0;
|
|
168
|
+
for (let index = 0; index < incoming.rawHeaders.length; index += 2) {
|
|
169
|
+
if (incoming.rawHeaders[index]?.toLowerCase() === name) {
|
|
170
|
+
count += 1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return count;
|
|
174
|
+
}
|
|
175
|
+
function mediaTypeIsUnsupported(request) {
|
|
176
|
+
return (request.headers["content-type"] !== JSON_CONTENT_TYPE ||
|
|
177
|
+
request.headers["content-encoding"] !== undefined);
|
|
178
|
+
}
|
|
179
|
+
function validateDeclaredLength(request, maximumBytes) {
|
|
180
|
+
const headerIsPresent = request.headers["content-length"] !== undefined;
|
|
181
|
+
const declaredLength = canonicalContentLength(request);
|
|
182
|
+
if (headerIsPresent && declaredLength === undefined) {
|
|
183
|
+
return rejectBeforeBodyRead(request, new MalformedRequestError());
|
|
184
|
+
}
|
|
185
|
+
if (declaredLength !== undefined && declaredLength > maximumBytes) {
|
|
186
|
+
return rejectBeforeBodyRead(request, new PayloadTooLargeError());
|
|
187
|
+
}
|
|
188
|
+
return Effect.void;
|
|
189
|
+
}
|
|
190
|
+
function canonicalContentLength(request) {
|
|
191
|
+
const value = request.headers["content-length"];
|
|
192
|
+
if (value === undefined || !/^(?:0|[1-9]\d*)$/.test(value)) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
const parsed = Number(value);
|
|
196
|
+
return Number.isSafeInteger(parsed) ? parsed : undefined;
|
|
197
|
+
}
|
|
198
|
+
function rejectBeforeBodyRead(request, error) {
|
|
199
|
+
return Effect.sync(() => {
|
|
200
|
+
NodeHttpServerRequest.toIncomingMessage(request).resume();
|
|
201
|
+
}).pipe(Effect.zipRight(Effect.fail(error)));
|
|
202
|
+
}
|
|
203
|
+
function readBoundedBody(request, maximumBytes) {
|
|
204
|
+
// #ignore-sloppy-code-next-line[async-keyword]: This Effect callback constructor does not use the JavaScript keyword.
|
|
205
|
+
return Effect.async((resume) => {
|
|
206
|
+
const incoming = NodeHttpServerRequest.toIncomingMessage(request);
|
|
207
|
+
const body = new Uint8Array(maximumBytes);
|
|
208
|
+
let length = 0;
|
|
209
|
+
const reader = {
|
|
210
|
+
cleanup: () => {
|
|
211
|
+
incoming.off("data", reader.onData);
|
|
212
|
+
incoming.off("end", reader.onEnd);
|
|
213
|
+
incoming.off("error", reader.onError);
|
|
214
|
+
},
|
|
215
|
+
onData: (chunk) => {
|
|
216
|
+
if (length + chunk.byteLength > maximumBytes) {
|
|
217
|
+
reader.cleanup();
|
|
218
|
+
incoming.resume();
|
|
219
|
+
resume(Effect.fail(new PayloadTooLargeError()));
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
body.set(chunk, length);
|
|
223
|
+
length += chunk.byteLength;
|
|
224
|
+
},
|
|
225
|
+
onEnd: () => {
|
|
226
|
+
reader.cleanup();
|
|
227
|
+
resume(Effect.succeed(body.slice(0, length)));
|
|
228
|
+
},
|
|
229
|
+
onError: () => {
|
|
230
|
+
reader.cleanup();
|
|
231
|
+
resume(Effect.fail(new MalformedRequestError()));
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
incoming.on("data", reader.onData);
|
|
235
|
+
incoming.once("end", reader.onEnd);
|
|
236
|
+
incoming.once("error", reader.onError);
|
|
237
|
+
return Effect.sync(() => {
|
|
238
|
+
reader.cleanup();
|
|
239
|
+
incoming.resume();
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function resultResponse(schema, value) {
|
|
244
|
+
return Schema.encode(schema)(value).pipe(Effect.flatMap(encodeCanonicalJson), Effect.map((bytes) => jsonResponse(bytes, 200)),
|
|
245
|
+
// eslint-disable-next-line agent-code-guard/no-effect-error-coalescing -- Response serialization is an internal closed boundary with no client-actionable detail.
|
|
246
|
+
Effect.mapError(() => new InternalServerError()));
|
|
247
|
+
}
|
|
248
|
+
function errorResponse(error) {
|
|
249
|
+
const envelope = httpEnvelope(error);
|
|
250
|
+
return jsonResponse(new TextEncoder().encode(`{"error":"${envelope.code}"}`), envelope.status);
|
|
251
|
+
}
|
|
252
|
+
function jsonResponse(bodyBytes, status) {
|
|
253
|
+
return HttpServerResponse.uint8Array(bodyBytes, {
|
|
254
|
+
status,
|
|
255
|
+
contentType: JSON_CONTENT_TYPE,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/registry/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,YAAY,EAEZ,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACL,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,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G,YAAY,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,YAAY,CACjB,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,aAAa,QAAQ,CAAC,IAAI,IAAI,CAAC,EACxD,QAAQ,CAAC,MAAM,CAChB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,SAAqB,EACrB,MAAc;IAEd,OAAO,kBAAkB,CAAC,UAAU,CAAC,SAAS,EAAE;QAC9C,MAAM;QACN,WAAW,EAAE,iBAAiB;KAC/B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** @file Initial PostgreSQL schema for Registry metadata, cards, operations, and replay nonces. */
|
|
2
|
+
import { SqlClient } from "@effect/sql/SqlClient";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
/** Canonical initial Registry schema exercised by Effect Migrator. */
|
|
5
|
+
export declare const registryMigration: Effect.Effect<void, import("@effect/sql/SqlError").SqlError, SqlClient>;
|
|
6
|
+
//# sourceMappingURL=0001_registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0001_registry.d.ts","sourceRoot":"","sources":["../../../src/registry/migrations/0001_registry.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,yEA8Be,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @file Initial PostgreSQL schema for Registry metadata, cards, operations, and replay nonces. */
|
|
2
|
+
import { SqlClient } from "@effect/sql/SqlClient";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
/** Canonical initial Registry schema exercised by Effect Migrator. */
|
|
5
|
+
export const registryMigration = Effect.gen(function* () {
|
|
6
|
+
const sql = yield* SqlClient;
|
|
7
|
+
yield* sql.unsafe(`
|
|
8
|
+
CREATE TABLE moltzap_registry_metadata (
|
|
9
|
+
singleton boolean PRIMARY KEY DEFAULT true CHECK (singleton),
|
|
10
|
+
moltzap_version text NOT NULL,
|
|
11
|
+
signer_thumbprint text NOT NULL
|
|
12
|
+
);
|
|
13
|
+
CREATE TABLE moltzap_registry_agents (
|
|
14
|
+
agent_id text PRIMARY KEY,
|
|
15
|
+
agent_id_bytes bytea NOT NULL UNIQUE,
|
|
16
|
+
principal_id text NOT NULL,
|
|
17
|
+
agent_name text NOT NULL UNIQUE,
|
|
18
|
+
public_key_thumbprint text NOT NULL UNIQUE,
|
|
19
|
+
agent_card_bytes bytea NOT NULL
|
|
20
|
+
);
|
|
21
|
+
CREATE TABLE moltzap_registry_operations (
|
|
22
|
+
public_key_thumbprint text NOT NULL,
|
|
23
|
+
operation_id text NOT NULL,
|
|
24
|
+
request_bytes bytea NOT NULL,
|
|
25
|
+
result_bytes bytea NOT NULL,
|
|
26
|
+
PRIMARY KEY (public_key_thumbprint, operation_id)
|
|
27
|
+
);
|
|
28
|
+
CREATE TABLE moltzap_registry_nonces (
|
|
29
|
+
nonce text PRIMARY KEY,
|
|
30
|
+
expires_at bigint NOT NULL
|
|
31
|
+
);
|
|
32
|
+
CREATE INDEX moltzap_registry_nonces_expiry
|
|
33
|
+
ON moltzap_registry_nonces (expires_at);
|
|
34
|
+
`);
|
|
35
|
+
}).pipe(Effect.withSpan("registryMigration"));
|
|
36
|
+
//# sourceMappingURL=0001_registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0001_registry.js","sourceRoot":"","sources":["../../../src/registry/migrations/0001_registry.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACnD,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC;IAC7B,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BjB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/** @file Private admitted Registry operations and in-process RPC dispatch. */
|
|
2
|
+
import { Rpc, RpcClient, RpcGroup, RpcMiddleware } from "@effect/rpc";
|
|
3
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
|
+
import type { AgentSigningAuthority } from "../agent-key.js";
|
|
5
|
+
import type { RegistryStorage } from "./storage.js";
|
|
6
|
+
import { AuthenticationFailedError, InternalServerError, MalformedRequestError, MethodNotAllowedError, OverloadedError, PayloadTooLargeError, RouteNotFoundError, UnavailableError, UnsupportedMediaTypeError, VersionMismatchError } from "../http-errors.js";
|
|
7
|
+
interface BootstrapAdmission {
|
|
8
|
+
readonly admitted: true;
|
|
9
|
+
}
|
|
10
|
+
declare const BootstrapAdmissionContext_base: Context.TagClass<BootstrapAdmissionContext, "@moltzap/identity/BootstrapAdmissionContext", BootstrapAdmission>;
|
|
11
|
+
declare class BootstrapAdmissionContext extends BootstrapAdmissionContext_base {
|
|
12
|
+
}
|
|
13
|
+
declare const RegistryAdmission_base: RpcMiddleware.TagClass<RegistryAdmission, "@moltzap/identity/RegistryAdmission", {
|
|
14
|
+
readonly provides: typeof BootstrapAdmissionContext;
|
|
15
|
+
readonly failure: typeof AuthenticationFailedError;
|
|
16
|
+
}>;
|
|
17
|
+
/** Required private RPC admission boundary for Registry registration. */
|
|
18
|
+
export declare class RegistryAdmission extends RegistryAdmission_base {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Runs private Registry dispatch with one already-verified admission proof.
|
|
22
|
+
*
|
|
23
|
+
* @param effect Private registration dispatch to admit.
|
|
24
|
+
* @returns The dispatch with its admission proof scoped to the current fiber.
|
|
25
|
+
*/
|
|
26
|
+
export declare const withBootstrapAdmission: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
27
|
+
/** Layer installed only inside the Registry process's private RPC runtime. */
|
|
28
|
+
export declare const registryAdmissionLayer: Layer.Layer<RegistryAdmission, never, never>;
|
|
29
|
+
/** The package-private no-serialization Registry operation group. */
|
|
30
|
+
declare const registryOperations: RpcGroup.RpcGroup<Rpc.Rpc<"list", Schema.Struct<{
|
|
31
|
+
afterAgentId: Schema.optional<Schema.brand<Schema.filter<typeof Schema.String>, "AgentId">>;
|
|
32
|
+
}>, Schema.Struct<{
|
|
33
|
+
kind: Schema.Literal<["page"]>;
|
|
34
|
+
agentCards: Schema.Array$<Schema.declare<import("../agent-card.js").VerifiedAgentCard, import("../agent-card.js").VerifiedAgentCard, readonly [], never>>;
|
|
35
|
+
hasMore: typeof Schema.Boolean;
|
|
36
|
+
}>, Schema.Union<[typeof MalformedRequestError, typeof RouteNotFoundError, typeof MethodNotAllowedError, typeof VersionMismatchError, typeof PayloadTooLargeError, typeof UnsupportedMediaTypeError, typeof OverloadedError, typeof UnavailableError, typeof InternalServerError]>, never> | Rpc.Rpc<"lookup", Schema.Union<[Schema.Struct<{
|
|
37
|
+
agentId: Schema.brand<Schema.filter<typeof Schema.String>, "AgentId">;
|
|
38
|
+
}>, Schema.Struct<{
|
|
39
|
+
agentName: Schema.brand<Schema.filter<Schema.filter<Schema.filter<typeof Schema.String>>>, "AgentName">;
|
|
40
|
+
}>]>, Schema.Union<[Schema.Struct<{
|
|
41
|
+
kind: Schema.Literal<["found"]>;
|
|
42
|
+
agentCard: Schema.declare<import("../agent-card.js").VerifiedAgentCard, import("../agent-card.js").VerifiedAgentCard, readonly [], never>;
|
|
43
|
+
}>, Schema.Struct<{
|
|
44
|
+
kind: Schema.Literal<["not_found"]>;
|
|
45
|
+
}>]>, Schema.Union<[typeof MalformedRequestError, typeof RouteNotFoundError, typeof MethodNotAllowedError, typeof VersionMismatchError, typeof PayloadTooLargeError, typeof UnsupportedMediaTypeError, typeof OverloadedError, typeof UnavailableError, typeof InternalServerError]>, never> | Rpc.Rpc<"register", Schema.Struct<{
|
|
46
|
+
operationId: Schema.brand<Schema.filter<typeof Schema.String>, "OperationId">;
|
|
47
|
+
principalId: Schema.brand<Schema.filter<typeof Schema.String>, "PrincipalId">;
|
|
48
|
+
agentName: Schema.brand<Schema.filter<Schema.filter<Schema.filter<typeof Schema.String>>>, "AgentName">;
|
|
49
|
+
publicKey: Schema.brand<Schema.transform<Schema.Struct<{
|
|
50
|
+
crv: Schema.Literal<["Ed25519"]>;
|
|
51
|
+
kty: Schema.Literal<["OKP"]>;
|
|
52
|
+
x: Schema.filter<typeof Schema.String>;
|
|
53
|
+
}>, Schema.declare<Readonly<{
|
|
54
|
+
crv: "Ed25519";
|
|
55
|
+
kty: "OKP";
|
|
56
|
+
x: string;
|
|
57
|
+
}>, Readonly<{
|
|
58
|
+
crv: "Ed25519";
|
|
59
|
+
kty: "OKP";
|
|
60
|
+
x: string;
|
|
61
|
+
}>, readonly [], never>>, "Ed25519PublicKey">;
|
|
62
|
+
}>, Schema.Union<[Schema.Struct<{
|
|
63
|
+
kind: Schema.Literal<["registered"]>;
|
|
64
|
+
agentCard: Schema.declare<import("../agent-card.js").VerifiedAgentCard, import("../agent-card.js").VerifiedAgentCard, readonly [], never>;
|
|
65
|
+
}>, Schema.Struct<{
|
|
66
|
+
kind: Schema.Literal<["name_taken"]>;
|
|
67
|
+
}>, Schema.Struct<{
|
|
68
|
+
kind: Schema.Literal<["key_already_registered"]>;
|
|
69
|
+
}>, Schema.Struct<{
|
|
70
|
+
kind: Schema.Literal<["idempotency_conflict"]>;
|
|
71
|
+
}>]>, Schema.Union<[typeof MalformedRequestError, typeof AuthenticationFailedError, typeof RouteNotFoundError, typeof MethodNotAllowedError, typeof VersionMismatchError, typeof PayloadTooLargeError, typeof UnsupportedMediaTypeError, typeof OverloadedError, typeof UnavailableError, typeof InternalServerError]>, typeof RegistryAdmission>>;
|
|
72
|
+
/** Private in-process client for the Registry operation group. */
|
|
73
|
+
export type RegistryRpcClient = RpcClient.FromGroup<typeof registryOperations>;
|
|
74
|
+
/** Connects the private Registry RPC client and server in memory. */
|
|
75
|
+
export declare const makeRegistryRpcClient: Effect.Effect<{
|
|
76
|
+
readonly list: <const AsMailbox extends boolean = false, const Discard = false>(input: {
|
|
77
|
+
readonly afterAgentId?: (string & import("effect/Brand").Brand<"AgentId">) | undefined;
|
|
78
|
+
}, options?: {
|
|
79
|
+
readonly headers?: import("@effect/platform/Headers").Input | undefined;
|
|
80
|
+
readonly context?: Context.Context<never> | undefined;
|
|
81
|
+
readonly discard?: Discard | undefined;
|
|
82
|
+
} | undefined) => Effect.Effect<Discard extends true ? void : {
|
|
83
|
+
readonly kind: "page";
|
|
84
|
+
readonly agentCards: readonly import("../agent-card.js").VerifiedAgentCard[];
|
|
85
|
+
readonly hasMore: boolean;
|
|
86
|
+
}, Discard extends true ? never : InternalServerError | MalformedRequestError | MethodNotAllowedError | OverloadedError | PayloadTooLargeError | RouteNotFoundError | UnavailableError | UnsupportedMediaTypeError | VersionMismatchError, never>;
|
|
87
|
+
readonly lookup: <const AsMailbox extends boolean = false, const Discard = false>(input: {
|
|
88
|
+
readonly agentId: string & import("effect/Brand").Brand<"AgentId">;
|
|
89
|
+
} | {
|
|
90
|
+
readonly agentName: string & import("effect/Brand").Brand<"AgentName">;
|
|
91
|
+
}, options?: {
|
|
92
|
+
readonly headers?: import("@effect/platform/Headers").Input | undefined;
|
|
93
|
+
readonly context?: Context.Context<never> | undefined;
|
|
94
|
+
readonly discard?: Discard | undefined;
|
|
95
|
+
} | undefined) => Effect.Effect<Discard extends true ? void : {
|
|
96
|
+
readonly kind: "found";
|
|
97
|
+
readonly agentCard: import("../agent-card.js").VerifiedAgentCard;
|
|
98
|
+
} | {
|
|
99
|
+
readonly kind: "not_found";
|
|
100
|
+
}, Discard extends true ? never : InternalServerError | MalformedRequestError | MethodNotAllowedError | OverloadedError | PayloadTooLargeError | RouteNotFoundError | UnavailableError | UnsupportedMediaTypeError | VersionMismatchError, never>;
|
|
101
|
+
readonly register: <const AsMailbox extends boolean = false, const Discard = false>(input: {
|
|
102
|
+
readonly operationId: string & import("effect/Brand").Brand<"OperationId">;
|
|
103
|
+
readonly principalId: string & import("effect/Brand").Brand<"PrincipalId">;
|
|
104
|
+
readonly agentName: string & import("effect/Brand").Brand<"AgentName">;
|
|
105
|
+
readonly publicKey: Readonly<{
|
|
106
|
+
crv: "Ed25519";
|
|
107
|
+
kty: "OKP";
|
|
108
|
+
x: string;
|
|
109
|
+
}> & import("effect/Brand").Brand<"Ed25519PublicKey">;
|
|
110
|
+
}, options?: {
|
|
111
|
+
readonly headers?: import("@effect/platform/Headers").Input | undefined;
|
|
112
|
+
readonly context?: Context.Context<never> | undefined;
|
|
113
|
+
readonly discard?: Discard | undefined;
|
|
114
|
+
} | undefined) => Effect.Effect<Discard extends true ? void : {
|
|
115
|
+
readonly kind: "registered";
|
|
116
|
+
readonly agentCard: import("../agent-card.js").VerifiedAgentCard;
|
|
117
|
+
} | {
|
|
118
|
+
readonly kind: "name_taken";
|
|
119
|
+
} | {
|
|
120
|
+
readonly kind: "key_already_registered";
|
|
121
|
+
} | {
|
|
122
|
+
readonly kind: "idempotency_conflict";
|
|
123
|
+
}, Discard extends true ? never : AuthenticationFailedError | InternalServerError | MalformedRequestError | MethodNotAllowedError | OverloadedError | PayloadTooLargeError | RouteNotFoundError | UnavailableError | UnsupportedMediaTypeError | VersionMismatchError, never>;
|
|
124
|
+
}, never, Rpc.Handler<"list"> | Rpc.Handler<"lookup"> | Rpc.Handler<"register"> | RegistryAdmission | import("effect/Scope").Scope>;
|
|
125
|
+
/**
|
|
126
|
+
* Implements the three private operations over durable Registry storage.
|
|
127
|
+
*
|
|
128
|
+
* @param input Private RPC handler dependencies.
|
|
129
|
+
* @param input.storage Durable Registry operations.
|
|
130
|
+
* @param input.registrySigningAuthority Registry card issuer.
|
|
131
|
+
* @returns A layer implementing the complete private operation group.
|
|
132
|
+
*/
|
|
133
|
+
export declare const makeRegistryRpcHandlersLayer: (input: {
|
|
134
|
+
readonly storage: RegistryStorage;
|
|
135
|
+
readonly registrySigningAuthority: AgentSigningAuthority;
|
|
136
|
+
}) => Layer.Layer<Rpc.Handler<"list"> | Rpc.Handler<"lookup"> | Rpc.Handler<"register">, never, never>;
|
|
137
|
+
export {};
|
|
138
|
+
//# sourceMappingURL=rpc.d.ts.map
|