@nepopsx/cli 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/catalog.d.ts.map +1 -1
- package/dist/agents/catalog.js +2 -1
- package/dist/agents/catalog.js.map +1 -1
- package/dist/commands/capture.d.ts.map +1 -1
- package/dist/commands/capture.js +29 -9
- package/dist/commands/capture.js.map +1 -1
- package/dist/commands/doctor.js +5 -6
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +18 -7
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/push-learnings.d.ts.map +1 -1
- package/dist/commands/push-learnings.js +38 -27
- package/dist/commands/push-learnings.js.map +1 -1
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +4 -2
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +21 -9
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +6 -1
- package/dist/commands/up.js.map +1 -1
- package/dist/enrichment/workflow.d.ts.map +1 -1
- package/dist/enrichment/workflow.js +2 -1
- package/dist/enrichment/workflow.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/licensing/entitlement-cache.d.ts +25 -0
- package/dist/licensing/entitlement-cache.d.ts.map +1 -0
- package/dist/licensing/entitlement-cache.js +42 -0
- package/dist/licensing/entitlement-cache.js.map +1 -0
- package/dist/licensing/index.d.ts +3 -1
- package/dist/licensing/index.d.ts.map +1 -1
- package/dist/licensing/index.js +3 -1
- package/dist/licensing/index.js.map +1 -1
- package/dist/licensing/installer.d.ts.map +1 -1
- package/dist/licensing/installer.js +3 -2
- package/dist/licensing/installer.js.map +1 -1
- package/dist/licensing/license-manager.d.ts +30 -7
- package/dist/licensing/license-manager.d.ts.map +1 -1
- package/dist/licensing/license-manager.js +76 -13
- package/dist/licensing/license-manager.js.map +1 -1
- package/dist/licensing/template-fetch.d.ts.map +1 -1
- package/dist/licensing/template-fetch.js +6 -1
- package/dist/licensing/template-fetch.js.map +1 -1
- package/dist/licensing/workspace-name.d.ts +36 -0
- package/dist/licensing/workspace-name.d.ts.map +1 -0
- package/dist/licensing/workspace-name.js +54 -0
- package/dist/licensing/workspace-name.js.map +1 -0
- package/dist/utils/disk-cache.d.ts +14 -0
- package/dist/utils/disk-cache.d.ts.map +1 -0
- package/dist/utils/disk-cache.js +53 -0
- package/dist/utils/disk-cache.js.map +1 -0
- package/dist/utils/fetch-plan-manifest.d.ts +20 -0
- package/dist/utils/fetch-plan-manifest.d.ts.map +1 -0
- package/dist/utils/fetch-plan-manifest.js +93 -0
- package/dist/utils/fetch-plan-manifest.js.map +1 -0
- package/dist/utils/handle-402.d.ts +17 -0
- package/dist/utils/handle-402.d.ts.map +1 -0
- package/dist/utils/handle-402.js +31 -0
- package/dist/utils/handle-402.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
package/dist/licensing/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Licensing barrel — re-export all licensing modules.
|
|
3
3
|
*/
|
|
4
|
-
export { readLicense, writeLicense, activateLicense, validateLicense, enforceTierLimits, isDevMode, } from './license-manager.js';
|
|
4
|
+
export { readLicense, writeLicense, reconcileLicenseWorkspace, activateLicense, validateLicense, resolveEntitlement, enforceTierLimits, isDevMode, } from './license-manager.js';
|
|
5
|
+
export { getCachedEntitlement, setCachedEntitlement, clearCachedEntitlement, serverEnforces, } from './entitlement-cache.js';
|
|
5
6
|
export { fetchRemoteTemplates, } from './template-fetch.js';
|
|
6
7
|
export { applySteganography, decodeSteganography, forensicDecode, fingerprintToId, } from './fingerprint.js';
|
|
8
|
+
export { resolveWorkspaceName, readWorkspaceNameFromDisk, UNKNOWN_WORKSPACE, } from './workspace-name.js';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,GAIV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAID;;GAEG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,kBAAkB,GAAE,iBAAiB,EAAO,EAC5C,SAAS,GAAE,cAAc,EAAO,GAC/B,OAAO,CAAC,eAAe,CAAC,CA2B1B;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,kBAAkB,GAAE,iBAAiB,EAAO,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CA6B/B;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAcjF;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAOhF;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,aAAa,EAAE,CAmBjB"}
|
|
@@ -14,6 +14,7 @@ import { dirname, join } from "node:path";
|
|
|
14
14
|
import { resolveApiBase } from "../config/api-config.js";
|
|
15
15
|
import { fetchWithTimeout } from "../utils/fetch.js";
|
|
16
16
|
import { DOWNLOAD_TIMEOUT_MS } from "../constants.js";
|
|
17
|
+
import { resolveWorkspaceName } from "./workspace-name.js";
|
|
17
18
|
// ─── Download ───────────────────────────────────────────────
|
|
18
19
|
/**
|
|
19
20
|
* Download an encrypted template bundle from the NEPOPSX API.
|
|
@@ -29,7 +30,7 @@ export async function downloadBundle(cwd, license, agent, version, customInstruc
|
|
|
29
30
|
},
|
|
30
31
|
body: JSON.stringify({
|
|
31
32
|
machine_id: license.machine_id,
|
|
32
|
-
workspace: license
|
|
33
|
+
workspace: resolveWorkspaceName(cwd, license),
|
|
33
34
|
custom_instructions: customInstructions,
|
|
34
35
|
// When set, the backend returns FINAL per-provider files.
|
|
35
36
|
providers,
|
|
@@ -52,7 +53,7 @@ export async function downloadBootstrapConfig(cwd, license, agent, version, cust
|
|
|
52
53
|
},
|
|
53
54
|
body: JSON.stringify({
|
|
54
55
|
machine_id: license.machine_id,
|
|
55
|
-
workspace: license
|
|
56
|
+
workspace: resolveWorkspaceName(cwd, license),
|
|
56
57
|
custom_instructions: customInstructions,
|
|
57
58
|
}),
|
|
58
59
|
}, DOWNLOAD_TIMEOUT_MS);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;A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AoB,EAAE,CAAC;IAEpC,KAAK,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC;QAE1B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;QAED,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACrC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEtB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* License manager — handles license activation, validation,
|
|
3
3
|
* online refresh, and tier-based feature gating.
|
|
4
4
|
*/
|
|
5
|
-
import { type License, type LicenseStatus, type LicenseTier, type WorkspaceConfig } from '@nepopsx/core';
|
|
5
|
+
import { type License, type LicenseStatus, type LicenseTier, type WorkspaceConfig, type Entitlement } from '@nepopsx/core';
|
|
6
6
|
/**
|
|
7
7
|
* Read the local license file. Returns null if not found or invalid.
|
|
8
8
|
*/
|
|
@@ -11,6 +11,17 @@ export declare function readLicense(rootDir: string): License | null;
|
|
|
11
11
|
* Write license to disk. Creates .nepopsx/ if needed.
|
|
12
12
|
*/
|
|
13
13
|
export declare function writeLicense(rootDir: string, license: License): void;
|
|
14
|
+
/**
|
|
15
|
+
* Heal the license's `workspace` field against the live `workspace.yaml`.
|
|
16
|
+
*
|
|
17
|
+
* The license is activated before `workspace.yaml` exists, so it is born with
|
|
18
|
+
* `workspace: "unknown"`. Once the real config exists, reconcile the in-memory
|
|
19
|
+
* license (and persist it) so every downstream `license.workspace` read — and
|
|
20
|
+
* every backend call derived from it — uses the live workspace name instead of
|
|
21
|
+
* the stale snapshot. Best-effort: returns the license unchanged when the config
|
|
22
|
+
* is absent or already matches. Accepts/returns `null` for the no-license path.
|
|
23
|
+
*/
|
|
24
|
+
export declare function reconcileLicenseWorkspace<T extends License | null>(rootDir: string, license: T): T;
|
|
14
25
|
export interface ActivationResult {
|
|
15
26
|
success: boolean;
|
|
16
27
|
license?: License;
|
|
@@ -26,6 +37,19 @@ export declare function activateLicense(rootDir: string, licenseKey: string, wor
|
|
|
26
37
|
* Returns detailed status.
|
|
27
38
|
*/
|
|
28
39
|
export declare function validateLicense(rootDir: string, config: WorkspaceConfig): Promise<LicenseStatus>;
|
|
40
|
+
/** Result of a successful refresh: the updated license + the org's entitlement (if returned). */
|
|
41
|
+
export interface RefreshResult {
|
|
42
|
+
license: License;
|
|
43
|
+
entitlement?: Entitlement;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolve the org's entitlement for DISPLAY: cache → synthesized from the plan manifest +
|
|
47
|
+
* the license's (denormalized) tier when offline or on an older backend. Never throws.
|
|
48
|
+
*
|
|
49
|
+
* This is advisory only — the backend's 402 responses are the single hard authority. Use it
|
|
50
|
+
* to show the user their current plan/limits, not to allow/deny an operation locally.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveEntitlement(rootDir: string, license: License): Promise<Entitlement>;
|
|
29
53
|
export interface TierViolation {
|
|
30
54
|
feature: string;
|
|
31
55
|
limit: string;
|
|
@@ -33,13 +57,12 @@ export interface TierViolation {
|
|
|
33
57
|
required_tier: LicenseTier;
|
|
34
58
|
}
|
|
35
59
|
/**
|
|
36
|
-
|
|
37
|
-
* Check if the workspace config exceeds the license tier's limits.
|
|
60
|
+
* Check whether the workspace config exceeds the license tier's scale limits.
|
|
38
61
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
62
|
+
* **Advisory only (ADR 0001/0002):** the server is the enforcement authority. Callers should
|
|
63
|
+
* surface violations as a *warning* + upgrade hint and proceed; they must not hard-block on
|
|
64
|
+
* this result. Agent quality (customs, philosophy, prompts) is identical across all tiers —
|
|
65
|
+
* the differentiators are scale (services / agent packages) and tooling access (LLM scan).
|
|
43
66
|
*/
|
|
44
67
|
export declare function enforceTierLimits(config: WorkspaceConfig, tier: LicenseTier): TierViolation[];
|
|
45
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"license-manager.d.ts","sourceRoot":"","sources":["../../src/licensing/license-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACL,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAmB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"license-manager.d.ts","sourceRoot":"","sources":["../../src/licensing/license-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACL,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAmB,KAAK,eAAe,EACzF,KAAK,WAAW,EAGjB,MAAM,eAAe,CAAC;AAavB;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAiB3D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAUpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,OAAO,GAAG,IAAI,EAChE,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,GACT,CAAC,CAWH;AAID,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAoD3B;AAID;;;GAGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,aAAa,CAAC,CA8IxB;AAID,iGAAiG;AACjG,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAmDD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAchG;AAID,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,WAAW,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,EAAE,CA4B7F;AAID;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC"}
|
|
@@ -7,7 +7,10 @@ import { join } from 'node:path';
|
|
|
7
7
|
import { TIER_LIMITS, generateMachineId, generateFingerprint, checkExpiry, } from '@nepopsx/core';
|
|
8
8
|
import { resolveApiBase } from '../config/api-config.js';
|
|
9
9
|
import { fetchWithTimeout } from '../utils/fetch.js';
|
|
10
|
+
import { fetchPlanManifest } from '../utils/fetch-plan-manifest.js';
|
|
10
11
|
import { API_TIMEOUT_MS } from '../constants.js';
|
|
12
|
+
import { readWorkspaceNameFromDisk } from './workspace-name.js';
|
|
13
|
+
import { getCachedEntitlement, setCachedEntitlement } from './entitlement-cache.js';
|
|
11
14
|
const LICENSE_DIR = '.nepopsx';
|
|
12
15
|
const LICENSE_FILE = 'license.json';
|
|
13
16
|
// ─── License file operations ────────────────────────────────
|
|
@@ -41,6 +44,31 @@ export function writeLicense(rootDir, license) {
|
|
|
41
44
|
}
|
|
42
45
|
writeFileSync(join(dir, LICENSE_FILE), JSON.stringify(license, null, 2) + '\n', 'utf-8');
|
|
43
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Heal the license's `workspace` field against the live `workspace.yaml`.
|
|
49
|
+
*
|
|
50
|
+
* The license is activated before `workspace.yaml` exists, so it is born with
|
|
51
|
+
* `workspace: "unknown"`. Once the real config exists, reconcile the in-memory
|
|
52
|
+
* license (and persist it) so every downstream `license.workspace` read — and
|
|
53
|
+
* every backend call derived from it — uses the live workspace name instead of
|
|
54
|
+
* the stale snapshot. Best-effort: returns the license unchanged when the config
|
|
55
|
+
* is absent or already matches. Accepts/returns `null` for the no-license path.
|
|
56
|
+
*/
|
|
57
|
+
export function reconcileLicenseWorkspace(rootDir, license) {
|
|
58
|
+
if (!license)
|
|
59
|
+
return license;
|
|
60
|
+
const liveName = readWorkspaceNameFromDisk(rootDir);
|
|
61
|
+
if (!liveName || liveName === license.workspace)
|
|
62
|
+
return license;
|
|
63
|
+
const reconciled = { ...license, workspace: liveName };
|
|
64
|
+
try {
|
|
65
|
+
writeLicense(rootDir, reconciled);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Persisting is best-effort — the in-memory heal is what callers rely on.
|
|
69
|
+
}
|
|
70
|
+
return reconciled;
|
|
71
|
+
}
|
|
44
72
|
/**
|
|
45
73
|
* Activate a license key for this machine + workspace.
|
|
46
74
|
* Calls the remote API to validate the key and bind it.
|
|
@@ -94,7 +122,11 @@ export async function activateLicense(rootDir, licenseKey, workspaceName) {
|
|
|
94
122
|
* Returns detailed status.
|
|
95
123
|
*/
|
|
96
124
|
export async function validateLicense(rootDir, config) {
|
|
97
|
-
|
|
125
|
+
// Heal a stale `workspace: "unknown"` against the live config before any
|
|
126
|
+
// backend call uses it. validateLicense always runs with a loaded config, so
|
|
127
|
+
// this self-heals license.json and every later readLicense() returns the
|
|
128
|
+
// correct workspace.
|
|
129
|
+
const license = reconcileLicenseWorkspace(rootDir, readLicense(rootDir));
|
|
98
130
|
const apiBase = resolveApiBase(rootDir);
|
|
99
131
|
// No license file
|
|
100
132
|
if (!license) {
|
|
@@ -146,6 +178,9 @@ export async function validateLicense(rootDir, config) {
|
|
|
146
178
|
last_refreshed: new Date().toISOString(),
|
|
147
179
|
};
|
|
148
180
|
writeLicense(rootDir, updatedLicense);
|
|
181
|
+
if (data.entitlement) {
|
|
182
|
+
setCachedEntitlement(rootDir, updatedLicense.key, data.entitlement);
|
|
183
|
+
}
|
|
149
184
|
const onlineExpiry = checkExpiry(updatedLicense.valid_until);
|
|
150
185
|
return {
|
|
151
186
|
valid: true,
|
|
@@ -155,6 +190,7 @@ export async function validateLicense(rootDir, config) {
|
|
|
155
190
|
org: updatedLicense.org,
|
|
156
191
|
fingerprint,
|
|
157
192
|
message: data.message,
|
|
193
|
+
entitlement: data.entitlement,
|
|
158
194
|
};
|
|
159
195
|
}
|
|
160
196
|
return {
|
|
@@ -186,15 +222,17 @@ export async function validateLicense(rootDir, config) {
|
|
|
186
222
|
// Expired — attempt online refresh
|
|
187
223
|
const refreshed = await refreshLicense(rootDir, license);
|
|
188
224
|
if (refreshed) {
|
|
189
|
-
const
|
|
225
|
+
const { license: refreshedLicense, entitlement } = refreshed;
|
|
226
|
+
const newExpiry = checkExpiry(refreshedLicense.valid_until);
|
|
190
227
|
return {
|
|
191
228
|
valid: true,
|
|
192
229
|
expired: false,
|
|
193
230
|
days_remaining: newExpiry.daysRemaining,
|
|
194
|
-
tier:
|
|
195
|
-
org:
|
|
231
|
+
tier: refreshedLicense.tier,
|
|
232
|
+
org: refreshedLicense.org,
|
|
196
233
|
fingerprint,
|
|
197
|
-
message: `License refreshed. Valid until ${
|
|
234
|
+
message: `License refreshed. Valid until ${refreshedLicense.valid_until}.`,
|
|
235
|
+
entitlement,
|
|
198
236
|
};
|
|
199
237
|
}
|
|
200
238
|
// Refresh failed — license is truly expired
|
|
@@ -208,10 +246,10 @@ export async function validateLicense(rootDir, config) {
|
|
|
208
246
|
message: `License expired on ${license.valid_until}. Renew at nepopsx.dev or run \`nepopsx activate <key>\`.`,
|
|
209
247
|
};
|
|
210
248
|
}
|
|
211
|
-
// ─── Refresh ────────────────────────────────────────────────
|
|
212
249
|
/**
|
|
213
250
|
* Attempt to refresh the license via the remote API.
|
|
214
|
-
* Returns updated license
|
|
251
|
+
* Returns the updated license (+ entitlement when the backend provides it) on success,
|
|
252
|
+
* null on failure.
|
|
215
253
|
*/
|
|
216
254
|
async function refreshLicense(rootDir, license) {
|
|
217
255
|
const apiBase = resolveApiBase(rootDir);
|
|
@@ -235,21 +273,46 @@ async function refreshLicense(rootDir, license) {
|
|
|
235
273
|
last_refreshed: new Date().toISOString(),
|
|
236
274
|
};
|
|
237
275
|
writeLicense(rootDir, updated);
|
|
238
|
-
|
|
276
|
+
if (data.entitlement) {
|
|
277
|
+
setCachedEntitlement(rootDir, updated.key, data.entitlement);
|
|
278
|
+
}
|
|
279
|
+
return { license: updated, entitlement: data.entitlement };
|
|
239
280
|
}
|
|
240
281
|
catch {
|
|
241
282
|
// Network failure — can't refresh
|
|
242
283
|
return null;
|
|
243
284
|
}
|
|
244
285
|
}
|
|
286
|
+
// ─── Resolved entitlement (display / advisory) ──────────────
|
|
245
287
|
/**
|
|
288
|
+
* Resolve the org's entitlement for DISPLAY: cache → synthesized from the plan manifest +
|
|
289
|
+
* the license's (denormalized) tier when offline or on an older backend. Never throws.
|
|
290
|
+
*
|
|
291
|
+
* This is advisory only — the backend's 402 responses are the single hard authority. Use it
|
|
292
|
+
* to show the user their current plan/limits, not to allow/deny an operation locally.
|
|
293
|
+
*/
|
|
294
|
+
export async function resolveEntitlement(rootDir, license) {
|
|
295
|
+
const cached = getCachedEntitlement(rootDir, license.key);
|
|
296
|
+
if (cached)
|
|
297
|
+
return cached;
|
|
298
|
+
const manifest = await fetchPlanManifest(rootDir);
|
|
299
|
+
const spec = manifest.plans.find((p) => p.id === license.tier) ?? manifest.plans[0];
|
|
300
|
+
return {
|
|
301
|
+
tier: license.tier,
|
|
302
|
+
status: license.tier === 'free' ? 'free' : 'active',
|
|
303
|
+
limits: spec.limits,
|
|
304
|
+
features: spec.features,
|
|
305
|
+
validUntil: license.valid_until || null,
|
|
306
|
+
trialEndsAt: null,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
246
309
|
/**
|
|
247
|
-
* Check
|
|
310
|
+
* Check whether the workspace config exceeds the license tier's scale limits.
|
|
248
311
|
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
312
|
+
* **Advisory only (ADR 0001/0002):** the server is the enforcement authority. Callers should
|
|
313
|
+
* surface violations as a *warning* + upgrade hint and proceed; they must not hard-block on
|
|
314
|
+
* this result. Agent quality (customs, philosophy, prompts) is identical across all tiers —
|
|
315
|
+
* the differentiators are scale (services / agent packages) and tooling access (LLM scan).
|
|
253
316
|
*/
|
|
254
317
|
export function enforceTierLimits(config, tier) {
|
|
255
318
|
const limits = TIER_LIMITS[tier];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"license-manager.js","sourceRoot":"","sources":["../../src/licensing/license-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAW,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"license-manager.js","sourceRoot":"","sources":["../../src/licensing/license-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,M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,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;YACnC,aAAa,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY;SACvD,CAAC,CAAC;IACL,CAAC;IAED,cAAc;IACd,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QACnF,IAAI,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;YACtC,UAAU,CAAC,IAAI,CAAC;gBACd,OAAO,EAAE,QAAQ;gBACjB,KAAK,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE;gBAC7B,MAAM,EAAE,GAAG,aAAa,EAAE;gBAC1B,aAAa,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY;aACvD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,+DAA+D;AAE/D;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;AACzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-fetch.d.ts","sourceRoot":"","sources":["../../src/licensing/template-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"template-fetch.d.ts","sourceRoot":"","sources":["../../src/licensing/template-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,sDAAsD;IACtD,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC5B;AAMD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,kBAAkB,GAAE,iBAAiB,EAAO,EAC5C,SAAS,GAAE,cAAc,EAAO,GAC/B,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA4ChC"}
|
|
@@ -14,6 +14,8 @@ import { resolveApiBase } from '../config/api-config.js';
|
|
|
14
14
|
import { fetchWithTimeout } from '../utils/fetch.js';
|
|
15
15
|
import { decryptBundle as decryptBundleRaw } from './installer.js';
|
|
16
16
|
import { DOWNLOAD_TIMEOUT_MS } from '../constants.js';
|
|
17
|
+
import { reportIfPaymentRequired } from '../utils/handle-402.js';
|
|
18
|
+
import { resolveWorkspaceName } from './workspace-name.js';
|
|
17
19
|
// EncryptedBundle is imported from installer.ts
|
|
18
20
|
// ─── Public API ─────────────────────────────────────────────
|
|
19
21
|
/**
|
|
@@ -33,7 +35,7 @@ export async function fetchRemoteTemplates(rootDir, license, agentName, agentVer
|
|
|
33
35
|
},
|
|
34
36
|
body: JSON.stringify({
|
|
35
37
|
machine_id: license.machine_id,
|
|
36
|
-
workspace: license
|
|
38
|
+
workspace: resolveWorkspaceName(rootDir, license),
|
|
37
39
|
custom_instructions: customInstructions,
|
|
38
40
|
// When set, the backend returns FINAL per-provider files (already path-
|
|
39
41
|
// mapped + frontmatter-transformed). The CLI just writes them.
|
|
@@ -41,6 +43,9 @@ export async function fetchRemoteTemplates(rootDir, license, agentName, agentVer
|
|
|
41
43
|
}),
|
|
42
44
|
}, DOWNLOAD_TIMEOUT_MS);
|
|
43
45
|
if (!response.ok) {
|
|
46
|
+
// Surface a plan gate (402) as an upgrade prompt instead of silently using local
|
|
47
|
+
// fallback; any other error falls through to the local-template path.
|
|
48
|
+
await reportIfPaymentRequired(response);
|
|
44
49
|
return null;
|
|
45
50
|
}
|
|
46
51
|
const encrypted = await response.json();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-fetch.js","sourceRoot":"","sources":["../../src/licensing/template-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAwB,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"template-fetch.js","sourceRoot":"","sources":["../../src/licensing/template-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAwB,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAgB3D,gDAAgD;AAEhD,+DAA+D;AAE/D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAe,EACf,OAAgB,EAChB,SAAi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**
|
|
2
|
+
* Workspace-name resolution.
|
|
3
|
+
*
|
|
4
|
+
* The license file (`.nepopsx/license.json`) carries a `workspace` field that is
|
|
5
|
+
* written ONCE at `nepopsx login` / `nepopsx activate` time. At first run the
|
|
6
|
+
* workspace config doesn't exist yet, so it is stored as the literal `"unknown"`.
|
|
7
|
+
* `nepopsx up` later creates `.nepopsx/workspace.yaml` with the real name, but the
|
|
8
|
+
* license file is not rewritten — so any command that sends `license.workspace`
|
|
9
|
+
* to the backend would query the wrong (`"unknown"`) workspace and 404/401.
|
|
10
|
+
*
|
|
11
|
+
* This resolver always prefers the LIVE workspace name (from the loaded config or,
|
|
12
|
+
* failing that, from `workspace.yaml` on disk) and only falls back to the license
|
|
13
|
+
* value as a last resort.
|
|
14
|
+
*/
|
|
15
|
+
import type { License } from '@nepopsx/core';
|
|
16
|
+
export declare const UNKNOWN_WORKSPACE = "unknown";
|
|
17
|
+
/** Shape covering both the validated WorkspaceConfig and a raw YAML parse. */
|
|
18
|
+
type ConfigLike = {
|
|
19
|
+
workspace?: {
|
|
20
|
+
name?: string;
|
|
21
|
+
} | null;
|
|
22
|
+
} | null | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Read `workspace.name` directly from `.nepopsx/workspace.yaml`. Best-effort —
|
|
25
|
+
* returns undefined if the file is missing, unparseable, or has no real name.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readWorkspaceNameFromDisk(rootDir: string): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the workspace name to send to the backend.
|
|
30
|
+
*
|
|
31
|
+
* Precedence: explicit live config → workspace.yaml on disk → license value.
|
|
32
|
+
* Only the license value may be `"unknown"`; the first two are validated to be real.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveWorkspaceName(rootDir: string, license: Pick<License, 'workspace'> | null | undefined, config?: ConfigLike): string;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=workspace-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-name.d.ts","sourceRoot":"","sources":["../../src/licensing/workspace-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,8EAA8E;AAC9E,KAAK,UAAU,GAAG;IAAE,SAAS,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAM9E;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAU7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,EACtD,MAAM,CAAC,EAAE,UAAU,GAClB,MAAM,CAQR"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace-name resolution.
|
|
3
|
+
*
|
|
4
|
+
* The license file (`.nepopsx/license.json`) carries a `workspace` field that is
|
|
5
|
+
* written ONCE at `nepopsx login` / `nepopsx activate` time. At first run the
|
|
6
|
+
* workspace config doesn't exist yet, so it is stored as the literal `"unknown"`.
|
|
7
|
+
* `nepopsx up` later creates `.nepopsx/workspace.yaml` with the real name, but the
|
|
8
|
+
* license file is not rewritten — so any command that sends `license.workspace`
|
|
9
|
+
* to the backend would query the wrong (`"unknown"`) workspace and 404/401.
|
|
10
|
+
*
|
|
11
|
+
* This resolver always prefers the LIVE workspace name (from the loaded config or,
|
|
12
|
+
* failing that, from `workspace.yaml` on disk) and only falls back to the license
|
|
13
|
+
* value as a last resort.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
16
|
+
import { resolve } from 'node:path';
|
|
17
|
+
import { parse as parseYaml } from 'yaml';
|
|
18
|
+
export const UNKNOWN_WORKSPACE = 'unknown';
|
|
19
|
+
function isRealName(name) {
|
|
20
|
+
return typeof name === 'string' && name.length > 0 && name !== UNKNOWN_WORKSPACE;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read `workspace.name` directly from `.nepopsx/workspace.yaml`. Best-effort —
|
|
24
|
+
* returns undefined if the file is missing, unparseable, or has no real name.
|
|
25
|
+
*/
|
|
26
|
+
export function readWorkspaceNameFromDisk(rootDir) {
|
|
27
|
+
try {
|
|
28
|
+
const configPath = resolve(rootDir, '.nepopsx', 'workspace.yaml');
|
|
29
|
+
if (!existsSync(configPath))
|
|
30
|
+
return undefined;
|
|
31
|
+
const raw = parseYaml(readFileSync(configPath, 'utf-8'));
|
|
32
|
+
const name = raw?.workspace?.name;
|
|
33
|
+
return isRealName(name) ? name : undefined;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the workspace name to send to the backend.
|
|
41
|
+
*
|
|
42
|
+
* Precedence: explicit live config → workspace.yaml on disk → license value.
|
|
43
|
+
* Only the license value may be `"unknown"`; the first two are validated to be real.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveWorkspaceName(rootDir, license, config) {
|
|
46
|
+
const fromConfig = config?.workspace?.name;
|
|
47
|
+
if (isRealName(fromConfig))
|
|
48
|
+
return fromConfig;
|
|
49
|
+
const fromDisk = readWorkspaceNameFromDisk(rootDir);
|
|
50
|
+
if (fromDisk)
|
|
51
|
+
return fromDisk;
|
|
52
|
+
return license?.workspace ?? UNKNOWN_WORKSPACE;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=workspace-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-name.js","sourceRoot":"","sources":["../../src/licensing/workspace-name.ts"],"names":[],"m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;IAE9B,OAAO,OAAO,EAAE,SAAS,IAAI,iBAAiB,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TTL JSON disk cache under `.nepopsx/cache/`.
|
|
3
|
+
*
|
|
4
|
+
* Used for read-only, advisory data the CLI displays (the plan manifest and the org's
|
|
5
|
+
* resolved entitlement). Every read self-expires; every write is best-effort. Nothing
|
|
6
|
+
* here is an enforcement authority — a miss simply means "ask the server / fall back".
|
|
7
|
+
*/
|
|
8
|
+
/** Read a cached value, or `null` if absent, unreadable, malformed, or expired. */
|
|
9
|
+
export declare function readDiskCache<T>(rootDir: string, file: string): T | null;
|
|
10
|
+
/** Write a value with a TTL. Best-effort: a write failure is swallowed (cache is optional). */
|
|
11
|
+
export declare function writeDiskCache<T>(rootDir: string, file: string, value: T, ttlMs: number): void;
|
|
12
|
+
/** Delete a cache entry (used to bust on org/key change). */
|
|
13
|
+
export declare function clearDiskCache(rootDir: string, file: string): void;
|
|
14
|
+
//# sourceMappingURL=disk-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk-cache.d.ts","sourceRoot":"","sources":["../../src/utils/disk-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAWxE;AAED,+FAA+F;AAC/F,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAS9F;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAMlE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TTL JSON disk cache under `.nepopsx/cache/`.
|
|
3
|
+
*
|
|
4
|
+
* Used for read-only, advisory data the CLI displays (the plan manifest and the org's
|
|
5
|
+
* resolved entitlement). Every read self-expires; every write is best-effort. Nothing
|
|
6
|
+
* here is an enforcement authority — a miss simply means "ask the server / fall back".
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
const CACHE_SUBDIR = join('.nepopsx', 'cache');
|
|
11
|
+
function cachePath(rootDir, file) {
|
|
12
|
+
return join(rootDir, CACHE_SUBDIR, file);
|
|
13
|
+
}
|
|
14
|
+
/** Read a cached value, or `null` if absent, unreadable, malformed, or expired. */
|
|
15
|
+
export function readDiskCache(rootDir, file) {
|
|
16
|
+
try {
|
|
17
|
+
const path = cachePath(rootDir, file);
|
|
18
|
+
if (!existsSync(path))
|
|
19
|
+
return null;
|
|
20
|
+
const env = JSON.parse(readFileSync(path, 'utf-8'));
|
|
21
|
+
if (typeof env?.savedAt !== 'number' || typeof env?.ttlMs !== 'number')
|
|
22
|
+
return null;
|
|
23
|
+
if (Date.now() - env.savedAt > env.ttlMs)
|
|
24
|
+
return null;
|
|
25
|
+
return env.value;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Write a value with a TTL. Best-effort: a write failure is swallowed (cache is optional). */
|
|
32
|
+
export function writeDiskCache(rootDir, file, value, ttlMs) {
|
|
33
|
+
try {
|
|
34
|
+
const dir = join(rootDir, CACHE_SUBDIR);
|
|
35
|
+
if (!existsSync(dir))
|
|
36
|
+
mkdirSync(dir, { recursive: true });
|
|
37
|
+
const env = { savedAt: Date.now(), ttlMs, value };
|
|
38
|
+
writeFileSync(cachePath(rootDir, file), JSON.stringify(env), 'utf-8');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// best-effort cache; ignore
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Delete a cache entry (used to bust on org/key change). */
|
|
45
|
+
export function clearDiskCache(rootDir, file) {
|
|
46
|
+
try {
|
|
47
|
+
rmSync(cachePath(rootDir, file), { force: true });
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// ignore
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=disk-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk-cache.js","sourceRoot":"","sources":["../../src/utils/disk-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAQ/C,SAAS,SAAS,CAAC,OAAe,EAAE,IAAY;IAC9C,OAAO,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,aAAa,CAAI,OAAe,EAAE,IAAY;IAC5D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAqB,CAAC;QACxE,IAAI,OAAO,GAAG,EAAE,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,EAAE,KAAK,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QACpF,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACtD,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,cAAc,CAAI,OAAe,EAAE,IAAY,EAAE,KAAQ,EAAE,KAAa;IACtF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACxC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAqB,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACpE,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,4BAA4B;IAC9B,CAAC;AACH,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,IAAY;IAC1D,IAAI,CAAC;QACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch + cache the plan manifest from the public, read-only `GET /v1/plans` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* The manifest is the backend's source of truth for plan limits/features (ADR 0002). The
|
|
5
|
+
* CLI consumes it for DISPLAY only. When the endpoint is unreachable or the backend predates
|
|
6
|
+
* it (404), we synthesize a manifest from core's `TIER_LIMITS` so the CLI never hard-fails —
|
|
7
|
+
* this keeps Phase 1 a no-op against the current backend (rollout step 1).
|
|
8
|
+
*/
|
|
9
|
+
import { type PlanManifest } from '@nepopsx/core';
|
|
10
|
+
/** A manifest derived from core `TIER_LIMITS` — used when the API is unreachable/old. */
|
|
11
|
+
export declare function fallbackManifest(): PlanManifest;
|
|
12
|
+
export interface FetchManifestOptions {
|
|
13
|
+
/** Bypass the disk cache and hit the API. */
|
|
14
|
+
force?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Return the plan manifest: cache → API → `TIER_LIMITS` fallback. Never throws.
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchPlanManifest(rootDir: string, opts?: FetchManifestOptions): Promise<PlanManifest>;
|
|
20
|
+
//# sourceMappingURL=fetch-plan-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-plan-manifest.d.ts","sourceRoot":"","sources":["../../src/utils/fetch-plan-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,YAAY,EAOlB,MAAM,eAAe,CAAC;AAqDvB,yFAAyF;AACzF,wBAAgB,gBAAgB,IAAI,YAAY,CAQ/C;AAED,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,YAAY,CAAC,CAyBvB"}
|