everything-dev 2.0.0-rc.6 → 2.0.0-rc.8
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/README.md +2 -2
- package/dist/api/auth-middleware.cjs +14 -1
- package/dist/api/auth-middleware.cjs.map +1 -1
- package/dist/api/auth-middleware.d.cts +9 -0
- package/dist/api/auth-middleware.d.mts +9 -0
- package/dist/api/auth-middleware.mjs +14 -1
- package/dist/api/auth-middleware.mjs.map +1 -1
- package/dist/build.cjs +1 -1
- package/dist/build.mjs +1 -1
- package/dist/bundle-cache.cjs +1 -1
- package/dist/bundle-cache.cjs.map +1 -1
- package/dist/bundle-cache.mjs +1 -1
- package/dist/bundle-cache.mjs.map +1 -1
- package/dist/cli/init.cjs +22 -10
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.mjs +22 -10
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli.cjs +6 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +5 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/commands/deploy.cjs +111 -1
- package/dist/commands/deploy.cjs.map +1 -1
- package/dist/commands/deploy.mjs +112 -2
- package/dist/commands/deploy.mjs.map +1 -1
- package/dist/commands/keys.cjs +1 -1
- package/dist/commands/keys.cjs.map +1 -1
- package/dist/commands/keys.mjs +1 -1
- package/dist/commands/keys.mjs.map +1 -1
- package/dist/commands/smoke.cjs +41 -0
- package/dist/commands/smoke.cjs.map +1 -0
- package/dist/commands/smoke.mjs +41 -0
- package/dist/commands/smoke.mjs.map +1 -0
- package/dist/commands/upgrade.cjs +2 -2
- package/dist/commands/upgrade.cjs.map +1 -1
- package/dist/commands/upgrade.mjs +1 -1
- package/dist/commands/upgrade.mjs.map +1 -1
- package/dist/contract.cjs +27 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +65 -1
- package/dist/contract.d.mts +65 -1
- package/dist/contract.meta.cjs +14 -2
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +24 -2
- package/dist/contract.meta.d.mts +24 -2
- package/dist/contract.meta.mjs +14 -2
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +26 -2
- package/dist/contract.mjs.map +1 -1
- package/dist/db/core.cjs +22 -4
- package/dist/db/core.cjs.map +1 -1
- package/dist/db/core.mjs +22 -4
- package/dist/db/core.mjs.map +1 -1
- package/dist/dev-log-pipeline.cjs +6 -0
- package/dist/dev-log-pipeline.cjs.map +1 -1
- package/dist/dev-log-pipeline.mjs +6 -0
- package/dist/dev-log-pipeline.mjs.map +1 -1
- package/dist/dev-program.cjs +20 -3
- package/dist/dev-program.cjs.map +1 -1
- package/dist/dev-program.mjs +20 -4
- package/dist/dev-program.mjs.map +1 -1
- package/dist/dev-session.cjs +1 -0
- package/dist/dev-session.cjs.map +1 -1
- package/dist/dev-session.mjs +1 -0
- package/dist/dev-session.mjs.map +1 -1
- package/dist/fastkv.cjs +21 -3
- package/dist/fastkv.cjs.map +1 -1
- package/dist/fastkv.d.cts +14 -1
- package/dist/fastkv.d.mts +14 -1
- package/dist/fastkv.mjs +21 -5
- package/dist/fastkv.mjs.map +1 -1
- package/dist/{mf.cjs → federation.cjs} +6 -13
- package/dist/federation.cjs.map +1 -0
- package/dist/{mf.d.cts → federation.d.cts} +2 -2
- package/dist/{mf.d.mts → federation.d.mts} +2 -2
- package/dist/{mf.mjs → federation.mjs} +6 -13
- package/dist/federation.mjs.map +1 -0
- package/dist/http-client.cjs +84 -57
- package/dist/http-client.cjs.map +1 -1
- package/dist/http-client.mjs +84 -58
- package/dist/http-client.mjs.map +1 -1
- package/dist/image-deploy.cjs +9 -0
- package/dist/image-deploy.cjs.map +1 -1
- package/dist/image-deploy.mjs +9 -1
- package/dist/image-deploy.mjs.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/infra/planner.cjs +6 -2
- package/dist/infra/planner.cjs.map +1 -1
- package/dist/infra/planner.mjs +6 -2
- package/dist/infra/planner.mjs.map +1 -1
- package/dist/orchestrator.cjs +39 -35
- package/dist/orchestrator.cjs.map +1 -1
- package/dist/orchestrator.mjs +39 -35
- package/dist/orchestrator.mjs.map +1 -1
- package/dist/plugin.cjs +2 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +24 -0
- package/dist/plugin.d.mts +24 -0
- package/dist/plugin.mjs +2 -0
- package/dist/plugin.mjs.map +1 -1
- package/dist/process-registry.cjs +1 -1
- package/dist/process-registry.mjs +1 -1
- package/dist/publish.cjs +3 -3
- package/dist/publish.cjs.map +1 -1
- package/dist/publish.mjs +4 -4
- package/dist/publish.mjs.map +1 -1
- package/dist/resolver.cjs +293 -0
- package/dist/resolver.cjs.map +1 -0
- package/dist/resolver.d.cts +99 -0
- package/dist/resolver.d.mts +99 -0
- package/dist/resolver.mjs +284 -0
- package/dist/resolver.mjs.map +1 -0
- package/dist/smoke.cjs +262 -0
- package/dist/smoke.cjs.map +1 -0
- package/dist/smoke.mjs +260 -0
- package/dist/smoke.mjs.map +1 -0
- package/dist/ui/auth.d.cts +217 -123
- package/dist/ui/auth.d.mts +217 -123
- package/dist/ui/router-client.cjs +2 -1
- package/dist/ui/router-client.cjs.map +1 -1
- package/dist/ui/router-client.mjs +2 -1
- package/dist/ui/router-client.mjs.map +1 -1
- package/dist/version-manifest-resolve.cjs +3 -3
- package/dist/version-manifest-resolve.cjs.map +1 -1
- package/dist/version-manifest-resolve.mjs +1 -1
- package/dist/version-manifest-resolve.mjs.map +1 -1
- package/dist/workspace.cjs +1 -1
- package/dist/workspace.mjs +1 -1
- package/package.json +18 -18
- package/skills/api-and-auth/SKILL.md +12 -9
- package/skills/api-and-auth/references/middleware.md +38 -0
- package/skills/cli-reference/SKILL.md +22 -6
- package/skills/talk-to-the-app/SKILL.md +32 -5
- package/dist/bundle-fs-resolve.cjs +0 -235
- package/dist/bundle-fs-resolve.cjs.map +0 -1
- package/dist/bundle-fs-resolve.d.cts +0 -82
- package/dist/bundle-fs-resolve.d.mts +0 -82
- package/dist/bundle-fs-resolve.mjs +0 -228
- package/dist/bundle-fs-resolve.mjs.map +0 -1
- package/dist/bundle-path.cjs +0 -48
- package/dist/bundle-path.cjs.map +0 -1
- package/dist/bundle-path.mjs +0 -45
- package/dist/bundle-path.mjs.map +0 -1
- package/dist/mf.cjs.map +0 -1
- package/dist/mf.mjs.map +0 -1
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_bundle_path = require('./bundle-path.cjs');
|
|
4
|
-
const require_config = require('./config.cjs');
|
|
5
|
-
const require_bundle_cache = require('./bundle-cache.cjs');
|
|
6
|
-
let node_fs = require("node:fs");
|
|
7
|
-
let node_path = require("node:path");
|
|
8
|
-
node_path = require_runtime.__toESM(node_path, 1);
|
|
9
|
-
let effect = require("effect");
|
|
10
|
-
let node_fs_promises = require("node:fs/promises");
|
|
11
|
-
let every_plugin_build_artifact_names = require("every-plugin/build/artifact-names");
|
|
12
|
-
|
|
13
|
-
//#region src/bundle-fs-resolve.ts
|
|
14
|
-
var BundleReadError = class extends effect.Schema.TaggedError()("BundleReadError", {
|
|
15
|
-
path: effect.Schema.String,
|
|
16
|
-
cause: effect.Schema.optional(effect.Schema.Unknown)
|
|
17
|
-
}) {};
|
|
18
|
-
const MIME_TYPES = {
|
|
19
|
-
".js": "text/javascript",
|
|
20
|
-
".mjs": "text/javascript",
|
|
21
|
-
".cjs": "text/javascript",
|
|
22
|
-
".css": "text/css",
|
|
23
|
-
".json": "application/json",
|
|
24
|
-
".map": "application/json",
|
|
25
|
-
".svg": "image/svg+xml",
|
|
26
|
-
".png": "image/png",
|
|
27
|
-
".jpg": "image/jpeg",
|
|
28
|
-
".jpeg": "image/jpeg",
|
|
29
|
-
".gif": "image/gif",
|
|
30
|
-
".webp": "image/webp",
|
|
31
|
-
".avif": "image/avif",
|
|
32
|
-
".ico": "image/x-icon",
|
|
33
|
-
".html": "text/html",
|
|
34
|
-
".htm": "text/html",
|
|
35
|
-
".webmanifest": "application/manifest+json",
|
|
36
|
-
".md": "text/markdown",
|
|
37
|
-
".ts": "text/plain",
|
|
38
|
-
".woff": "font/woff",
|
|
39
|
-
".woff2": "font/woff2",
|
|
40
|
-
".ttf": "font/ttf",
|
|
41
|
-
".otf": "font/otf",
|
|
42
|
-
".eot": "application/vnd.ms-fontobject",
|
|
43
|
-
".wasm": "application/wasm",
|
|
44
|
-
".txt": "text/plain",
|
|
45
|
-
".xml": "application/xml"
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
|
|
49
|
-
* narrowed to the runtime identity — a URL whose encoded namespace differs
|
|
50
|
-
* from `namespace.account`/`namespace.gateway` must fall to the network/cache
|
|
51
|
-
* path, never serve a sibling namespace's staged bytes.
|
|
52
|
-
*/
|
|
53
|
-
function bundleUrlToLocalPath(url, namespace) {
|
|
54
|
-
const filePath = require_bundle_path.bundleUrlToStagedPath(url, namespace.bundleDir);
|
|
55
|
-
if (!filePath) return null;
|
|
56
|
-
const nsDir = node_path.default.resolve(namespace.bundleDir, namespace.account, namespace.gateway);
|
|
57
|
-
if (filePath !== nsDir && !filePath.startsWith(nsDir + node_path.default.sep)) return null;
|
|
58
|
-
return filePath;
|
|
59
|
-
}
|
|
60
|
-
var BundleResolver = class BundleResolver extends effect.Context.Service()("everything-dev/bundle-fs-resolve/BundleResolver") {
|
|
61
|
-
static layer(namespace) {
|
|
62
|
-
const respond = effect.Effect.fn("BundleResolver.respond")(function* (url) {
|
|
63
|
-
const filePath = bundleUrlToLocalPath(url, namespace);
|
|
64
|
-
if (!filePath) return null;
|
|
65
|
-
const bytes = yield* effect.Effect.tryPromise({
|
|
66
|
-
try: () => (0, node_fs_promises.readFile)(filePath),
|
|
67
|
-
catch: (cause) => new BundleReadError({
|
|
68
|
-
path: filePath,
|
|
69
|
-
cause
|
|
70
|
-
})
|
|
71
|
-
}).pipe(effect.Effect.catchTag("BundleReadError", () => effect.Effect.succeed(null)));
|
|
72
|
-
if (bytes === null) return null;
|
|
73
|
-
const name = node_path.default.basename(filePath);
|
|
74
|
-
const contentType = MIME_TYPES[node_path.default.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
75
|
-
return new Response(new Uint8Array(bytes), { headers: {
|
|
76
|
-
"content-type": contentType,
|
|
77
|
-
"cache-control": (0, every_plugin_build_artifact_names.cacheControlOf)(name),
|
|
78
|
-
etag: `"${Buffer.from(bytes.subarray(0, 4096)).toString("base64").slice(0, 24)}"`
|
|
79
|
-
} });
|
|
80
|
-
});
|
|
81
|
-
return effect.Layer.effect(BundleResolver, effect.Effect.succeed(BundleResolver.of({ lookup: (input) => {
|
|
82
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
83
|
-
return respond(url);
|
|
84
|
-
} })));
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const staleResponse = (bytes, url) => {
|
|
88
|
-
const name = url.split("?")[0].split("/").pop() ?? "";
|
|
89
|
-
const contentType = MIME_TYPES[node_path.default.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
90
|
-
return new Response(bytes.slice().buffer, {
|
|
91
|
-
status: 200,
|
|
92
|
-
headers: {
|
|
93
|
-
"content-type": contentType,
|
|
94
|
-
"x-bundle-cache": "stale"
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
const FETCH_RETRY_ATTEMPTS = 3;
|
|
99
|
-
const FETCH_RETRY_BASE_DELAY_MS = 250;
|
|
100
|
-
const isTransientStatus = (status) => status === 429 || status >= 500;
|
|
101
|
-
function requestMethod(input, init) {
|
|
102
|
-
if (init?.method) return init.method.toUpperCase();
|
|
103
|
-
if (typeof input === "string" || input instanceof URL) return "GET";
|
|
104
|
-
return input.method.toUpperCase();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Bounded transient-failure retry for idempotent GETs crossing the
|
|
108
|
-
* interceptor (ADR 0021 amendment — the CDN-only image): a cold boot has no
|
|
109
|
-
* staged fallback, so one edge/registry hiccup during the load window would
|
|
110
|
-
* hard-fail the host or a plugin with no recourse. Network errors and
|
|
111
|
-
* 429/5xx responses retry twice (250ms, 750ms backoff) before propagating;
|
|
112
|
-
* non-transient statuses and non-GET requests pass through untouched. After
|
|
113
|
-
* exhausting attempts a stale-if-error cache still sees the final failure.
|
|
114
|
-
*/
|
|
115
|
-
async function fetchWithTransientRetry(original, input, init) {
|
|
116
|
-
if (requestMethod(input, init) !== "GET") return original(input, init);
|
|
117
|
-
let lastError;
|
|
118
|
-
let lastResponse = null;
|
|
119
|
-
for (let attempt = 0; attempt < FETCH_RETRY_ATTEMPTS; attempt++) {
|
|
120
|
-
if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, FETCH_RETRY_BASE_DELAY_MS * 3 ** (attempt - 1)));
|
|
121
|
-
try {
|
|
122
|
-
const response = await original(input, init);
|
|
123
|
-
if (!isTransientStatus(response.status)) return response;
|
|
124
|
-
lastResponse = response;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
lastError = error;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (lastResponse) return lastResponse;
|
|
130
|
-
throw lastError;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Installs the resolver as a global fetch interceptor — the one seam every
|
|
134
|
-
* boot-time consumer shares (config manifest discovery, contract-type
|
|
135
|
-
* fetches, orchestrator host loading, MF remoteEntry/identity probes).
|
|
136
|
-
* One layered resolution policy: staged disk → network → stale-if-error.
|
|
137
|
-
* Own-namespace URLs resolve from the staged directory and fall through to
|
|
138
|
-
* the original fetch on a miss (a partially-staged namespace boots over the
|
|
139
|
-
* wire instead of failing); a miss never touches the write-through cache —
|
|
140
|
-
* for the own namespace the staged disk IS the resilience artifact. Foreign
|
|
141
|
-
* `/bundles/…` URLs get the network with the stale-if-error cache; every
|
|
142
|
-
* other URL falls through to the original fetch untouched. Inert when
|
|
143
|
-
* neither a staged namespace nor a cache is configured.
|
|
144
|
-
*/
|
|
145
|
-
function installGlobalBundleFetch(options) {
|
|
146
|
-
const namespace = options.namespace;
|
|
147
|
-
const cacheDir = options.cacheDir;
|
|
148
|
-
const runtime = namespace ? effect.ManagedRuntime.make(BundleResolver.layer(namespace)) : null;
|
|
149
|
-
const original = globalThis.fetch;
|
|
150
|
-
const patched = (async (input, init) => {
|
|
151
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
152
|
-
if (namespace && bundleUrlToLocalPath(url, namespace)) {
|
|
153
|
-
if (!runtime) throw new Error("unreachable: resolver runtime missing");
|
|
154
|
-
const response = await runtime.runPromise(effect.Effect.gen(function* () {
|
|
155
|
-
return yield* (yield* BundleResolver).lookup(input);
|
|
156
|
-
}));
|
|
157
|
-
if (response !== null) return response;
|
|
158
|
-
return fetchWithTransientRetry(original, input, init);
|
|
159
|
-
}
|
|
160
|
-
if (cacheDir !== void 0 && require_bundle_cache.bundleCachePath(url, { cacheDir })) return (async () => {
|
|
161
|
-
try {
|
|
162
|
-
const response = await fetchWithTransientRetry(original, input, init);
|
|
163
|
-
if (response.ok) try {
|
|
164
|
-
const bytes = new Uint8Array(await response.clone().arrayBuffer());
|
|
165
|
-
await require_bundle_cache.writeBundleCache(url, bytes, { cacheDir });
|
|
166
|
-
} catch {}
|
|
167
|
-
else {
|
|
168
|
-
const cached = await require_bundle_cache.readBundleCache(url, { cacheDir });
|
|
169
|
-
if (cached) return staleResponse(cached, url);
|
|
170
|
-
}
|
|
171
|
-
return response;
|
|
172
|
-
} catch (error) {
|
|
173
|
-
const cached = await require_bundle_cache.readBundleCache(url, { cacheDir });
|
|
174
|
-
if (cached) return staleResponse(cached, url);
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
})();
|
|
178
|
-
return fetchWithTransientRetry(original, input, init);
|
|
179
|
-
});
|
|
180
|
-
const originalPreconnect = original.preconnect;
|
|
181
|
-
if (originalPreconnect) patched.preconnect = originalPreconnect.bind(original);
|
|
182
|
-
globalThis.fetch = patched;
|
|
183
|
-
return { uninstall: async () => {
|
|
184
|
-
if (globalThis.fetch === patched) globalThis.fetch = original;
|
|
185
|
-
if (runtime) await runtime.dispose();
|
|
186
|
-
} };
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Boot-time installer for the CLI: derives the own namespace from
|
|
190
|
-
* `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`
|
|
191
|
-
* registry env taking precedence over the bos.config.json fields), and the
|
|
192
|
-
* foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection
|
|
193
|
-
* (ADR 0021): an identity whose namespace is not actually staged under the
|
|
194
|
-
* bundle dir drops to the registry tier — plain network fetch — instead of
|
|
195
|
-
* deterministically 404ing own-namespace URLs against a foreign image's
|
|
196
|
-
* staged bytes. Never throws — a missing or malformed identity leaves the
|
|
197
|
-
* default network fetch in place.
|
|
198
|
-
*/
|
|
199
|
-
function installBundleFetchFromEnv(input) {
|
|
200
|
-
const bundleDir = process.env.BOS_BUNDLE_DIR;
|
|
201
|
-
const cacheDir = process.env.BOS_BUNDLE_CACHE_DIR;
|
|
202
|
-
if (!bundleDir && cacheDir === void 0) return null;
|
|
203
|
-
let configAccount;
|
|
204
|
-
let configGateway;
|
|
205
|
-
const configPath = input.configPath;
|
|
206
|
-
if (configPath && !require_config.isAppDescriptorPath(configPath)) try {
|
|
207
|
-
const parsed = JSON.parse((0, node_fs.readFileSync)(configPath, "utf8"));
|
|
208
|
-
configAccount = parsed.account;
|
|
209
|
-
configGateway = parsed.domain;
|
|
210
|
-
} catch {}
|
|
211
|
-
const account = process.env.BOS_ACCOUNT ?? configAccount;
|
|
212
|
-
const gateway = process.env.BOS_GATEWAY ?? configGateway;
|
|
213
|
-
if (bundleDir && (!account || !gateway)) return null;
|
|
214
|
-
let namespace;
|
|
215
|
-
if (bundleDir && account && gateway) {
|
|
216
|
-
if ((0, node_fs.existsSync)(node_path.default.join(bundleDir, account, gateway))) namespace = {
|
|
217
|
-
bundleDir,
|
|
218
|
-
account,
|
|
219
|
-
gateway
|
|
220
|
-
};
|
|
221
|
-
else console.warn(`[bundles] staged namespace ${account}/${gateway} not found under ${bundleDir} — registry tier (network fetch)`);
|
|
222
|
-
}
|
|
223
|
-
return installGlobalBundleFetch({
|
|
224
|
-
namespace,
|
|
225
|
-
cacheDir: cacheDir ?? (namespace ? require_bundle_cache.bundleCacheRoot() : void 0)
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
//#endregion
|
|
230
|
-
exports.BundleReadError = BundleReadError;
|
|
231
|
-
exports.BundleResolver = BundleResolver;
|
|
232
|
-
exports.bundleUrlToLocalPath = bundleUrlToLocalPath;
|
|
233
|
-
exports.installBundleFetchFromEnv = installBundleFetchFromEnv;
|
|
234
|
-
exports.installGlobalBundleFetch = installGlobalBundleFetch;
|
|
235
|
-
//# sourceMappingURL=bundle-fs-resolve.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-fs-resolve.cjs","names":["Schema","bundleUrlToStagedPath","path","Context","Effect","readFile","cacheControlOf","Layer","ManagedRuntime","bundleCachePath","writeBundleCache","readBundleCache","isAppDescriptorPath","readFileSync","existsSync","bundleCacheRoot"],"sources":["../src/bundle-fs-resolve.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Context, Effect, Layer, ManagedRuntime, Schema } from \"effect\";\nimport { cacheControlOf } from \"every-plugin/build/artifact-names\";\nimport {\n bundleCachePath,\n bundleCacheRoot,\n readBundleCache,\n writeBundleCache,\n} from \"./bundle-cache\";\nimport { bundleUrlToStagedPath } from \"./bundle-path\";\nimport { isAppDescriptorPath } from \"./config\";\n\n/**\n * Local-first bundle resolution (ADR 0011 amendment; unified policy, ADR 0021\n * amendment): a self-contained runtime image stages its own namespace under\n * `BOS_BUNDLE_DIR` as `bundles/<account>/<gateway>/<workspace>/…` and consumes\n * those bytes directly from disk; a miss falls through to the network, so a\n * partially-staged namespace boots over the wire instead of failing. The\n * registry tier (children, `BOS_BUNDLE_DIR` unset) keeps the network fetch —\n * the namespace guard below only ever matches the runtime's own\n * account/gateway, never another runtime's layout.\n */\n\nexport interface BundleNamespace {\n readonly bundleDir: string;\n readonly account: string;\n readonly gateway: string;\n}\n\nexport class BundleReadError extends Schema.TaggedError<BundleReadError>()(\"BundleReadError\", {\n path: Schema.String,\n cause: Schema.optional(Schema.Unknown),\n}) {}\n\nconst MIME_TYPES: Record<string, string> = {\n \".js\": \"text/javascript\",\n \".mjs\": \"text/javascript\",\n \".cjs\": \"text/javascript\",\n \".css\": \"text/css\",\n \".json\": \"application/json\",\n \".map\": \"application/json\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".ico\": \"image/x-icon\",\n \".html\": \"text/html\",\n \".htm\": \"text/html\",\n \".webmanifest\": \"application/manifest+json\",\n \".md\": \"text/markdown\",\n \".ts\": \"text/plain\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".otf\": \"font/otf\",\n \".eot\": \"application/vnd.ms-fontobject\",\n \".wasm\": \"application/wasm\",\n \".txt\": \"text/plain\",\n \".xml\": \"application/xml\",\n};\n\n/**\n * Own-namespace path for a bundle URL: the shared URL→staged-path mapping,\n * narrowed to the runtime identity — a URL whose encoded namespace differs\n * from `namespace.account`/`namespace.gateway` must fall to the network/cache\n * path, never serve a sibling namespace's staged bytes.\n */\nexport function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null {\n const filePath = bundleUrlToStagedPath(url, namespace.bundleDir);\n if (!filePath) return null;\n\n const nsDir = path.resolve(namespace.bundleDir, namespace.account, namespace.gateway);\n if (filePath !== nsDir && !filePath.startsWith(nsDir + path.sep)) return null;\n\n return filePath;\n}\n\nexport class BundleResolver extends Context.Service<\n BundleResolver,\n {\n /** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */\n readonly lookup: (input: string | URL | Request) => Effect.Effect<Response | null>;\n }\n>()(\"everything-dev/bundle-fs-resolve/BundleResolver\") {\n static layer(namespace: BundleNamespace): Layer.Layer<BundleResolver> {\n const respond = Effect.fn(\"BundleResolver.respond\")(function* (\n url: string,\n ): Effect.fn.Return<Response | null, never> {\n const filePath = bundleUrlToLocalPath(url, namespace);\n if (!filePath) return null;\n const bytes = yield* Effect.tryPromise({\n try: () => readFile(filePath),\n catch: (cause) => new BundleReadError({ path: filePath, cause }),\n }).pipe(Effect.catchTag(\"BundleReadError\", () => Effect.succeed(null)));\n if (bytes === null) return null;\n const name = path.basename(filePath);\n const contentType =\n MIME_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n return new Response(new Uint8Array(bytes), {\n headers: {\n \"content-type\": contentType,\n \"cache-control\": cacheControlOf(name),\n etag: `\"${Buffer.from(bytes.subarray(0, 4096)).toString(\"base64\").slice(0, 24)}\"`,\n },\n });\n });\n\n return Layer.effect(\n BundleResolver,\n Effect.succeed(\n BundleResolver.of({\n lookup: (input) => {\n const url =\n typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n return respond(url);\n },\n }),\n ),\n );\n }\n}\n\nexport interface BundleFetchHandle {\n readonly uninstall: () => Promise<void>;\n}\n\nexport interface BundleFetchOptions {\n /** Own-namespace FS resolution — requires a staged `BOS_BUNDLE_DIR`. */\n namespace?: BundleNamespace;\n /**\n * Foreign-namespace stale-if-error cache (child tier): `/bundles/…` URLs\n * outside the own namespace write through to disk on success and serve\n * the last-known-good bytes when the origin fails. Enabled implicitly\n * when `namespace` is present (deployment contexts), or explicitly via\n * `BOS_BUNDLE_CACHE_DIR`.\n */\n cacheDir?: string;\n}\n\ntype FetchImpl = typeof globalThis.fetch;\n\nconst staleResponse = (bytes: Uint8Array, url: string): Response => {\n const name = url.split(\"?\")[0].split(\"/\").pop() ?? \"\";\n const contentType = MIME_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n return new Response(bytes.slice().buffer, {\n status: 200,\n headers: { \"content-type\": contentType, \"x-bundle-cache\": \"stale\" },\n });\n};\n\nconst FETCH_RETRY_ATTEMPTS = 3;\nconst FETCH_RETRY_BASE_DELAY_MS = 250;\n\nconst isTransientStatus = (status: number): boolean => status === 429 || status >= 500;\n\nfunction requestMethod(input: Parameters<FetchImpl>[0], init?: Parameters<FetchImpl>[1]): string {\n if (init?.method) return init.method.toUpperCase();\n if (typeof input === \"string\" || input instanceof URL) return \"GET\";\n return input.method.toUpperCase();\n}\n\n/**\n * Bounded transient-failure retry for idempotent GETs crossing the\n * interceptor (ADR 0021 amendment — the CDN-only image): a cold boot has no\n * staged fallback, so one edge/registry hiccup during the load window would\n * hard-fail the host or a plugin with no recourse. Network errors and\n * 429/5xx responses retry twice (250ms, 750ms backoff) before propagating;\n * non-transient statuses and non-GET requests pass through untouched. After\n * exhausting attempts a stale-if-error cache still sees the final failure.\n */\nasync function fetchWithTransientRetry(\n original: FetchImpl,\n input: Parameters<FetchImpl>[0],\n init?: Parameters<FetchImpl>[1],\n): Promise<Response> {\n if (requestMethod(input, init) !== \"GET\") return original(input, init);\n let lastError: unknown;\n let lastResponse: Response | null = null;\n for (let attempt = 0; attempt < FETCH_RETRY_ATTEMPTS; attempt++) {\n if (attempt > 0) {\n await new Promise((resolve) =>\n setTimeout(resolve, FETCH_RETRY_BASE_DELAY_MS * 3 ** (attempt - 1)),\n );\n }\n try {\n const response = await original(input, init);\n if (!isTransientStatus(response.status)) return response;\n lastResponse = response;\n } catch (error) {\n lastError = error;\n }\n }\n if (lastResponse) return lastResponse;\n throw lastError;\n}\n\n/**\n * Installs the resolver as a global fetch interceptor — the one seam every\n * boot-time consumer shares (config manifest discovery, contract-type\n * fetches, orchestrator host loading, MF remoteEntry/identity probes).\n * One layered resolution policy: staged disk → network → stale-if-error.\n * Own-namespace URLs resolve from the staged directory and fall through to\n * the original fetch on a miss (a partially-staged namespace boots over the\n * wire instead of failing); a miss never touches the write-through cache —\n * for the own namespace the staged disk IS the resilience artifact. Foreign\n * `/bundles/…` URLs get the network with the stale-if-error cache; every\n * other URL falls through to the original fetch untouched. Inert when\n * neither a staged namespace nor a cache is configured.\n */\nexport function installGlobalBundleFetch(options: BundleFetchOptions): BundleFetchHandle {\n const namespace = options.namespace;\n const cacheDir = options.cacheDir;\n const runtime = namespace ? ManagedRuntime.make(BundleResolver.layer(namespace)) : null;\n const original: FetchImpl = globalThis.fetch;\n const patched = (async (input: Parameters<FetchImpl>[0], init?: Parameters<FetchImpl>[1]) => {\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n\n if (namespace && bundleUrlToLocalPath(url, namespace)) {\n if (!runtime) throw new Error(\"unreachable: resolver runtime missing\");\n const response = await runtime.runPromise(\n Effect.gen(function* () {\n const resolver = yield* BundleResolver;\n return yield* resolver.lookup(input);\n }),\n );\n if (response !== null) return response;\n return fetchWithTransientRetry(original, input, init);\n }\n\n if (cacheDir !== undefined && bundleCachePath(url, { cacheDir })) {\n return (async () => {\n try {\n const response = await fetchWithTransientRetry(original, input, init);\n if (response.ok) {\n try {\n const bytes = new Uint8Array(await response.clone().arrayBuffer());\n await writeBundleCache(url, bytes, { cacheDir });\n } catch {\n // write-through is best-effort\n }\n } else {\n const cached = await readBundleCache(url, { cacheDir });\n if (cached) return staleResponse(cached, url);\n }\n return response;\n } catch (error) {\n const cached = await readBundleCache(url, { cacheDir });\n if (cached) return staleResponse(cached, url);\n throw error;\n }\n })();\n }\n\n return fetchWithTransientRetry(original, input, init);\n }) as FetchImpl;\n const originalPreconnect = (original as Partial<FetchImpl>).preconnect;\n if (originalPreconnect) {\n patched.preconnect = originalPreconnect.bind(original);\n }\n globalThis.fetch = patched;\n return {\n uninstall: async () => {\n if (globalThis.fetch === patched) {\n globalThis.fetch = original;\n }\n if (runtime) await runtime.dispose();\n },\n };\n}\n\n/**\n * Boot-time installer for the CLI: derives the own namespace from\n * `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`\n * registry env taking precedence over the bos.config.json fields), and the\n * foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection\n * (ADR 0021): an identity whose namespace is not actually staged under the\n * bundle dir drops to the registry tier — plain network fetch — instead of\n * deterministically 404ing own-namespace URLs against a foreign image's\n * staged bytes. Never throws — a missing or malformed identity leaves the\n * default network fetch in place.\n */\nexport function installBundleFetchFromEnv(input: {\n configPath?: string | null;\n}): BundleFetchHandle | null {\n const bundleDir = process.env.BOS_BUNDLE_DIR;\n const cacheDir = process.env.BOS_BUNDLE_CACHE_DIR;\n if (!bundleDir && cacheDir === undefined) return null;\n\n let configAccount: string | undefined;\n let configGateway: string | undefined;\n const configPath = input.configPath;\n if (configPath && !isAppDescriptorPath(configPath)) {\n try {\n const parsed = JSON.parse(readFileSync(configPath, \"utf8\")) as {\n account?: string;\n domain?: string;\n };\n configAccount = parsed.account;\n configGateway = parsed.domain;\n } catch {\n // unreadable config — identity may still come from the registry env\n }\n }\n\n const account = process.env.BOS_ACCOUNT ?? configAccount;\n const gateway = process.env.BOS_GATEWAY ?? configGateway;\n if (bundleDir && (!account || !gateway)) return null;\n\n let namespace: BundleNamespace | undefined;\n if (bundleDir && account && gateway) {\n if (existsSync(path.join(bundleDir, account, gateway))) {\n namespace = { bundleDir, account, gateway };\n } else {\n console.warn(\n `[bundles] staged namespace ${account}/${gateway} not found under ${bundleDir} — registry tier (network fetch)`,\n );\n }\n }\n return installGlobalBundleFetch({\n namespace,\n cacheDir: cacheDir ??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CACJ,IAAI,aAAa,WAAW,SAAS;EACnC,QAAIC,oBAAWZ,kBAAK,KAAK,WAAW,SAAS,OAAO,CAAC,GACnD,YAAY;GAAE;GAAW;GAAS;EAAQ;OAE1C,QAAQ,KACN,8BAA8B,QAAQ,GAAG,QAAQ,mBAAmB,UAAU,iCAChF;CAEJ;CACA,OAAO,yBAAyB;EAC9B;EACA,UAAU,aAAa,YAAYa,qCAAgB,IAAI;CACzD,CAAC;AACH"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
|
-
//#region src/bundle-fs-resolve.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Local-first bundle resolution (ADR 0011 amendment; unified policy, ADR 0021
|
|
5
|
-
* amendment): a self-contained runtime image stages its own namespace under
|
|
6
|
-
* `BOS_BUNDLE_DIR` as `bundles/<account>/<gateway>/<workspace>/…` and consumes
|
|
7
|
-
* those bytes directly from disk; a miss falls through to the network, so a
|
|
8
|
-
* partially-staged namespace boots over the wire instead of failing. The
|
|
9
|
-
* registry tier (children, `BOS_BUNDLE_DIR` unset) keeps the network fetch —
|
|
10
|
-
* the namespace guard below only ever matches the runtime's own
|
|
11
|
-
* account/gateway, never another runtime's layout.
|
|
12
|
-
*/
|
|
13
|
-
interface BundleNamespace {
|
|
14
|
-
readonly bundleDir: string;
|
|
15
|
-
readonly account: string;
|
|
16
|
-
readonly gateway: string;
|
|
17
|
-
}
|
|
18
|
-
declare const BundleReadError_base: Schema.Class<BundleReadError, Schema.TaggedStruct<"BundleReadError", {
|
|
19
|
-
readonly path: Schema.String;
|
|
20
|
-
readonly cause: Schema.optional<Schema.Unknown>;
|
|
21
|
-
}>, import("effect/Cause").YieldableError>;
|
|
22
|
-
declare class BundleReadError extends BundleReadError_base {}
|
|
23
|
-
/**
|
|
24
|
-
* Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
|
|
25
|
-
* narrowed to the runtime identity — a URL whose encoded namespace differs
|
|
26
|
-
* from `namespace.account`/`namespace.gateway` must fall to the network/cache
|
|
27
|
-
* path, never serve a sibling namespace's staged bytes.
|
|
28
|
-
*/
|
|
29
|
-
declare function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null;
|
|
30
|
-
declare const BundleResolver_base: Context.ServiceClass<BundleResolver, "everything-dev/bundle-fs-resolve/BundleResolver", {
|
|
31
|
-
/** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */
|
|
32
|
-
readonly lookup: (input: string | URL | Request) => Effect.Effect<Response | null>;
|
|
33
|
-
}>;
|
|
34
|
-
declare class BundleResolver extends BundleResolver_base {
|
|
35
|
-
static layer(namespace: BundleNamespace): Layer.Layer<BundleResolver>;
|
|
36
|
-
}
|
|
37
|
-
interface BundleFetchHandle {
|
|
38
|
-
readonly uninstall: () => Promise<void>;
|
|
39
|
-
}
|
|
40
|
-
interface BundleFetchOptions {
|
|
41
|
-
/** Own-namespace FS resolution — requires a staged `BOS_BUNDLE_DIR`. */
|
|
42
|
-
namespace?: BundleNamespace;
|
|
43
|
-
/**
|
|
44
|
-
* Foreign-namespace stale-if-error cache (child tier): `/bundles/…` URLs
|
|
45
|
-
* outside the own namespace write through to disk on success and serve
|
|
46
|
-
* the last-known-good bytes when the origin fails. Enabled implicitly
|
|
47
|
-
* when `namespace` is present (deployment contexts), or explicitly via
|
|
48
|
-
* `BOS_BUNDLE_CACHE_DIR`.
|
|
49
|
-
*/
|
|
50
|
-
cacheDir?: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Installs the resolver as a global fetch interceptor — the one seam every
|
|
54
|
-
* boot-time consumer shares (config manifest discovery, contract-type
|
|
55
|
-
* fetches, orchestrator host loading, MF remoteEntry/identity probes).
|
|
56
|
-
* One layered resolution policy: staged disk → network → stale-if-error.
|
|
57
|
-
* Own-namespace URLs resolve from the staged directory and fall through to
|
|
58
|
-
* the original fetch on a miss (a partially-staged namespace boots over the
|
|
59
|
-
* wire instead of failing); a miss never touches the write-through cache —
|
|
60
|
-
* for the own namespace the staged disk IS the resilience artifact. Foreign
|
|
61
|
-
* `/bundles/…` URLs get the network with the stale-if-error cache; every
|
|
62
|
-
* other URL falls through to the original fetch untouched. Inert when
|
|
63
|
-
* neither a staged namespace nor a cache is configured.
|
|
64
|
-
*/
|
|
65
|
-
declare function installGlobalBundleFetch(options: BundleFetchOptions): BundleFetchHandle;
|
|
66
|
-
/**
|
|
67
|
-
* Boot-time installer for the CLI: derives the own namespace from
|
|
68
|
-
* `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`
|
|
69
|
-
* registry env taking precedence over the bos.config.json fields), and the
|
|
70
|
-
* foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection
|
|
71
|
-
* (ADR 0021): an identity whose namespace is not actually staged under the
|
|
72
|
-
* bundle dir drops to the registry tier — plain network fetch — instead of
|
|
73
|
-
* deterministically 404ing own-namespace URLs against a foreign image's
|
|
74
|
-
* staged bytes. Never throws — a missing or malformed identity leaves the
|
|
75
|
-
* default network fetch in place.
|
|
76
|
-
*/
|
|
77
|
-
declare function installBundleFetchFromEnv(input: {
|
|
78
|
-
configPath?: string | null;
|
|
79
|
-
}): BundleFetchHandle | null;
|
|
80
|
-
//#endregion
|
|
81
|
-
export { BundleFetchHandle, BundleFetchOptions, BundleNamespace, BundleReadError, BundleResolver, bundleUrlToLocalPath, installBundleFetchFromEnv, installGlobalBundleFetch };
|
|
82
|
-
//# sourceMappingURL=bundle-fs-resolve.d.cts.map
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
|
-
//#region src/bundle-fs-resolve.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Local-first bundle resolution (ADR 0011 amendment; unified policy, ADR 0021
|
|
5
|
-
* amendment): a self-contained runtime image stages its own namespace under
|
|
6
|
-
* `BOS_BUNDLE_DIR` as `bundles/<account>/<gateway>/<workspace>/…` and consumes
|
|
7
|
-
* those bytes directly from disk; a miss falls through to the network, so a
|
|
8
|
-
* partially-staged namespace boots over the wire instead of failing. The
|
|
9
|
-
* registry tier (children, `BOS_BUNDLE_DIR` unset) keeps the network fetch —
|
|
10
|
-
* the namespace guard below only ever matches the runtime's own
|
|
11
|
-
* account/gateway, never another runtime's layout.
|
|
12
|
-
*/
|
|
13
|
-
interface BundleNamespace {
|
|
14
|
-
readonly bundleDir: string;
|
|
15
|
-
readonly account: string;
|
|
16
|
-
readonly gateway: string;
|
|
17
|
-
}
|
|
18
|
-
declare const BundleReadError_base: Schema.Class<BundleReadError, Schema.TaggedStruct<"BundleReadError", {
|
|
19
|
-
readonly path: Schema.String;
|
|
20
|
-
readonly cause: Schema.optional<Schema.Unknown>;
|
|
21
|
-
}>, import("effect/Cause").YieldableError>;
|
|
22
|
-
declare class BundleReadError extends BundleReadError_base {}
|
|
23
|
-
/**
|
|
24
|
-
* Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
|
|
25
|
-
* narrowed to the runtime identity — a URL whose encoded namespace differs
|
|
26
|
-
* from `namespace.account`/`namespace.gateway` must fall to the network/cache
|
|
27
|
-
* path, never serve a sibling namespace's staged bytes.
|
|
28
|
-
*/
|
|
29
|
-
declare function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null;
|
|
30
|
-
declare const BundleResolver_base: Context.ServiceClass<BundleResolver, "everything-dev/bundle-fs-resolve/BundleResolver", {
|
|
31
|
-
/** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */
|
|
32
|
-
readonly lookup: (input: string | URL | Request) => Effect.Effect<Response | null>;
|
|
33
|
-
}>;
|
|
34
|
-
declare class BundleResolver extends BundleResolver_base {
|
|
35
|
-
static layer(namespace: BundleNamespace): Layer.Layer<BundleResolver>;
|
|
36
|
-
}
|
|
37
|
-
interface BundleFetchHandle {
|
|
38
|
-
readonly uninstall: () => Promise<void>;
|
|
39
|
-
}
|
|
40
|
-
interface BundleFetchOptions {
|
|
41
|
-
/** Own-namespace FS resolution — requires a staged `BOS_BUNDLE_DIR`. */
|
|
42
|
-
namespace?: BundleNamespace;
|
|
43
|
-
/**
|
|
44
|
-
* Foreign-namespace stale-if-error cache (child tier): `/bundles/…` URLs
|
|
45
|
-
* outside the own namespace write through to disk on success and serve
|
|
46
|
-
* the last-known-good bytes when the origin fails. Enabled implicitly
|
|
47
|
-
* when `namespace` is present (deployment contexts), or explicitly via
|
|
48
|
-
* `BOS_BUNDLE_CACHE_DIR`.
|
|
49
|
-
*/
|
|
50
|
-
cacheDir?: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Installs the resolver as a global fetch interceptor — the one seam every
|
|
54
|
-
* boot-time consumer shares (config manifest discovery, contract-type
|
|
55
|
-
* fetches, orchestrator host loading, MF remoteEntry/identity probes).
|
|
56
|
-
* One layered resolution policy: staged disk → network → stale-if-error.
|
|
57
|
-
* Own-namespace URLs resolve from the staged directory and fall through to
|
|
58
|
-
* the original fetch on a miss (a partially-staged namespace boots over the
|
|
59
|
-
* wire instead of failing); a miss never touches the write-through cache —
|
|
60
|
-
* for the own namespace the staged disk IS the resilience artifact. Foreign
|
|
61
|
-
* `/bundles/…` URLs get the network with the stale-if-error cache; every
|
|
62
|
-
* other URL falls through to the original fetch untouched. Inert when
|
|
63
|
-
* neither a staged namespace nor a cache is configured.
|
|
64
|
-
*/
|
|
65
|
-
declare function installGlobalBundleFetch(options: BundleFetchOptions): BundleFetchHandle;
|
|
66
|
-
/**
|
|
67
|
-
* Boot-time installer for the CLI: derives the own namespace from
|
|
68
|
-
* `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`
|
|
69
|
-
* registry env taking precedence over the bos.config.json fields), and the
|
|
70
|
-
* foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection
|
|
71
|
-
* (ADR 0021): an identity whose namespace is not actually staged under the
|
|
72
|
-
* bundle dir drops to the registry tier — plain network fetch — instead of
|
|
73
|
-
* deterministically 404ing own-namespace URLs against a foreign image's
|
|
74
|
-
* staged bytes. Never throws — a missing or malformed identity leaves the
|
|
75
|
-
* default network fetch in place.
|
|
76
|
-
*/
|
|
77
|
-
declare function installBundleFetchFromEnv(input: {
|
|
78
|
-
configPath?: string | null;
|
|
79
|
-
}): BundleFetchHandle | null;
|
|
80
|
-
//#endregion
|
|
81
|
-
export { BundleFetchHandle, BundleFetchOptions, BundleNamespace, BundleReadError, BundleResolver, bundleUrlToLocalPath, installBundleFetchFromEnv, installGlobalBundleFetch };
|
|
82
|
-
//# sourceMappingURL=bundle-fs-resolve.d.mts.map
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { bundleUrlToStagedPath } from "./bundle-path.mjs";
|
|
2
|
-
import { isAppDescriptorPath } from "./config.mjs";
|
|
3
|
-
import { bundleCachePath, bundleCacheRoot, readBundleCache, writeBundleCache } from "./bundle-cache.mjs";
|
|
4
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { Context, Effect, Layer, ManagedRuntime, Schema } from "effect";
|
|
7
|
-
import { readFile } from "node:fs/promises";
|
|
8
|
-
import { cacheControlOf } from "every-plugin/build/artifact-names";
|
|
9
|
-
|
|
10
|
-
//#region src/bundle-fs-resolve.ts
|
|
11
|
-
var BundleReadError = class extends Schema.TaggedError()("BundleReadError", {
|
|
12
|
-
path: Schema.String,
|
|
13
|
-
cause: Schema.optional(Schema.Unknown)
|
|
14
|
-
}) {};
|
|
15
|
-
const MIME_TYPES = {
|
|
16
|
-
".js": "text/javascript",
|
|
17
|
-
".mjs": "text/javascript",
|
|
18
|
-
".cjs": "text/javascript",
|
|
19
|
-
".css": "text/css",
|
|
20
|
-
".json": "application/json",
|
|
21
|
-
".map": "application/json",
|
|
22
|
-
".svg": "image/svg+xml",
|
|
23
|
-
".png": "image/png",
|
|
24
|
-
".jpg": "image/jpeg",
|
|
25
|
-
".jpeg": "image/jpeg",
|
|
26
|
-
".gif": "image/gif",
|
|
27
|
-
".webp": "image/webp",
|
|
28
|
-
".avif": "image/avif",
|
|
29
|
-
".ico": "image/x-icon",
|
|
30
|
-
".html": "text/html",
|
|
31
|
-
".htm": "text/html",
|
|
32
|
-
".webmanifest": "application/manifest+json",
|
|
33
|
-
".md": "text/markdown",
|
|
34
|
-
".ts": "text/plain",
|
|
35
|
-
".woff": "font/woff",
|
|
36
|
-
".woff2": "font/woff2",
|
|
37
|
-
".ttf": "font/ttf",
|
|
38
|
-
".otf": "font/otf",
|
|
39
|
-
".eot": "application/vnd.ms-fontobject",
|
|
40
|
-
".wasm": "application/wasm",
|
|
41
|
-
".txt": "text/plain",
|
|
42
|
-
".xml": "application/xml"
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
|
|
46
|
-
* narrowed to the runtime identity — a URL whose encoded namespace differs
|
|
47
|
-
* from `namespace.account`/`namespace.gateway` must fall to the network/cache
|
|
48
|
-
* path, never serve a sibling namespace's staged bytes.
|
|
49
|
-
*/
|
|
50
|
-
function bundleUrlToLocalPath(url, namespace) {
|
|
51
|
-
const filePath = bundleUrlToStagedPath(url, namespace.bundleDir);
|
|
52
|
-
if (!filePath) return null;
|
|
53
|
-
const nsDir = path.resolve(namespace.bundleDir, namespace.account, namespace.gateway);
|
|
54
|
-
if (filePath !== nsDir && !filePath.startsWith(nsDir + path.sep)) return null;
|
|
55
|
-
return filePath;
|
|
56
|
-
}
|
|
57
|
-
var BundleResolver = class BundleResolver extends Context.Service()("everything-dev/bundle-fs-resolve/BundleResolver") {
|
|
58
|
-
static layer(namespace) {
|
|
59
|
-
const respond = Effect.fn("BundleResolver.respond")(function* (url) {
|
|
60
|
-
const filePath = bundleUrlToLocalPath(url, namespace);
|
|
61
|
-
if (!filePath) return null;
|
|
62
|
-
const bytes = yield* Effect.tryPromise({
|
|
63
|
-
try: () => readFile(filePath),
|
|
64
|
-
catch: (cause) => new BundleReadError({
|
|
65
|
-
path: filePath,
|
|
66
|
-
cause
|
|
67
|
-
})
|
|
68
|
-
}).pipe(Effect.catchTag("BundleReadError", () => Effect.succeed(null)));
|
|
69
|
-
if (bytes === null) return null;
|
|
70
|
-
const name = path.basename(filePath);
|
|
71
|
-
const contentType = MIME_TYPES[path.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
72
|
-
return new Response(new Uint8Array(bytes), { headers: {
|
|
73
|
-
"content-type": contentType,
|
|
74
|
-
"cache-control": cacheControlOf(name),
|
|
75
|
-
etag: `"${Buffer.from(bytes.subarray(0, 4096)).toString("base64").slice(0, 24)}"`
|
|
76
|
-
} });
|
|
77
|
-
});
|
|
78
|
-
return Layer.effect(BundleResolver, Effect.succeed(BundleResolver.of({ lookup: (input) => {
|
|
79
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
80
|
-
return respond(url);
|
|
81
|
-
} })));
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const staleResponse = (bytes, url) => {
|
|
85
|
-
const name = url.split("?")[0].split("/").pop() ?? "";
|
|
86
|
-
const contentType = MIME_TYPES[path.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
87
|
-
return new Response(bytes.slice().buffer, {
|
|
88
|
-
status: 200,
|
|
89
|
-
headers: {
|
|
90
|
-
"content-type": contentType,
|
|
91
|
-
"x-bundle-cache": "stale"
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
const FETCH_RETRY_ATTEMPTS = 3;
|
|
96
|
-
const FETCH_RETRY_BASE_DELAY_MS = 250;
|
|
97
|
-
const isTransientStatus = (status) => status === 429 || status >= 500;
|
|
98
|
-
function requestMethod(input, init) {
|
|
99
|
-
if (init?.method) return init.method.toUpperCase();
|
|
100
|
-
if (typeof input === "string" || input instanceof URL) return "GET";
|
|
101
|
-
return input.method.toUpperCase();
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Bounded transient-failure retry for idempotent GETs crossing the
|
|
105
|
-
* interceptor (ADR 0021 amendment — the CDN-only image): a cold boot has no
|
|
106
|
-
* staged fallback, so one edge/registry hiccup during the load window would
|
|
107
|
-
* hard-fail the host or a plugin with no recourse. Network errors and
|
|
108
|
-
* 429/5xx responses retry twice (250ms, 750ms backoff) before propagating;
|
|
109
|
-
* non-transient statuses and non-GET requests pass through untouched. After
|
|
110
|
-
* exhausting attempts a stale-if-error cache still sees the final failure.
|
|
111
|
-
*/
|
|
112
|
-
async function fetchWithTransientRetry(original, input, init) {
|
|
113
|
-
if (requestMethod(input, init) !== "GET") return original(input, init);
|
|
114
|
-
let lastError;
|
|
115
|
-
let lastResponse = null;
|
|
116
|
-
for (let attempt = 0; attempt < FETCH_RETRY_ATTEMPTS; attempt++) {
|
|
117
|
-
if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, FETCH_RETRY_BASE_DELAY_MS * 3 ** (attempt - 1)));
|
|
118
|
-
try {
|
|
119
|
-
const response = await original(input, init);
|
|
120
|
-
if (!isTransientStatus(response.status)) return response;
|
|
121
|
-
lastResponse = response;
|
|
122
|
-
} catch (error) {
|
|
123
|
-
lastError = error;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (lastResponse) return lastResponse;
|
|
127
|
-
throw lastError;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Installs the resolver as a global fetch interceptor — the one seam every
|
|
131
|
-
* boot-time consumer shares (config manifest discovery, contract-type
|
|
132
|
-
* fetches, orchestrator host loading, MF remoteEntry/identity probes).
|
|
133
|
-
* One layered resolution policy: staged disk → network → stale-if-error.
|
|
134
|
-
* Own-namespace URLs resolve from the staged directory and fall through to
|
|
135
|
-
* the original fetch on a miss (a partially-staged namespace boots over the
|
|
136
|
-
* wire instead of failing); a miss never touches the write-through cache —
|
|
137
|
-
* for the own namespace the staged disk IS the resilience artifact. Foreign
|
|
138
|
-
* `/bundles/…` URLs get the network with the stale-if-error cache; every
|
|
139
|
-
* other URL falls through to the original fetch untouched. Inert when
|
|
140
|
-
* neither a staged namespace nor a cache is configured.
|
|
141
|
-
*/
|
|
142
|
-
function installGlobalBundleFetch(options) {
|
|
143
|
-
const namespace = options.namespace;
|
|
144
|
-
const cacheDir = options.cacheDir;
|
|
145
|
-
const runtime = namespace ? ManagedRuntime.make(BundleResolver.layer(namespace)) : null;
|
|
146
|
-
const original = globalThis.fetch;
|
|
147
|
-
const patched = (async (input, init) => {
|
|
148
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
149
|
-
if (namespace && bundleUrlToLocalPath(url, namespace)) {
|
|
150
|
-
if (!runtime) throw new Error("unreachable: resolver runtime missing");
|
|
151
|
-
const response = await runtime.runPromise(Effect.gen(function* () {
|
|
152
|
-
return yield* (yield* BundleResolver).lookup(input);
|
|
153
|
-
}));
|
|
154
|
-
if (response !== null) return response;
|
|
155
|
-
return fetchWithTransientRetry(original, input, init);
|
|
156
|
-
}
|
|
157
|
-
if (cacheDir !== void 0 && bundleCachePath(url, { cacheDir })) return (async () => {
|
|
158
|
-
try {
|
|
159
|
-
const response = await fetchWithTransientRetry(original, input, init);
|
|
160
|
-
if (response.ok) try {
|
|
161
|
-
const bytes = new Uint8Array(await response.clone().arrayBuffer());
|
|
162
|
-
await writeBundleCache(url, bytes, { cacheDir });
|
|
163
|
-
} catch {}
|
|
164
|
-
else {
|
|
165
|
-
const cached = await readBundleCache(url, { cacheDir });
|
|
166
|
-
if (cached) return staleResponse(cached, url);
|
|
167
|
-
}
|
|
168
|
-
return response;
|
|
169
|
-
} catch (error) {
|
|
170
|
-
const cached = await readBundleCache(url, { cacheDir });
|
|
171
|
-
if (cached) return staleResponse(cached, url);
|
|
172
|
-
throw error;
|
|
173
|
-
}
|
|
174
|
-
})();
|
|
175
|
-
return fetchWithTransientRetry(original, input, init);
|
|
176
|
-
});
|
|
177
|
-
const originalPreconnect = original.preconnect;
|
|
178
|
-
if (originalPreconnect) patched.preconnect = originalPreconnect.bind(original);
|
|
179
|
-
globalThis.fetch = patched;
|
|
180
|
-
return { uninstall: async () => {
|
|
181
|
-
if (globalThis.fetch === patched) globalThis.fetch = original;
|
|
182
|
-
if (runtime) await runtime.dispose();
|
|
183
|
-
} };
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Boot-time installer for the CLI: derives the own namespace from
|
|
187
|
-
* `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`
|
|
188
|
-
* registry env taking precedence over the bos.config.json fields), and the
|
|
189
|
-
* foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection
|
|
190
|
-
* (ADR 0021): an identity whose namespace is not actually staged under the
|
|
191
|
-
* bundle dir drops to the registry tier — plain network fetch — instead of
|
|
192
|
-
* deterministically 404ing own-namespace URLs against a foreign image's
|
|
193
|
-
* staged bytes. Never throws — a missing or malformed identity leaves the
|
|
194
|
-
* default network fetch in place.
|
|
195
|
-
*/
|
|
196
|
-
function installBundleFetchFromEnv(input) {
|
|
197
|
-
const bundleDir = process.env.BOS_BUNDLE_DIR;
|
|
198
|
-
const cacheDir = process.env.BOS_BUNDLE_CACHE_DIR;
|
|
199
|
-
if (!bundleDir && cacheDir === void 0) return null;
|
|
200
|
-
let configAccount;
|
|
201
|
-
let configGateway;
|
|
202
|
-
const configPath = input.configPath;
|
|
203
|
-
if (configPath && !isAppDescriptorPath(configPath)) try {
|
|
204
|
-
const parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
|
205
|
-
configAccount = parsed.account;
|
|
206
|
-
configGateway = parsed.domain;
|
|
207
|
-
} catch {}
|
|
208
|
-
const account = process.env.BOS_ACCOUNT ?? configAccount;
|
|
209
|
-
const gateway = process.env.BOS_GATEWAY ?? configGateway;
|
|
210
|
-
if (bundleDir && (!account || !gateway)) return null;
|
|
211
|
-
let namespace;
|
|
212
|
-
if (bundleDir && account && gateway) {
|
|
213
|
-
if (existsSync(path.join(bundleDir, account, gateway))) namespace = {
|
|
214
|
-
bundleDir,
|
|
215
|
-
account,
|
|
216
|
-
gateway
|
|
217
|
-
};
|
|
218
|
-
else console.warn(`[bundles] staged namespace ${account}/${gateway} not found under ${bundleDir} — registry tier (network fetch)`);
|
|
219
|
-
}
|
|
220
|
-
return installGlobalBundleFetch({
|
|
221
|
-
namespace,
|
|
222
|
-
cacheDir: cacheDir ?? (namespace ? bundleCacheRoot() : void 0)
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
//#endregion
|
|
227
|
-
export { BundleReadError, BundleResolver, bundleUrlToLocalPath, installBundleFetchFromEnv, installGlobalBundleFetch };
|
|
228
|
-
//# sourceMappingURL=bundle-fs-resolve.mjs.map
|