Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
0f4f360
fix: chatbot image save (input and generation)
adityajunwal Feb 21, 2026
3020d33
fix: revmove embed user agent from the webhook
dhiraj-parihar Feb 21, 2026
2994984
Merge pull request #752 from dhirajparihar/create_agent_webhook_embed
Natwar589 Feb 21, 2026
f051c6e
Merge pull request #769 from adityajunwal/image_save_bug_109
Husainbw786 Feb 21, 2026
e73dd5c
refactor: prompt spilit fix
Natwar589 Feb 21, 2026
1d5c369
add grafanna package
Feb 21, 2026
c6b06b7
fix: update resource creation settings to include keepDuplicate option
husainhackerrank-afk Feb 23, 2026
0457510
Merge pull request #771 from Walkover-Web-Solution/dublicate_key_addd…
Natwar589 Feb 23, 2026
85a613b
fix: update settings in createCollection and createResourceInCollecti…
husainhackerrank-afk Feb 23, 2026
d03ec95
Merge pull request #774 from Walkover-Web-Solution/update_collection_…
Prayanshrajput Feb 23, 2026
b10b492
key name change
Feb 23, 2026
41dcfe2
proxy url remove from env
Feb 23, 2026
6b941f4
change proxy_refrence_id to PUBLIC_REFERENCEID
Feb 24, 2026
6de465b
feat: added the 'status' key to the apikey model
adityajunwal Feb 11, 2026
afe1895
removed status key
Feb 24, 2026
5906f31
Merge pull request #777 from Walkover-Web-Solution/remove_status
Natwar589 Feb 24, 2026
0660dcb
status removed
Feb 24, 2026
759a459
fixed prompt_enhancer_percentage and criteria_check
Feb 24, 2026
fcad889
Merge pull request #781 from Walkover-Web-Solution/fixed_prompt_score
Prayanshrajput Feb 24, 2026
690ec9d
Merge pull request #770 from Walkover-Web-Solution/promt_split_refact…
Natwar589 Feb 24, 2026
f675b6a
static data with security key
Feb 25, 2026
bee6744
feat: add hide feature to hide prompt helper
Natwar589 Feb 26, 2026
66b258e
fix: prompt optimiser fix
Natwar589 Feb 26, 2026
3f0c142
feat auto reset limit and remove cron
Feb 26, 2026
a99c6ab
fix: embed preview
Feb 26, 2026
f8b0d90
fix: embed preview
Feb 26, 2026
199eab2
Merge pull request #790 from Walkover-Web-Solution/embedTokenGenerator
Husainbw786 Feb 26, 2026
a97be6c
feat: transform ViaSocket fields structure for new payload format
Anushtha-Rathore Jan 18, 2026
f2e3253
feat: add model type in get all agent api
Natwar589 Feb 27, 2026
49beff5
fix: resolved windsurf comments
Anushtha-Rathore Mar 2, 2026
52d0066
feat: add configuration type in get agents by user id projection
Natwar589 Mar 2, 2026
eb875ef
feat: integrate Not Diamond model selection and update agent version …
Husainbw786 Mar 2, 2026
5fcc3a5
fix: resolved windsurd comments
Anushtha-Rathore Mar 5, 2026
3b359a4
Merge pull request #792 from Anushtha-Rathore/viasocketToolFieldTrans…
Natwar589 Mar 5, 2026
847407f
feat: response caching
adityajunwal Mar 5, 2026
5d5d062
feat: auto model select
adityajunwal Mar 3, 2026
33a88dd
feat: added batch in model
LAVI9966 Mar 7, 2026
c20e5b0
feat: implement log queue processing with multiple services for enhan…
Husainbw786 Mar 7, 2026
14bcf29
feat: auto model select
adityajunwal Mar 9, 2026
0f7c237
fix: improve Redis error handling and connection strategy
Husainbw786 Mar 9, 2026
66d7e50
Merge pull request #805 from LAVI9966/batchdata
Natwar589 Mar 10, 2026
573e876
refactor: rich ui
Natwar589 Mar 9, 2026
ac989c3
feat: implement multi-type pre-tool support (#803)
Anushtha-Rathore Mar 10, 2026
08c6d8f
feat: agent to template (#810)
yogeshpatel70 Mar 11, 2026
94cf586
feat: response caching (#813)
adityajunwal Mar 11, 2026
1e09001
create proxy auth token for automaint (#815)
Prayanshrajput Mar 12, 2026
14015e4
cosumer logic change
Mar 13, 2026
6fa176d
grafanna added
Mar 13, 2026
b790bd2
not take start date from frontend
Mar 13, 2026
6508418
fix: add pre_tools to simple_fields in updateAgentController
Anushtha-Rathore Mar 17, 2026
6a8c1ff
Merge pull request #822 from Anushtha-Rathore/fix-add-pre_tools-to-si…
Husainbw786 Mar 17, 2026
db6490c
Merge pull request #817 from Walkover-Web-Solution/prayansh/not-take-…
Husainbw786 Mar 18, 2026
d21bd3c
refactor: consolidate actionData and onClickType field schema handlin…
Natwar589 Mar 18, 2026
3aa2111
fix: handled the notdiamond api failure safely
adityajunwal Mar 18, 2026
9dbc829
Merge pull request #825 from adityajunwal/notdiamond-failure-handling
Husainbw786 Mar 18, 2026
42495b4
refactor: convert Pyroscope import from require to ES6 import syntax …
Natwar589 Mar 18, 2026
c01f9df
fix: agent template knowledgeBase added
Mar 18, 2026
15dda5b
Merge pull request #827 from yogeshpatel70/template_bug_fixed
Husainbw786 Mar 19, 2026
6aa55ec
update local token generation config
Mar 19, 2026
e2ede26
fix: chatbot preveiw bug fixed
Mar 19, 2026
b788640
Merge pull request #829 from yogeshpatel70/chatbotPreview_bug_fixed
Natwar589 Mar 19, 2026
59b2775
fix: pass template name and description to schema builder and remove …
Natwar589 Mar 19, 2026
692a781
Merge pull request #830 from Walkover-Web-Solution/action_type_fix
Husainbw786 Mar 19, 2026
c3b99da
fix: tempalte tool call count bug fixed
Mar 19, 2026
845ee30
Merge pull request #832 from yogeshpatel70/template_tool_call_count_b…
Husainbw786 Mar 19, 2026
2e6fb39
refactor: apply code review suggestions
Anushtha-Rathore Mar 20, 2026
990c98f
Merge pull request #833 from Anushtha-Rathore/tool-field-transform
Husainbw786 Mar 20, 2026
023c7c1
Merge pull request #828 from Walkover-Web-Solution/change_localToken_…
Husainbw786 Mar 21, 2026
afa6b02
Merge branch 'main' into testing
harshhsahu Mar 21, 2026
cdbae0a
fix: add bridge_id to Thread query filter in saveSubThreadIdAndName
Mar 21, 2026
c58d05a
Merge pull request #838 from Walkover-Web-Solution/fixed_subthread_bug
Husainbw786 Mar 21, 2026
e1ef1f4
feat: enhance log processing and metrics storage (#823)
Husainbw786 Mar 24, 2026
2bef84f
fix: stream in subscribe api (#847)
Natwar589 Mar 25, 2026
9cf244e
feat: added reasoning in history and fixed orchestral history
adityajunwal Mar 25, 2026
2df9258
refactor: enhance Redis cache clearing response (#852)
Husainbw786 Mar 25, 2026
bb517d1
Clear redid while publish (#855)
Natwar589 Mar 26, 2026
3be13c2
refactor: change connected_agents key from agent_name to bridge_id ac…
Mar 26, 2026
4f94682
changes
Mar 26, 2026
580a96d
Merge pull request #851 from adityajunwal/reasoning-support
Husainbw786 Mar 26, 2026
ef1d0c8
fix: pr comment resolved (#853)
LAVI9966 Mar 26, 2026
7f1b54d
chore: optimise apicalls collections, migration (#844)
Anushtha-Rathore Mar 26, 2026
61e60e3
feat: api key validation (#789)
Anushtha-Rathore Mar 26, 2026
b5fc357
feat: template validation by agent (#843)
LAVI9966 Mar 26, 2026
c6b60a1
fix: agent changes and one commit (#799)
LAVI9966 Mar 26, 2026
ca31b50
chore: optimized apicredentials collection and wrote migreation (#845)
Anushtha-Rathore Mar 26, 2026
e2f61ac
chore: optimised apilerts collection , removed duplicate schema from …
Anushtha-Rathore Mar 26, 2026
24fd970
Merge branch 'testing' into Agent_name_update_fix_migration
Husainbw786 Mar 27, 2026
83b7200
Merge pull request #854 from yogeshpatel70/Agent_name_update_fix_migr…
Husainbw786 Mar 27, 2026
0a05396
chore: migrate orgAccessToken from ResponseType collection to Proxy o…
Anushtha-Rathore Mar 27, 2026
9eeb1e8
fix: history queue bug
adityajunwal Mar 27, 2026
db8ac82
Merge pull request #862 from adityajunwal/history-bug
Husainbw786 Mar 28, 2026
3d046fe
fix: log queue bugs
adityajunwal Mar 28, 2026
1ebbba7
Merge pull request #866 from adityajunwal/log-queue-changes
Husainbw786 Mar 28, 2026
2897377
fix: prod or test env check added
LAVI9966 Mar 30, 2026
cf5131a
feat: update model configuration modes and include additional fields …
Natwar589 Mar 30, 2026
778732d
refactor: replace flattenDict with extractPrimitiveValues and include…
Natwar589 Mar 30, 2026
a7a84f7
Merge pull request #869 from LAVI9966/agent_prod_test_checker
Natwar589 Mar 30, 2026
8a9a65a
chore: add migration script to remap connected_agents keys from agent…
yogeshpatel70 Mar 30, 2026
ce7b315
fix: added stream for model (#871)
Natwar589 Mar 30, 2026
9444dcd
fix: missed condition (#874)
LAVI9966 Mar 31, 2026
2bf6dec
Merge branch 'main' of github.com:Walkover-Web-Solution/AI-middleware…
Mar 31, 2026
21098c8
axios package fix
Mar 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions migrations/mongo/alerts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { MongoClient } from "mongodb";
import dotenv from "dotenv";
dotenv.config();

const MONGODB_URI = process.env.MONGODB_CONNECTION_URI;
if (!MONGODB_URI) {
console.error("Error: MONGODB_CONNECTION_URI environment variable is not set.");
process.exit(1);
}

async function migrateAlerts() {
const client = new MongoClient(MONGODB_URI);

try {
await client.connect();
console.log("Connected to MongoDB");

const db = client.db();
const alerts = db.collection("alerts");

// STEP 1: Remove deprecated fields (user_url)
console.log("\n--- Step 1: Removing deprecated fields ---");
const result = await alerts.updateMany({}, { $unset: { "webhookConfiguration.user_url": "" } });
console.log(` ✓ Modified ${result.modifiedCount} / ${result.matchedCount} documents`);

// Summary
console.log("\n" + "=".repeat(60));
console.log("Migration Summary:");
console.log(` Matched: ${result.matchedCount}`);
console.log(` Modified: ${result.modifiedCount}`);
console.log(` Total docs: ${await alerts.countDocuments()}`);
console.log("=".repeat(60));
} catch (error) {
console.error("Migration failed:", error);
throw error;
} finally {
await client.close();
console.log("\nMongoDB connection closed");
}
}

export { migrateAlerts };
273 changes: 273 additions & 0 deletions migrations/mongo/apiCalls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
import { MongoClient, ObjectId } from "mongodb";
import axios from "axios";
import dotenv from "dotenv";
dotenv.config();

const MONGODB_URI = process.env.MONGODB_CONNECTION_URI;
const orgOwnerCache = {};

async function getOrgOwner(orgId) {
if (!orgId) return null;
if (orgOwnerCache[orgId] !== undefined) return orgOwnerCache[orgId];
try {
const response = await axios.get(`https://routes.msg91.com/api/${process.env.PUBLIC_REFERENCEID}/getCompanies?id=${orgId}`, {
headers: { "Content-Type": "application/json", Authkey: process.env.ADMIN_API_KEY }
});
const orgData = response?.data?.data?.data?.[0];
orgOwnerCache[orgId] = orgData?.created_by?.toString() || null;
} catch (e) {
console.log(` Proxy call failed for org ${orgId}: ${e.message}`);
orgOwnerCache[orgId] = null;
}
return orgOwnerCache[orgId];
}

async function removeDeprecatedKeys(apicalls) {
const r = await apicalls.updateMany(
{},
{
$unset: {
bridge_id: "",
activated: "",
status: "",
parameters: "",
axios: "",
required_fields: "",
new0: "",
new1: "",
endpoint: "",
optional_fields: "",
function_name: "",
short_description: ""
}
}
);
console.log(` ✓ Step 1: Removed deprecated keys from ${r.modifiedCount} docs`);
return r;
}

async function setDefaults(apicalls) {
const defaults = [
[{ folder_id: { $exists: false } }, { $set: { folder_id: "" } }],
[{ description: { $exists: false } }, { $set: { description: "" } }],
[{ title: { $exists: false } }, { $set: { title: "" } }],
[{ required_params: { $exists: false } }, { $set: { required_params: [] } }],
[{ fields: { $exists: false } }, { $set: { fields: {} } }]
];
const results = await Promise.all(defaults.map(([filter, update]) => apicalls.updateMany(filter, update)));
results.forEach((r, i) => {
if (r.modifiedCount > 0) console.log(` ✓ Step 2: ${JSON.stringify(defaults[i][1].$set)} → ${r.modifiedCount} docs`);
});
return results;
}

async function backfillOldFields(apicalls) {
const cursor = apicalls.find({ old_fields: { $exists: false } }, { projection: { _id: 1, fields: 1 } });
const bulk = [];
while (await cursor.hasNext()) {
const doc = await cursor.next();
bulk.push({ updateOne: { filter: { _id: doc._id }, update: { $set: { old_fields: doc.fields || {} } } } });
}
if (bulk.length > 0) {
const r = await apicalls.bulkWrite(bulk);
console.log(` ✓ Step 3: Backfilled old_fields for ${r.modifiedCount} docs`);
} else {
console.log(` - Step 3: No documents missing old_fields`);
}
}

async function fixMissingUserIds(apicalls) {
let migrated = 0;
let skipped = 0;
const cursor = apicalls.find({ $or: [{ user_id: { $exists: false } }, { user_id: "" }] });
while (await cursor.hasNext()) {
const doc = await cursor.next();
const userId = await getOrgOwner(doc.org_id);
if (userId) {
const r = await apicalls.updateOne({ _id: doc._id }, { $set: { user_id: userId } });
if (r.modifiedCount > 0) migrated++;
else skipped++;
} else {
skipped++;
}
}
console.log(` ✓ Step 6: user_id fixed: ${migrated}, skipped: ${skipped}`);
return { migrated, skipped };
}

async function renameTimestamps(apicalls) {
const r = await apicalls.updateMany({ created_at: { $exists: true } }, { $rename: { created_at: "createdAt", updated_at: "updatedAt" } });
console.log(` ✓ Step 7: Renamed timestamps in ${r.modifiedCount} docs`);
return r;
}

async function convertObjectIds(apicalls, field) {
const cursor = apicalls.find({ [`${field}.0`]: { $exists: true } }, { projection: { _id: 1, [field]: 1 } });
const bulk = [];
while (await cursor.hasNext()) {
const doc = await cursor.next();
if (doc[field].some((id) => typeof id !== "string")) {
bulk.push({
updateOne: { filter: { _id: doc._id }, update: { $set: { [field]: doc[field].map((id) => id.toString()) } } }
});
}
}
if (bulk.length > 0) {
const r = await apicalls.bulkWrite(bulk);
console.log(` ✓ Converted ${field} for ${r.modifiedCount} docs`);
} else {
console.log(` - No ObjectId ${field} found`);
}
}

async function migrateApiCalls() {
const client = new MongoClient(MONGODB_URI);

try {
await client.connect();
console.log("Connected to MongoDB");

const db = client.db();
const apicalls = db.collection("apicalls");
const configurations = db.collection("configurations");
const versions = db.collection("configuration_versions");

// =============================================================
// Phase 1: Independent operations (parallel)
// =============================================================
console.log("\n=== Phase 1: Independent operations (parallel) ===");

const step1 = removeDeprecatedKeys(apicalls);
const step2 = setDefaults(apicalls);
const step3 = backfillOldFields(apicalls);
const step6 = fixMissingUserIds(apicalls);
const step7 = renameTimestamps(apicalls);

await Promise.all([step1, step2, step3, step6, step7]);

// =============================================================
// Phase 2: Sync bridge_ids/version_ids + cleanup stale refs
// =============================================================
console.log("\n=== Phase 2: Sync bridge_ids/version_ids ===");

const allApicallIds = new Set((await apicalls.find({}, { projection: { _id: 1 } }).toArray()).map((d) => d._id.toString()));

const [allConfigs, allVersions] = await Promise.all([
configurations.find({ "function_ids.0": { $exists: true } }, { projection: { _id: 1, function_ids: 1 } }).toArray(),
versions.find({ "function_ids.0": { $exists: true } }, { projection: { _id: 1, function_ids: 1 } }).toArray()
]);

const apicallToBridges = {};
const apicallToVersions = {};
const staleConfigRefs = {};
const staleVersionRefs = {};

for (const config of allConfigs) {
for (const funcId of config.function_ids) {
const funcIdStr = funcId.toString();
if (allApicallIds.has(funcIdStr)) {
if (!apicallToBridges[funcIdStr]) apicallToBridges[funcIdStr] = new Set();
apicallToBridges[funcIdStr].add(config._id.toString());
} else {
if (!staleConfigRefs[config._id.toString()]) staleConfigRefs[config._id.toString()] = [];
staleConfigRefs[config._id.toString()].push(funcId);
}
}
}

for (const ver of allVersions) {
for (const funcId of ver.function_ids) {
const funcIdStr = funcId.toString();
if (allApicallIds.has(funcIdStr)) {
if (!apicallToVersions[funcIdStr]) apicallToVersions[funcIdStr] = new Set();
apicallToVersions[funcIdStr].add(ver._id.toString());
} else {
if (!staleVersionRefs[ver._id.toString()]) staleVersionRefs[ver._id.toString()] = [];
staleVersionRefs[ver._id.toString()].push(funcId);
}
}
}

const bulkApicallUpdates = [];
for (const [apicallId, bridgeIds] of Object.entries(apicallToBridges)) {
bulkApicallUpdates.push({
updateOne: {
filter: { _id: new ObjectId(apicallId) },
update: { $addToSet: { bridge_ids: { $each: [...bridgeIds] } } }
}
});
}
for (const [apicallId, versionIds] of Object.entries(apicallToVersions)) {
bulkApicallUpdates.push({
updateOne: {
filter: { _id: new ObjectId(apicallId) },
update: { $addToSet: { version_ids: { $each: [...versionIds] } } }
}
});
}

const bulkConfigCleanup = [];
for (const [configId, staleFuncIds] of Object.entries(staleConfigRefs)) {
bulkConfigCleanup.push({
updateOne: {
filter: { _id: new ObjectId(configId) },
update: { $pull: { function_ids: { $in: staleFuncIds } } }
}
});
}

const bulkVersionCleanup = [];
for (const [versionId, staleFuncIds] of Object.entries(staleVersionRefs)) {
bulkVersionCleanup.push({
updateOne: {
filter: { _id: new ObjectId(versionId) },
update: { $pull: { function_ids: { $in: staleFuncIds } } }
}
});
}

const phase2Ops = [];
if (bulkApicallUpdates.length > 0)
phase2Ops.push(
apicalls.bulkWrite(bulkApicallUpdates).then((r) => console.log(` ✓ Added bridge_ids/version_ids to ${r.modifiedCount} apicalls`))
);
else console.log(` - No apicalls needed bridge_ids/version_ids update`);
if (bulkConfigCleanup.length > 0)
phase2Ops.push(
configurations.bulkWrite(bulkConfigCleanup).then((r) => console.log(` ✓ Removed stale function_ids from ${r.modifiedCount} configurations`))
);
else console.log(` - No stale function_ids in configurations`);
if (bulkVersionCleanup.length > 0)
phase2Ops.push(
versions.bulkWrite(bulkVersionCleanup).then((r) => console.log(` ✓ Removed stale function_ids from ${r.modifiedCount} versions`))
);
else console.log(` - No stale function_ids in versions`);

if (phase2Ops.length > 0) await Promise.all(phase2Ops);

// =============================================================
// Phase 3: Convert ObjectId → String (parallel)
// =============================================================
console.log("\n=== Phase 3: Convert ObjectId → String ===");

const bridgeConvert = convertObjectIds(apicalls, "bridge_ids");
const versionConvert = convertObjectIds(apicalls, "version_ids");
await Promise.all([bridgeConvert, versionConvert]);

// Summary
console.log("\n" + "=".repeat(60));
console.log("Migration Summary:");
console.log(` Stale config refs cleaned: ${Object.values(staleConfigRefs).flat().length}`);
console.log(` Stale version refs cleaned: ${Object.values(staleVersionRefs).flat().length}`);
console.log(` Total apicall docs: ${await apicalls.countDocuments()}`);
console.log("=".repeat(60));
} catch (error) {
console.error("Migration failed:", error);
throw error;
} finally {
await client.close();
console.log("\nConnection closed");
}
}

export { migrateApiCalls };
Loading