ai-extension-preview 0.1.13 → 0.1.14
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.
|
@@ -38,15 +38,37 @@ export const ServerPlugin = {
|
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
40
|
else if (req.url === '/refresh' && req.method === 'POST') {
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}).catch((err) => {
|
|
46
|
-
ctx.actions.runAction('core:log', { level: 'error', message: `[API] Check failed: ${err.message}` });
|
|
41
|
+
// Collect body
|
|
42
|
+
let body = '';
|
|
43
|
+
req.on('data', chunk => {
|
|
44
|
+
body += chunk.toString();
|
|
47
45
|
});
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
req.on('end', () => {
|
|
47
|
+
let newJobId = null;
|
|
48
|
+
try {
|
|
49
|
+
if (body) {
|
|
50
|
+
const data = JSON.parse(body);
|
|
51
|
+
if (data.jobId) {
|
|
52
|
+
newJobId = data.jobId;
|
|
53
|
+
ctx.host.config.jobId = newJobId;
|
|
54
|
+
ctx.actions.runAction('core:log', { level: 'info', message: `[API] Switched to new Job ID: ${newJobId}` });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
// Ignore parse error
|
|
60
|
+
}
|
|
61
|
+
// Trigger manual check
|
|
62
|
+
ctx.actions.runAction('core:log', { level: 'info', message: '[API] Refresh request received' });
|
|
63
|
+
ctx.actions.runAction('downloader:check', null).then((result) => {
|
|
64
|
+
ctx.actions.runAction('core:log', { level: 'info', message: `[API] Check result: ${result}` });
|
|
65
|
+
}).catch((err) => {
|
|
66
|
+
ctx.actions.runAction('core:log', { level: 'error', message: `[API] Check failed: ${err.message}` });
|
|
67
|
+
});
|
|
68
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
69
|
+
res.end(JSON.stringify({ success: true, jobId: ctx.host.config.jobId }));
|
|
70
|
+
});
|
|
71
|
+
return; // Return because we handle response in 'end' callback
|
|
50
72
|
}
|
|
51
73
|
else if (req.url === '/disconnect' && req.method === 'POST') {
|
|
52
74
|
// Trigger browser stop
|
|
@@ -72,7 +72,13 @@ export const BrowserManagerPlugin = {
|
|
|
72
72
|
// Event: Update detected
|
|
73
73
|
ctx.events.on('downloader:updated', async () => {
|
|
74
74
|
if (isInitialized) {
|
|
75
|
-
await ctx.actions.runAction('core:log', { level: 'info', message: 'Update detected.
|
|
75
|
+
await ctx.actions.runAction('core:log', { level: 'info', message: 'Update detected. Restarting browser...' });
|
|
76
|
+
try {
|
|
77
|
+
await ctx.actions.runAction('browser:stop', {});
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
// Ignore if already stopped
|
|
81
|
+
}
|
|
76
82
|
await ctx.actions.runAction('browser:start', {});
|
|
77
83
|
}
|
|
78
84
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-extension-preview",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Local preview tool for AI Extension Builder",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
"typescript": "^5.7.2",
|
|
52
52
|
"vitest": "^4.0.16"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|