@signetai/core 0.147.21 → 0.147.24

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 CHANGED
@@ -7097,6 +7097,278 @@ function defaultPipelineModel(provider) {
7097
7097
  return modelDefaultForProvider(provider);
7098
7098
  }
7099
7099
 
7100
+ // src/recall.ts
7101
+ function isRecord(value) {
7102
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7103
+ }
7104
+ function withDefined(value) {
7105
+ return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
7106
+ }
7107
+ function normalizeRememberTags(tags) {
7108
+ if (typeof tags === "string") {
7109
+ const value = tags.split(",").map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
7110
+ return value.length > 0 ? value : undefined;
7111
+ }
7112
+ if (Array.isArray(tags)) {
7113
+ const value = tags.map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
7114
+ return value.length > 0 ? value : undefined;
7115
+ }
7116
+ return;
7117
+ }
7118
+ function normalizeRecallLimit(limit) {
7119
+ if (typeof limit !== "number" || !Number.isFinite(limit))
7120
+ return 10;
7121
+ return Math.min(100, Math.max(1, Math.trunc(limit)));
7122
+ }
7123
+ function partitionRecallRows(rows) {
7124
+ return {
7125
+ primary: rows.filter((row) => row.supplementary !== true),
7126
+ supporting: rows.filter((row) => row.supplementary === true)
7127
+ };
7128
+ }
7129
+ function parseRecallMeta(raw, fallbackCount) {
7130
+ if (!isRecord(raw)) {
7131
+ return {
7132
+ totalReturned: fallbackCount,
7133
+ hasSupplementary: false,
7134
+ noHits: fallbackCount === 0
7135
+ };
7136
+ }
7137
+ const totalReturned = typeof raw.totalReturned === "number" ? raw.totalReturned : fallbackCount;
7138
+ const hasSupplementary = raw.hasSupplementary === true;
7139
+ const noHits = "noHits" in raw ? raw.noHits === true : totalReturned === 0;
7140
+ const dedupe = isRecord(raw.dedupe) ? {
7141
+ enabled: raw.dedupe.enabled === true,
7142
+ contextEpoch: typeof raw.dedupe.contextEpoch === "number" ? raw.dedupe.contextEpoch : undefined,
7143
+ suppressed: typeof raw.dedupe.suppressed === "number" ? raw.dedupe.suppressed : 0,
7144
+ repeatedReturned: typeof raw.dedupe.repeatedReturned === "number" ? raw.dedupe.repeatedReturned : 0
7145
+ } : undefined;
7146
+ const temporal = isRecord(raw.temporal) ? raw.temporal : undefined;
7147
+ return { totalReturned, hasSupplementary, noHits, ...dedupe ? { dedupe } : {}, ...temporal ? { temporal } : {} };
7148
+ }
7149
+ function parseRecallPayload(raw) {
7150
+ const payload = isRecord(raw) ? raw : {};
7151
+ const results = Array.isArray(payload.results) ? payload.results : Array.isArray(payload.memories) ? payload.memories : [];
7152
+ const rows = results.filter(isRecord);
7153
+ return {
7154
+ query: typeof payload.query === "string" ? payload.query : undefined,
7155
+ method: typeof payload.method === "string" ? payload.method : undefined,
7156
+ rows,
7157
+ meta: parseRecallMeta(payload.meta, rows.length),
7158
+ message: typeof payload.message === "string" ? payload.message : undefined
7159
+ };
7160
+ }
7161
+ function applyRecallScoreThreshold(raw, minScore) {
7162
+ if (typeof minScore !== "number" || !Number.isFinite(minScore) || typeof raw !== "object" || raw === null || Array.isArray(raw)) {
7163
+ return raw;
7164
+ }
7165
+ const payload = raw;
7166
+ const rows = Array.isArray(payload.results) ? payload.results : [];
7167
+ const filtered = rows.filter((row) => typeof row.score !== "number" || row.score >= minScore);
7168
+ return {
7169
+ ...payload,
7170
+ results: filtered,
7171
+ meta: {
7172
+ ...isRecord(payload.meta) ? payload.meta : {},
7173
+ totalReturned: filtered.length,
7174
+ hasSupplementary: filtered.some((row) => row.supplementary === true),
7175
+ noHits: filtered.length === 0
7176
+ }
7177
+ };
7178
+ }
7179
+ function formatDate(value) {
7180
+ return typeof value === "string" && value.length > 0 ? value.slice(0, 10) : "unknown";
7181
+ }
7182
+ function formatRecallRow(row, options) {
7183
+ const score = typeof row.score === "number" ? `[${(row.score * 100).toFixed(0)}%] ` : "";
7184
+ const source = typeof row.source === "string" ? row.source : "unknown";
7185
+ const type = typeof row.type === "string" ? row.type : "memory";
7186
+ const who = typeof row.who === "string" && row.who.length > 0 ? `, by ${row.who}` : "";
7187
+ const createdAt = formatDate(row.created_at);
7188
+ const id = typeof row.id === "string" && row.id.length > 0 ? `id: ${row.id}; ` : "";
7189
+ const prefix = options?.includeIndex ? `${options.includeIndex}. ` : "- ";
7190
+ return `${prefix}${score}${id}${row.content ?? ""} (${type}, ${source}, ${createdAt}${who})`;
7191
+ }
7192
+ function temporalGroupLabel(row) {
7193
+ if (row.temporal_facet === "session")
7194
+ return "Sessions";
7195
+ if (row.temporal_facet === "source")
7196
+ return "Source Activity";
7197
+ if (row.temporal_facet === "occurred" || row.temporal_facet === "observed" || row.temporal_facet === "valid") {
7198
+ return "Events";
7199
+ }
7200
+ return "Memories Captured";
7201
+ }
7202
+ function formatTemporalDate(value) {
7203
+ const parsed = new Date(value);
7204
+ if (Number.isNaN(parsed.getTime()))
7205
+ return value.slice(0, 10);
7206
+ return parsed.toLocaleDateString("en-US", {
7207
+ month: "long",
7208
+ day: "numeric",
7209
+ year: "numeric",
7210
+ timeZone: "UTC"
7211
+ });
7212
+ }
7213
+ function formatTemporalRecallText(rows, meta) {
7214
+ const parts = [formatTemporalDate(meta.start)];
7215
+ const groups = new Map;
7216
+ for (const row of rows) {
7217
+ const label = temporalGroupLabel(row);
7218
+ groups.set(label, [...groups.get(label) ?? [], row]);
7219
+ }
7220
+ for (const label of ["Sessions", "Source Activity", "Events", "Memories Captured"]) {
7221
+ const group = groups.get(label);
7222
+ if (!group || group.length === 0)
7223
+ continue;
7224
+ parts.push("", label, ...group.map((row) => formatRecallRow(row)));
7225
+ }
7226
+ return parts.join(`
7227
+ `);
7228
+ }
7229
+ function formatRecallText(raw) {
7230
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
7231
+ return typeof raw === "string" ? raw : JSON.stringify(raw, null, 2);
7232
+ }
7233
+ const payload = raw;
7234
+ const parsed = parseRecallPayload(payload);
7235
+ if (parsed.message && parsed.rows.length === 0)
7236
+ return parsed.message;
7237
+ if (parsed.meta.noHits || parsed.rows.length === 0)
7238
+ return "No matching memories found.";
7239
+ const { primary, supporting } = partitionRecallRows(parsed.rows);
7240
+ if (parsed.meta.temporal?.mode === "timeline")
7241
+ return formatTemporalRecallText(primary, parsed.meta.temporal);
7242
+ const noun = parsed.meta.totalReturned === 1 ? "memory" : "memories";
7243
+ const parts = payload.aggregate?.partial === true && typeof payload.aggregate.message === "string" ? [
7244
+ payload.aggregate.message,
7245
+ "",
7246
+ `Found ${parsed.meta.totalReturned} ${noun}${parsed.method ? ` (${parsed.method})` : ""}.`
7247
+ ] : [`Found ${parsed.meta.totalReturned} ${noun}${parsed.method ? ` (${parsed.method})` : ""}.`];
7248
+ if (primary.length > 0) {
7249
+ parts.push("", "Primary matches:", ...primary.map((row) => formatRecallRow(row)));
7250
+ }
7251
+ if (supporting.length > 0) {
7252
+ parts.push("", "Supporting context:", ...supporting.map((row) => formatRecallRow(row)));
7253
+ }
7254
+ return parts.join(`
7255
+ `);
7256
+ }
7257
+ function buildRecallRequestBody(query, options = {}) {
7258
+ return withDefined({
7259
+ query,
7260
+ keywordQuery: options.keywordQuery ?? options.keyword_query,
7261
+ limit: normalizeRecallLimit(options.limit),
7262
+ project: options.project,
7263
+ type: options.type,
7264
+ tags: options.tags,
7265
+ who: options.who,
7266
+ pinned: options.pinned === true ? true : undefined,
7267
+ importance_min: options.importance_min,
7268
+ since: options.since,
7269
+ until: options.until,
7270
+ time: options.time,
7271
+ expand: options.expand === true ? true : undefined,
7272
+ agentId: options.agentId ?? options.agent_id ?? options.contextAgentId,
7273
+ sessionKey: options.sessionKey ?? options.session_key,
7274
+ includeRecalled: options.includeRecalled === true || options.include_recalled === true ? true : undefined,
7275
+ scope: options.scope,
7276
+ sourceOnly: options.sourceOnly === true || options.source_only === true ? true : undefined,
7277
+ aggregate: options.aggregate === true ? true : undefined,
7278
+ aggregateBudget: options.aggregateBudget ?? options.aggregate_budget,
7279
+ saveAggregate: options.saveAggregate === false || options.save_aggregate === false ? false : options.saveAggregate === true || options.save_aggregate === true ? true : undefined
7280
+ });
7281
+ }
7282
+ function normalizeStructuredMemoryPayload(value) {
7283
+ if (!isRecord(value))
7284
+ return value;
7285
+ const aspects = value.aspects;
7286
+ if (!Array.isArray(aspects))
7287
+ return value;
7288
+ return {
7289
+ ...value,
7290
+ aspects: aspects.map((aspect) => {
7291
+ if (!isRecord(aspect))
7292
+ return aspect;
7293
+ if (typeof aspect.entityName === "string" && Array.isArray(aspect.attributes))
7294
+ return aspect;
7295
+ if (typeof aspect.entity === "string" && typeof aspect.aspect === "string" && typeof aspect.value === "string") {
7296
+ return {
7297
+ entityName: aspect.entity,
7298
+ aspect: aspect.aspect,
7299
+ attributes: [
7300
+ withDefined({
7301
+ content: aspect.value,
7302
+ groupKey: typeof aspect.groupKey === "string" ? aspect.groupKey : undefined,
7303
+ claimKey: typeof aspect.claimKey === "string" ? aspect.claimKey : undefined,
7304
+ confidence: typeof aspect.confidence === "number" ? aspect.confidence : undefined,
7305
+ importance: typeof aspect.importance === "number" ? aspect.importance : undefined
7306
+ })
7307
+ ]
7308
+ };
7309
+ }
7310
+ return aspect;
7311
+ })
7312
+ };
7313
+ }
7314
+ function buildRememberRequestBody(content, options = {}) {
7315
+ return withDefined({
7316
+ content,
7317
+ type: options.type,
7318
+ importance: options.importance,
7319
+ tags: normalizeRememberTags(options.tags),
7320
+ who: options.who,
7321
+ pinned: options.pinned === true ? true : undefined,
7322
+ sourceType: options.sourceType,
7323
+ sourceId: options.sourceId,
7324
+ sourcePath: options.sourcePath,
7325
+ createdAt: options.createdAt,
7326
+ occurredAt: options.occurredAt,
7327
+ observedAt: options.observedAt,
7328
+ validFrom: options.validFrom,
7329
+ validUntil: options.validUntil,
7330
+ sourceCreatedAt: options.sourceCreatedAt,
7331
+ hints: options.hints,
7332
+ transcript: options.transcript,
7333
+ structured: normalizeStructuredMemoryPayload(options.structured),
7334
+ agentId: options.agentId,
7335
+ visibility: options.visibility,
7336
+ mode: options.mode,
7337
+ idempotencyKey: options.idempotencyKey,
7338
+ runtimePath: options.runtimePath,
7339
+ harness: options.harness,
7340
+ source: options.source
7341
+ });
7342
+ }
7343
+ function withHookRecallCompat(result) {
7344
+ return {
7345
+ ...result,
7346
+ memories: result.results,
7347
+ count: result.results.length,
7348
+ message: formatRecallText(result)
7349
+ };
7350
+ }
7351
+ function emptyHookRecallResponse(query, extras) {
7352
+ const response = {
7353
+ results: [],
7354
+ memories: [],
7355
+ count: 0,
7356
+ query,
7357
+ method: "hybrid",
7358
+ meta: {
7359
+ totalReturned: 0,
7360
+ hasSupplementary: false,
7361
+ noHits: true
7362
+ },
7363
+ message: "No matching memories found."
7364
+ };
7365
+ return {
7366
+ ...response,
7367
+ ...extras?.bypassed ? { bypassed: true } : {},
7368
+ ...extras?.internal ? { internal: true } : {}
7369
+ };
7370
+ }
7371
+
7100
7372
  // src/database.ts
