@upx-us/shield 0.3.4 → 0.3.5

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/src/index.js CHANGED
@@ -45,8 +45,10 @@ const version_1 = require("./version");
45
45
  let running = true;
46
46
  let lastTelemetryAt = 0;
47
47
  let consecutiveFailures = 0;
48
+ let registrationOk = false;
48
49
  const TELEMETRY_INTERVAL_MS = 5 * 60 * 1000;
49
50
  const MAX_BACKOFF_MS = 5 * 60 * 1000;
51
+ const MAX_REGISTRATION_FAILURES = 10;
50
52
  function getBackoffInterval(baseMs) {
51
53
  if (consecutiveFailures === 0)
52
54
  return baseMs;
@@ -86,16 +88,27 @@ async function poll() {
86
88
  };
87
89
  const result = await (0, sender_1.reportInstance)(instancePayload, config.credentials);
88
90
  log.info('bridge', `Instance report → Platform: success=${result.ok}`);
89
- if (result.ok && result.score) {
90
- log.info('bridge', `Protection score: ${result.score.badge} ${result.score.total}/100 (${result.score.grade})`);
91
- if (result.score.recommendations?.length) {
92
- for (const rec of result.score.recommendations) {
93
- log.warn('bridge', `⚠ ${rec}`);
91
+ if (result.ok) {
92
+ registrationOk = true;
93
+ lastTelemetryAt = now;
94
+ if (result.score) {
95
+ log.info('bridge', `Protection score: ${result.score.badge} ${result.score.total}/100 (${result.score.grade})`);
96
+ if (result.score.recommendations?.length) {
97
+ for (const rec of result.score.recommendations) {
98
+ log.warn('bridge', `⚠ ${rec}`);
99
+ }
94
100
  }
95
101
  }
96
102
  }
97
- if (result.ok)
98
- lastTelemetryAt = now;
103
+ else if (!registrationOk) {
104
+ consecutiveFailures++;
105
+ if (consecutiveFailures >= MAX_REGISTRATION_FAILURES) {
106
+ log.error('bridge', `reportInstance failed ${consecutiveFailures} consecutive times — instance not recognized. Re-run setup wizard. Exiting.`);
107
+ process.exit(1);
108
+ }
109
+ log.warn('bridge', `reportInstance failed (attempt ${consecutiveFailures}/${MAX_REGISTRATION_FAILURES}) — skipping events this cycle (platform may still be syncing)`);
110
+ continue;
111
+ }
99
112
  }
100
113
  if (entries.length > 0) {
101
114
  let envelopes = (0, transformer_1.transformEntries)(entries);
@@ -126,8 +139,15 @@ async function poll() {
126
139
  }
127
140
  }
128
141
  if (results.some(r => r.needsRegistration)) {
129
- log.error('bridge', 'Instance not registered (needs_registration=true). Re-run the setup wizard. Exiting.');
130
- process.exit(1);
142
+ consecutiveFailures++;
143
+ registrationOk = false;
144
+ lastTelemetryAt = 0;
145
+ if (consecutiveFailures >= MAX_REGISTRATION_FAILURES) {
146
+ log.error('bridge', `Instance not recognized by platform after ${consecutiveFailures} attempts. Re-run the setup wizard. Exiting.`);
147
+ process.exit(1);
148
+ }
149
+ log.warn('bridge', `Instance not registered on platform (attempt ${consecutiveFailures}/${MAX_REGISTRATION_FAILURES}) — will re-register on next cycle`);
150
+ continue;
131
151
  }
132
152
  const pendingResult = results.find(r => r.pendingNamespace);
133
153
  if (pendingResult) {
@@ -2,7 +2,7 @@
2
2
  "id": "shield",
3
3
  "name": "OpenClaw Shield",
4
4
  "description": "Real-time security monitoring \u2014 streams enriched, redacted security events to the Shield detection platform.",
5
- "version": "0.3.4",
5
+ "version": "0.3.5",
6
6
  "skills": [
7
7
  "./skills"
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upx-us/shield",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Security monitoring plugin for OpenClaw agents — streams enriched security events to the Shield detection platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",