@dmsdc-ai/aigentry-deliberation 0.0.39 → 0.0.40

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/install.js CHANGED
@@ -55,7 +55,7 @@ const FILES_TO_COPY = [
55
55
  "package-lock.json",
56
56
  ];
57
57
 
58
- const DIRS_TO_COPY = ["selectors", "public", "skills"];
58
+ const DIRS_TO_COPY = ["selectors", "public", "skills", "lib"];
59
59
 
60
60
  function log(msg) {
61
61
  console.log(` ${msg}`);
@@ -0,0 +1,120 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import os from "os";
4
+
5
+ const LICENSE_PATH = path.join(os.homedir(), ".aigentry", "license.json");
6
+
7
+ // Feature → tier mapping
8
+ const FEATURE_TIERS = {
9
+ "deliberation.core": ["free", "pro", "team"],
10
+ "deliberation.multi_session": ["pro", "team"],
11
+ "deliberation.browser_integration": ["pro", "team"],
12
+ "deliberation.auto_run": ["pro", "team"],
13
+ "deliberation.remote": ["pro", "team"],
14
+ "deliberation.decision_engine": ["pro", "team"],
15
+ "deliberation.code_review": ["pro", "team"],
16
+ "deliberation.unlimited_speakers": ["pro", "team"],
17
+ };
18
+
19
+ // Free tier limits
20
+ const FREE_LIMITS = {
21
+ "deliberation.multi_session": 1,
22
+ "deliberation.unlimited_speakers": 3,
23
+ };
24
+
25
+ // Tool → feature mapping
26
+ const TOOL_FEATURE_MAP = {
27
+ deliberation_start: "deliberation.core",
28
+ deliberation_respond: "deliberation.core",
29
+ deliberation_synthesize: "deliberation.core",
30
+ deliberation_status: "deliberation.core",
31
+ deliberation_history: "deliberation.core",
32
+ deliberation_reset: "deliberation.core",
33
+ deliberation_cli_config: "deliberation.core",
34
+ deliberation_speaker_candidates: "deliberation.core",
35
+ deliberation_confirm_speakers: "deliberation.core",
36
+ deliberation_list: "deliberation.core",
37
+ deliberation_list_active: "deliberation.core",
38
+ deliberation_context: "deliberation.core",
39
+ deliberation_copy_last_turn: "deliberation.core",
40
+ deliberation_browser_auto_turn: "deliberation.browser_integration",
41
+ deliberation_browser_llm_tabs: "deliberation.browser_integration",
42
+ deliberation_run_until_blocked: "deliberation.auto_run",
43
+ deliberation_cli_auto_turn: "deliberation.auto_run",
44
+ deliberation_ingest_remote_reply: "deliberation.remote",
45
+ deliberation_list_remote_sessions: "deliberation.remote",
46
+ deliberation_inject_context: "deliberation.remote",
47
+ deliberation_request_review: "deliberation.code_review",
48
+ decision_start: "deliberation.decision_engine",
49
+ decision_status: "deliberation.decision_engine",
50
+ decision_respond: "deliberation.decision_engine",
51
+ decision_resume: "deliberation.decision_engine",
52
+ decision_history: "deliberation.decision_engine",
53
+ decision_templates: "deliberation.decision_engine",
54
+ };
55
+
56
+ function loadLicense() {
57
+ // Environment variable override for testing and CI
58
+ const envTier = process.env.AIGENTRY_TIER;
59
+ if (envTier && ["free", "pro", "team"].includes(envTier)) {
60
+ return { tier: envTier };
61
+ }
62
+ try {
63
+ if (!fs.existsSync(LICENSE_PATH)) return { tier: "free" };
64
+ const raw = fs.readFileSync(LICENSE_PATH, "utf8");
65
+ const license = JSON.parse(raw);
66
+ // Check expiry (30-day grace period)
67
+ if (license.expires_at) {
68
+ const expiry = new Date(license.expires_at);
69
+ const grace = new Date(expiry.getTime() + 30 * 24 * 60 * 60 * 1000);
70
+ if (new Date() > grace) return { tier: "free" };
71
+ }
72
+ // Check disabled features
73
+ return license;
74
+ } catch {
75
+ return { tier: "free" };
76
+ }
77
+ }
78
+
79
+ export function checkEntitlement({ feature }) {
80
+ const license = loadLicense();
81
+ const tier = license.tier || "free";
82
+ const allowedTiers = FEATURE_TIERS[feature];
83
+
84
+ if (!allowedTiers) return { allowed: true, tier }; // unknown feature = allow
85
+
86
+ // Check explicit feature overrides
87
+ if (license.features?.includes(feature)) return { allowed: true, tier };
88
+ if (license.disabled_features?.includes(feature)) {
89
+ return { allowed: false, tier, reason: `Feature '${feature}' is disabled by admin` };
90
+ }
91
+
92
+ const allowed = allowedTiers.includes(tier);
93
+ if (!allowed) {
94
+ const requiredTier = allowedTiers[0] === "free" ? allowedTiers[1] : allowedTiers[0];
95
+ return {
96
+ allowed: false,
97
+ tier,
98
+ reason: `Requires ${requiredTier} tier`,
99
+ upgrade_url: "https://aigentry.dev/upgrade",
100
+ };
101
+ }
102
+
103
+ return { allowed: true, tier };
104
+ }
105
+
106
+ export function checkToolEntitlement(toolName) {
107
+ const feature = TOOL_FEATURE_MAP[toolName];
108
+ if (!feature) return { allowed: true, tier: loadLicense().tier || "free" };
109
+ return checkEntitlement({ feature });
110
+ }
111
+
112
+ export function getFreeLimits(feature) {
113
+ return FREE_LIMITS[feature] || null;
114
+ }
115
+
116
+ export function getCurrentTier() {
117
+ return loadLicense().tier || "free";
118
+ }
119
+
120
+ export { TOOL_FEATURE_MAP, FEATURE_TIERS, FREE_LIMITS };