paperclip-plugin-supermemory-otomatik 0.2.11 → 0.2.13
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 +7 -4
- package/dist/manifest.js +12 -1
- package/dist/manifest.js.map +2 -2
- package/dist/ui/index.js +543 -208
- package/dist/ui/index.js.map +4 -4
- package/dist/worker.js +76 -0
- package/dist/worker.js.map +3 -3
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -77228,6 +77228,66 @@ function errorText(error62) {
|
|
|
77228
77228
|
function isRecord(value) {
|
|
77229
77229
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
77230
77230
|
}
|
|
77231
|
+
function memoryText(value) {
|
|
77232
|
+
if (typeof value === "string") return value.trim();
|
|
77233
|
+
if (!isRecord(value)) return "";
|
|
77234
|
+
for (const key of ["memory", "content", "text", "summary"]) {
|
|
77235
|
+
const candidate = value[key];
|
|
77236
|
+
if (typeof candidate === "string" && candidate.trim()) return candidate.trim();
|
|
77237
|
+
}
|
|
77238
|
+
return "";
|
|
77239
|
+
}
|
|
77240
|
+
function memoryGraphPayload(raw, assignment, query) {
|
|
77241
|
+
const root = isRecord(raw) ? raw : {};
|
|
77242
|
+
const rawResults = Array.isArray(root.results) ? root.results : Array.isArray(root.memories) ? root.memories : [];
|
|
77243
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
77244
|
+
const edgeKeys = /* @__PURE__ */ new Set();
|
|
77245
|
+
const edges = [];
|
|
77246
|
+
const addNode = (candidate, matched) => {
|
|
77247
|
+
if (!isRecord(candidate) || typeof candidate.id !== "string" || !candidate.id) return null;
|
|
77248
|
+
const id = candidate.id.slice(0, 300);
|
|
77249
|
+
const text2 = memoryText(candidate.memory ?? candidate.chunk ?? candidate) || `Memoria ${id.slice(0, 12)}`;
|
|
77250
|
+
const prior = nodes.get(id);
|
|
77251
|
+
nodes.set(id, {
|
|
77252
|
+
id,
|
|
77253
|
+
text: text2.slice(0, 1200),
|
|
77254
|
+
label: text2.replace(/\s+/g, " ").slice(0, 120) || `Memoria ${id.slice(0, 12)}`,
|
|
77255
|
+
similarity: typeof candidate.similarity === "number" && Number.isFinite(candidate.similarity) ? candidate.similarity : prior?.similarity ?? null,
|
|
77256
|
+
matched: matched || prior?.matched === true
|
|
77257
|
+
});
|
|
77258
|
+
return id;
|
|
77259
|
+
};
|
|
77260
|
+
const addEdge = (source, target, relation) => {
|
|
77261
|
+
if (!source || !target || source === target) return;
|
|
77262
|
+
const key = [source, target, relation].join("|");
|
|
77263
|
+
if (edgeKeys.has(key) || edges.length >= 100) return;
|
|
77264
|
+
edgeKeys.add(key);
|
|
77265
|
+
edges.push({ source, target, relation });
|
|
77266
|
+
};
|
|
77267
|
+
for (const resultValue of rawResults.slice(0, 12)) {
|
|
77268
|
+
if (!isRecord(resultValue)) continue;
|
|
77269
|
+
const id = addNode(resultValue, true);
|
|
77270
|
+
if (!id) continue;
|
|
77271
|
+
const included = isRecord(resultValue.included) ? resultValue.included : {};
|
|
77272
|
+
const related = isRecord(included.related) ? included.related : {};
|
|
77273
|
+
for (const [field3, relation] of [["parents", "parent"], ["children", "child"], ["siblings", "sibling"]]) {
|
|
77274
|
+
const candidates = Array.isArray(related[field3]) ? related[field3] : [];
|
|
77275
|
+
for (const candidate of candidates.slice(0, 12)) {
|
|
77276
|
+
const relatedId = addNode(candidate, false);
|
|
77277
|
+
if (relation === "parent") addEdge(relatedId, id, relation);
|
|
77278
|
+
else addEdge(id, relatedId, relation);
|
|
77279
|
+
}
|
|
77280
|
+
}
|
|
77281
|
+
}
|
|
77282
|
+
return {
|
|
77283
|
+
assignmentId: assignment.id,
|
|
77284
|
+
namespaceLabel: assignment.label,
|
|
77285
|
+
query,
|
|
77286
|
+
nodes: [...nodes.values()].slice(0, 48),
|
|
77287
|
+
edges,
|
|
77288
|
+
truncated: nodes.size > 48 || edges.length >= 100
|
|
77289
|
+
};
|
|
77290
|
+
}
|
|
77231
77291
|
function isSecretRef(value) {
|
|
77232
77292
|
return isRecord(value) && value.type === "secret_ref" && typeof value.secretId === "string";
|
|
77233
77293
|
}
|
|
@@ -77643,6 +77703,22 @@ var plugin = definePlugin({
|
|
|
77643
77703
|
await ownerFor(ctx, companyId, actionCtx);
|
|
77644
77704
|
return await listCatalog(ctx, companyId);
|
|
77645
77705
|
});
|
|
77706
|
+
ctx.actions.register("memory-graph", async (params, actionCtx) => {
|
|
77707
|
+
const companyId = actionCompany(params, actionCtx);
|
|
77708
|
+
await ownerFor(ctx, companyId, actionCtx);
|
|
77709
|
+
const assignment = await requireAssignment(ctx, companyId, String(params.assignmentId ?? ""));
|
|
77710
|
+
const query = typeof params.query === "string" ? params.query.trim() : "";
|
|
77711
|
+
if (!query || query.length > 300 || query.includes("\n")) throw new Error("Inserisci una ricerca di massimo 300 caratteri.");
|
|
77712
|
+
const { base, key } = await adminConfig(ctx, companyId);
|
|
77713
|
+
const requestedLimit = typeof params.limit === "number" ? params.limit : 8;
|
|
77714
|
+
const limit = Number.isInteger(requestedLimit) ? Math.max(1, Math.min(requestedLimit, 12)) : 8;
|
|
77715
|
+
const result = await ownerGatewayRequest(ctx, base, key, localNamespacePath(assignment.namespace, "/search"), {
|
|
77716
|
+
method: "POST",
|
|
77717
|
+
headers: { "content-type": "application/json" },
|
|
77718
|
+
body: JSON.stringify({ query, searchMode: "memories", include: { related: true }, limit })
|
|
77719
|
+
});
|
|
77720
|
+
return memoryGraphPayload(result, assignment, query);
|
|
77721
|
+
});
|
|
77646
77722
|
ctx.actions.register("memory-assignment-save", async (params, actionCtx) => {
|
|
77647
77723
|
const companyId = actionCompany(params, actionCtx);
|
|
77648
77724
|
const actorUserId = await ownerFor(ctx, companyId, actionCtx);
|