autobranch-daemon 1.0.0
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/index.js +54 -0
- package/package.json +28 -0
package/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const { createClient } = require('@insforge/sdk');
|
|
2
|
+
|
|
3
|
+
class AutoBranchDaemon {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.insforgeUrl = config.insforgeUrl;
|
|
6
|
+
this.anonKey = config.anonKey;
|
|
7
|
+
this.environment = config.environment || 'production';
|
|
8
|
+
|
|
9
|
+
// Instantiate the SDK client
|
|
10
|
+
this.insforge = createClient({
|
|
11
|
+
baseUrl: this.insforgeUrl,
|
|
12
|
+
anonKey: this.anonKey
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async handleCrash(error) {
|
|
17
|
+
console.log(`\n======================================================`);
|
|
18
|
+
console.log(`[AutoBranch Daemon] FATAL CRASH INTERCEPTED`);
|
|
19
|
+
console.log(`======================================================`);
|
|
20
|
+
console.log(error.message);
|
|
21
|
+
|
|
22
|
+
const errorText = error.stack;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
// The SDK inserts the incident directly into the Postgres table.
|
|
26
|
+
// The Control Plane backend listens for this DB insertion using Realtime.
|
|
27
|
+
|
|
28
|
+
// 2. Insert into the database to persist the incident
|
|
29
|
+
let incidentId = null;
|
|
30
|
+
try {
|
|
31
|
+
const { data: incident } = await this.insforge.database
|
|
32
|
+
.from('incidents')
|
|
33
|
+
.insert([{
|
|
34
|
+
scenario: 'Live API Crash',
|
|
35
|
+
error_text: errorText,
|
|
36
|
+
status: 'detected'
|
|
37
|
+
}])
|
|
38
|
+
.select()
|
|
39
|
+
.single();
|
|
40
|
+
|
|
41
|
+
if (incident) incidentId = incident.id;
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.warn(`[AutoBranchDaemon] Failed to log incident to DB: ${err.message}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(`[AutoBranchDaemon] Telemetry payload dispatched to Control Plane. Daemon sequence complete.`);
|
|
47
|
+
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.error('[AutoBranchDaemon] Encountered error during crash reporting:', e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = { AutoBranchDaemon };
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "autobranch-daemon",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Agentic self-healing daemon for Node.js. Captures exceptions and triggers isolated InsForge AI patches.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/ashmeet-chhabra/autobranch.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"autobranch",
|
|
15
|
+
"incident-response",
|
|
16
|
+
"insforge",
|
|
17
|
+
"self-healing",
|
|
18
|
+
"ai",
|
|
19
|
+
"telemetry",
|
|
20
|
+
"express",
|
|
21
|
+
"error-handling"
|
|
22
|
+
],
|
|
23
|
+
"author": "AutoBranch Team",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@insforge/sdk": "^1.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|