dsh-mnemon-provider-hindsight 0.5.5 → 0.5.6
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/lib/index.js +14 -2
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -2,6 +2,18 @@ import { t as descriptor } from "./descriptor-BxGaZkfv.js";
|
|
|
2
2
|
import { HttpMemoryProvider, MEMORY_SPACE_PROVIDER_API_VERSION, NORMALIZED_RELEVANCE_SCORE, defineMemorySpaceProvider, defineMemorySpaceProviderDefinition, firstArray, jsonArray, jsonNumber, jsonObject, jsonString } from "dsh-mnemon-source-memory-spaces/provider-sdk";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region src/driver.ts
|
|
5
|
+
/**
|
|
6
|
+
* An entity name without the note Hindsight may append in parentheses, `Alice (person)`. The same
|
|
7
|
+
* result as removing /\s*\([^)]*\)\s*$/u, in one pass: that pattern took quadratic time on a
|
|
8
|
+
* name of many "(" without a ")", and the name comes from the server.
|
|
9
|
+
*/
|
|
10
|
+
function withoutTrailingNote(entry) {
|
|
11
|
+
const trimmed = entry.trimEnd();
|
|
12
|
+
if (!trimmed.endsWith(")")) return entry.trim();
|
|
13
|
+
const close = trimmed.length - 1;
|
|
14
|
+
const open = trimmed.indexOf("(", trimmed.lastIndexOf(")", close - 1) + 1);
|
|
15
|
+
return open < 0 || open >= close ? entry.trim() : trimmed.slice(0, open).trim();
|
|
16
|
+
}
|
|
5
17
|
function insight(value) {
|
|
6
18
|
const item = jsonObject(value);
|
|
7
19
|
const id = jsonString(item?.id);
|
|
@@ -11,7 +23,7 @@ function insight(value) {
|
|
|
11
23
|
const score = jsonNumber(scores?.final) ?? jsonNumber(item?.score);
|
|
12
24
|
const createdAt = jsonString(item?.mentioned_at) ?? jsonString(item?.date) ?? jsonString(item?.occurred_start);
|
|
13
25
|
const rawEntities = item?.entities;
|
|
14
|
-
const entities = Array.isArray(rawEntities) ? rawEntities.filter((entry) => typeof entry === "string") : typeof rawEntities === "string" ? rawEntities.split(",").map(
|
|
26
|
+
const entities = Array.isArray(rawEntities) ? rawEntities.filter((entry) => typeof entry === "string") : typeof rawEntities === "string" ? rawEntities.split(",").map(withoutTrailingNote).filter(Boolean) : [];
|
|
15
27
|
const tags = jsonArray(item?.tags).filter((entry) => typeof entry === "string");
|
|
16
28
|
return {
|
|
17
29
|
id,
|
|
@@ -252,7 +264,7 @@ const definition = defineMemorySpaceProviderDefinition({
|
|
|
252
264
|
kind: "provider",
|
|
253
265
|
typeId: descriptor.id,
|
|
254
266
|
packageName: "dsh-mnemon-provider-hindsight",
|
|
255
|
-
version: "0.5.
|
|
267
|
+
version: "0.5.6",
|
|
256
268
|
label: descriptor.label,
|
|
257
269
|
icon: descriptor.icon,
|
|
258
270
|
summary: descriptor.summary,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon-provider-hindsight",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Hindsight Provider child for the Memory Spaces Source.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^22.0.0",
|
|
37
|
-
"dsh-mnemon-source-memory-spaces": "^0.5.
|
|
37
|
+
"dsh-mnemon-source-memory-spaces": "^0.5.19",
|
|
38
38
|
"tsdown": "^0.22.0",
|
|
39
39
|
"typescript": "^5.9.0",
|
|
40
40
|
"vitest": "^3.2.0"
|