ticketlens 0.1.21 → 0.1.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/package.json
CHANGED
|
@@ -45,6 +45,7 @@ export function writeLicense(data, configDir = DEFAULT_CONFIG_DIR) {
|
|
|
45
45
|
export function isLicensed(tier, configDir = DEFAULT_CONFIG_DIR) {
|
|
46
46
|
const required = LICENSE_TIERS[tier] ?? 0;
|
|
47
47
|
if (required === 0) return true;
|
|
48
|
+
if (process.env.TICKETLENS_SKIP_LICENSE === 'true') return true;
|
|
48
49
|
|
|
49
50
|
const license = readLicense(configDir);
|
|
50
51
|
if (!license) return false;
|
|
@@ -102,6 +103,16 @@ export function showUpgradePrompt(requiredTier, featureFlag, { stream = process.
|
|
|
102
103
|
const LEMONSQUEEZY_ACTIVATE_URL = 'https://api.lemonsqueezy.com/v1/licenses/activate';
|
|
103
104
|
const LEMONSQUEEZY_VALIDATE_URL = 'https://api.lemonsqueezy.com/v1/licenses/validate';
|
|
104
105
|
|
|
106
|
+
function resolveActivateUrl() {
|
|
107
|
+
const base = process.env.TICKETLENS_API_URL;
|
|
108
|
+
return base ? `${base.replace(/\/$/, '')}/v1/licenses/activate` : LEMONSQUEEZY_ACTIVATE_URL;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function resolveValidateUrl() {
|
|
112
|
+
const base = process.env.TICKETLENS_API_URL;
|
|
113
|
+
return base ? `${base.replace(/\/$/, '')}/v1/licenses/validate` : LEMONSQUEEZY_VALIDATE_URL;
|
|
114
|
+
}
|
|
115
|
+
|
|
105
116
|
function extractTier(meta) {
|
|
106
117
|
if (!meta) return 'pro';
|
|
107
118
|
const name = (meta.variant_name || meta.product_name || '').toLowerCase();
|
|
@@ -114,7 +125,7 @@ export async function activateLicense(key, opts = {}) {
|
|
|
114
125
|
const instance = instanceName || os.hostname();
|
|
115
126
|
|
|
116
127
|
try {
|
|
117
|
-
const res = await fetcher(
|
|
128
|
+
const res = await fetcher(resolveActivateUrl(), {
|
|
118
129
|
method: 'POST',
|
|
119
130
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
120
131
|
body: JSON.stringify({ license_key: key, instance_name: instance }),
|
|
@@ -154,7 +165,7 @@ export async function revalidateLicense(opts = {}) {
|
|
|
154
165
|
const instance = instanceName || os.hostname();
|
|
155
166
|
|
|
156
167
|
try {
|
|
157
|
-
const res = await fetcher(
|
|
168
|
+
const res = await fetcher(resolveValidateUrl(), {
|
|
158
169
|
method: 'POST',
|
|
159
170
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
160
171
|
body: JSON.stringify({ license_key: license.key, instance_name: instance }),
|
|
@@ -49,14 +49,16 @@ async function callAnthropic({ brief, apiKey, fetcher, timeoutMs, prompt, maxTok
|
|
|
49
49
|
'anthropic-version': '2023-06-01',
|
|
50
50
|
},
|
|
51
51
|
body: JSON.stringify({
|
|
52
|
-
model: 'claude-
|
|
52
|
+
model: 'claude-3-5-haiku-20241022',
|
|
53
53
|
max_tokens: maxTokens,
|
|
54
54
|
messages: [{ role: 'user', content: prompt + brief }],
|
|
55
55
|
}),
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
if (!res.ok) {
|
|
59
|
-
|
|
59
|
+
let detail = '';
|
|
60
|
+
try { detail = (await res.json()).error?.message || ''; } catch {}
|
|
61
|
+
const err = new Error(`Anthropic API error ${res.status}${detail ? ': ' + detail : ''}`);
|
|
60
62
|
err.status = res.status;
|
|
61
63
|
throw err;
|
|
62
64
|
}
|
|
@@ -81,7 +83,9 @@ async function callOpenAi({ brief, apiKey, fetcher, timeoutMs, prompt, maxTokens
|
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
if (!res.ok) {
|
|
84
|
-
|
|
86
|
+
let detail = '';
|
|
87
|
+
try { detail = (await res.json()).error?.message || ''; } catch {}
|
|
88
|
+
const err = new Error(`OpenAI API error ${res.status}${detail ? ': ' + detail : ''}`);
|
|
85
89
|
err.status = res.status;
|
|
86
90
|
throw err;
|
|
87
91
|
}
|