@massa-ai/tools-api 1.18.0 → 1.20.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.
Files changed (2) hide show
  1. package/dist/index.js +94 -8
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -50705,6 +50705,9 @@ async function _checkJsonSchemaSupport() {
50705
50705
  return false;
50706
50706
  }
50707
50707
  }
50708
+ function _setJsonSchemaSupportedForTesting(flag) {
50709
+ _jsonSchemaSupported = flag;
50710
+ }
50708
50711
  function isLlmEnabled() {
50709
50712
  if (testEnabledOverride !== null)
50710
50713
  return testEnabledOverride;
@@ -50714,6 +50717,9 @@ function isLlmEnabled() {
50714
50717
  return false;
50715
50718
  }
50716
50719
  }
50720
+ function _setLlmEnabledForTesting(flag) {
50721
+ testEnabledOverride = flag;
50722
+ }
50717
50723
  function getLlmConfig(opts) {
50718
50724
  const cfg = config.get("llm");
50719
50725
  const role = opts?.modelRole ?? "instruct";
@@ -150436,6 +150442,8 @@ __export(exports_services, {
150436
150442
  applyChainInhibition: () => applyChainInhibition,
150437
150443
  applyAttentionScore: () => applyAttentionScore,
150438
150444
  analyzeSpectrum: () => analyzeSpectrum,
150445
+ _setLlmEnabledForTesting: () => _setLlmEnabledForTesting,
150446
+ _setJsonSchemaSupportedForTesting: () => _setJsonSchemaSupportedForTesting,
150439
150447
  ZIG_QUERY_PACK: () => ZIG_QUERY_PACK,
150440
150448
  WorkspaceManager: () => WorkspaceManager,
150441
150449
  WorkingMemoryBuffer: () => WorkingMemoryBuffer,
@@ -150558,6 +150566,7 @@ var init_services = __esm(() => {
150558
150566
  init_index_manager();
150559
150567
  init_search_diagnostics();
150560
150568
  init_memory_controller();
150569
+ init_llm_client();
150561
150570
  init_search_controller();
150562
150571
  init_context_controller();
150563
150572
  init_executor_controller();
@@ -175207,6 +175216,69 @@ function getAttributionResolver() {
175207
175216
  return sharedResolver2;
175208
175217
  }
175209
175218
 
175219
+ // ../../packages/core/dist/kernel/sanitize/credential-scrub.js
175220
+ function markerFor(id) {
175221
+ return `[REDACTED:${id}]`;
175222
+ }
175223
+ function fullMatchRule(id, pattern) {
175224
+ const marker26 = markerFor(id);
175225
+ return {
175226
+ id,
175227
+ replace(text3) {
175228
+ let count = 0;
175229
+ const replaced = text3.replace(pattern, () => {
175230
+ count++;
175231
+ return marker26;
175232
+ });
175233
+ return { text: replaced, count };
175234
+ }
175235
+ };
175236
+ }
175237
+ var PEM_PATTERN = /-----BEGIN [A-Z ]{0,32}PRIVATE KEY-----[\s\S]{0,8192}?-----END [A-Z ]{0,32}PRIVATE KEY-----/g;
175238
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
175239
+ var AWS_KEY_PATTERN = /\b(?:AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}\b/g;
175240
+ var SK_KEY_PATTERN = /\bsk-[A-Za-z0-9_-]{20,}\b/g;
175241
+ var GITHUB_TOKEN_PATTERN = /\bgh[pousr]_[A-Za-z0-9]{36,}\b|\bgithub_pat_[A-Za-z0-9_]{22,}\b/g;
175242
+ var SLACK_TOKEN_PATTERN = /\bxox[baprs]-[A-Za-z0-9-]{18,}\b/g;
175243
+ var BEARER_PATTERN = /(Bearer\s+)([A-Za-z0-9._~+/=-]{20,})/g;
175244
+ var RULES = [
175245
+ fullMatchRule("pem", PEM_PATTERN),
175246
+ fullMatchRule("jwt", JWT_PATTERN),
175247
+ fullMatchRule("aws-key", AWS_KEY_PATTERN),
175248
+ fullMatchRule("sk-key", SK_KEY_PATTERN),
175249
+ fullMatchRule("github-token", GITHUB_TOKEN_PATTERN),
175250
+ fullMatchRule("slack-token", SLACK_TOKEN_PATTERN),
175251
+ {
175252
+ id: "bearer",
175253
+ replace(text3) {
175254
+ let count = 0;
175255
+ const replaced = text3.replace(BEARER_PATTERN, (_m, prefix) => {
175256
+ count++;
175257
+ return `${prefix}${markerFor("bearer")}`;
175258
+ });
175259
+ return { text: replaced, count };
175260
+ }
175261
+ }
175262
+ ];
175263
+ var RULE_IDS = RULES.map((r2) => r2.id);
175264
+ function scrubCredentials(payloadJson) {
175265
+ const redactions = {};
175266
+ for (const id of RULE_IDS)
175267
+ redactions[id] = 0;
175268
+ let text3 = payloadJson;
175269
+ for (const rule of RULES) {
175270
+ const { text: next, count } = rule.replace(text3);
175271
+ text3 = next;
175272
+ redactions[rule.id] += count;
175273
+ }
175274
+ const total = Object.values(redactions).reduce((sum, n2) => sum + n2, 0);
175275
+ return {
175276
+ sanitized: text3,
175277
+ redactions,
175278
+ total
175279
+ };
175280
+ }
175281
+
175210
175282
  // ../../packages/core/dist/tools/compact_snapshot.js
175211
175283
  class CompactSnapshotTool {
175212
175284
  name = "compact_snapshot";
@@ -175258,19 +175330,26 @@ class CompactSnapshotTool {
175258
175330
  persistedId = newObservationId();
175259
175331
  try {
175260
175332
  const attribution = await (this.resolverOverride ?? getAttributionResolver()).resolve({ callerProjectId: projectId, sessionId, cwd });
175333
+ const scrub = scrubCredentials(JSON.stringify({
175334
+ snapshot: snapshot.xml,
175335
+ eventCount: snapshot.eventCount,
175336
+ compactCount: snapshot.compactCount,
175337
+ generatedAt: snapshot.generatedAt,
175338
+ sectionCount: snapshot.sections.length
175339
+ }));
175340
+ if (scrub.total > 0) {
175341
+ logger.debug("compact_snapshot payload redacted before persist", {
175342
+ redactions: scrub.redactions,
175343
+ total: scrub.total
175344
+ });
175345
+ }
175261
175346
  store4.insert({
175262
175347
  id: persistedId,
175263
175348
  projectId: attribution.projectId,
175264
175349
  sessionId,
175265
175350
  source: "pre-compact",
175266
175351
  category: "compaction-snapshots",
175267
- payloadJson: JSON.stringify({
175268
- snapshot: snapshot.xml,
175269
- eventCount: snapshot.eventCount,
175270
- compactCount: snapshot.compactCount,
175271
- generatedAt: snapshot.generatedAt,
175272
- sectionCount: snapshot.sections.length
175273
- }),
175352
+ payloadJson: scrub.sanitized,
175274
175353
  importance: 0.8,
175275
175354
  createdAt: Date.now(),
175276
175355
  attributionSource: attribution.source
@@ -176698,13 +176777,20 @@ class HookService {
176698
176777
  });
176699
176778
  const id = this.idFactory();
176700
176779
  this.queue.enqueue(async () => {
176780
+ const scrub = scrubCredentials(JSON.stringify(ev.payload));
176781
+ if (scrub.total > 0) {
176782
+ logger.debug("hook payload redacted before persist", {
176783
+ redactions: scrub.redactions,
176784
+ total: scrub.total
176785
+ });
176786
+ }
176701
176787
  const obs = {
176702
176788
  id,
176703
176789
  projectId: attribution.projectId,
176704
176790
  sessionId: ev.sessionId,
176705
176791
  source: ev.event,
176706
176792
  category: extractCategory(ev.event, ev.payload),
176707
- payloadJson: JSON.stringify(ev.payload),
176793
+ payloadJson: scrub.sanitized,
176708
176794
  importance: ev.importance,
176709
176795
  createdAt: ev.ts,
176710
176796
  agentId: ev.agentId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massa-ai/tools-api",
3
- "version": "1.18.0",
3
+ "version": "1.20.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.18.0",
25
- "@massa-ai/shared": "^1.18.0",
24
+ "@massa-ai/core": "^1.20.0",
25
+ "@massa-ai/shared": "^1.20.0",
26
26
  "elysia": "^1.2.25",
27
27
  "@elysiajs/swagger": "^1.2.0",
28
28
  "@elysiajs/cors": "^1.2.0",