session-steward 0.1.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.
@@ -0,0 +1,18 @@
1
+ import { codexProvider } from "./codex/index.mjs";
2
+
3
+ const providers = Object.freeze([codexProvider]);
4
+ const providersById = new Map(providers.map((provider) => [provider.id, provider]));
5
+
6
+ export function getProvider(providerId) {
7
+ const provider = providersById.get(providerId);
8
+
9
+ if (!provider) {
10
+ throw new Error(`Unsupported provider: ${providerId}`);
11
+ }
12
+
13
+ return provider;
14
+ }
15
+
16
+ export function listProviders() {
17
+ return [...providers];
18
+ }
@@ -0,0 +1,27 @@
1
+ export const MINIMUM_NODE_VERSION = "24.15.0";
2
+
3
+ function parseVersion(value) {
4
+ const match = /^(\d+)\.(\d+)\.(\d+)/u.exec(value);
5
+
6
+ if (!match) {
7
+ return null;
8
+ }
9
+
10
+ return match.slice(1).map(Number);
11
+ }
12
+
13
+ export function assertSupportedNode(version = process.versions.node) {
14
+ const current = parseVersion(version);
15
+ const minimum = parseVersion(MINIMUM_NODE_VERSION);
16
+
17
+ if (!current || !minimum) {
18
+ throw new Error(`Session Steward could not read the Node.js version. Node.js ${MINIMUM_NODE_VERSION} or newer is required.`);
19
+ }
20
+
21
+ for (let index = 0; index < minimum.length; index += 1) {
22
+ if (current[index] > minimum[index]) return;
23
+ if (current[index] < minimum[index]) {
24
+ throw new Error(`Session Steward requires Node.js ${MINIMUM_NODE_VERSION} or newer. You have ${version}.`);
25
+ }
26
+ }
27
+ }