@massa-ai/tools-api 1.18.0 → 1.19.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/dist/index.js +85 -8
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -175207,6 +175207,69 @@ function getAttributionResolver() {
|
|
|
175207
175207
|
return sharedResolver2;
|
|
175208
175208
|
}
|
|
175209
175209
|
|
|
175210
|
+
// ../../packages/core/dist/kernel/sanitize/credential-scrub.js
|
|
175211
|
+
function markerFor(id) {
|
|
175212
|
+
return `[REDACTED:${id}]`;
|
|
175213
|
+
}
|
|
175214
|
+
function fullMatchRule(id, pattern) {
|
|
175215
|
+
const marker26 = markerFor(id);
|
|
175216
|
+
return {
|
|
175217
|
+
id,
|
|
175218
|
+
replace(text3) {
|
|
175219
|
+
let count = 0;
|
|
175220
|
+
const replaced = text3.replace(pattern, () => {
|
|
175221
|
+
count++;
|
|
175222
|
+
return marker26;
|
|
175223
|
+
});
|
|
175224
|
+
return { text: replaced, count };
|
|
175225
|
+
}
|
|
175226
|
+
};
|
|
175227
|
+
}
|
|
175228
|
+
var PEM_PATTERN = /-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----[\s\S]{0,8192}?-----END [A-Z ]{0,32}PRIVATE KEY-----/g;
|
|
175229
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
|
|
175230
|
+
var AWS_KEY_PATTERN = /\b(?:AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}\b/g;
|
|
175231
|
+
var SK_KEY_PATTERN = /\bsk-[A-Za-z0-9_-]{20,}\b/g;
|
|
175232
|
+
var GITHUB_TOKEN_PATTERN = /\bgh[pousr]_[A-Za-z0-9]{36,}\b|\bgithub_pat_[A-Za-z0-9_]{22,}\b/g;
|
|
175233
|
+
var SLACK_TOKEN_PATTERN = /\bxox[baprs]-[A-Za-z0-9-]{18,}\b/g;
|
|
175234
|
+
var BEARER_PATTERN = /(Bearer\s+)([A-Za-z0-9._~+/=-]{20,})/g;
|
|
175235
|
+
var RULES = [
|
|
175236
|
+
fullMatchRule("pem", PEM_PATTERN),
|
|
175237
|
+
fullMatchRule("jwt", JWT_PATTERN),
|
|
175238
|
+
fullMatchRule("aws-key", AWS_KEY_PATTERN),
|
|
175239
|
+
fullMatchRule("sk-key", SK_KEY_PATTERN),
|
|
175240
|
+
fullMatchRule("github-token", GITHUB_TOKEN_PATTERN),
|
|
175241
|
+
fullMatchRule("slack-token", SLACK_TOKEN_PATTERN),
|
|
175242
|
+
{
|
|
175243
|
+
id: "bearer",
|
|
175244
|
+
replace(text3) {
|
|
175245
|
+
let count = 0;
|
|
175246
|
+
const replaced = text3.replace(BEARER_PATTERN, (_m, prefix) => {
|
|
175247
|
+
count++;
|
|
175248
|
+
return `${prefix}${markerFor("bearer")}`;
|
|
175249
|
+
});
|
|
175250
|
+
return { text: replaced, count };
|
|
175251
|
+
}
|
|
175252
|
+
}
|
|
175253
|
+
];
|
|
175254
|
+
var RULE_IDS = RULES.map((r2) => r2.id);
|
|
175255
|
+
function scrubCredentials(payloadJson) {
|
|
175256
|
+
const redactions = {};
|
|
175257
|
+
for (const id of RULE_IDS)
|
|
175258
|
+
redactions[id] = 0;
|
|
175259
|
+
let text3 = payloadJson;
|
|
175260
|
+
for (const rule of RULES) {
|
|
175261
|
+
const { text: next, count } = rule.replace(text3);
|
|
175262
|
+
text3 = next;
|
|
175263
|
+
redactions[rule.id] += count;
|
|
175264
|
+
}
|
|
175265
|
+
const total = Object.values(redactions).reduce((sum, n2) => sum + n2, 0);
|
|
175266
|
+
return {
|
|
175267
|
+
sanitized: text3,
|
|
175268
|
+
redactions,
|
|
175269
|
+
total
|
|
175270
|
+
};
|
|
175271
|
+
}
|
|
175272
|
+
|
|
175210
175273
|
// ../../packages/core/dist/tools/compact_snapshot.js
|
|
175211
175274
|
class CompactSnapshotTool {
|
|
175212
175275
|
name = "compact_snapshot";
|
|
@@ -175258,19 +175321,26 @@ class CompactSnapshotTool {
|
|
|
175258
175321
|
persistedId = newObservationId();
|
|
175259
175322
|
try {
|
|
175260
175323
|
const attribution = await (this.resolverOverride ?? getAttributionResolver()).resolve({ callerProjectId: projectId, sessionId, cwd });
|
|
175324
|
+
const scrub = scrubCredentials(JSON.stringify({
|
|
175325
|
+
snapshot: snapshot.xml,
|
|
175326
|
+
eventCount: snapshot.eventCount,
|
|
175327
|
+
compactCount: snapshot.compactCount,
|
|
175328
|
+
generatedAt: snapshot.generatedAt,
|
|
175329
|
+
sectionCount: snapshot.sections.length
|
|
175330
|
+
}));
|
|
175331
|
+
if (scrub.total > 0) {
|
|
175332
|
+
logger.debug("compact_snapshot payload redacted before persist", {
|
|
175333
|
+
redactions: scrub.redactions,
|
|
175334
|
+
total: scrub.total
|
|
175335
|
+
});
|
|
175336
|
+
}
|
|
175261
175337
|
store4.insert({
|
|
175262
175338
|
id: persistedId,
|
|
175263
175339
|
projectId: attribution.projectId,
|
|
175264
175340
|
sessionId,
|
|
175265
175341
|
source: "pre-compact",
|
|
175266
175342
|
category: "compaction-snapshots",
|
|
175267
|
-
payloadJson:
|
|
175268
|
-
snapshot: snapshot.xml,
|
|
175269
|
-
eventCount: snapshot.eventCount,
|
|
175270
|
-
compactCount: snapshot.compactCount,
|
|
175271
|
-
generatedAt: snapshot.generatedAt,
|
|
175272
|
-
sectionCount: snapshot.sections.length
|
|
175273
|
-
}),
|
|
175343
|
+
payloadJson: scrub.sanitized,
|
|
175274
175344
|
importance: 0.8,
|
|
175275
175345
|
createdAt: Date.now(),
|
|
175276
175346
|
attributionSource: attribution.source
|
|
@@ -176698,13 +176768,20 @@ class HookService {
|
|
|
176698
176768
|
});
|
|
176699
176769
|
const id = this.idFactory();
|
|
176700
176770
|
this.queue.enqueue(async () => {
|
|
176771
|
+
const scrub = scrubCredentials(JSON.stringify(ev.payload));
|
|
176772
|
+
if (scrub.total > 0) {
|
|
176773
|
+
logger.debug("hook payload redacted before persist", {
|
|
176774
|
+
redactions: scrub.redactions,
|
|
176775
|
+
total: scrub.total
|
|
176776
|
+
});
|
|
176777
|
+
}
|
|
176701
176778
|
const obs = {
|
|
176702
176779
|
id,
|
|
176703
176780
|
projectId: attribution.projectId,
|
|
176704
176781
|
sessionId: ev.sessionId,
|
|
176705
176782
|
source: ev.event,
|
|
176706
176783
|
category: extractCategory(ev.event, ev.payload),
|
|
176707
|
-
payloadJson:
|
|
176784
|
+
payloadJson: scrub.sanitized,
|
|
176708
176785
|
importance: ev.importance,
|
|
176709
176786
|
createdAt: ev.ts,
|
|
176710
176787
|
agentId: ev.agentId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massa-ai/tools-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"author": "luizgmassa",
|
|
5
5
|
"description": "massa-ai REST API server - Semantic code search, memory, and context compression",
|
|
6
6
|
"type": "module",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test": "bun scripts/run-tests-isolated.ts"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@massa-ai/core": "^1.
|
|
25
|
-
"@massa-ai/shared": "^1.
|
|
24
|
+
"@massa-ai/core": "^1.19.0",
|
|
25
|
+
"@massa-ai/shared": "^1.19.0",
|
|
26
26
|
"elysia": "^1.2.25",
|
|
27
27
|
"@elysiajs/swagger": "^1.2.0",
|
|
28
28
|
"@elysiajs/cors": "^1.2.0",
|