7101
7373
  import { existsSync, readdirSync } from "node:fs";
7102
7374
  import { homedir } from "node:os";
@@ -11991,16 +12263,16 @@ var ONTOLOGY_PROPOSAL_OPERATIONS = [
11991
12263
  // src/network.ts
11992
12264
  var NETWORK_MODES = ["localhost", "tailscale"];
11993
12265
  var LOCAL_BINDS = new Set(["127.0.0.1", "localhost", "::1", "::ffff:127.0.0.1"]);
11994
- function isRecord(value) {
12266
+ function isRecord2(value) {
11995
12267
  return typeof value === "object" && value !== null;
11996
12268
  }
11997
12269
  function normalizeNetworkMode(value) {
11998
12270
  return value === "localhost" || value === "tailscale" ? value : null;
11999
12271
  }
12000
12272
  function readNetworkMode(raw) {
12001
- if (!isRecord(raw))
12273
+ if (!isRecord2(raw))
12002
12274
  return "localhost";
12003
- if (!isRecord(raw.network))
12275
+ if (!isRecord2(raw.network))
12004
12276
  return "localhost";
12005
12277
  return normalizeNetworkMode(raw.network.mode) ?? "localhost";
12006
12278
  }
@@ -12055,7 +12327,7 @@ function loadConfiguredHarnesses(agentsDir) {
12055
12327
  continue;
12056
12328
  try {
12057
12329
  const parsed = parseSimpleYaml(readFileSync2(path, "utf-8"));
12058
- if (!isRecord2(parsed))
12330
+ if (!isRecord3(parsed))
12059
12331
  return [];
12060
12332
  return parseHarnessList(parsed.harnesses);
12061
12333
  } catch {
@@ -12073,7 +12345,7 @@ function parseHarnessList(value) {
12073
12345
  }
12074
12346
  return [];
12075
12347
  }
12076
- function isRecord2(value) {
12348
+ function isRecord3(value) {
12077
12349
  return typeof value === "object" && value !== null;
12078
12350
  }
12079
12351
  // src/daemon-url.ts
@@ -12289,360 +12561,88 @@ function hybridSearch(db, queryVector, queryText, options) {
12289
12561
  source = "vector";
12290
12562
  } else {
12291
12563
  score = keywordScore;
12292
- source = "keyword";
12293
- }
12294
- if (score >= minScore) {
12295
- scored.push({ id, score, source });
12296
- }
12297
- }
12298
- scored.sort((a, b) => b.score - a.score);
12299
- }
12300
- const topIds = scored.slice(0, limit).map((s) => s.id);
12301
- if (topIds.length === 0) {
12302
- return [];
12303
- }
12304
- const placeholders = topIds.map(() => "?").join(", ");
12305
- let typeFilter = "";
12306
- const params = [...topIds];
12307
- if (options?.type) {
12308
- typeFilter = " AND type = ?";
12309
- params.push(options.type);
12310
- }
12311
- const rows = db.prepare(`
12312
- SELECT id, content, type, tags, confidence
12313
- FROM memories
12314
- WHERE id IN (${placeholders})${typeFilter}
12315
- `).all(...params);
12316
- const rowMap = new Map(rows.map((r) => [r.id, r]));
12317
- return scored.slice(0, limit).filter((s) => rowMap.has(s.id)).map((s) => {
12318
- const r = rowMap.get(s.id);
12319
- if (!r)
12320
- return null;
12321
- return {
12322
- id: s.id,
12323
- content: r.content,
12324
- score: Math.round(s.score * 100) / 100,
12325
- type: r.type,
12326
- source: s.source,
12327
- tags: safeParseTags(r.tags),
12328
- confidence: r.confidence
12329
- };
12330
- }).filter((r) => r !== null);
12331
- }
12332
- function hasPrepareMethod(db) {
12333
- return typeof db === "object" && db !== null && "prepare" in db && typeof db.prepare === "function";
12334
- }
12335
- function getRawDb(db) {
12336
- if (typeof db === "object" && db !== null && "db" in db && db.db !== null && hasPrepareMethod(db.db)) {
12337
- return db.db;
12338
- }
12339
- if (hasPrepareMethod(db)) {
12340
- return db;
12341
- }
12342
- return null;
12343
- }
12344
- async function search(db, options) {
12345
- const { query, limit = 10, alpha = DEFAULT_HYBRID_ALPHA, minScore = 0.1, topK = 50 } = options;
12346
- const rawDb = getRawDb(db);
12347
- if (rawDb) {
12348
- const results = hybridSearch(rawDb, null, query, {
12349
- limit,
12350
- alpha,
12351
- minScore,
12352
- topK,
12353
- type: options.type
12354
- });
12355
- if (results.length > 0) {
12356
- return results;
12357
- }
12358
- }
12359
- try {
12360
- const wrapper = db;
12361
- const memories = typeof wrapper.getMemories === "function" ? wrapper.getMemories(options.type) : [];
12362
- return memories.filter((m) => m.content.toLowerCase().includes(query.toLowerCase())).slice(0, limit).map((m) => ({
12363
- id: m.id,
12364
- content: m.content,
12365
- score: 1,
12366
- type: m.type,
12367
- source: "keyword",
12368
- tags: m.tags,
12369
- confidence: m.confidence
12370
- }));
12371
- } catch {
12372
- return [];
12373
- }
12374
- }
12375
- // src/recall.ts
12376
- function isRecord3(value) {
12377
- return typeof value === "object" && value !== null && !Array.isArray(value);
12378
- }
12379
- function withDefined(value) {
12380
- return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
12381
- }
12382
- function normalizeRememberTags(tags) {
12383
- if (typeof tags === "string") {
12384
- const value = tags.split(",").map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
12385
- return value.length > 0 ? value : undefined;
12386
- }
12387
- if (Array.isArray(tags)) {
12388
- const value = tags.map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
12389
- return value.length > 0 ? value : undefined;
12390
- }
12391
- return;
12392
- }
12393
- function normalizeRecallLimit(limit) {
12394
- if (typeof limit !== "number" || !Number.isFinite(limit))
12395
- return 10;
12396
- return Math.min(100, Math.max(1, Math.trunc(limit)));
12397
- }
12398
- function partitionRecallRows(rows) {
12399
- return {
12400
- primary: rows.filter((row) => row.supplementary !== true),
12401
- supporting: rows.filter((row) => row.supplementary === true)
12402
- };
12403
- }
12404
- function parseRecallMeta(raw, fallbackCount) {
12405
- if (!isRecord3(raw)) {
12406
- return {
12407
- totalReturned: fallbackCount,
12408
- hasSupplementary: false,
12409
- noHits: fallbackCount === 0
12410
- };
12411
- }
12412
- const totalReturned = typeof raw.totalReturned === "number" ? raw.totalReturned : fallbackCount;
12413
- const hasSupplementary = raw.hasSupplementary === true;
12414
- const noHits = "noHits" in raw ? raw.noHits === true : totalReturned === 0;
12415
- const dedupe = isRecord3(raw.dedupe) ? {
12416
- enabled: raw.dedupe.enabled === true,
12417
- contextEpoch: typeof raw.dedupe.contextEpoch === "number" ? raw.dedupe.contextEpoch : undefined,
12418
- suppressed: typeof raw.dedupe.suppressed === "number" ? raw.dedupe.suppressed : 0,
12419
- repeatedReturned: typeof raw.dedupe.repeatedReturned === "number" ? raw.dedupe.repeatedReturned : 0
12420
- } : undefined;
12421
- const temporal = isRecord3(raw.temporal) ? raw.temporal : undefined;
12422
- return { totalReturned, hasSupplementary, noHits, ...dedupe ? { dedupe } : {}, ...temporal ? { temporal } : {} };
12423
- }
12424
- function parseRecallPayload(raw) {
12425
- const payload = isRecord3(raw) ? raw : {};
12426
- const results = Array.isArray(payload.results) ? payload.results : Array.isArray(payload.memories) ? payload.memories : [];
12427
- const rows = results.filter(isRecord3);
12428
- return {
12429
- query: typeof payload.query === "string" ? payload.query : undefined,
12430
- method: typeof payload.method === "string" ? payload.method : undefined,
12431
- rows,
12432
- meta: parseRecallMeta(payload.meta, rows.length),
12433
- message: typeof payload.message === "string" ? payload.message : undefined
12434
- };
12435
- }
12436
- function applyRecallScoreThreshold(raw, minScore) {
12437
- if (typeof minScore !== "number" || !Number.isFinite(minScore) || typeof raw !== "object" || raw === null || Array.isArray(raw)) {
12438
- return raw;
12439
- }
12440
- const payload = raw;
12441
- const rows = Array.isArray(payload.results) ? payload.results : [];
12442
- const filtered = rows.filter((row) => typeof row.score !== "number" || row.score >= minScore);
12443
- return {
12444
- ...payload,
12445
- results: filtered,
12446
- meta: {
12447
- totalReturned: filtered.length,
12448
- hasSupplementary: filtered.some((row) => row.supplementary === true),
12449
- noHits: filtered.length === 0,
12450
- ...isRecord3(payload.meta) && isRecord3(payload.meta.dedupe) ? { dedupe: payload.meta.dedupe } : {},
12451
- ...isRecord3(payload.meta) && isRecord3(payload.meta.temporal) ? { temporal: payload.meta.temporal } : {}
12564
+ source = "keyword";
12565
+ }
12566
+ if (score >= minScore) {
12567
+ scored.push({ id, score, source });
12568
+ }
12452
12569
  }
12453
- };
12454
- }
12455
- function formatDate(value) {
12456
- return typeof value === "string" && value.length > 0 ? value.slice(0, 10) : "unknown";
12457
- }
12458
- function formatRecallRow(row, options) {
12459
- const score = typeof row.score === "number" ? `[${(row.score * 100).toFixed(0)}%] ` : "";
12460
- const source = typeof row.source === "string" ? row.source : "unknown";
12461
- const type = typeof row.type === "string" ? row.type : "memory";
12462
- const who = typeof row.who === "string" && row.who.length > 0 ? `, by ${row.who}` : "";
12463
- const createdAt = formatDate(row.created_at);
12464
- const id = typeof row.id === "string" && row.id.length > 0 ? `id: ${row.id}; ` : "";
12465
- const prefix = options?.includeIndex ? `${options.includeIndex}. ` : "- ";
12466
- return `${prefix}${score}${id}${row.content ?? ""} (${type}, ${source}, ${createdAt}${who})`;
12467
- }
12468
- function temporalGroupLabel(row) {
12469
- if (row.temporal_facet === "session")
12470
- return "Sessions";
12471
- if (row.temporal_facet === "source")
12472
- return "Source Activity";
12473
- if (row.temporal_facet === "occurred" || row.temporal_facet === "observed" || row.temporal_facet === "valid") {
12474
- return "Events";
12570
+ scored.sort((a, b) => b.score - a.score);
12475
12571
  }
12476
- return "Memories Captured";
12572
+ const topIds = scored.slice(0, limit).map((s) => s.id);
12573
+ if (topIds.length === 0) {
12574
+ return [];
12575
+ }
12576
+ const placeholders = topIds.map(() => "?").join(", ");
12577
+ let typeFilter = "";
12578
+ const params = [...topIds];
12579
+ if (options?.type) {
12580
+ typeFilter = " AND type = ?";
12581
+ params.push(options.type);
12582
+ }
12583
+ const rows = db.prepare(`
12584
+ SELECT id, content, type, tags, confidence
12585
+ FROM memories
12586
+ WHERE id IN (${placeholders})${typeFilter}
12587
+ `).all(...params);
12588
+ const rowMap = new Map(rows.map((r) => [r.id, r]));
12589
+ return scored.slice(0, limit).filter((s) => rowMap.has(s.id)).map((s) => {
12590
+ const r = rowMap.get(s.id);
12591
+ if (!r)
12592
+ return null;
12593
+ return {
12594
+ id: s.id,
12595
+ content: r.content,
12596
+ score: Math.round(s.score * 100) / 100,
12597
+ type: r.type,
12598
+ source: s.source,
12599
+ tags: safeParseTags(r.tags),
12600
+ confidence: r.confidence
12601
+ };
12602
+ }).filter((r) => r !== null);
12477
12603
  }
