opencode-interrupt-plugin 0.4.42 → 0.4.44
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/index.js +4 -3
- package/dist/license/validator.js +13 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -203,10 +203,11 @@ const TTS_COMMANDS = [
|
|
|
203
203
|
{ name: 'ptt', description: 'Toggle walkie-talkie recording (start/stop + transcribe)', template: 'Toggles PTT recording.' },
|
|
204
204
|
];
|
|
205
205
|
export const InterruptPlugin = (userConfig = {}) => {
|
|
206
|
-
return async ({ client }) => {
|
|
207
|
-
const
|
|
206
|
+
return async ({ client }, pluginOptions) => {
|
|
207
|
+
const cfg = { ...userConfig, ...pluginOptions };
|
|
208
|
+
const licenseResult = await checkLicense(cfg.licenseKey);
|
|
208
209
|
isLicensed = licenseResult.allowed;
|
|
209
|
-
const config = resolveConfig(
|
|
210
|
+
const config = resolveConfig(cfg, licenseResult.allowed);
|
|
210
211
|
if (config.debug) {
|
|
211
212
|
console.log(`[interrupt] Plugin loaded (${isLicensed ? 'licensed' : 'free'} mode)`);
|
|
212
213
|
}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
|
-
import { writeFileSync, unlinkSync } from 'node:fs';
|
|
2
|
+
import { appendFileSync, 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 DEBUG_LOG = '/tmp/interrupt-license-debug.log';
|
|
6
7
|
const TMP_BODY = '/tmp/interrupt-voice-polar-body.json';
|
|
8
|
+
function debug(msg) {
|
|
9
|
+
try {
|
|
10
|
+
appendFileSync(DEBUG_LOG, `${new Date().toISOString()} ${msg}\n`);
|
|
11
|
+
}
|
|
12
|
+
catch { /* ignore */ }
|
|
13
|
+
}
|
|
7
14
|
function curlPost(path, body, timeoutMs) {
|
|
8
15
|
const connectTimeout = Math.ceil(timeoutMs / 1000);
|
|
9
16
|
const bodyStr = JSON.stringify(body);
|
|
10
17
|
writeFileSync(TMP_BODY, bodyStr, 'utf-8');
|
|
11
18
|
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}'`;
|
|
12
19
|
try {
|
|
13
|
-
|
|
20
|
+
debug(`curl: POST ${POLAR_HOST}${path}`);
|
|
14
21
|
const output = execSync(cmd, { encoding: 'utf-8', timeout: timeoutMs + 5000 });
|
|
15
22
|
const parts = output.trim().split('\n');
|
|
16
23
|
const statusCode = parseInt(parts.pop() || '0', 10);
|
|
17
24
|
const raw = parts.join('\n');
|
|
18
|
-
|
|
25
|
+
debug(`curl response: status=${statusCode}, body=${raw.slice(0, 300)}`);
|
|
19
26
|
let data;
|
|
20
27
|
try {
|
|
21
28
|
data = JSON.parse(raw);
|
|
@@ -26,7 +33,7 @@ function curlPost(path, body, timeoutMs) {
|
|
|
26
33
|
return { status: statusCode, data };
|
|
27
34
|
}
|
|
28
35
|
catch (err) {
|
|
29
|
-
|
|
36
|
+
debug(`curl error: ${err.message}`);
|
|
30
37
|
throw err;
|
|
31
38
|
}
|
|
32
39
|
finally {
|
|
@@ -37,7 +44,7 @@ function curlPost(path, body, timeoutMs) {
|
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
export async function activateLicense(key, machineLabel) {
|
|
40
|
-
|
|
47
|
+
debug(`activateLicense: ${key.slice(0, 20)}... machine=${machineLabel}`);
|
|
41
48
|
try {
|
|
42
49
|
const { status, data } = curlPost('/v1/customer-portal/license-keys/activate', { key, organization_id: POLAR_ORG_ID, label: machineLabel, conditions: { major_version: 1 } }, 8000);
|
|
43
50
|
if (status === 200) {
|
|
@@ -57,7 +64,7 @@ export async function activateLicense(key, machineLabel) {
|
|
|
57
64
|
}
|
|
58
65
|
catch (err) {
|
|
59
66
|
const msg = `Activation error: ${err.message}`;
|
|
60
|
-
|
|
67
|
+
debug(msg);
|
|
61
68
|
return { valid: false, reason: msg };
|
|
62
69
|
}
|
|
63
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-interrupt-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.44",
|
|
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",
|