opencode-interrupt-plugin 0.4.41 → 0.4.42
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/license/validator.js +17 -7
- package/package.json +1 -1
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
2
|
-
import { writeFileSync, unlinkSync } from 'fs';
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import { writeFileSync, unlinkSync } from 'node:fs';
|
|
3
3
|
const POLAR_ORG_ID = '166f4429-84b8-4e41-9c74-eff1b8724873';
|
|
4
4
|
const POLAR_HOST = 'https://api.polar.sh';
|
|
5
5
|
const OFFLINE_GRACE_DAYS = 7;
|
|
6
|
-
const TMP_BODY = '/tmp/polar-
|
|
6
|
+
const TMP_BODY = '/tmp/interrupt-voice-polar-body.json';
|
|
7
7
|
function curlPost(path, body, timeoutMs) {
|
|
8
8
|
const connectTimeout = Math.ceil(timeoutMs / 1000);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const bodyStr = JSON.stringify(body);
|
|
10
|
+
writeFileSync(TMP_BODY, bodyStr, 'utf-8');
|
|
11
|
+
const cmd = `/usr/bin/curl -s -w '\n%{http_code}' -X POST -H 'Content-Type: application/json' -d @${TMP_BODY} --connect-timeout ${connectTimeout} --max-time ${connectTimeout} '${POLAR_HOST}${path}'`;
|
|
11
12
|
try {
|
|
12
|
-
|
|
13
|
+
console.log(`[interrupt] curl: POST ${POLAR_HOST}${path}`);
|
|
14
|
+
const output = execSync(cmd, { encoding: 'utf-8', timeout: timeoutMs + 5000 });
|
|
13
15
|
const parts = output.trim().split('\n');
|
|
14
16
|
const statusCode = parseInt(parts.pop() || '0', 10);
|
|
15
17
|
const raw = parts.join('\n');
|
|
18
|
+
console.log(`[interrupt] curl response: status=${statusCode}, body=${raw.slice(0, 200)}`);
|
|
16
19
|
let data;
|
|
17
20
|
try {
|
|
18
21
|
data = JSON.parse(raw);
|
|
@@ -22,6 +25,10 @@ function curlPost(path, body, timeoutMs) {
|
|
|
22
25
|
}
|
|
23
26
|
return { status: statusCode, data };
|
|
24
27
|
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
console.log(`[interrupt] curl error: ${err.message}`);
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
25
32
|
finally {
|
|
26
33
|
try {
|
|
27
34
|
unlinkSync(TMP_BODY);
|
|
@@ -30,6 +37,7 @@ function curlPost(path, body, timeoutMs) {
|
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
export async function activateLicense(key, machineLabel) {
|
|
40
|
+
console.log(`[interrupt] activateLicense: ${key.slice(0, 20)}... machine=${machineLabel}`);
|
|
33
41
|
try {
|
|
34
42
|
const { status, data } = curlPost('/v1/customer-portal/license-keys/activate', { key, organization_id: POLAR_ORG_ID, label: machineLabel, conditions: { major_version: 1 } }, 8000);
|
|
35
43
|
if (status === 200) {
|
|
@@ -48,7 +56,9 @@ export async function activateLicense(key, machineLabel) {
|
|
|
48
56
|
return { valid: false, reason: `Activation failed (status ${status})` };
|
|
49
57
|
}
|
|
50
58
|
catch (err) {
|
|
51
|
-
|
|
59
|
+
const msg = `Activation error: ${err.message}`;
|
|
60
|
+
console.log(`[interrupt] ${msg}`);
|
|
61
|
+
return { valid: false, reason: msg };
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
64
|
export async function validateLicense(key, activationId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-interrupt-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.42",
|
|
4
4
|
"description": "Streaming TTS + voice interruption for OpenCode. Speaks responses as they arrive and detects when you talk over it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|