@upx-us/shield 0.3.16 → 0.4.36
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/CHANGELOG.md +601 -0
- package/README.md +174 -19
- package/dist/index.js +196 -13
- package/dist/src/case-monitor.d.ts +24 -0
- package/dist/src/case-monitor.js +193 -0
- package/dist/src/cli-cases.d.ts +1 -0
- package/dist/src/cli-cases.js +184 -0
- package/dist/src/config.d.ts +2 -0
- package/dist/src/config.js +2 -0
- package/dist/src/event-store.d.ts +31 -0
- package/dist/src/event-store.js +163 -0
- package/dist/src/events/exec/enrich.d.ts +1 -0
- package/dist/src/events/exec/enrich.js +74 -7
- package/dist/src/index.js +75 -0
- package/dist/src/inventory.d.ts +26 -0
- package/dist/src/inventory.js +191 -0
- package/dist/src/rpc/client.d.ts +12 -0
- package/dist/src/rpc/client.js +105 -0
- package/dist/src/rpc/handlers.d.ts +57 -0
- package/dist/src/rpc/handlers.js +141 -0
- package/dist/src/rpc/index.d.ts +10 -0
- package/dist/src/rpc/index.js +13 -0
- package/dist/src/safe-io.d.ts +2 -0
- package/dist/src/safe-io.js +78 -0
- package/dist/src/transformer.d.ts +1 -0
- package/dist/src/transformer.js +59 -20
- package/dist/src/updater.d.ts +49 -0
- package/dist/src/updater.js +477 -0
- package/openclaw.plugin.json +81 -57
- package/package.json +80 -70
- package/skills/shield/README.md +39 -0
- package/skills/shield/SKILL.md +66 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALID_ROOT_CAUSES = exports.VALID_RESOLUTIONS = void 0;
|
|
4
|
+
exports.createEventsRecentHandler = createEventsRecentHandler;
|
|
5
|
+
exports.createEventsSummaryHandler = createEventsSummaryHandler;
|
|
6
|
+
exports.createSubscriptionStatusHandler = createSubscriptionStatusHandler;
|
|
7
|
+
exports.createCasesListHandler = createCasesListHandler;
|
|
8
|
+
exports.createCaseDetailHandler = createCaseDetailHandler;
|
|
9
|
+
exports.createCaseResolveHandler = createCaseResolveHandler;
|
|
10
|
+
exports.createCasesAckHandler = createCasesAckHandler;
|
|
11
|
+
const event_store_1 = require("../event-store");
|
|
12
|
+
const client_1 = require("./client");
|
|
13
|
+
function formatResponse(result) {
|
|
14
|
+
if (result.ok) {
|
|
15
|
+
return { ok: true, data: result.data };
|
|
16
|
+
}
|
|
17
|
+
const errorData = { error: result.error };
|
|
18
|
+
if (result.upgradeUrl) {
|
|
19
|
+
errorData.upgradeUrl = result.upgradeUrl;
|
|
20
|
+
}
|
|
21
|
+
return { ok: false, data: errorData };
|
|
22
|
+
}
|
|
23
|
+
function createEventsRecentHandler(_config) {
|
|
24
|
+
return async ({ respond, params }) => {
|
|
25
|
+
const limit = typeof params?.limit === 'number' ? params.limit : 20;
|
|
26
|
+
const type = typeof params?.type === 'string' ? params.type : undefined;
|
|
27
|
+
const sinceMs = typeof params?.sinceMs === 'number' ? params.sinceMs : undefined;
|
|
28
|
+
const events = (0, event_store_1.queryEvents)({ limit, type, sinceMs });
|
|
29
|
+
respond(true, { events, count: events.length, source: 'local' });
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function createEventsSummaryHandler(_config) {
|
|
33
|
+
return async ({ respond, params }) => {
|
|
34
|
+
const sinceMs = typeof params?.sinceMs === 'number' ? params.sinceMs : undefined;
|
|
35
|
+
const summary = (0, event_store_1.summarizeEvents)(sinceMs);
|
|
36
|
+
respond(true, { ...summary, source: 'local' });
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function createSubscriptionStatusHandler(config) {
|
|
40
|
+
return async ({ respond }) => {
|
|
41
|
+
const result = await (0, client_1.callPlatformApi)(config, '/v1/subscription/status');
|
|
42
|
+
const { ok, data } = formatResponse(result);
|
|
43
|
+
respond(ok, data);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.VALID_RESOLUTIONS = ['true_positive', 'false_positive', 'benign', 'duplicate'];
|
|
47
|
+
exports.VALID_ROOT_CAUSES = ['user_initiated', 'misconfiguration', 'expected_behavior', 'actual_threat', 'testing', 'unknown'];
|
|
48
|
+
function createCasesListHandler(config) {
|
|
49
|
+
return async ({ respond, params }) => {
|
|
50
|
+
const { getPendingCases, formatCaseNotification } = require('../case-monitor');
|
|
51
|
+
const pending = getPendingCases();
|
|
52
|
+
if (!config.apiUrl) {
|
|
53
|
+
respond(true, {
|
|
54
|
+
cases: pending,
|
|
55
|
+
total: pending.length,
|
|
56
|
+
has_more: false,
|
|
57
|
+
pending_count: pending.length,
|
|
58
|
+
pending_notifications: pending.map((c) => ({
|
|
59
|
+
...c,
|
|
60
|
+
formatted_message: formatCaseNotification(c),
|
|
61
|
+
})),
|
|
62
|
+
source: 'local_cache',
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const queryParams = {
|
|
67
|
+
status: typeof params?.status === 'string' ? params.status : 'open',
|
|
68
|
+
limit: typeof params?.limit === 'number' ? params.limit : 20,
|
|
69
|
+
};
|
|
70
|
+
if (typeof params?.since === 'string') {
|
|
71
|
+
queryParams.since = params.since;
|
|
72
|
+
}
|
|
73
|
+
const result = await (0, client_1.callPlatformApi)(config, '/v1/agent/cases', queryParams);
|
|
74
|
+
const { ok, data } = formatResponse(result);
|
|
75
|
+
if (ok && data && typeof data === 'object') {
|
|
76
|
+
data.pending_count = pending.length;
|
|
77
|
+
data.pending_notifications = pending.map((c) => ({
|
|
78
|
+
...c,
|
|
79
|
+
formatted_message: formatCaseNotification(c),
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
respond(ok, data);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function createCaseDetailHandler(config) {
|
|
86
|
+
return async ({ respond, params }) => {
|
|
87
|
+
const caseId = typeof params?.id === 'string' ? params.id : null;
|
|
88
|
+
if (!caseId) {
|
|
89
|
+
respond(false, { error: 'Missing required parameter: id' });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const result = await (0, client_1.callPlatformApi)(config, `/v1/agent/cases/${caseId}`);
|
|
93
|
+
const { ok, data } = formatResponse(result);
|
|
94
|
+
respond(ok, data);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function createCaseResolveHandler(config) {
|
|
98
|
+
return async ({ respond, params }) => {
|
|
99
|
+
const caseId = typeof params?.id === 'string' ? params.id : null;
|
|
100
|
+
if (!caseId) {
|
|
101
|
+
respond(false, { error: 'Missing required parameter: id' });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const resolution = params?.resolution;
|
|
105
|
+
const rootCause = params?.root_cause;
|
|
106
|
+
const comment = typeof params?.comment === 'string' ? params.comment : '';
|
|
107
|
+
if (!resolution || !exports.VALID_RESOLUTIONS.includes(resolution)) {
|
|
108
|
+
respond(false, {
|
|
109
|
+
error: `Invalid resolution. Must be one of: ${exports.VALID_RESOLUTIONS.join(', ')}`,
|
|
110
|
+
valid_resolutions: exports.VALID_RESOLUTIONS,
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!rootCause || !exports.VALID_ROOT_CAUSES.includes(rootCause)) {
|
|
115
|
+
respond(false, {
|
|
116
|
+
error: `Invalid root_cause. Must be one of: ${exports.VALID_ROOT_CAUSES.join(', ')}`,
|
|
117
|
+
valid_root_causes: exports.VALID_ROOT_CAUSES,
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const result = await (0, client_1.callPlatformApi)(config, `/v1/agent/cases/${caseId}/resolve`, {
|
|
122
|
+
resolution,
|
|
123
|
+
root_cause: rootCause,
|
|
124
|
+
comment,
|
|
125
|
+
});
|
|
126
|
+
const { ok, data } = formatResponse(result);
|
|
127
|
+
respond(ok, data);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function createCasesAckHandler() {
|
|
131
|
+
return async ({ respond, params }) => {
|
|
132
|
+
const { acknowledgeCases } = require('../case-monitor');
|
|
133
|
+
const ids = Array.isArray(params?.ids) ? params.ids : [];
|
|
134
|
+
if (ids.length === 0) {
|
|
135
|
+
respond(false, { error: 'Missing required parameter: ids (array of case IDs)' });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
acknowledgeCases(ids);
|
|
139
|
+
respond(true, { acknowledged: ids.length });
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PlatformApiConfig } from './client';
|
|
2
|
+
interface PluginAPI {
|
|
3
|
+
registerGatewayMethod(method: string, handler: (ctx: {
|
|
4
|
+
respond: (ok: boolean, data: unknown) => void;
|
|
5
|
+
params?: Record<string, unknown>;
|
|
6
|
+
}) => void): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function registerAllRpcs(api: PluginAPI, config: PlatformApiConfig): void;
|
|
9
|
+
export type { PlatformApiConfig } from './client';
|
|
10
|
+
export type { EventSummary, RecentEvent, SubscriptionStatus } from './handlers';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAllRpcs = registerAllRpcs;
|
|
4
|
+
const handlers_1 = require("./handlers");
|
|
5
|
+
function registerAllRpcs(api, config) {
|
|
6
|
+
api.registerGatewayMethod('shield.events_recent', (0, handlers_1.createEventsRecentHandler)(config));
|
|
7
|
+
api.registerGatewayMethod('shield.events_summary', (0, handlers_1.createEventsSummaryHandler)(config));
|
|
8
|
+
api.registerGatewayMethod('shield.subscription_status', (0, handlers_1.createSubscriptionStatusHandler)(config));
|
|
9
|
+
api.registerGatewayMethod('shield.cases_list', (0, handlers_1.createCasesListHandler)(config));
|
|
10
|
+
api.registerGatewayMethod('shield.case_detail', (0, handlers_1.createCaseDetailHandler)(config));
|
|
11
|
+
api.registerGatewayMethod('shield.case_resolve', (0, handlers_1.createCaseResolveHandler)(config));
|
|
12
|
+
api.registerGatewayMethod('shield.cases_ack', (0, handlers_1.createCasesAckHandler)());
|
|
13
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.writeJsonSafe = writeJsonSafe;
|
|
37
|
+
exports.readJsonSafe = readJsonSafe;
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const path_1 = require("path");
|
|
40
|
+
const log = __importStar(require("./log"));
|
|
41
|
+
function writeJsonSafe(filePath, data) {
|
|
42
|
+
const dir = (0, path_1.dirname)(filePath);
|
|
43
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
44
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
45
|
+
const tmp = filePath + '.tmp';
|
|
46
|
+
try {
|
|
47
|
+
(0, fs_1.writeFileSync)(tmp, JSON.stringify(data, null, 2) + '\n');
|
|
48
|
+
(0, fs_1.renameSync)(tmp, filePath);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
try {
|
|
52
|
+
(0, fs_1.unlinkSync)(tmp);
|
|
53
|
+
}
|
|
54
|
+
catch { }
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function readJsonSafe(filePath, fallback, label) {
|
|
59
|
+
if (!(0, fs_1.existsSync)(filePath))
|
|
60
|
+
return fallback;
|
|
61
|
+
try {
|
|
62
|
+
const raw = (0, fs_1.readFileSync)(filePath, 'utf8').trim();
|
|
63
|
+
if (!raw)
|
|
64
|
+
return fallback;
|
|
65
|
+
return JSON.parse(raw);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
const tag = label || filePath;
|
|
69
|
+
log.warn('safe-io', `Corrupt JSON in ${tag} — using defaults: ${err instanceof Error ? err.message : String(err)}`);
|
|
70
|
+
try {
|
|
71
|
+
const backup = filePath + '.corrupt.' + Date.now();
|
|
72
|
+
(0, fs_1.renameSync)(filePath, backup);
|
|
73
|
+
log.warn('safe-io', `Corrupt file preserved as ${backup}`);
|
|
74
|
+
}
|
|
75
|
+
catch { }
|
|
76
|
+
return fallback;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -9,6 +9,7 @@ export interface IngestPayload {
|
|
|
9
9
|
entries: EnvelopeEvent[];
|
|
10
10
|
}
|
|
11
11
|
export declare function resolveOpenClawVersion(): string;
|
|
12
|
+
export declare function _resetCachedOpenClawVersion(): void;
|
|
12
13
|
export declare function resolveAgentLabel(agentId: string): string;
|
|
13
14
|
export declare function getCachedPublicIp(): string | null;
|
|
14
15
|
export declare function resolveOutboundIp(): Promise<string | null>;
|
package/dist/src/transformer.js
CHANGED
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.resolveOpenClawVersion = resolveOpenClawVersion;
|
|
37
|
+
exports._resetCachedOpenClawVersion = _resetCachedOpenClawVersion;
|
|
37
38
|
exports.resolveAgentLabel = resolveAgentLabel;
|
|
38
39
|
exports.getCachedPublicIp = getCachedPublicIp;
|
|
39
40
|
exports.resolveOutboundIp = resolveOutboundIp;
|
|
@@ -41,37 +42,59 @@ exports.transformEntries = transformEntries;
|
|
|
41
42
|
exports.generateHostTelemetry = generateHostTelemetry;
|
|
42
43
|
const os = __importStar(require("os"));
|
|
43
44
|
const fs = __importStar(require("fs"));
|
|
45
|
+
const safe_io_1 = require("./safe-io");
|
|
44
46
|
const path = __importStar(require("path"));
|
|
45
47
|
const dgram_1 = require("dgram");
|
|
46
48
|
const events_1 = require("./events");
|
|
47
49
|
const log = __importStar(require("./log"));
|
|
48
50
|
const version_1 = require("./version");
|
|
49
51
|
const counters_1 = require("./counters");
|
|
52
|
+
const inventory_1 = require("./inventory");
|
|
53
|
+
let _cachedOpenClawVersion = "";
|
|
50
54
|
function resolveOpenClawVersion() {
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return pkg.version;
|
|
64
|
-
}
|
|
55
|
+
if (_cachedOpenClawVersion !== "")
|
|
56
|
+
return _cachedOpenClawVersion;
|
|
57
|
+
if (process.env.OPENCLAW_VERSION) {
|
|
58
|
+
_cachedOpenClawVersion = process.env.OPENCLAW_VERSION;
|
|
59
|
+
return _cachedOpenClawVersion;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const pkgPath = require.resolve('openclaw/package.json');
|
|
63
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
64
|
+
if (pkg.version) {
|
|
65
|
+
_cachedOpenClawVersion = pkg.version;
|
|
66
|
+
return _cachedOpenClawVersion;
|
|
65
67
|
}
|
|
66
|
-
catch { }
|
|
67
68
|
}
|
|
69
|
+
catch { }
|
|
68
70
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
+
const { execSync } = require('child_process');
|
|
72
|
+
const output = execSync('openclaw --version', {
|
|
73
|
+
timeout: 5000,
|
|
74
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
75
|
+
encoding: 'utf8',
|
|
76
|
+
}).trim();
|
|
77
|
+
const version = output.includes('/') ? output.split('/').pop() : output;
|
|
78
|
+
if (version && version !== 'unknown') {
|
|
79
|
+
_cachedOpenClawVersion = version;
|
|
80
|
+
return _cachedOpenClawVersion;
|
|
81
|
+
}
|
|
71
82
|
}
|
|
72
|
-
catch {
|
|
73
|
-
|
|
83
|
+
catch { }
|
|
84
|
+
try {
|
|
85
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), '.openclaw/openclaw.json'), 'utf8'));
|
|
86
|
+
const v = cfg?.meta?.lastTouchedVersion;
|
|
87
|
+
if (v) {
|
|
88
|
+
_cachedOpenClawVersion = v;
|
|
89
|
+
return _cachedOpenClawVersion;
|
|
90
|
+
}
|
|
74
91
|
}
|
|
92
|
+
catch { }
|
|
93
|
+
_cachedOpenClawVersion = 'unknown';
|
|
94
|
+
return _cachedOpenClawVersion;
|
|
95
|
+
}
|
|
96
|
+
function _resetCachedOpenClawVersion() {
|
|
97
|
+
_cachedOpenClawVersion = "";
|
|
75
98
|
}
|
|
76
99
|
function resolveAgentLabel(agentId) {
|
|
77
100
|
if (process.env.OPENCLAW_AGENT_LABEL)
|
|
@@ -113,7 +136,7 @@ function writeIpCache(ip) {
|
|
|
113
136
|
const dir = path.dirname(IP_CACHE_FILE);
|
|
114
137
|
if (!fs.existsSync(dir))
|
|
115
138
|
fs.mkdirSync(dir, { recursive: true });
|
|
116
|
-
|
|
139
|
+
(0, safe_io_1.writeJsonSafe)(IP_CACHE_FILE, { ip, resolvedAt: Date.now() });
|
|
117
140
|
}
|
|
118
141
|
catch { }
|
|
119
142
|
}
|
|
@@ -205,6 +228,8 @@ function isAdministrativeEvent(toolName, args, sessionId) {
|
|
|
205
228
|
return true;
|
|
206
229
|
if (/openclaw\s+cron\s+(list|log|runs|status)/.test(cmd))
|
|
207
230
|
return true;
|
|
231
|
+
if (/openclaw\s+shield\s+cases/.test(cmd))
|
|
232
|
+
return true;
|
|
208
233
|
if (/ps\s+aux.*grep.*(ts-node|bridge|shield)/.test(cmd))
|
|
209
234
|
return true;
|
|
210
235
|
if (/gcloud\s+auth\s+print-access-token/.test(cmd))
|
|
@@ -223,6 +248,8 @@ function isAdministrativeEvent(toolName, args, sessionId) {
|
|
|
223
248
|
return true;
|
|
224
249
|
if (['sessions_list', 'sessions_history', 'session_status'].includes(toolName))
|
|
225
250
|
return true;
|
|
251
|
+
if (/^shield\.cases_/.test(toolName) || /^shield\.status$/.test(toolName))
|
|
252
|
+
return true;
|
|
226
253
|
return false;
|
|
227
254
|
}
|
|
228
255
|
function transformEntries(entries) {
|
|
@@ -251,6 +278,18 @@ function transformEntries(entries) {
|
|
|
251
278
|
event.tool_metadata = {};
|
|
252
279
|
event.tool_metadata['openclaw.is_administrative'] = 'true';
|
|
253
280
|
}
|
|
281
|
+
const crossText = [
|
|
282
|
+
args.command || '',
|
|
283
|
+
args.file_path || args.path || args.filePath || '',
|
|
284
|
+
args.url || '',
|
|
285
|
+
].join(' ');
|
|
286
|
+
const targetWorkspace = (0, inventory_1.detectCrossWorkspace)(crossText, agentId);
|
|
287
|
+
if (targetWorkspace) {
|
|
288
|
+
if (!event.tool_metadata)
|
|
289
|
+
event.tool_metadata = {};
|
|
290
|
+
event.tool_metadata['openclaw.cross_workspace_access'] = 'true';
|
|
291
|
+
event.tool_metadata['openclaw.target_workspace'] = targetWorkspace;
|
|
292
|
+
}
|
|
254
293
|
log.debug('transformer', `TOOL_CALL tool=${toolName} session=${entry._sessionId} agent=${agentId} schema=${schema.constructor?.name || 'unknown'} admin=${event.tool_metadata?.['openclaw.is_administrative'] === 'true'}`, log.isDebug ? event : undefined);
|
|
255
294
|
(0, counters_1.recordEventType)(event.event_type);
|
|
256
295
|
envelopes.push({ source, event });
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type AutoUpdateMode = boolean | 'notify-only';
|
|
2
|
+
export interface UpdateState {
|
|
3
|
+
lastCheckAt: number;
|
|
4
|
+
lastUpdateAt: number;
|
|
5
|
+
currentVersion: string;
|
|
6
|
+
latestVersion: string | null;
|
|
7
|
+
updateAvailable: boolean;
|
|
8
|
+
lastError: string | null;
|
|
9
|
+
rollbackVersion: string | null;
|
|
10
|
+
consecutiveFailures: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UpdateCheckResult {
|
|
13
|
+
updateAvailable: boolean;
|
|
14
|
+
currentVersion: string;
|
|
15
|
+
latestVersion: string;
|
|
16
|
+
isPatch: boolean;
|
|
17
|
+
isMinor: boolean;
|
|
18
|
+
isMajor: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface SemVer {
|
|
21
|
+
major: number;
|
|
22
|
+
minor: number;
|
|
23
|
+
patch: number;
|
|
24
|
+
prerelease: string | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function parseSemVer(version: string): SemVer | null;
|
|
27
|
+
export declare function isNewerVersion(current: string, candidate: string): boolean;
|
|
28
|
+
export declare function classifyUpdate(current: string, candidate: string): {
|
|
29
|
+
isPatch: boolean;
|
|
30
|
+
isMinor: boolean;
|
|
31
|
+
isMajor: boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare function loadUpdateState(): UpdateState;
|
|
34
|
+
export declare function saveUpdateState(state: UpdateState): void;
|
|
35
|
+
export declare function checkNpmVersion(): string | null;
|
|
36
|
+
export declare function checkForUpdate(overrideInterval?: number): UpdateCheckResult | null;
|
|
37
|
+
export declare function backupCurrentVersion(): string | null;
|
|
38
|
+
export declare function restoreFromBackup(backupPath: string): boolean;
|
|
39
|
+
export declare function downloadAndInstall(targetVersion: string): boolean;
|
|
40
|
+
export interface UpdateResult {
|
|
41
|
+
action: 'none' | 'notify' | 'updated' | 'rollback' | 'error';
|
|
42
|
+
fromVersion: string;
|
|
43
|
+
toVersion: string | null;
|
|
44
|
+
message: string;
|
|
45
|
+
requiresRestart: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare function performAutoUpdate(mode: AutoUpdateMode, checkIntervalMs?: number): UpdateResult;
|
|
48
|
+
export declare function requestGatewayRestart(): boolean;
|
|
49
|
+
export {};
|