paperclip-plugin-supermemory-otomatik 0.2.5 → 0.2.7
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/README.md +1 -1
- package/dist/manifest.js +1 -1
- package/dist/manifest.js.map +1 -1
- package/dist/ui/index.js +36 -11
- package/dist/ui/index.js.map +2 -2
- package/dist/worker.js +48 -1
- package/dist/worker.js.map +3 -3
- package/package.json +5 -3
package/dist/worker.js
CHANGED
|
@@ -44579,6 +44579,8 @@ var plugin = definePlugin({
|
|
|
44579
44579
|
ctx.actions.register("memory-assignment-save", async (params, actionCtx) => {
|
|
44580
44580
|
const companyId = actionCompany(params, actionCtx);
|
|
44581
44581
|
const actorUserId = await ownerFor(ctx, companyId, actionCtx);
|
|
44582
|
+
const assignmentId = typeof params.assignmentId === "string" ? params.assignmentId.trim() : "";
|
|
44583
|
+
const previousAssignment = assignmentId ? await requireAssignment(ctx, companyId, assignmentId) : null;
|
|
44582
44584
|
const scopeType = params.scopeType;
|
|
44583
44585
|
const scopeId = typeof params.scopeId === "string" ? params.scopeId.trim() : "";
|
|
44584
44586
|
const label2 = typeof params.label === "string" ? params.label.trim().slice(0, 180) : "";
|
|
@@ -44591,8 +44593,15 @@ var plugin = definePlugin({
|
|
|
44591
44593
|
]);
|
|
44592
44594
|
if (!scope) throw new Error("L\u2019agente o progetto selezionato non appartiene a questa organizzazione.");
|
|
44593
44595
|
if (authorizedAgents.some((agent) => !agent || agent.status === "terminated" || agent.status === "pending_approval")) throw new Error("Tutti gli agenti autorizzati devono essere attivi e appartenere a questa organizzazione.");
|
|
44594
|
-
const namespace = assignmentNamespace(companyId, scopeType, scopeId);
|
|
44595
44596
|
const externalId = `${scopeType}:${scopeId}`;
|
|
44597
|
+
const assignmentRows = await ctx.entities.list({ entityType: ASSIGNMENT_ENTITY, scopeKind: "company", scopeId: companyId, limit: 500 });
|
|
44598
|
+
const targetRows = assignmentRows.filter((candidate) => candidate.externalId === externalId);
|
|
44599
|
+
const activeTargetRow = targetRows.find((candidate) => candidate.status === "active");
|
|
44600
|
+
if (activeTargetRow && activeTargetRow.id !== previousAssignment?.id) {
|
|
44601
|
+
throw new Error("Questo agente o progetto ha gi\xE0 un\u2019assegnazione. Apri quella esistente per modificarla.");
|
|
44602
|
+
}
|
|
44603
|
+
const storedTargetData = targetRows.find((candidate) => isRecord(candidate.data) && typeof candidate.data.namespace === "string")?.data;
|
|
44604
|
+
const namespace = previousAssignment?.namespace ?? (isRecord(storedTargetData) && typeof storedTargetData.namespace === "string" ? storedTargetData.namespace : null) ?? assignmentNamespace(companyId, scopeType, scopeId);
|
|
44596
44605
|
const row = await ctx.entities.upsert({
|
|
44597
44606
|
entityType: ASSIGNMENT_ENTITY,
|
|
44598
44607
|
scopeKind: "company",
|
|
@@ -44602,6 +44611,44 @@ var plugin = definePlugin({
|
|
|
44602
44611
|
status: "active",
|
|
44603
44612
|
data: { companyId, scopeType, scopeId, label: label2, namespace, authorizedAgentIds, updatedBy: actorUserId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
44604
44613
|
});
|
|
44614
|
+
if (previousAssignment && `${previousAssignment.scopeType}:${previousAssignment.scopeId}` !== externalId) {
|
|
44615
|
+
const previousRows = await ctx.entities.list({
|
|
44616
|
+
entityType: ASSIGNMENT_ENTITY,
|
|
44617
|
+
scopeKind: "company",
|
|
44618
|
+
scopeId: companyId,
|
|
44619
|
+
externalId: `${previousAssignment.scopeType}:${previousAssignment.scopeId}`,
|
|
44620
|
+
limit: 1
|
|
44621
|
+
});
|
|
44622
|
+
const previousRow = previousRows.find((candidate) => candidate.id === previousAssignment.id);
|
|
44623
|
+
if (previousRow) {
|
|
44624
|
+
await ctx.entities.upsert({
|
|
44625
|
+
entityType: ASSIGNMENT_ENTITY,
|
|
44626
|
+
scopeKind: "company",
|
|
44627
|
+
scopeId: companyId,
|
|
44628
|
+
externalId: `${previousAssignment.scopeType}:${previousAssignment.scopeId}`,
|
|
44629
|
+
title: previousRow.title ?? void 0,
|
|
44630
|
+
status: "disabled",
|
|
44631
|
+
data: { ...isRecord(previousRow.data) ? previousRow.data : {}, updatedBy: actorUserId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
44632
|
+
});
|
|
44633
|
+
}
|
|
44634
|
+
}
|
|
44635
|
+
const documents = await ctx.entities.list({ entityType: DOCUMENT_ENTITY, scopeKind: "company", scopeId: companyId, limit: 500 });
|
|
44636
|
+
const staleAssignmentIds = new Set(assignmentRows.filter((candidate) => candidate.id !== row.id && candidate.status !== "active" && isRecord(candidate.data) && candidate.data.namespace === namespace).map((candidate) => candidate.id));
|
|
44637
|
+
if (previousAssignment && `${previousAssignment.scopeType}:${previousAssignment.scopeId}` !== externalId) {
|
|
44638
|
+
staleAssignmentIds.add(previousAssignment.id);
|
|
44639
|
+
}
|
|
44640
|
+
for (const document2 of documents) {
|
|
44641
|
+
if (!isRecord(document2.data) || !staleAssignmentIds.has(String(document2.data.assignmentId ?? "")) || document2.data.namespace !== namespace) continue;
|
|
44642
|
+
await ctx.entities.upsert({
|
|
44643
|
+
entityType: DOCUMENT_ENTITY,
|
|
44644
|
+
scopeKind: "company",
|
|
44645
|
+
scopeId: companyId,
|
|
44646
|
+
externalId: document2.externalId ?? void 0,
|
|
44647
|
+
title: document2.title ?? void 0,
|
|
44648
|
+
status: document2.status ?? "active",
|
|
44649
|
+
data: { ...document2.data, assignmentId: row.id }
|
|
44650
|
+
});
|
|
44651
|
+
}
|
|
44605
44652
|
return assignmentFromEntity(row, companyId);
|
|
44606
44653
|
});
|
|
44607
44654
|
ctx.actions.register("memory-assignment-disable", async (params, actionCtx) => {
|