@agentxm/registry-client 0.28.4-bootstrap.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 +110 -0
- package/README.md +9 -0
- package/dist/src/__generated__/registry-client.d.ts +6501 -0
- package/dist/src/__generated__/registry-client.js +2270 -0
- package/dist/src/admin-client.d.ts +181 -0
- package/dist/src/admin-client.js +165 -0
- package/dist/src/archive-cache.d.ts +46 -0
- package/dist/src/archive-cache.js +179 -0
- package/dist/src/atomic-write.d.ts +49 -0
- package/dist/src/atomic-write.js +60 -0
- package/dist/src/axm-package-meta.d.ts +31 -0
- package/dist/src/axm-package-meta.js +31 -0
- package/dist/src/cache-root.d.ts +11 -0
- package/dist/src/cache-root.js +43 -0
- package/dist/src/client.d.ts +270 -0
- package/dist/src/client.js +43 -0
- package/dist/src/deprecation-warning.d.ts +3 -0
- package/dist/src/deprecation-warning.js +16 -0
- package/dist/src/error-mapping.d.ts +82 -0
- package/dist/src/error-mapping.js +186 -0
- package/dist/src/errors.d.ts +107 -0
- package/dist/src/errors.js +98 -0
- package/dist/src/failure-mapping.d.ts +14 -0
- package/dist/src/failure-mapping.js +100 -0
- package/dist/src/fs-helpers.d.ts +12 -0
- package/dist/src/fs-helpers.js +13 -0
- package/dist/src/index.d.ts +33 -0
- package/dist/src/index.js +37 -0
- package/dist/src/integrity.d.ts +13 -0
- package/dist/src/integrity.js +17 -0
- package/dist/src/local-client.d.ts +24 -0
- package/dist/src/local-client.js +815 -0
- package/dist/src/network.d.ts +6 -0
- package/dist/src/network.js +6 -0
- package/dist/src/path-safety.d.ts +18 -0
- package/dist/src/path-safety.js +26 -0
- package/dist/src/purl-match.d.ts +28 -0
- package/dist/src/purl-match.js +35 -0
- package/dist/src/registry-url.d.ts +14 -0
- package/dist/src/registry-url.js +12 -0
- package/dist/src/remote-client.d.ts +27 -0
- package/dist/src/remote-client.js +725 -0
- package/dist/src/request-policy.d.ts +29 -0
- package/dist/src/request-policy.js +190 -0
- package/dist/src/response-body.d.ts +11 -0
- package/dist/src/response-body.js +32 -0
- package/dist/src/retry-after.d.ts +9 -0
- package/dist/src/retry-after.js +28 -0
- package/dist/src/translate.d.ts +20 -0
- package/dist/src/translate.js +170 -0
- package/dist/src/utils.d.ts +60 -0
- package/dist/src/utils.js +187 -0
- package/package.json +55 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared error mapping helpers for registry and auth client implementations.
|
|
3
|
+
*
|
|
4
|
+
* Provides reusable predicates and mappers for converting generated client
|
|
5
|
+
* errors (RegistryClientError, HttpClientError, SchemaError) to the typed
|
|
6
|
+
* registry failure vocabulary.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
12
|
+
import * as Predicate from "effect/Predicate";
|
|
13
|
+
import { isLoopbackAddress } from "./network.js";
|
|
14
|
+
import { RegistryRequestFailed } from "./errors.js";
|
|
15
|
+
import { registryClientErrorToProblem } from "./translate.js";
|
|
16
|
+
// -----------------------------------------------------------------------------
|
|
17
|
+
// Safe Field Access
|
|
18
|
+
// -----------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Safely read a string field from an unknown object.
|
|
21
|
+
*/
|
|
22
|
+
export const getString = (obj, field) => {
|
|
23
|
+
if (obj === null || obj === undefined || typeof obj !== "object")
|
|
24
|
+
return undefined;
|
|
25
|
+
const value = Reflect.get(obj, field);
|
|
26
|
+
return typeof value === "string" ? value : undefined;
|
|
27
|
+
};
|
|
28
|
+
// -----------------------------------------------------------------------------
|
|
29
|
+
// RegistryClientError Predicate
|
|
30
|
+
// -----------------------------------------------------------------------------
|
|
31
|
+
/**
|
|
32
|
+
* Create a type predicate that matches a specific RegistryClientError tag.
|
|
33
|
+
*
|
|
34
|
+
* Usage:
|
|
35
|
+
* ```ts
|
|
36
|
+
* Effect.catchIf(isRegistryClientError("ExtensionsGet404"), ...)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const isRegistryClientError = (tag) => (e) => Predicate.isTagged(e, tag);
|
|
40
|
+
// -----------------------------------------------------------------------------
|
|
41
|
+
// HttpClientError Predicate
|
|
42
|
+
// -----------------------------------------------------------------------------
|
|
43
|
+
/**
|
|
44
|
+
* Type predicate for HttpClientError.
|
|
45
|
+
*/
|
|
46
|
+
export const isHttpClientError = (e) => HttpClientError.isHttpClientError(e);
|
|
47
|
+
/**
|
|
48
|
+
* Type predicate matching HttpClientErrors that are reasonable to retry:
|
|
49
|
+
* transport-level failures (ECONNREFUSED, DNS, etc.) and 5xx status codes.
|
|
50
|
+
* Deterministic failures — encode errors, invalid URLs, decode errors,
|
|
51
|
+
* 4xx statuses — are excluded so they fail fast.
|
|
52
|
+
*/
|
|
53
|
+
export const isTransientHttpClientError = (e) => {
|
|
54
|
+
if (!HttpClientError.isHttpClientError(e))
|
|
55
|
+
return false;
|
|
56
|
+
const reason = e.reason;
|
|
57
|
+
if (reason._tag === "TransportError")
|
|
58
|
+
return true;
|
|
59
|
+
if (reason._tag === "StatusCodeError" && reason.response.status >= 500)
|
|
60
|
+
return true;
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Type predicate for SchemaError from effect/Schema.
|
|
65
|
+
*/
|
|
66
|
+
export const isSchemaError = (e) => e !== null && e !== undefined && typeof e === "object" && "_tag" in e && e._tag === "SchemaError";
|
|
67
|
+
// -----------------------------------------------------------------------------
|
|
68
|
+
// Network Diagnostics
|
|
69
|
+
// -----------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Build user-facing suggestions for network errors.
|
|
72
|
+
* Detects localhost+HTTPS mismatches and provides targeted guidance.
|
|
73
|
+
*/
|
|
74
|
+
export const buildNetworkSuggestions = (baseUrl) => {
|
|
75
|
+
const fallback = "Check registry URL/network connectivity and retry.";
|
|
76
|
+
try {
|
|
77
|
+
const parsed = new URL(baseUrl);
|
|
78
|
+
const isLocalAddr = isLoopbackAddress(parsed.hostname);
|
|
79
|
+
if (isLocalAddr && parsed.protocol === "https:") {
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
description: "Ensure local registry is running with TLS, or switch the source URL to http://localhost:<port>.",
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
if (isLocalAddr) {
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
description: "Ensure local registry is running and reachable at the configured host/port.",
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
return [{ description: fallback }];
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return [{ description: fallback }];
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Build diagnostic details array for network errors.
|
|
101
|
+
* Detects localhost+HTTPS protocol mismatch.
|
|
102
|
+
*/
|
|
103
|
+
export const buildNetworkDiagnosis = (baseUrl) => {
|
|
104
|
+
try {
|
|
105
|
+
const parsed = new URL(baseUrl);
|
|
106
|
+
const isLocalAddr = isLoopbackAddress(parsed.hostname);
|
|
107
|
+
if (isLocalAddr && parsed.protocol === "https:") {
|
|
108
|
+
return ["Diagnosis: Local registry appears HTTP-only while source uses HTTPS."];
|
|
109
|
+
}
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
// -----------------------------------------------------------------------------
|
|
117
|
+
// Tag Utilities
|
|
118
|
+
// -----------------------------------------------------------------------------
|
|
119
|
+
/**
|
|
120
|
+
* Safely read the _tag from an unknown value.
|
|
121
|
+
*/
|
|
122
|
+
export const getTag = (e) => getString(e, "_tag");
|
|
123
|
+
/**
|
|
124
|
+
* Check if an unknown value is a RegistryClientError (has _tag, request, response fields).
|
|
125
|
+
*/
|
|
126
|
+
export const isAnyRegistryClientError = (e) => e !== null &&
|
|
127
|
+
e !== undefined &&
|
|
128
|
+
typeof e === "object" &&
|
|
129
|
+
!HttpClientError.isHttpClientError(e) &&
|
|
130
|
+
"_tag" in e &&
|
|
131
|
+
"response" in e &&
|
|
132
|
+
"request" in e;
|
|
133
|
+
/**
|
|
134
|
+
* Check if an unknown value has a _tag ending with the given suffix.
|
|
135
|
+
*/
|
|
136
|
+
export const hasTagSuffix = (e, suffix) => {
|
|
137
|
+
const tag = getTag(e);
|
|
138
|
+
return tag !== undefined && tag.endsWith(suffix);
|
|
139
|
+
};
|
|
140
|
+
// -----------------------------------------------------------------------------
|
|
141
|
+
// Network Error Mapping
|
|
142
|
+
// -----------------------------------------------------------------------------
|
|
143
|
+
/**
|
|
144
|
+
* Map an HttpClientError to a typed registry failure with the network category.
|
|
145
|
+
*/
|
|
146
|
+
export const mapNetworkError = (error, message, baseUrl) => new RegistryRequestFailed({
|
|
147
|
+
category: "network",
|
|
148
|
+
detail: message,
|
|
149
|
+
metadata: {
|
|
150
|
+
request: {
|
|
151
|
+
service: "registry",
|
|
152
|
+
method: error.request.method,
|
|
153
|
+
url: error.request.url,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
suggestions: buildNetworkSuggestions(baseUrl),
|
|
157
|
+
cause: error,
|
|
158
|
+
});
|
|
159
|
+
// -----------------------------------------------------------------------------
|
|
160
|
+
// Schema Error Mapping
|
|
161
|
+
// -----------------------------------------------------------------------------
|
|
162
|
+
/**
|
|
163
|
+
* Map an input Schema encode error to a typed registry failure.
|
|
164
|
+
*/
|
|
165
|
+
export const mapInputSchemaError = (error, message) => new RegistryRequestFailed({
|
|
166
|
+
category: "validation",
|
|
167
|
+
detail: message,
|
|
168
|
+
cause: error,
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* Map a response Schema decode error to a typed registry failure.
|
|
172
|
+
*/
|
|
173
|
+
export const mapResponseSchemaError = (error, message) => new RegistryRequestFailed({
|
|
174
|
+
category: "internal",
|
|
175
|
+
detail: message,
|
|
176
|
+
cause: error,
|
|
177
|
+
});
|
|
178
|
+
export const mapSchemaError = mapResponseSchemaError;
|
|
179
|
+
// -----------------------------------------------------------------------------
|
|
180
|
+
// Generic Error Mapping
|
|
181
|
+
// -----------------------------------------------------------------------------
|
|
182
|
+
/**
|
|
183
|
+
* Map a RegistryClientError to a typed registry failure for unexpected status codes.
|
|
184
|
+
*/
|
|
185
|
+
export const mapUnexpectedStatusError = (error, _message) => registryClientErrorToProblem(error);
|
|
186
|
+
//# sourceMappingURL=error-mapping.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure vocabulary for the registry-client layer.
|
|
3
|
+
*
|
|
4
|
+
* The three families carry registry-born facts — the problem-details
|
|
5
|
+
* document, the transport evidence, and the request-policy verdict — as
|
|
6
|
+
* typed fields. The category vocabulary uses the same strings as the
|
|
7
|
+
* application error codes so the boundary conversion is a field copy; the
|
|
8
|
+
* application asserts the parity at compile time. Suggestions carried here
|
|
9
|
+
* are external display data (registry-supplied problem guidance, retry
|
|
10
|
+
* hints, network diagnosis) in the shared `SuggestedAction` contract shape.
|
|
11
|
+
*
|
|
12
|
+
* @experimental This API is unstable and may change without notice.
|
|
13
|
+
*/
|
|
14
|
+
import type { SuggestedAction } from "@agentxm/registry-protocol/unstable/suggested-action";
|
|
15
|
+
/** Every category a registry failure can carry. Identical strings to the CLI error codes. */
|
|
16
|
+
export declare const REGISTRY_ERROR_CATEGORIES: readonly ["auth", "conflict", "forbidden", "internal", "network", "not_found", "quota", "rate_limit", "timeout", "unavailable", "validation"];
|
|
17
|
+
export type RegistryErrorCategory = (typeof REGISTRY_ERROR_CATEGORIES)[number];
|
|
18
|
+
export interface RegistryRequestMetadata {
|
|
19
|
+
readonly service: "registry";
|
|
20
|
+
readonly method?: string;
|
|
21
|
+
readonly url: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RegistryResponseMetadata {
|
|
24
|
+
readonly status: number;
|
|
25
|
+
readonly requestId?: string;
|
|
26
|
+
readonly problemCode?: string;
|
|
27
|
+
readonly body?: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface RegistryRequestPolicyMetadata {
|
|
30
|
+
readonly retryable: boolean;
|
|
31
|
+
readonly attemptCount: number;
|
|
32
|
+
readonly maxAttempts: number;
|
|
33
|
+
readonly exhausted: boolean;
|
|
34
|
+
readonly stoppedBy?: "attempt-limit" | "deadline" | "replay-unsafe";
|
|
35
|
+
readonly replaySafety: "safe" | "mutation" | "idempotency-keyed";
|
|
36
|
+
}
|
|
37
|
+
export interface RegistryErrorMetadata {
|
|
38
|
+
readonly request?: RegistryRequestMetadata;
|
|
39
|
+
readonly response?: RegistryResponseMetadata;
|
|
40
|
+
readonly requestPolicy?: RegistryRequestPolicyMetadata;
|
|
41
|
+
}
|
|
42
|
+
declare const RegistryProblem_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
43
|
+
readonly _tag: "RegistryProblem";
|
|
44
|
+
} & Readonly<A>;
|
|
45
|
+
/**
|
|
46
|
+
* The registry answered with a problem-details document. `title` and
|
|
47
|
+
* `detail` are the registry-supplied display strings (absent when the
|
|
48
|
+
* document had none — the application boundary supplies its per-category
|
|
49
|
+
* defaults); `metadata` retains the request and response evidence.
|
|
50
|
+
*/
|
|
51
|
+
export declare class RegistryProblem extends RegistryProblem_base<{
|
|
52
|
+
readonly category: RegistryErrorCategory;
|
|
53
|
+
readonly title?: string;
|
|
54
|
+
readonly detail?: string;
|
|
55
|
+
readonly metadata: RegistryErrorMetadata;
|
|
56
|
+
readonly suggestions?: ReadonlyArray<SuggestedAction>;
|
|
57
|
+
readonly cause: unknown;
|
|
58
|
+
}> {
|
|
59
|
+
}
|
|
60
|
+
declare const RegistryRequestFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
61
|
+
readonly _tag: "RegistryRequestFailed";
|
|
62
|
+
} & Readonly<A>;
|
|
63
|
+
/**
|
|
64
|
+
* A registry request failed without a decodable problem document: network
|
|
65
|
+
* transport, an incompatible response shape, request construction, a
|
|
66
|
+
* deadline timeout, or an unexpected failure.
|
|
67
|
+
*/
|
|
68
|
+
export declare class RegistryRequestFailed extends RegistryRequestFailed_base<{
|
|
69
|
+
readonly category: RegistryErrorCategory;
|
|
70
|
+
readonly detail: string;
|
|
71
|
+
readonly metadata?: RegistryErrorMetadata;
|
|
72
|
+
readonly suggestions?: ReadonlyArray<SuggestedAction>;
|
|
73
|
+
readonly cause?: unknown;
|
|
74
|
+
}> {
|
|
75
|
+
}
|
|
76
|
+
declare const RegistryOperationFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
77
|
+
readonly _tag: "RegistryOperationFailed";
|
|
78
|
+
} & Readonly<A>;
|
|
79
|
+
/**
|
|
80
|
+
* A registry operation failed outside request transport: the local
|
|
81
|
+
* filesystem registry, the archive cache, version selection, or archive
|
|
82
|
+
* extraction.
|
|
83
|
+
*/
|
|
84
|
+
export declare class RegistryOperationFailed extends RegistryOperationFailed_base<{
|
|
85
|
+
readonly category: RegistryErrorCategory;
|
|
86
|
+
readonly detail: string;
|
|
87
|
+
readonly metadata?: RegistryErrorMetadata;
|
|
88
|
+
readonly suggestions?: ReadonlyArray<SuggestedAction>;
|
|
89
|
+
readonly cause?: unknown;
|
|
90
|
+
}> {
|
|
91
|
+
}
|
|
92
|
+
/** Every typed failure the registry-client modules construct. */
|
|
93
|
+
export type RegistryClientFailure = RegistryProblem | RegistryRequestFailed | RegistryOperationFailed;
|
|
94
|
+
export declare const isRegistryClientFailure: (error: unknown) => error is RegistryClientFailure;
|
|
95
|
+
/**
|
|
96
|
+
* Change endpoint semantics while preserving failure evidence and recovery:
|
|
97
|
+
* the given category/title/detail/suggestions replace the carried values,
|
|
98
|
+
* metadata and cause travel unchanged.
|
|
99
|
+
*/
|
|
100
|
+
export declare const withRegistrySemantics: (error: RegistryClientFailure, semantics: {
|
|
101
|
+
readonly category?: RegistryErrorCategory;
|
|
102
|
+
readonly title?: string;
|
|
103
|
+
readonly detail?: string;
|
|
104
|
+
readonly suggestions?: ReadonlyArray<SuggestedAction>;
|
|
105
|
+
}) => RegistryClientFailure;
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure vocabulary for the registry-client layer.
|
|
3
|
+
*
|
|
4
|
+
* The three families carry registry-born facts — the problem-details
|
|
5
|
+
* document, the transport evidence, and the request-policy verdict — as
|
|
6
|
+
* typed fields. The category vocabulary uses the same strings as the
|
|
7
|
+
* application error codes so the boundary conversion is a field copy; the
|
|
8
|
+
* application asserts the parity at compile time. Suggestions carried here
|
|
9
|
+
* are external display data (registry-supplied problem guidance, retry
|
|
10
|
+
* hints, network diagnosis) in the shared `SuggestedAction` contract shape.
|
|
11
|
+
*
|
|
12
|
+
* @experimental This API is unstable and may change without notice.
|
|
13
|
+
*/
|
|
14
|
+
import * as Data from "effect/Data";
|
|
15
|
+
/** Every category a registry failure can carry. Identical strings to the CLI error codes. */
|
|
16
|
+
export const REGISTRY_ERROR_CATEGORIES = [
|
|
17
|
+
"auth",
|
|
18
|
+
"conflict",
|
|
19
|
+
"forbidden",
|
|
20
|
+
"internal",
|
|
21
|
+
"network",
|
|
22
|
+
"not_found",
|
|
23
|
+
"quota",
|
|
24
|
+
"rate_limit",
|
|
25
|
+
"timeout",
|
|
26
|
+
"unavailable",
|
|
27
|
+
"validation",
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* The registry answered with a problem-details document. `title` and
|
|
31
|
+
* `detail` are the registry-supplied display strings (absent when the
|
|
32
|
+
* document had none — the application boundary supplies its per-category
|
|
33
|
+
* defaults); `metadata` retains the request and response evidence.
|
|
34
|
+
*/
|
|
35
|
+
export class RegistryProblem extends Data.TaggedError("RegistryProblem") {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A registry request failed without a decodable problem document: network
|
|
39
|
+
* transport, an incompatible response shape, request construction, a
|
|
40
|
+
* deadline timeout, or an unexpected failure.
|
|
41
|
+
*/
|
|
42
|
+
export class RegistryRequestFailed extends Data.TaggedError("RegistryRequestFailed") {
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A registry operation failed outside request transport: the local
|
|
46
|
+
* filesystem registry, the archive cache, version selection, or archive
|
|
47
|
+
* extraction.
|
|
48
|
+
*/
|
|
49
|
+
export class RegistryOperationFailed extends Data.TaggedError("RegistryOperationFailed") {
|
|
50
|
+
}
|
|
51
|
+
export const isRegistryClientFailure = (error) => error instanceof RegistryProblem ||
|
|
52
|
+
error instanceof RegistryRequestFailed ||
|
|
53
|
+
error instanceof RegistryOperationFailed;
|
|
54
|
+
/**
|
|
55
|
+
* Change endpoint semantics while preserving failure evidence and recovery:
|
|
56
|
+
* the given category/title/detail/suggestions replace the carried values,
|
|
57
|
+
* metadata and cause travel unchanged.
|
|
58
|
+
*/
|
|
59
|
+
export const withRegistrySemantics = (error, semantics) => {
|
|
60
|
+
switch (error._tag) {
|
|
61
|
+
case "RegistryProblem":
|
|
62
|
+
return new RegistryProblem({
|
|
63
|
+
category: semantics.category ?? error.category,
|
|
64
|
+
...((semantics.title ?? error.title) === undefined
|
|
65
|
+
? {}
|
|
66
|
+
: { title: semantics.title ?? error.title }),
|
|
67
|
+
...((semantics.detail ?? error.detail) === undefined
|
|
68
|
+
? {}
|
|
69
|
+
: { detail: semantics.detail ?? error.detail }),
|
|
70
|
+
metadata: error.metadata,
|
|
71
|
+
...((semantics.suggestions ?? error.suggestions) === undefined
|
|
72
|
+
? {}
|
|
73
|
+
: { suggestions: semantics.suggestions ?? error.suggestions }),
|
|
74
|
+
cause: error.cause,
|
|
75
|
+
});
|
|
76
|
+
case "RegistryRequestFailed":
|
|
77
|
+
return new RegistryRequestFailed({
|
|
78
|
+
category: semantics.category ?? error.category,
|
|
79
|
+
detail: semantics.detail ?? error.detail,
|
|
80
|
+
...(error.metadata === undefined ? {} : { metadata: error.metadata }),
|
|
81
|
+
...((semantics.suggestions ?? error.suggestions) === undefined
|
|
82
|
+
? {}
|
|
83
|
+
: { suggestions: semantics.suggestions ?? error.suggestions }),
|
|
84
|
+
...(error.cause === undefined ? {} : { cause: error.cause }),
|
|
85
|
+
});
|
|
86
|
+
case "RegistryOperationFailed":
|
|
87
|
+
return new RegistryOperationFailed({
|
|
88
|
+
category: semantics.category ?? error.category,
|
|
89
|
+
detail: semantics.detail ?? error.detail,
|
|
90
|
+
...(error.metadata === undefined ? {} : { metadata: error.metadata }),
|
|
91
|
+
...((semantics.suggestions ?? error.suggestions) === undefined
|
|
92
|
+
? {}
|
|
93
|
+
: { suggestions: semantics.suggestions ?? error.suggestions }),
|
|
94
|
+
...(error.cause === undefined ? {} : { cause: error.cause }),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SuggestedAction } from "@agentxm/registry-protocol/unstable/suggested-action";
|
|
2
|
+
import { type RegistryClientFailure } from "./errors.js";
|
|
3
|
+
export { captureRegistryErrorResponseBodies } from "./response-body.js";
|
|
4
|
+
export interface RegistryFailureContext {
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
readonly networkDetail: string;
|
|
7
|
+
readonly incompatibleDetail: string;
|
|
8
|
+
readonly requestConstructionDetail: string;
|
|
9
|
+
readonly fallbackDetail: string;
|
|
10
|
+
readonly suggestions?: ReadonlyArray<SuggestedAction>;
|
|
11
|
+
}
|
|
12
|
+
/** Translate one Registry boundary failure without discarding HTTP evidence. */
|
|
13
|
+
export declare const mapRegistryFailure: (error: unknown, context: RegistryFailureContext) => RegistryClientFailure;
|
|
14
|
+
//# sourceMappingURL=failure-mapping.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { isAnyRegistryClientError, isHttpClientError, isSchemaError, mapNetworkError, } from "./error-mapping.js";
|
|
2
|
+
import { RegistryRequestFailed, isRegistryClientFailure, } from "./errors.js";
|
|
3
|
+
import { recoverRegistryResponseBodyText, retainedRegistryResponseBody } from "./response-body.js";
|
|
4
|
+
import { registryClientErrorToProblem, registryErrorToProblem } from "./translate.js";
|
|
5
|
+
export { captureRegistryErrorResponseBodies } from "./response-body.js";
|
|
6
|
+
const incompatibleResponse = (error, context) => {
|
|
7
|
+
if (!isHttpClientError(error)) {
|
|
8
|
+
return new RegistryRequestFailed({
|
|
9
|
+
category: "internal",
|
|
10
|
+
detail: context.incompatibleDetail,
|
|
11
|
+
...(context.suggestions === undefined ? {} : { suggestions: context.suggestions }),
|
|
12
|
+
cause: error,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const response = error.response;
|
|
16
|
+
return new RegistryRequestFailed({
|
|
17
|
+
category: "internal",
|
|
18
|
+
detail: context.incompatibleDetail,
|
|
19
|
+
metadata: {
|
|
20
|
+
request: {
|
|
21
|
+
service: "registry",
|
|
22
|
+
method: error.request.method,
|
|
23
|
+
url: error.request.url,
|
|
24
|
+
},
|
|
25
|
+
...(response === undefined
|
|
26
|
+
? {}
|
|
27
|
+
: {
|
|
28
|
+
response: {
|
|
29
|
+
status: response.status,
|
|
30
|
+
body: retainedRegistryResponseBody(response, ""),
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
...(context.suggestions === undefined ? {} : { suggestions: context.suggestions }),
|
|
35
|
+
cause: error,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const requestConstructionError = (error, context) => {
|
|
39
|
+
if (!isHttpClientError(error)) {
|
|
40
|
+
return new RegistryRequestFailed({
|
|
41
|
+
category: "internal",
|
|
42
|
+
detail: context.requestConstructionDetail,
|
|
43
|
+
cause: error,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return new RegistryRequestFailed({
|
|
47
|
+
category: "internal",
|
|
48
|
+
detail: context.requestConstructionDetail,
|
|
49
|
+
metadata: {
|
|
50
|
+
request: {
|
|
51
|
+
service: "registry",
|
|
52
|
+
method: error.request.method,
|
|
53
|
+
url: error.request.url,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
cause: error,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/** Translate one Registry boundary failure without discarding HTTP evidence. */
|
|
60
|
+
export const mapRegistryFailure = (error, context) => {
|
|
61
|
+
if (isRegistryClientFailure(error))
|
|
62
|
+
return error;
|
|
63
|
+
if (isAnyRegistryClientError(error)) {
|
|
64
|
+
return registryClientErrorToProblem(error, {
|
|
65
|
+
...(context.suggestions === undefined ? {} : { suggestions: context.suggestions }),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (isHttpClientError(error)) {
|
|
69
|
+
switch (error.reason._tag) {
|
|
70
|
+
case "StatusCodeError":
|
|
71
|
+
return registryErrorToProblem(retainedRegistryResponseBody(error.reason.response, recoverRegistryResponseBodyText(error.reason.description ?? "")), error.reason.response, {
|
|
72
|
+
...(context.suggestions === undefined ? {} : { suggestions: context.suggestions }),
|
|
73
|
+
cause: error,
|
|
74
|
+
});
|
|
75
|
+
case "DecodeError":
|
|
76
|
+
case "EmptyBodyError":
|
|
77
|
+
return incompatibleResponse(error, context);
|
|
78
|
+
case "TransportError":
|
|
79
|
+
return mapNetworkError(error, context.networkDetail, context.baseUrl);
|
|
80
|
+
case "EncodeError":
|
|
81
|
+
case "InvalidUrlError":
|
|
82
|
+
return requestConstructionError(error, context);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (isSchemaError(error)) {
|
|
86
|
+
return new RegistryRequestFailed({
|
|
87
|
+
category: "internal",
|
|
88
|
+
detail: context.incompatibleDetail,
|
|
89
|
+
...(context.suggestions === undefined ? {} : { suggestions: context.suggestions }),
|
|
90
|
+
cause: error,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return new RegistryRequestFailed({
|
|
94
|
+
category: "internal",
|
|
95
|
+
detail: context.fallbackDetail,
|
|
96
|
+
...(context.suggestions === undefined ? {} : { suggestions: context.suggestions }),
|
|
97
|
+
cause: error,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=failure-mapping.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure filesystem path helpers.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately duplicated from the CLI-destined fs-helpers module: the
|
|
5
|
+
* integration may not depend on application utilities, and this helper is
|
|
6
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
*/
|
|
10
|
+
/** Convert a file URL to the current platform's native path representation. */
|
|
11
|
+
export declare const stripFileProtocol: (location: string) => string;
|
|
12
|
+
//# sourceMappingURL=fs-helpers.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure filesystem path helpers.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately duplicated from the CLI-destined fs-helpers module: the
|
|
5
|
+
* integration may not depend on application utilities, and this helper is
|
|
6
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
*/
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
/** Convert a file URL to the current platform's native path representation. */
|
|
12
|
+
export const stripFileProtocol = (location) => location.startsWith("file:") ? fileURLToPath(location) : location;
|
|
13
|
+
//# sourceMappingURL=fs-helpers.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentxm/registry-client public API.
|
|
3
|
+
*
|
|
4
|
+
* The registry integration: local and remote registry clients over the
|
|
5
|
+
* generated OpenAPI transport, request policy and retry, the typed registry
|
|
6
|
+
* failure vocabulary with problem-details translation, the content-addressed
|
|
7
|
+
* archive cache, lifecycle administration, and package metadata schemas.
|
|
8
|
+
*
|
|
9
|
+
* @experimental This API is unstable and may change without notice.
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export type { RegistryClient, RegistryExtensionManifest, DiscoverPackageInput, DiscoverPackagesArgs, GetExtensionsByOwnerArgs, GetExtensionsByOwnerResponse, GetExtensionIndexArgs, GetExactExtensionVersionArgs, ExactExtensionVersion, GetExtensionVisibilityArgs, GetExtensionPackageArgs, GetExtensionPackageResponse, PublishExtensionArgs, PublishExtensionResponse, RegistryPublishWarning, PreviewExtensionPublishesArgs, PublishPreviewResult, PublishPreviewTarget, OwnerExistsResponse, ExtensionExistsArgs, ExtensionExistsResponse, ExtensionVisibility, UpdateExtensionVisibilityArgs, } from "./client.js";
|
|
13
|
+
export { createRegistryClient } from "./client.js";
|
|
14
|
+
export { createLocalRegistryClient } from "./local-client.js";
|
|
15
|
+
export { createRemoteRegistryClient } from "./remote-client.js";
|
|
16
|
+
export { DEFAULT_REGISTRY_REQUEST_POLICY, PUBLISH_REGISTRY_REQUEST_POLICY, executeRegistryRequest, type RegistryRequestPolicy, type RegistryRequestReplaySafety, } from "./request-policy.js";
|
|
17
|
+
export type { ArchiveCache, ArchiveCacheOptions, ArchiveCachePruneResult, ArchiveCacheStatus, ArchiveCacheVerifyResult, } from "./archive-cache.js";
|
|
18
|
+
export { resolveAxmCacheRoot, resolveAxmCacheRootPure, type AxmCacheEnvironment, } from "./cache-root.js";
|
|
19
|
+
export { ARCHIVE_CACHE_MAX_AGE, ARCHIVE_CACHE_MAX_BYTES, makeArchiveCache, makeUserArchiveCache, } from "./archive-cache.js";
|
|
20
|
+
export type { RegistryExtensionReference, RegistryExtensionVersionReference, RegistryLifecycleCallOptions, PutExtensionDeprecationInput, YankCategory, } from "./admin-client.js";
|
|
21
|
+
export { yankExtensionVersion, yankAvailableExtensionVersions, unyankExtensionVersion, deprecateExtension, getExtensionDeprecation, undeprecateExtension, } from "./admin-client.js";
|
|
22
|
+
export { REGISTRY_ERROR_CATEGORIES, RegistryOperationFailed, RegistryProblem, RegistryRequestFailed, isRegistryClientFailure, withRegistrySemantics, type RegistryClientFailure, type RegistryErrorCategory, type RegistryErrorMetadata, type RegistryRequestMetadata, type RegistryRequestPolicyMetadata, type RegistryResponseMetadata, } from "./errors.js";
|
|
23
|
+
export { httpStatusToCategory, registryClientErrorToProblem, registryErrorToProblem, type ProblemDetails, } from "./translate.js";
|
|
24
|
+
export { captureRegistryErrorResponseBodies, mapRegistryFailure, type RegistryFailureContext, } from "./failure-mapping.js";
|
|
25
|
+
export { buildNetworkSuggestions, buildNetworkDiagnosis, getString, isRegistryClientError, isHttpClientError, isSchemaError, isTransientHttpClientError, mapNetworkError, mapSchemaError, mapUnexpectedStatusError, } from "./error-mapping.js";
|
|
26
|
+
export { extensionDir, extensionLifecycleWarnings, extractZip, pluralizeType, resolveVersionEntry, resolveVersionEntryForReleaseAge, resolveVersionEntryWithReleaseAge, selectVersion, } from "./utils.js";
|
|
27
|
+
export { formatDeprecationWarning } from "./deprecation-warning.js";
|
|
28
|
+
export type { ReleaseAgeVersionResolution } from "./utils.js";
|
|
29
|
+
export { RegistryUrl } from "./registry-url.js";
|
|
30
|
+
export { AxmPackageMetaSchema, PackageExtensionDeclarationSchema, type AxmPackageMeta, type PackageExtensionDeclaration, } from "./axm-package-meta.js";
|
|
31
|
+
export { purlIdentityMatch, purlMatch } from "./purl-match.js";
|
|
32
|
+
export * as GeneratedRegistryClient from "./__generated__/registry-client.js";
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentxm/registry-client public API.
|
|
3
|
+
*
|
|
4
|
+
* The registry integration: local and remote registry clients over the
|
|
5
|
+
* generated OpenAPI transport, request policy and retry, the typed registry
|
|
6
|
+
* failure vocabulary with problem-details translation, the content-addressed
|
|
7
|
+
* archive cache, lifecycle administration, and package metadata schemas.
|
|
8
|
+
*
|
|
9
|
+
* @experimental This API is unstable and may change without notice.
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export { createRegistryClient } from "./client.js";
|
|
13
|
+
// Local client
|
|
14
|
+
export { createLocalRegistryClient } from "./local-client.js";
|
|
15
|
+
// Remote client
|
|
16
|
+
export { createRemoteRegistryClient } from "./remote-client.js";
|
|
17
|
+
export { DEFAULT_REGISTRY_REQUEST_POLICY, PUBLISH_REGISTRY_REQUEST_POLICY, executeRegistryRequest, } from "./request-policy.js";
|
|
18
|
+
export { resolveAxmCacheRoot, resolveAxmCacheRootPure, } from "./cache-root.js";
|
|
19
|
+
export { ARCHIVE_CACHE_MAX_AGE, ARCHIVE_CACHE_MAX_BYTES, makeArchiveCache, makeUserArchiveCache, } from "./archive-cache.js";
|
|
20
|
+
export { yankExtensionVersion, yankAvailableExtensionVersions, unyankExtensionVersion, deprecateExtension, getExtensionDeprecation, undeprecateExtension, } from "./admin-client.js";
|
|
21
|
+
// Failure vocabulary
|
|
22
|
+
export { REGISTRY_ERROR_CATEGORIES, RegistryOperationFailed, RegistryProblem, RegistryRequestFailed, isRegistryClientFailure, withRegistrySemantics, } from "./errors.js";
|
|
23
|
+
// Failure translation
|
|
24
|
+
export { httpStatusToCategory, registryClientErrorToProblem, registryErrorToProblem, } from "./translate.js";
|
|
25
|
+
export { captureRegistryErrorResponseBodies, mapRegistryFailure, } from "./failure-mapping.js";
|
|
26
|
+
// Error mapping helpers
|
|
27
|
+
export { buildNetworkSuggestions, buildNetworkDiagnosis, getString, isRegistryClientError, isHttpClientError, isSchemaError, isTransientHttpClientError, mapNetworkError, mapSchemaError, mapUnexpectedStatusError, } from "./error-mapping.js";
|
|
28
|
+
// Utilities
|
|
29
|
+
export { extensionDir, extensionLifecycleWarnings, extractZip, pluralizeType, resolveVersionEntry, resolveVersionEntryForReleaseAge, resolveVersionEntryWithReleaseAge, selectVersion, } from "./utils.js";
|
|
30
|
+
export { formatDeprecationWarning } from "./deprecation-warning.js";
|
|
31
|
+
export { RegistryUrl } from "./registry-url.js";
|
|
32
|
+
// Package metadata schemas
|
|
33
|
+
export { AxmPackageMetaSchema, PackageExtensionDeclarationSchema, } from "./axm-package-meta.js";
|
|
34
|
+
export { purlIdentityMatch, purlMatch } from "./purl-match.js";
|
|
35
|
+
// Generated OpenAPI transport (consumed by the registry-auth feature)
|
|
36
|
+
export * as GeneratedRegistryClient from "./__generated__/registry-client.js";
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA-512 integrity utility.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately duplicated from the CLI-destined integrity module: the
|
|
5
|
+
* integration may not depend on application utilities, and this helper is
|
|
6
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
*/
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
/** Compute SHA-512 integrity in `sha512-<base64>` SRI format. */
|
|
12
|
+
export declare const computeIntegrity: (data: Uint8Array) => Effect.Effect<string>;
|
|
13
|
+
//# sourceMappingURL=integrity.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA-512 integrity utility.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately duplicated from the CLI-destined integrity module: the
|
|
5
|
+
* integration may not depend on application utilities, and this helper is
|
|
6
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
*/
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
/** Compute SHA-512 integrity in `sha512-<base64>` SRI format. */
|
|
13
|
+
export const computeIntegrity = (data) => Effect.sync(() => {
|
|
14
|
+
const base64 = createHash("sha512").update(data).digest("base64");
|
|
15
|
+
return `sha512-${base64}`;
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=integrity.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local filesystem-backed registry client.
|
|
3
|
+
*
|
|
4
|
+
* All operations read/write files relative to a registry root using the
|
|
5
|
+
* layout: `<root>/extensions/@<owner>/<type>/<name>/`.
|
|
6
|
+
*
|
|
7
|
+
* @experimental This API is unstable and may change without notice.
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import type * as FileSystem from "effect/FileSystem";
|
|
11
|
+
import type * as Path from "effect/Path";
|
|
12
|
+
import type { RegistryClient } from "./client.js";
|
|
13
|
+
/**
|
|
14
|
+
* Creates a local filesystem-backed registry client.
|
|
15
|
+
*
|
|
16
|
+
* All operations read/write files relative to `registryRoot` using the
|
|
17
|
+
* registry layout: `<root>/extensions/@<owner>/<type>/<name>/`.
|
|
18
|
+
*
|
|
19
|
+
* @param registryRoot - Absolute path to the registry root directory
|
|
20
|
+
*
|
|
21
|
+
* @experimental This API is unstable and may change without notice.
|
|
22
|
+
*/
|
|
23
|
+
export declare const createLocalRegistryClient: (registryRoot: string, fs: FileSystem.FileSystem, path: Path.Path) => RegistryClient;
|
|
24
|
+
//# sourceMappingURL=local-client.d.ts.map
|