12478
- function formatTemporalDate(value) {
12479
- const parsed = new Date(value);
12480
- if (Number.isNaN(parsed.getTime()))
12481
- return value.slice(0, 10);
12482
- return parsed.toLocaleDateString("en-US", {
12483
- month: "long",
12484
- day: "numeric",
12485
- year: "numeric",
12486
- timeZone: "UTC"
12487
- });
12604
+ function hasPrepareMethod(db) {
12605
+ return typeof db === "object" && db !== null && "prepare" in db && typeof db.prepare === "function";
12488
12606
  }
12489
- function formatTemporalRecallText(rows, meta) {
12490
- const parts = [formatTemporalDate(meta.start)];
12491
- const groups = new Map;
12492
- for (const row of rows) {
12493
- const label = temporalGroupLabel(row);
12494
- groups.set(label, [...groups.get(label) ?? [], row]);
12607
+ function getRawDb(db) {
12608
+ if (typeof db === "object" && db !== null && "db" in db && db.db !== null && hasPrepareMethod(db.db)) {
12609
+ return db.db;
12495
12610
  }
12496
- for (const label of ["Sessions", "Source Activity", "Events", "Memories Captured"]) {
12497
- const group = groups.get(label);
12498
- if (!group || group.length === 0)
12499
- continue;
12500
- parts.push("", label, ...group.map((row) => formatRecallRow(row)));
12611
+ if (hasPrepareMethod(db)) {
12612
+ return db;
12501
12613
  }
12502
- return parts.join(`
12503
- `);
12614
+ return null;
12504
12615
  }
12505
- function formatRecallText(raw) {
12506
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
12507
- return typeof raw === "string" ? raw : JSON.stringify(raw, null, 2);
12508
- }
12509
- const payload = raw;
12510
- const parsed = parseRecallPayload(payload);
12511
- if (parsed.message && parsed.rows.length === 0)
12512
- return parsed.message;
12513
- if (parsed.meta.noHits || parsed.rows.length === 0)
12514
- return "No matching memories found.";
12515
- const { primary, supporting } = partitionRecallRows(parsed.rows);
12516
- if (parsed.meta.temporal?.mode === "timeline")
12517
- return formatTemporalRecallText(primary, parsed.meta.temporal);
12518
- const noun = parsed.meta.totalReturned === 1 ? "memory" : "memories";
12519
- const parts = payload.aggregate?.partial === true && typeof payload.aggregate.message === "string" ? [
12520
- payload.aggregate.message,
12521
- "",
12522
- `Found ${parsed.meta.totalReturned} ${noun}${parsed.method ? ` (${parsed.method})` : ""}.`
12523
- ] : [`Found ${parsed.meta.totalReturned} ${noun}${parsed.method ? ` (${parsed.method})` : ""}.`];
12524
- if (primary.length > 0) {
12525
- parts.push("", "Primary matches:", ...primary.map((row) => formatRecallRow(row)));
12616
+ async function search(db, options) {
12617
+ const { query, limit = 10, alpha = DEFAULT_HYBRID_ALPHA, minScore = 0.1, topK = 50 } = options;
12618
+ const rawDb = getRawDb(db);
12619
+ if (rawDb) {
12620
+ const results = hybridSearch(rawDb, null, query, {
12621
+ limit,
12622
+ alpha,
12623
+ minScore,
12624
+ topK,
12625
+ type: options.type
12626
+ });
12627
+ if (results.length > 0) {
12628
+ return results;
12629
+ }
12526
12630
  }
12527
- if (supporting.length > 0) {
12528
- parts.push("", "Supporting context:", ...supporting.map((row) => formatRecallRow(row)));
12631
+ try {
12632
+ const wrapper = db;
12633
+ const memories = typeof wrapper.getMemories === "function" ? wrapper.getMemories(options.type) : [];
12634
+ return memories.filter((m) => m.content.toLowerCase().includes(query.toLowerCase())).slice(0, limit).map((m) => ({
12635
+ id: m.id,
12636
+ content: m.content,
12637
+ score: 1,
12638
+ type: m.type,
12639
+ source: "keyword",
12640
+ tags: m.tags,
12641
+ confidence: m.confidence
12642
+ }));
12643
+ } catch {
12644
+ return [];
12529
12645
  }
12530
- return parts.join(`
12531
- `);
12532
- }
12533
- function buildRecallRequestBody(query, options = {}) {
12534
- return withDefined({
12535
- query,
12536
- keywordQuery: options.keywordQuery ?? options.keyword_query,
12537
- limit: normalizeRecallLimit(options.limit),
12538
- project: options.project,
12539
- type: options.type,
12540
- tags: options.tags,
12541
- who: options.who,
12542
- pinned: options.pinned === true ? true : undefined,
12543
- importance_min: options.importance_min,
12544
- since: options.since,
12545
- until: options.until,
12546
- time: options.time,
12547
- expand: options.expand === true ? true : undefined,
12548
- agentId: options.agentId ?? options.agent_id ?? options.contextAgentId,
12549
- sessionKey: options.sessionKey ?? options.session_key,
12550
- includeRecalled: options.includeRecalled === true || options.include_recalled === true ? true : undefined,
12551
- scope: options.scope,
12552
- sourceOnly: options.sourceOnly === true || options.source_only === true ? true : undefined,
12553
- aggregate: options.aggregate === true ? true : undefined,
12554
- aggregateBudget: options.aggregateBudget ?? options.aggregate_budget,
12555
- saveAggregate: options.saveAggregate === false || options.save_aggregate === false ? false : options.saveAggregate === true || options.save_aggregate === true ? true : undefined
12556
- });
12557
- }
12558
- function normalizeStructuredMemoryPayload(value) {
12559
- if (!isRecord3(value))
12560
- return value;
12561
- const aspects = value.aspects;
12562
- if (!Array.isArray(aspects))
12563
- return value;
12564
- return {
12565
- ...value,
12566
- aspects: aspects.map((aspect) => {
12567
- if (!isRecord3(aspect))
12568
- return aspect;
12569
- if (typeof aspect.entityName === "string" && Array.isArray(aspect.attributes))
12570
- return aspect;
12571
- if (typeof aspect.entity === "string" && typeof aspect.aspect === "string" && typeof aspect.value === "string") {
12572
- return {
12573
- entityName: aspect.entity,
12574
- aspect: aspect.aspect,
12575
- attributes: [
12576
- withDefined({
12577
- content: aspect.value,
12578
- groupKey: typeof aspect.groupKey === "string" ? aspect.groupKey : undefined,
12579
- claimKey: typeof aspect.claimKey === "string" ? aspect.claimKey : undefined,
12580
- confidence: typeof aspect.confidence === "number" ? aspect.confidence : undefined,
12581
- importance: typeof aspect.importance === "number" ? aspect.importance : undefined
12582
- })
12583
- ]
12584
- };
12585
- }
12586
- return aspect;
12587
- })
12588
- };
12589
- }
12590
- function buildRememberRequestBody(content, options = {}) {
12591
- return withDefined({
12592
- content,
12593
- type: options.type,
12594
- importance: options.importance,
12595
- tags: normalizeRememberTags(options.tags),
12596
- who: options.who,
12597
- pinned: options.pinned === true ? true : undefined,
12598
- sourceType: options.sourceType,
12599
- sourceId: options.sourceId,
12600
- sourcePath: options.sourcePath,
12601
- createdAt: options.createdAt,
12602
- occurredAt: options.occurredAt,
12603
- observedAt: options.observedAt,
12604
- validFrom: options.validFrom,
12605
- validUntil: options.validUntil,
12606
- sourceCreatedAt: options.sourceCreatedAt,
12607
- hints: options.hints,
12608
- transcript: options.transcript,
12609
- structured: normalizeStructuredMemoryPayload(options.structured),
12610
- agentId: options.agentId,
12611
- visibility: options.visibility,
12612
- mode: options.mode,
12613
- idempotencyKey: options.idempotencyKey,
12614
- runtimePath: options.runtimePath,
12615
- harness: options.harness,
12616
- source: options.source
12617
- });
12618
- }
12619
- function withHookRecallCompat(result) {
12620
- return {
12621
- ...result,
12622
- memories: result.results,
12623
- count: result.results.length,
12624
- message: formatRecallText(result)
12625
- };
12626
- }
12627
- function emptyHookRecallResponse(query, extras) {
12628
- const response = {
12629
- results: [],
12630
- memories: [],
12631
- count: 0,
12632
- query,
12633
- method: "hybrid",
12634
- meta: {
12635
- totalReturned: 0,
12636
- hasSupplementary: false,
12637
- noHits: true
12638
- },
12639
- message: "No matching memories found."
12640
- };
12641
- return {
12642
- ...response,
12643
- ...extras?.bypassed ? { bypassed: true } : {},
12644
- ...extras?.internal ? { internal: true } : {}
12645
- };
12646
12646
  }
12647
12647
  // src/migrate.ts
12648
12648
  async function migrate(options) {
package/dist/recall.d.ts CHANGED
@@ -119,7 +119,8 @@ export interface RecallRequestOptions {
119
119
  readonly session_key?: string;
120
120
  readonly includeRecalled?: boolean;
121
121
  readonly include_recalled?: boolean;
122
- readonly scope?: "global" | "agent" | "session";
122
+ /** Exact daemon memory-scope string; agent/session isolation use their dedicated fields. */
123
+ readonly scope?: string;
123
124
  readonly sourceOnly?: boolean;
124
125
  readonly source_only?: boolean;
125
126
  readonly aggregate?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../src/recall.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,SAAU,SAAQ,sBAAsB;IACxD,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACj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,EAAE,MAAM,CAAA;CAAE,CAO3F;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GACnE;IACF,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC5B,CAmBA"}
package/dist/recall.js ADDED
@@ -0,0 +1,317 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
34
+
35
+ // src/recall.ts
36
+ function isRecord(value) {
37
+ return typeof value === "object" && value !== null && !Array.isArray(value);
38
+ }
39
+ function withDefined(value) {
40
+ return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
41
+ }
42
+ function normalizeRememberTags(tags) {
43
+ if (typeof tags === "string") {
44
+ const value = tags.split(",").map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
45
+ return value.length > 0 ? value : undefined;
46
+ }
47
+ if (Array.isArray(tags)) {
48
+ const value = tags.map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
49
+ return value.length > 0 ? value : undefined;
50
+ }
51
+ return;
52
+ }
53
+ function normalizeRecallLimit(limit) {
54
+ if (typeof limit !== "number" || !Number.isFinite(limit))
55
+ return 10;
56
+ return Math.min(100, Math.max(1, Math.trunc(limit)));
57
+ }
58
+ function partitionRecallRows(rows) {
59
+ return {
60
+ primary: rows.filter((row) => row.supplementary !== true),
61
+ supporting: rows.filter((row) => row.supplementary === true)
62
+ };
63
+ }
64
+ function parseRecallMeta(raw, fallbackCount) {
65
+ if (!isRecord(raw)) {
66
+ return {
67
+ totalReturned: fallbackCount,
68
+ hasSupplementary: false,
69
+ noHits: fallbackCount === 0
70
+ };
71
+ }
72
+ const totalReturned = typeof raw.totalReturned === "number" ? raw.totalReturned : fallbackCount;
73
+ const hasSupplementary = raw.hasSupplementary === true;
74
+ const noHits = "noHits" in raw ? raw.noHits === true : totalReturned === 0;
75
+ const dedupe = isRecord(raw.dedupe) ? {
76
+ enabled: raw.dedupe.enabled === true,
77
+ contextEpoch: typeof raw.dedupe.contextEpoch === "number" ? raw.dedupe.contextEpoch : undefined,
78
+ suppressed: typeof raw.dedupe.suppressed === "number" ? raw.dedupe.suppressed : 0,
79
+ repeatedReturned: typeof raw.dedupe.repeatedReturned === "number" ? raw.dedupe.repeatedReturned : 0
80
+ } : undefined;
81
+ const temporal = isRecord(raw.temporal) ? raw.temporal : undefined;
82
+ return { totalReturned, hasSupplementary, noHits, ...dedupe ? { dedupe } : {}, ...temporal ? { temporal } : {} };
83
+ }
84
+ function parseRecallPayload(raw) {
85
+ const payload = isRecord(raw) ? raw : {};
86
+ const results = Array.isArray(payload.results) ? payload.results : Array.isArray(payload.memories) ? payload.memories : [];
87
+ const rows = results.filter(isRecord);
88
+ return {
89
+ query: typeof payload.query === "string" ? payload.query : undefined,
90
+ method: typeof payload.method === "string" ? payload.method : undefined,
91
+ rows,
92
+ meta: parseRecallMeta(payload.meta, rows.length),
93
+ message: typeof payload.message === "string" ? payload.message : undefined
94
+ };
95
+ }
96
+ function applyRecallScoreThreshold(raw, minScore) {
97
+ if (typeof minScore !== "number" || !Number.isFinite(minScore) || typeof raw !== "object" || raw === null || Array.isArray(raw)) {
98
+ return raw;
99
+ }
100
+ const payload = raw;
101
+ const rows = Array.isArray(payload.results) ? payload.results : [];
102
+ const filtered = rows.filter((row) => typeof row.score !== "number" || row.score >= minScore);
103
+ return {
104
+ ...payload,
105
+ results: filtered,
106
+ meta: {
107
+ ...isRecord(payload.meta) ? payload.meta : {},
108
+ totalReturned: filtered.length,
109
+ hasSupplementary: filtered.some((row) => row.supplementary === true),
110
+ noHits: filtered.length === 0
111
+ }
112
+ };
113
+ }
114
+ function formatDate(value) {
115
+ return typeof value === "string" && value.length > 0 ? value.slice(0, 10) : "unknown";
116
+ }
117
+ function formatRecallRow(row, options) {
118
+ const score = typeof row.score === "number" ? `[${(row.score * 100).toFixed(0)}%] ` : "";
119
+ const source = typeof row.source === "string" ? row.source : "unknown";
120
+ const type = typeof row.type === "string" ? row.type : "memory";
121
+ const who = typeof row.who === "string" && row.who.length > 0 ? `, by ${row.who}` : "";
122
+ const createdAt = formatDate(row.created_at);
123
+ const id = typeof row.id === "string" && row.id.length > 0 ? `id: ${row.id}; ` : "";
124
+ const prefix = options?.includeIndex ? `${options.includeIndex}. ` : "- ";
125
+ return `${prefix}${score}${id}${row.content ?? ""} (${type}, ${source}, ${createdAt}${who})`;
126
+ }
127
+ function temporalGroupLabel(row) {
128
+ if (row.temporal_facet === "session")
129
+ return "Sessions";
130
+ if (row.temporal_facet === "source")
131
+ return "Source Activity";
132
+ if (row.temporal_facet === "occurred" || row.temporal_facet === "observed" || row.temporal_facet === "valid") {
133
+ return "Events";
134
+ }
135
+ return "Memories Captured";
136
+ }
137
+ function formatTemporalDate(value) {
138
+ const parsed = new Date(value);
139
+ if (Number.isNaN(parsed.getTime()))
140
+ return value.slice(0, 10);
141
+ return parsed.toLocaleDateString("en-US", {
142
+ month: "long",
143
+ day: "numeric",
144
+ year: "numeric",
145
+ timeZone: "UTC"
146
+ });
147
+ }
148
+ function formatTemporalRecallText(rows, meta) {
149
+ const parts = [formatTemporalDate(meta.start)];
150
+ const groups = new Map;
151
+ for (const row of rows) {
152
+ const label = temporalGroupLabel(row);
153
+ groups.set(label, [...groups.get(label) ?? [], row]);
154
+ }
155
+ for (const label of ["Sessions", "Source Activity", "Events", "Memories Captured"]) {
156
+ const group = groups.get(label);
157
+ if (!group || group.length === 0)
158
+ continue;
159
+ parts.push("", label, ...group.map((row) => formatRecallRow(row)));
160
+ }
161
+ return parts.join(`
162
+ `);
163
+ }
164
+ function formatRecallText(raw) {
165
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
166
+ return typeof raw === "string" ? raw : JSON.stringify(raw, null, 2);
167
+ }
168
+ const payload = raw;
169
+ const parsed = parseRecallPayload(payload);
170
+ if (parsed.message && parsed.rows.length === 0)
171
+ return parsed.message;
172
+ if (parsed.meta.noHits || parsed.rows.length === 0)
173
+ return "No matching memories found.";
174
+ const { primary, supporting } = partitionRecallRows(parsed.rows);
175
+ if (parsed.meta.temporal?.mode === "timeline")
176
+ return formatTemporalRecallText(primary, parsed.meta.temporal);
177
+ const noun = parsed.meta.totalReturned === 1 ? "memory" : "memories";
178
+ const parts = payload.aggregate?.partial === true && typeof payload.aggregate.message === "string" ? [
179
+ payload.aggregate.message,
180
+ "",
181
+ `Found ${parsed.meta.totalReturned} ${noun}${parsed.method ? ` (${parsed.method})` : ""}.`
182
+ ] : [`Found ${parsed.meta.totalReturned} ${noun}${parsed.method ? ` (${parsed.method})` : ""}.`];
183
+ if (primary.length > 0) {
184
+ parts.push("", "Primary matches:", ...primary.map((row) => formatRecallRow(row)));
185
+ }
186
+ if (supporting.length > 0) {
187
+ parts.push("", "Supporting context:", ...supporting.map((row) => formatRecallRow(row)));
188
+ }
189
+ return parts.join(`
190
+ `);
191
+ }
192
+ function buildRecallRequestBody(query, options = {}) {
193
+ return withDefined({
194
+ query,
195
+ keywordQuery: options.keywordQuery ?? options.keyword_query,
196
+ limit: normalizeRecallLimit(options.limit),
197
+ project: options.project,
198
+ type: options.type,
199
+ tags: options.tags,
200
+ who: options.who,
201
+ pinned: options.pinned === true ? true : undefined,
202
+ importance_min: options.importance_min,
203
+ since: options.since,
204
+ until: options.until,
205
+ time: options.time,
206
+ expand: options.expand === true ? true : undefined,
207
+ agentId: options.agentId ?? options.agent_id ?? options.contextAgentId,
208
+ sessionKey: options.sessionKey ?? options.session_key,
209
+ includeRecalled: options.includeRecalled === true || options.include_recalled === true ? true : undefined,
210
+ scope: options.scope,
211
+ sourceOnly: options.sourceOnly === true || options.source_only === true ? true : undefined,
212
+ aggregate: options.aggregate === true ? true : undefined,
213
+ aggregateBudget: options.aggregateBudget ?? options.aggregate_budget,
214
+ saveAggregate: options.saveAggregate === false || options.save_aggregate === false ? false : options.saveAggregate === true || options.save_aggregate === true ? true : undefined
215
+ });
216
+ }
217
+ function normalizeStructuredMemoryPayload(value) {
218
+ if (!isRecord(value))
219
+ return value;
220
+ const aspects = value.aspects;
221
+ if (!Array.isArray(aspects))
222
+ return value;
223
+ return {
224
+ ...value,
225
+ aspects: aspects.map((aspect) => {
226
+ if (!isRecord(aspect))
227
+ return aspect;
228
+ if (typeof aspect.entityName === "string" && Array.isArray(aspect.attributes))
229
+ return aspect;
230
+ if (typeof aspect.entity === "string" && typeof aspect.aspect === "string" && typeof aspect.value === "string") {
231
+ return {
232
+ entityName: aspect.entity,
233
+ aspect: aspect.aspect,
234
+ attributes: [
235
+ withDefined({
236
+ content: aspect.value,
237
+ groupKey: typeof aspect.groupKey === "string" ? aspect.groupKey : undefined,
238
+ claimKey: typeof aspect.claimKey === "string" ? aspect.claimKey : undefined,
239
+ confidence: typeof aspect.confidence === "number" ? aspect.confidence : undefined,
240
+ importance: typeof aspect.importance === "number" ? aspect.importance : undefined
241
+ })
242
+ ]
243
+ };
244
+ }
245
+ return aspect;
246
+ })
247
+ };
248
+ }
249
+ function buildRememberRequestBody(content, options = {}) {
250
+ return withDefined({
251
+ content,
252
+ type: options.type,
253
+ importance: options.importance,
254
+ tags: normalizeRememberTags(options.tags),
255
+ who: options.who,
256
+ pinned: options.pinned === true ? true : undefined,
257
+ sourceType: options.sourceType,
258
+ sourceId: options.sourceId,
259
+ sourcePath: options.sourcePath,
260
+ createdAt: options.createdAt,
261
+ occurredAt: options.occurredAt,
262
+ observedAt: options.observedAt,
263
+ validFrom: options.validFrom,
264
+ validUntil: options.validUntil,
265
+ sourceCreatedAt: options.sourceCreatedAt,
266
+ hints: options.hints,
267
+ transcript: options.transcript,
268
+ structured: normalizeStructuredMemoryPayload(options.structured),
269
+ agentId: options.agentId,
270
+ visibility: options.visibility,
271
+ mode: options.mode,
272
+ idempotencyKey: options.idempotencyKey,
273
+ runtimePath: options.runtimePath,
274
+ harness: options.harness,
275
+ source: options.source
276
+ });
277
+ }
278
+ function withHookRecallCompat(result) {
279
+ return {
280
+ ...result,
281
+ memories: result.results,
282
+ count: result.results.length,
283
+ message: formatRecallText(result)
284
+ };
285
+ }
286
+ function emptyHookRecallResponse(query, extras) {
287
+ const response = {
288
+ results: [],
289
+ memories: [],
290
+ count: 0,
291
+ query,
292
+ method: "hybrid",
293
+ meta: {
294
+ totalReturned: 0,
295
+ hasSupplementary: false,
296
+ noHits: true
297
+ },
298
+ message: "No matching memories found."
299
+ };
300
+ return {
301
+ ...response,
302
+ ...extras?.bypassed ? { bypassed: true } : {},
303
+ ...extras?.internal ? { internal: true } : {}
304
+ };
305
+ }
306
+ export {
307
+ withHookRecallCompat,
308
+ partitionRecallRows,
309
+ parseRecallPayload,
310
+ parseRecallMeta,
311
+ normalizeStructuredMemoryPayload,
312
+ formatRecallText,
313
+ emptyHookRecallResponse,
314
+ buildRememberRequestBody,
315
+ buildRecallRequestBody,
316
+ applyRecallScoreThreshold
317
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/core",
3
- "version": "0.147.21",
3
+ "version": "0.147.24",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Core library for Signet - portable AI agent identity",
6
6
  "type": "module",
@@ -18,6 +18,10 @@
18
18
  "./llm-model-catalog": {
19
19
  "import": "./dist/llm-model-catalog.js",
20
20
  "types": "./dist/llm-model-catalog.d.ts"
21
+ },
22
+ "./recall": {
23
+ "import": "./dist/recall.js",
24
+ "types": "./dist/recall.d.ts"
21
25
  }
22
26
  },
23
27
  "files": [
@@ -26,7 +30,7 @@
26
30
  "!dist/**/__tests__/**"
27
31
  ],
28
32
  "scripts": {
29
- "build": "bun build ./src/index.ts ./src/pipeline-providers.ts ./src/llm-model-catalog.ts --outdir ./dist --target node --external better-sqlite3 && bun run build:types",
33
+ "build": "bun build ./src/index.ts ./src/pipeline-providers.ts ./src/llm-model-catalog.ts ./src/recall.ts --outdir ./dist --target node --external better-sqlite3 && bun run build:types",
30
34
  "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
31
35
  "dev": "bun --watch src/index.ts",
32
36
  "test": "bun test",