@massa-ai/tools-api 1.12.0 → 1.13.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 +144 -28
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8326,7 +8326,7 @@ function sanitizeFTS5Query(query) {
|
|
|
8326
8326
|
return quotedTerms.join(" OR ");
|
|
8327
8327
|
}
|
|
8328
8328
|
function sanitizeFilePath(filePath) {
|
|
8329
|
-
return filePath.
|
|
8329
|
+
return filePath.split(/[/\\]+/).filter((segment) => segment !== ".." && segment !== "").join("/");
|
|
8330
8330
|
}
|
|
8331
8331
|
var init_sanitizer = __esm(() => {
|
|
8332
8332
|
init_config();
|
|
@@ -106205,8 +106205,102 @@ function findCodeBoundaries(lines) {
|
|
|
106205
106205
|
return boundaries;
|
|
106206
106206
|
}
|
|
106207
106207
|
function netBraceDelta(line) {
|
|
106208
|
-
|
|
106209
|
-
|
|
106208
|
+
let delta2 = 0;
|
|
106209
|
+
let i = 0;
|
|
106210
|
+
const n2 = line.length;
|
|
106211
|
+
let lastSig = -1;
|
|
106212
|
+
let word = "";
|
|
106213
|
+
let regexPossible = true;
|
|
106214
|
+
const opensRegex = () => {
|
|
106215
|
+
if (lastSig === -1)
|
|
106216
|
+
return true;
|
|
106217
|
+
const c = String.fromCharCode(lastSig);
|
|
106218
|
+
if (/[\w)\]}'"`]/.test(c))
|
|
106219
|
+
return REGEX_PREFIX_KEYWORDS.has(word);
|
|
106220
|
+
return true;
|
|
106221
|
+
};
|
|
106222
|
+
while (i < n2) {
|
|
106223
|
+
const code = line.charCodeAt(i);
|
|
106224
|
+
const next = line.charCodeAt(i + 1);
|
|
106225
|
+
if (code === 47 && next === 47)
|
|
106226
|
+
break;
|
|
106227
|
+
if (code === 47 && next === 42) {
|
|
106228
|
+
const end = line.indexOf("*/", i + 2);
|
|
106229
|
+
if (end === -1) {
|
|
106230
|
+
lastSig = code;
|
|
106231
|
+
word = "";
|
|
106232
|
+
i++;
|
|
106233
|
+
continue;
|
|
106234
|
+
}
|
|
106235
|
+
i = end + 2;
|
|
106236
|
+
continue;
|
|
106237
|
+
}
|
|
106238
|
+
if (code === 47 && regexPossible && opensRegex()) {
|
|
106239
|
+
let j = i + 1;
|
|
106240
|
+
let closed = false;
|
|
106241
|
+
while (j < n2) {
|
|
106242
|
+
const inner = line.charCodeAt(j);
|
|
106243
|
+
if (inner === 92) {
|
|
106244
|
+
j += 2;
|
|
106245
|
+
continue;
|
|
106246
|
+
}
|
|
106247
|
+
if (inner === 47) {
|
|
106248
|
+
closed = true;
|
|
106249
|
+
break;
|
|
106250
|
+
}
|
|
106251
|
+
if (inner === 10)
|
|
106252
|
+
break;
|
|
106253
|
+
j++;
|
|
106254
|
+
}
|
|
106255
|
+
if (closed) {
|
|
106256
|
+
j++;
|
|
106257
|
+
while (j < n2 && /[a-z]/.test(line[j]))
|
|
106258
|
+
j++;
|
|
106259
|
+
lastSig = 47;
|
|
106260
|
+
word = "";
|
|
106261
|
+
i = j;
|
|
106262
|
+
continue;
|
|
106263
|
+
}
|
|
106264
|
+
regexPossible = false;
|
|
106265
|
+
lastSig = code;
|
|
106266
|
+
word = "";
|
|
106267
|
+
i++;
|
|
106268
|
+
continue;
|
|
106269
|
+
}
|
|
106270
|
+
if (code === 39 || code === 34 || code === 96) {
|
|
106271
|
+
const quote = code;
|
|
106272
|
+
i++;
|
|
106273
|
+
while (i < n2) {
|
|
106274
|
+
const inner = line.charCodeAt(i);
|
|
106275
|
+
if (inner === 92) {
|
|
106276
|
+
i += 2;
|
|
106277
|
+
continue;
|
|
106278
|
+
}
|
|
106279
|
+
i++;
|
|
106280
|
+
if (inner === quote)
|
|
106281
|
+
break;
|
|
106282
|
+
}
|
|
106283
|
+
lastSig = quote;
|
|
106284
|
+
word = "";
|
|
106285
|
+
continue;
|
|
106286
|
+
}
|
|
106287
|
+
if (code === 123)
|
|
106288
|
+
delta2++;
|
|
106289
|
+
else if (code === 125)
|
|
106290
|
+
delta2--;
|
|
106291
|
+
if (code === 32 || code === 9) {
|
|
106292
|
+
i++;
|
|
106293
|
+
continue;
|
|
106294
|
+
}
|
|
106295
|
+
if (code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 95 || code === 36) {
|
|
106296
|
+
word += line[i];
|
|
106297
|
+
} else {
|
|
106298
|
+
word = "";
|
|
106299
|
+
}
|
|
106300
|
+
lastSig = code;
|
|
106301
|
+
i++;
|
|
106302
|
+
}
|
|
106303
|
+
return delta2;
|
|
106210
106304
|
}
|
|
106211
106305
|
function extractFileImports(content, ext2) {
|
|
106212
106306
|
const lines = content.split(`
|
|
@@ -106237,7 +106331,7 @@ function extractFileImports(content, ext2) {
|
|
|
106237
106331
|
function isCodeFile(ext2) {
|
|
106238
106332
|
return CODE_EXTENSIONS.has(ext2);
|
|
106239
106333
|
}
|
|
106240
|
-
var RESERVED_KEYWORDS, CONTAINER_RE, TOP_LEVEL_RE, METHOD_RE, CODE_EXTENSIONS;
|
|
106334
|
+
var RESERVED_KEYWORDS, CONTAINER_RE, TOP_LEVEL_RE, METHOD_RE, REGEX_PREFIX_KEYWORDS, CODE_EXTENSIONS;
|
|
106241
106335
|
var init_chunker_code = __esm(() => {
|
|
106242
106336
|
RESERVED_KEYWORDS = new Set([
|
|
106243
106337
|
"if",
|
|
@@ -106258,6 +106352,22 @@ var init_chunker_code = __esm(() => {
|
|
|
106258
106352
|
CONTAINER_RE = /^(?:export\s+(?:default\s+)?)?(?:abstract\s+)?(?:class|interface|enum|namespace|trait|impl)\s+(\w+)/;
|
|
106259
106353
|
TOP_LEVEL_RE = /^(?:export\s+(?:default\s+)?)?(?:async\s+)?(?:function|const|let|var|type|struct|fn|def|func)\s+(\w+)/;
|
|
106260
106354
|
METHOD_RE = /^(?:public\s+|private\s+|protected\s+|static\s+|readonly\s+|override\s+|async\s+|abstract\s+|get\s+|set\s+)*(\w+)\s*[(<]/;
|
|
106355
|
+
REGEX_PREFIX_KEYWORDS = new Set([
|
|
106356
|
+
"return",
|
|
106357
|
+
"typeof",
|
|
106358
|
+
"case",
|
|
106359
|
+
"do",
|
|
106360
|
+
"else",
|
|
106361
|
+
"in",
|
|
106362
|
+
"of",
|
|
106363
|
+
"new",
|
|
106364
|
+
"delete",
|
|
106365
|
+
"void",
|
|
106366
|
+
"throw",
|
|
106367
|
+
"yield",
|
|
106368
|
+
"await",
|
|
106369
|
+
"instanceof"
|
|
106370
|
+
]);
|
|
106261
106371
|
CODE_EXTENSIONS = new Set([
|
|
106262
106372
|
".ts",
|
|
106263
106373
|
".js",
|
|
@@ -112795,6 +112905,7 @@ var init_session_store = __esm(() => {
|
|
|
112795
112905
|
});
|
|
112796
112906
|
|
|
112797
112907
|
// ../../packages/core/dist/services/synapse/session/session-registry.js
|
|
112908
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
112798
112909
|
function tokenize3(text2) {
|
|
112799
112910
|
const tokens = new Set;
|
|
112800
112911
|
for (const match2 of text2.toLowerCase().matchAll(TOKEN_RE2)) {
|
|
@@ -112802,6 +112913,9 @@ function tokenize3(text2) {
|
|
|
112802
112913
|
}
|
|
112803
112914
|
return tokens;
|
|
112804
112915
|
}
|
|
112916
|
+
function newSynapseSessionId() {
|
|
112917
|
+
return `syn_${randomUUID3()}`;
|
|
112918
|
+
}
|
|
112805
112919
|
|
|
112806
112920
|
class SessionRegistry {
|
|
112807
112921
|
sessions = new Map;
|
|
@@ -114205,7 +114319,7 @@ class TaskEnvelopeService {
|
|
|
114205
114319
|
const registry3 = getSessionRegistry();
|
|
114206
114320
|
let sessionId;
|
|
114207
114321
|
try {
|
|
114208
|
-
sessionId =
|
|
114322
|
+
sessionId = newSynapseSessionId();
|
|
114209
114323
|
registry3.create({
|
|
114210
114324
|
sessionId,
|
|
114211
114325
|
agentId: input.agentId,
|
|
@@ -115874,7 +115988,7 @@ var init_index_job_store = __esm(() => {
|
|
|
115874
115988
|
});
|
|
115875
115989
|
|
|
115876
115990
|
// ../../packages/core/dist/services/jobs/index-job-tracker.js
|
|
115877
|
-
import { randomUUID as
|
|
115991
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
115878
115992
|
|
|
115879
115993
|
class IndexJobTracker {
|
|
115880
115994
|
static instance;
|
|
@@ -115898,7 +116012,7 @@ class IndexJobTracker {
|
|
|
115898
116012
|
return IndexJobTracker.instance;
|
|
115899
116013
|
}
|
|
115900
116014
|
createJob(projectId, projectPath) {
|
|
115901
|
-
const jobId =
|
|
116015
|
+
const jobId = randomUUID4();
|
|
115902
116016
|
const job = {
|
|
115903
116017
|
jobId,
|
|
115904
116018
|
projectId,
|
|
@@ -120457,7 +120571,7 @@ var init_load = __esm(() => {
|
|
|
120457
120571
|
});
|
|
120458
120572
|
|
|
120459
120573
|
// ../../packages/core/dist/data/graph-generation/graph-generation-repository-pg.js
|
|
120460
|
-
import { randomUUID as
|
|
120574
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
120461
120575
|
function boundedText2(value, label, max = 512) {
|
|
120462
120576
|
const normalized = value.normalize("NFC").trim();
|
|
120463
120577
|
if (!normalized || normalized.length > max || normalized.includes("\x00")) {
|
|
@@ -120561,8 +120675,8 @@ class GraphGenerationRepositoryPg {
|
|
|
120561
120675
|
}
|
|
120562
120676
|
async begin(rawInput) {
|
|
120563
120677
|
const input = validateBegin2(rawInput);
|
|
120564
|
-
const generationId =
|
|
120565
|
-
const leaseToken =
|
|
120678
|
+
const generationId = randomUUID5();
|
|
120679
|
+
const leaseToken = randomUUID5();
|
|
120566
120680
|
return getPrismaClient2().$transaction(async (tx) => {
|
|
120567
120681
|
const workspace = await lockWorkspace(tx, input.projectId);
|
|
120568
120682
|
if (workspace.active_graph_generation_id !== input.expectedActiveGenerationId) {
|
|
@@ -123679,7 +123793,7 @@ __export(exports_memory_consolidation_job, {
|
|
|
123679
123793
|
memoryConsolidationJob: () => memoryConsolidationJob,
|
|
123680
123794
|
MemoryConsolidationJob: () => MemoryConsolidationJob
|
|
123681
123795
|
});
|
|
123682
|
-
import { randomUUID as
|
|
123796
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
123683
123797
|
async function addSupercedesEdge(store3, newId, sourceId, batchId) {
|
|
123684
123798
|
const evidence = JSON.stringify({ batchId, consolidated: true });
|
|
123685
123799
|
await store3.createEdge({
|
|
@@ -123823,11 +123937,11 @@ class MemoryConsolidationJob {
|
|
|
123823
123937
|
});
|
|
123824
123938
|
return { merged: 0, batchesCreated: 0 };
|
|
123825
123939
|
}
|
|
123826
|
-
const batch = await consolidateWindow(rowsToCandidates(candidates2), this.llm, { idFactory: () => `batch-${now2}-${
|
|
123940
|
+
const batch = await consolidateWindow(rowsToCandidates(candidates2), this.llm, { idFactory: () => `batch-${now2}-${randomUUID6().slice(0, 8)}` }).catch(() => null);
|
|
123827
123941
|
if (!batch)
|
|
123828
123942
|
return { merged: 0, batchesCreated: 0 };
|
|
123829
123943
|
const sourceRows = candidates2.filter((c) => batch.sourceIds.includes(c.id));
|
|
123830
|
-
const newId = `mem-${now2}-${
|
|
123944
|
+
const newId = `mem-${now2}-${randomUUID6().slice(0, 8)}`;
|
|
123831
123945
|
const importance = sourceRows.length ? Math.min(1, Math.max(...sourceRows.map((r2) => r2.importance))) : 0.7;
|
|
123832
123946
|
const projectId = sourceRows.find((r2) => r2.project_id)?.project_id ?? null;
|
|
123833
123947
|
try {
|
|
@@ -125879,11 +125993,12 @@ function buildRetrievalCall(category, sessionId, _projectId, summaryTokens) {
|
|
|
125879
125993
|
queries.push(short);
|
|
125880
125994
|
}
|
|
125881
125995
|
}
|
|
125882
|
-
const
|
|
125883
|
-
|
|
125884
|
-
|
|
125996
|
+
const primaryQuery = queries[0] ?? "";
|
|
125997
|
+
const queryArr = queries.map((q) => JSON.stringify(q)).join(", ");
|
|
125998
|
+
return `recall(query: ${JSON.stringify(primaryQuery)}, projectId: ${JSON.stringify(_projectId)}, limit: 10)
|
|
125999
|
+
// or: search(query: ${JSON.stringify(primaryQuery)}, projectId: ${JSON.stringify(_projectId)}, maxResults: 5)
|
|
125885
126000
|
// queries: [${queryArr}]
|
|
125886
|
-
// sessionId:
|
|
126001
|
+
// sessionId: ${JSON.stringify(sessionId)}`;
|
|
125887
126002
|
}
|
|
125888
126003
|
|
|
125889
126004
|
class CompactionSnapshotService {
|
|
@@ -130347,7 +130462,7 @@ var init_auto_improve_llm = __esm(() => {
|
|
|
130347
130462
|
});
|
|
130348
130463
|
|
|
130349
130464
|
// ../../packages/core/dist/services/jobs/auto-improve-apply.js
|
|
130350
|
-
import { randomUUID as
|
|
130465
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
130351
130466
|
function validateCreatePayload(p) {
|
|
130352
130467
|
if ("type" in p && p.type !== undefined && p.type !== null) {
|
|
130353
130468
|
if (typeof p.type !== "string" || !VALID_MEMORY_TYPES.has(p.type)) {
|
|
@@ -130388,7 +130503,7 @@ function buildUpdatePatch(p) {
|
|
|
130388
130503
|
return patch;
|
|
130389
130504
|
}
|
|
130390
130505
|
async function applyProposal(job, record2) {
|
|
130391
|
-
const memId = record2.targetMemoryId ?? `proposal-mem-${record2.id}-${
|
|
130506
|
+
const memId = record2.targetMemoryId ?? `proposal-mem-${record2.id}-${randomUUID7().slice(0, 8)}`;
|
|
130392
130507
|
const p = record2.payload;
|
|
130393
130508
|
if (record2.kind === "memory.create") {
|
|
130394
130509
|
validateCreatePayload(p);
|
|
@@ -130750,7 +130865,7 @@ __export(exports_observation_consolidation_job, {
|
|
|
130750
130865
|
observationConsolidationJob: () => observationConsolidationJob,
|
|
130751
130866
|
ObservationConsolidationJob: () => ObservationConsolidationJob
|
|
130752
130867
|
});
|
|
130753
|
-
import { randomUUID as
|
|
130868
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
130754
130869
|
function readBridgeConfig() {
|
|
130755
130870
|
try {
|
|
130756
130871
|
const c = config.get("hooks")?.bridge;
|
|
@@ -130840,7 +130955,7 @@ class ObservationConsolidationJob {
|
|
|
130840
130955
|
if (observations.length < 2)
|
|
130841
130956
|
return noop2;
|
|
130842
130957
|
const window2 = observations.slice(0, this.maxWindow);
|
|
130843
|
-
const batchId = `obs-batch-${Date.now()}-${
|
|
130958
|
+
const batchId = `obs-batch-${Date.now()}-${randomUUID8().slice(0, 8)}`;
|
|
130844
130959
|
const prompt = buildObservationPrompt(window2);
|
|
130845
130960
|
let batch;
|
|
130846
130961
|
try {
|
|
@@ -130866,7 +130981,7 @@ class ObservationConsolidationJob {
|
|
|
130866
130981
|
}
|
|
130867
130982
|
if (!batch)
|
|
130868
130983
|
return noop2;
|
|
130869
|
-
const newId = `mem-${Date.now()}-${
|
|
130984
|
+
const newId = `mem-${Date.now()}-${randomUUID8().slice(0, 8)}`;
|
|
130870
130985
|
const importance = 0.7;
|
|
130871
130986
|
try {
|
|
130872
130987
|
await Promise.resolve(this.memoryRepo.insert({
|
|
@@ -149509,6 +149624,7 @@ __export(exports_services, {
|
|
|
149509
149624
|
normalizeStructuralFile: () => normalizeStructuralFile,
|
|
149510
149625
|
normalizeQueryCaptures: () => normalizeQueryCaptures,
|
|
149511
149626
|
nextCronRun: () => nextCronRun,
|
|
149627
|
+
newSynapseSessionId: () => newSynapseSessionId,
|
|
149512
149628
|
jsonToKeyPathChunks: () => jsonToKeyPathChunks,
|
|
149513
149629
|
isKnownRegistryTable: () => isKnownRegistryTable,
|
|
149514
149630
|
intentSearch: () => intentSearch,
|
|
@@ -176486,7 +176602,7 @@ init_memory_repository_factory();
|
|
|
176486
176602
|
init_event_bus();
|
|
176487
176603
|
init_llm_client();
|
|
176488
176604
|
init_symbol_graph_service();
|
|
176489
|
-
import { randomUUID as
|
|
176605
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
176490
176606
|
import fs14 from "fs";
|
|
176491
176607
|
import path24 from "path";
|
|
176492
176608
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -176612,7 +176728,7 @@ class BootstrapService {
|
|
|
176612
176728
|
return { ...noopResult("no-signals"), signalCount };
|
|
176613
176729
|
}
|
|
176614
176730
|
const capped = seeds.slice(0, cfg.maxSeedMemories);
|
|
176615
|
-
const bootstrapId = `boot-${Date.now()}-${
|
|
176731
|
+
const bootstrapId = `boot-${Date.now()}-${randomUUID9().slice(0, 8)}`;
|
|
176616
176732
|
let ids;
|
|
176617
176733
|
try {
|
|
176618
176734
|
ids = await storeSeeds(this.memoryRepo, projectId, bootstrapId, capped, signals);
|
|
@@ -176866,7 +176982,7 @@ async function storeSeeds(memoryRepo, projectId, bootstrapId, seeds, signals) {
|
|
|
176866
176982
|
const ids = [];
|
|
176867
176983
|
const signalCount = countSignals(signals);
|
|
176868
176984
|
for (const seed of seeds) {
|
|
176869
|
-
const id = `seed-${Date.now()}-${
|
|
176985
|
+
const id = `seed-${Date.now()}-${randomUUID9().slice(0, 8)}`;
|
|
176870
176986
|
const input = {
|
|
176871
176987
|
id,
|
|
176872
176988
|
content: truncate3(seed.summary, MAX_SUMMARY_CHARS),
|
|
@@ -177140,7 +177256,7 @@ function newHandoffId() {
|
|
|
177140
177256
|
// ../../packages/core/dist/services/handoff/handoff-service.js
|
|
177141
177257
|
init_zod();
|
|
177142
177258
|
init_dist();
|
|
177143
|
-
import { randomUUID as
|
|
177259
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
177144
177260
|
init_memory_repository_factory();
|
|
177145
177261
|
init_event_bus();
|
|
177146
177262
|
init_llm_client();
|
|
@@ -177203,7 +177319,7 @@ class HandoffService {
|
|
|
177203
177319
|
return { ok: true, id, status: "open", memoryId };
|
|
177204
177320
|
}
|
|
177205
177321
|
async dualWrite(record2) {
|
|
177206
|
-
const memId = `handoff-mem-${record2.id}-${
|
|
177322
|
+
const memId = `handoff-mem-${record2.id}-${randomUUID10().slice(0, 8)}`;
|
|
177207
177323
|
const input = buildHandoffMemoryInput(memId, record2);
|
|
177208
177324
|
await Promise.resolve(this.memoryRepo.insert(input));
|
|
177209
177325
|
return memId;
|
|
@@ -179012,7 +179128,7 @@ function serializeSession(s) {
|
|
|
179012
179128
|
};
|
|
179013
179129
|
}
|
|
179014
179130
|
function newSessionId() {
|
|
179015
|
-
return
|
|
179131
|
+
return newSynapseSessionId();
|
|
179016
179132
|
}
|
|
179017
179133
|
var synapseRoutes = new Elysia({ prefix: "/api/v1/synapse" }).post("/session", ({ body }) => {
|
|
179018
179134
|
const registry3 = getSessionRegistry();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massa-ai/tools-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.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.13.0",
|
|
25
|
+
"@massa-ai/shared": "^1.13.0",
|
|
26
26
|
"elysia": "^1.2.25",
|
|
27
27
|
"@elysiajs/swagger": "^1.2.0",
|
|
28
28
|
"@elysiajs/cors": "^1.2.0",
|