@signetai/signet-memory-openclaw 0.102.4 → 0.102.5
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.d.ts +9 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +199 -28
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* All operations route through daemon APIs with the "plugin" runtime
|
|
9
9
|
* path for dedup safety.
|
|
10
10
|
*/
|
|
11
|
+
import type { RecallPayload, RecallRow } from "@signet/core";
|
|
11
12
|
import type { OpenClawPluginApi } from "./openclaw-types.js";
|
|
12
13
|
export interface SignetConfig {
|
|
13
14
|
enabled?: boolean;
|
|
@@ -52,14 +53,6 @@ interface MemoryRecord {
|
|
|
52
53
|
created_at: string;
|
|
53
54
|
updated_at: string;
|
|
54
55
|
}
|
|
55
|
-
interface RecallResult {
|
|
56
|
-
id: string;
|
|
57
|
-
content: string;
|
|
58
|
-
type: string;
|
|
59
|
-
importance: number;
|
|
60
|
-
score: number;
|
|
61
|
-
created_at: string;
|
|
62
|
-
}
|
|
63
56
|
interface MarketplaceToolEntry {
|
|
64
57
|
id: string;
|
|
65
58
|
serverId: string;
|
|
@@ -123,12 +116,18 @@ export declare function onSessionEnd(harness: string, options?: {
|
|
|
123
116
|
cwd?: string;
|
|
124
117
|
reason?: string;
|
|
125
118
|
}): Promise<SessionEndResult | null>;
|
|
119
|
+
export declare function memoryRecall(query: string, options?: {
|
|
120
|
+
daemonUrl?: string;
|
|
121
|
+
limit?: number;
|
|
122
|
+
type?: string;
|
|
123
|
+
minScore?: number;
|
|
124
|
+
}): Promise<RecallPayload | null>;
|
|
126
125
|
export declare function memorySearch(query: string, options?: {
|
|
127
126
|
daemonUrl?: string;
|
|
128
127
|
limit?: number;
|
|
129
128
|
type?: string;
|
|
130
129
|
minScore?: number;
|
|
131
|
-
}): Promise<
|
|
130
|
+
}): Promise<RecallRow[]>;
|
|
132
131
|
export declare function memoryStore(content: string, options?: {
|
|
133
132
|
daemonUrl?: string;
|
|
134
133
|
type?: string;
|
|
@@ -183,7 +182,7 @@ export declare function recall(query: string, options?: {
|
|
|
183
182
|
limit?: number;
|
|
184
183
|
type?: string;
|
|
185
184
|
minScore?: number;
|
|
186
|
-
}): Promise<
|
|
185
|
+
}): Promise<RecallRow[]>;
|
|
187
186
|
export declare function cleanupTimedMap(map: Map<string, number>, now: number, ttlMs?: number): void;
|
|
188
187
|
/**
|
|
189
188
|
* Inject the routing metadata block as system[0] if not already present.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAeH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EACX,iBAAiB,EAQjB,MAAM,qBAAqB,CAAC;AA0H7B,MAAM,WAAW,YAAY;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE,KAAK,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IACnC,a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AAE,MAAM,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzD;AAED;;;GAGG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAoB7D;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAelE;AAID,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAM/C;AAED;;;GAGG;AACH,iBAAS,wBAAwB,IAAI,MAAM,GAAG,SAAS,CAoBtD;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAQlF;AAED,iBAAS,qBAAqB,IAAI,MAAM,IAAI,CA6C3C;AAID;;;;;GAKG;AACH,iBAAS,oBAAoB,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,SAAS,CA8BjF;AAED,iBAAS,mBAAmB,IAAI,MAAM,IAAI,CA+CzC;AAwRD,QAAA,MAAM,YAAY;;;;;;qBA/nBJ,OAAO,GAAG,YAAY;;kBAsoBrB,iBAAiB,GAAG,IAAI;CAk6BtC,CAAC;AAEF,2FAA2F;AAC3F,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC;AAED,kEAAkE;AAClE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAchB,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9594,6 +9594,179 @@ try {
|
|
|
9594
9594
|
const esmRequire = createRequire22(import.meta.url);
|
|
9595
9595
|
native = esmRequire("@signet/native");
|
|
9596
9596
|
} catch {}
|
|
9597
|
+
function isRecord2(value) {
|
|
9598
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9599
|
+
}
|
|
9600
|
+
function withDefined(value) {
|
|
9601
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
9602
|
+
}
|
|
9603
|
+
function normalizeRememberTags(tags) {
|
|
9604
|
+
if (typeof tags === "string") {
|
|
9605
|
+
const value = tags.split(",").map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
|
|
9606
|
+
return value.length > 0 ? value : undefined;
|
|
9607
|
+
}
|
|
9608
|
+
if (Array.isArray(tags)) {
|
|
9609
|
+
const value = tags.map((tag) => tag.trim()).filter((tag) => tag.length > 0).join(",");
|
|
9610
|
+
return value.length > 0 ? value : undefined;
|
|
9611
|
+
}
|
|
9612
|
+
return;
|
|
9613
|
+
}
|
|
9614
|
+
function partitionRecallRows(rows) {
|
|
9615
|
+
return {
|
|
9616
|
+
primary: rows.filter((row) => row.supplementary !== true),
|
|
9617
|
+
supporting: rows.filter((row) => row.supplementary === true)
|
|
9618
|
+
};
|
|
9619
|
+
}
|
|
9620
|
+
function parseRecallMeta(raw, fallbackCount) {
|
|
9621
|
+
if (!isRecord2(raw)) {
|
|
9622
|
+
return {
|
|
9623
|
+
totalReturned: fallbackCount,
|
|
9624
|
+
hasSupplementary: false,
|
|
9625
|
+
noHits: fallbackCount === 0
|
|
9626
|
+
};
|
|
9627
|
+
}
|
|
9628
|
+
const totalReturned = typeof raw.totalReturned === "number" ? raw.totalReturned : fallbackCount;
|
|
9629
|
+
const hasSupplementary = raw.hasSupplementary === true;
|
|
9630
|
+
const noHits = "noHits" in raw ? raw.noHits === true : totalReturned === 0;
|
|
9631
|
+
return { totalReturned, hasSupplementary, noHits };
|
|
9632
|
+
}
|
|
9633
|
+
function parseRecallPayload(raw) {
|
|
9634
|
+
const payload = isRecord2(raw) ? raw : {};
|
|
9635
|
+
const results = Array.isArray(payload.results) ? payload.results : Array.isArray(payload.memories) ? payload.memories : [];
|
|
9636
|
+
const rows = results.filter(isRecord2);
|
|
9637
|
+
return {
|
|
9638
|
+
query: typeof payload.query === "string" ? payload.query : undefined,
|
|
9639
|
+
method: typeof payload.method === "string" ? payload.method : undefined,
|
|
9640
|
+
rows,
|
|
9641
|
+
meta: parseRecallMeta(payload.meta, rows.length),
|
|
9642
|
+
message: typeof payload.message === "string" ? payload.message : undefined
|
|
9643
|
+
};
|
|
9644
|
+
}
|
|
9645
|
+
function applyRecallScoreThreshold(raw, minScore) {
|
|
9646
|
+
if (typeof minScore !== "number" || !Number.isFinite(minScore) || typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
9647
|
+
return raw;
|
|
9648
|
+
}
|
|
9649
|
+
const payload = raw;
|
|
9650
|
+
const rows = Array.isArray(payload.results) ? payload.results : [];
|
|
9651
|
+
const filtered = rows.filter((row) => typeof row.score !== "number" || row.score >= minScore);
|
|
9652
|
+
return {
|
|
9653
|
+
...payload,
|
|
9654
|
+
results: filtered,
|
|
9655
|
+
meta: {
|
|
9656
|
+
totalReturned: filtered.length,
|
|
9657
|
+
hasSupplementary: filtered.some((row) => row.supplementary === true),
|
|
9658
|
+
noHits: filtered.length === 0
|
|
9659
|
+
}
|
|
9660
|
+
};
|
|
9661
|
+
}
|
|
9662
|
+
function formatDate(value) {
|
|
9663
|
+
return typeof value === "string" && value.length > 0 ? value.slice(0, 10) : "unknown";
|
|
9664
|
+
}
|
|
9665
|
+
function formatRecallRow(row, options) {
|
|
9666
|
+
const score = typeof row.score === "number" ? `[${(row.score * 100).toFixed(0)}%] ` : "";
|
|
9667
|
+
const source = typeof row.source === "string" ? row.source : "unknown";
|
|
9668
|
+
const type = typeof row.type === "string" ? row.type : "memory";
|
|
9669
|
+
const who = typeof row.who === "string" && row.who.length > 0 ? `, by ${row.who}` : "";
|
|
9670
|
+
const createdAt = formatDate(row.created_at);
|
|
9671
|
+
const id = typeof row.id === "string" && row.id.length > 0 ? `id: ${row.id}; ` : "";
|
|
9672
|
+
const prefix = options?.includeIndex ? `${options.includeIndex}. ` : "- ";
|
|
9673
|
+
return `${prefix}${score}${id}${row.content ?? ""} (${type}, ${source}, ${createdAt}${who})`;
|
|
9674
|
+
}
|
|
9675
|
+
function formatRecallText(raw) {
|
|
9676
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
9677
|
+
return typeof raw === "string" ? raw : JSON.stringify(raw, null, 2);
|
|
9678
|
+
}
|
|
9679
|
+
const payload = raw;
|
|
9680
|
+
const parsed = parseRecallPayload(payload);
|
|
9681
|
+
if (parsed.message && parsed.rows.length === 0)
|
|
9682
|
+
return parsed.message;
|
|
9683
|
+
if (parsed.meta.noHits || parsed.rows.length === 0)
|
|
9684
|
+
return "No matching memories found.";
|
|
9685
|
+
const { primary, supporting } = partitionRecallRows(parsed.rows);
|
|
9686
|
+
const noun = parsed.meta.totalReturned === 1 ? "memory" : "memories";
|
|
9687
|
+
const parts = [`Found ${parsed.meta.totalReturned} ${noun}${parsed.method ? ` (${parsed.method})` : ""}.`];
|
|
9688
|
+
if (primary.length > 0) {
|
|
9689
|
+
parts.push("", "Primary matches:", ...primary.map((row) => formatRecallRow(row)));
|
|
9690
|
+
}
|
|
9691
|
+
if (supporting.length > 0) {
|
|
9692
|
+
parts.push("", "Supporting context:", ...supporting.map((row) => formatRecallRow(row)));
|
|
9693
|
+
}
|
|
9694
|
+
return parts.join(`
|
|
9695
|
+
`);
|
|
9696
|
+
}
|
|
9697
|
+
function buildRecallRequestBody(query, options = {}) {
|
|
9698
|
+
return withDefined({
|
|
9699
|
+
query,
|
|
9700
|
+
keywordQuery: options.keywordQuery ?? options.keyword_query,
|
|
9701
|
+
limit: options.limit,
|
|
9702
|
+
project: options.project,
|
|
9703
|
+
type: options.type,
|
|
9704
|
+
tags: options.tags,
|
|
9705
|
+
who: options.who,
|
|
9706
|
+
pinned: options.pinned === true ? true : undefined,
|
|
9707
|
+
importance_min: options.importance_min,
|
|
9708
|
+
since: options.since,
|
|
9709
|
+
until: options.until,
|
|
9710
|
+
expand: options.expand === true ? true : undefined,
|
|
9711
|
+
agentId: options.agentId,
|
|
9712
|
+
scope: options.scope
|
|
9713
|
+
});
|
|
9714
|
+
}
|
|
9715
|
+
function normalizeStructuredMemoryPayload(value) {
|
|
9716
|
+
if (!isRecord2(value))
|
|
9717
|
+
return value;
|
|
9718
|
+
const aspects = value.aspects;
|
|
9719
|
+
if (!Array.isArray(aspects))
|
|
9720
|
+
return value;
|
|
9721
|
+
return {
|
|
9722
|
+
...value,
|
|
9723
|
+
aspects: aspects.map((aspect) => {
|
|
9724
|
+
if (!isRecord2(aspect))
|
|
9725
|
+
return aspect;
|
|
9726
|
+
if (typeof aspect.entityName === "string" && Array.isArray(aspect.attributes))
|
|
9727
|
+
return aspect;
|
|
9728
|
+
if (typeof aspect.entity === "string" && typeof aspect.aspect === "string" && typeof aspect.value === "string") {
|
|
9729
|
+
return {
|
|
9730
|
+
entityName: aspect.entity,
|
|
9731
|
+
aspect: aspect.aspect,
|
|
9732
|
+
attributes: [
|
|
9733
|
+
withDefined({
|
|
9734
|
+
content: aspect.value,
|
|
9735
|
+
groupKey: typeof aspect.groupKey === "string" ? aspect.groupKey : undefined,
|
|
9736
|
+
claimKey: typeof aspect.claimKey === "string" ? aspect.claimKey : undefined,
|
|
9737
|
+
confidence: typeof aspect.confidence === "number" ? aspect.confidence : undefined,
|
|
9738
|
+
importance: typeof aspect.importance === "number" ? aspect.importance : undefined
|
|
9739
|
+
})
|
|
9740
|
+
]
|
|
9741
|
+
};
|
|
9742
|
+
}
|
|
9743
|
+
return aspect;
|
|
9744
|
+
})
|
|
9745
|
+
};
|
|
9746
|
+
}
|
|
9747
|
+
function buildRememberRequestBody(content, options = {}) {
|
|
9748
|
+
return withDefined({
|
|
9749
|
+
content,
|
|
9750
|
+
type: options.type,
|
|
9751
|
+
importance: options.importance,
|
|
9752
|
+
tags: normalizeRememberTags(options.tags),
|
|
9753
|
+
who: options.who,
|
|
9754
|
+
pinned: options.pinned === true ? true : undefined,
|
|
9755
|
+
sourceType: options.sourceType,
|
|
9756
|
+
sourceId: options.sourceId,
|
|
9757
|
+
createdAt: options.createdAt,
|
|
9758
|
+
hints: options.hints,
|
|
9759
|
+
transcript: options.transcript,
|
|
9760
|
+
structured: normalizeStructuredMemoryPayload(options.structured),
|
|
9761
|
+
agentId: options.agentId,
|
|
9762
|
+
visibility: options.visibility,
|
|
9763
|
+
mode: options.mode,
|
|
9764
|
+
idempotencyKey: options.idempotencyKey,
|
|
9765
|
+
runtimePath: options.runtimePath,
|
|
9766
|
+
harness: options.harness,
|
|
9767
|
+
source: options.source
|
|
9768
|
+
});
|
|
9769
|
+
}
|
|
9597
9770
|
var SIGNET_SOURCE_CHECKOUT_DIRNAME = "signetai";
|
|
9598
9771
|
var SIGNET_GIT_PROTECTED_PATHS = [
|
|
9599
9772
|
"memory/memories.db",
|
|
@@ -12704,31 +12877,32 @@ async function onSessionEnd(harness, options = {}) {
|
|
|
12704
12877
|
timeout: WRITE_TIMEOUT
|
|
12705
12878
|
});
|
|
12706
12879
|
}
|
|
12707
|
-
async function
|
|
12880
|
+
async function memoryRecall(query, options = {}) {
|
|
12708
12881
|
const daemonUrl = options.daemonUrl || DEFAULT_DAEMON_URL;
|
|
12709
12882
|
const result = await daemonFetch(daemonUrl, "/api/memory/recall", {
|
|
12710
12883
|
method: "POST",
|
|
12711
|
-
body: {
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
min_score: options.minScore
|
|
12716
|
-
},
|
|
12884
|
+
body: buildRecallRequestBody(query, {
|
|
12885
|
+
limit: options.limit ?? 10,
|
|
12886
|
+
type: options.type
|
|
12887
|
+
}),
|
|
12717
12888
|
timeout: READ_TIMEOUT
|
|
12718
12889
|
});
|
|
12719
|
-
return result
|
|
12890
|
+
return result ? applyRecallScoreThreshold(result, options.minScore) : null;
|
|
12891
|
+
}
|
|
12892
|
+
async function memorySearch(query, options = {}) {
|
|
12893
|
+
const result = await memoryRecall(query, options);
|
|
12894
|
+
return result ? parseRecallPayload(result).rows : [];
|
|
12720
12895
|
}
|
|
12721
12896
|
async function memoryStore(content, options = {}) {
|
|
12722
12897
|
const daemonUrl = options.daemonUrl || DEFAULT_DAEMON_URL;
|
|
12723
12898
|
const result = await daemonFetch(daemonUrl, "/api/memory/remember", {
|
|
12724
12899
|
method: "POST",
|
|
12725
|
-
body: {
|
|
12726
|
-
content,
|
|
12900
|
+
body: buildRememberRequestBody(content, {
|
|
12727
12901
|
type: options.type,
|
|
12728
12902
|
importance: options.importance,
|
|
12729
|
-
tags:
|
|
12903
|
+
tags: options.tags,
|
|
12730
12904
|
who: options.who || "openclaw"
|
|
12731
|
-
},
|
|
12905
|
+
}),
|
|
12732
12906
|
timeout: WRITE_TIMEOUT
|
|
12733
12907
|
});
|
|
12734
12908
|
return result?.id || result?.memoryId || null;
|
|
@@ -12889,10 +13063,7 @@ function injectBillingBlock(body) {
|
|
|
12889
13063
|
return true;
|
|
12890
13064
|
}
|
|
12891
13065
|
if (typeof system === "string") {
|
|
12892
|
-
body.system = [
|
|
12893
|
-
{ ...BILLING_BLOCK },
|
|
12894
|
-
{ type: "text", text: system }
|
|
12895
|
-
];
|
|
13066
|
+
body.system = [{ ...BILLING_BLOCK }, { type: "text", text: system }];
|
|
12896
13067
|
return true;
|
|
12897
13068
|
}
|
|
12898
13069
|
body.system = [{ ...BILLING_BLOCK }];
|
|
@@ -12982,7 +13153,7 @@ function swapAuthHeaders(headers, oauthToken) {
|
|
|
12982
13153
|
delete headers[key];
|
|
12983
13154
|
}
|
|
12984
13155
|
}
|
|
12985
|
-
headers
|
|
13156
|
+
headers.authorization = `Bearer ${oauthToken}`;
|
|
12986
13157
|
}
|
|
12987
13158
|
function installFetchSanitizer() {
|
|
12988
13159
|
const original = globalThis.fetch;
|
|
@@ -13069,10 +13240,11 @@ function installSdkSanitizer() {
|
|
|
13069
13240
|
if (!found)
|
|
13070
13241
|
return false;
|
|
13071
13242
|
Base = found;
|
|
13072
|
-
|
|
13243
|
+
const previous = Base.prototype.prepareRequest;
|
|
13244
|
+
original = previous;
|
|
13073
13245
|
Base.prototype.prepareRequest = async function(request, context) {
|
|
13074
13246
|
sanitizeRequest(request);
|
|
13075
|
-
return
|
|
13247
|
+
return previous.call(this, request, context);
|
|
13076
13248
|
};
|
|
13077
13249
|
return true;
|
|
13078
13250
|
}
|
|
@@ -13335,24 +13507,22 @@ var signetPlugin = {
|
|
|
13335
13507
|
async execute(_toolCallId, params) {
|
|
13336
13508
|
const { query, limit, type, min_score } = params;
|
|
13337
13509
|
try {
|
|
13338
|
-
const
|
|
13510
|
+
const recall2 = await memoryRecall(query, {
|
|
13339
13511
|
...opts,
|
|
13340
13512
|
limit,
|
|
13341
13513
|
type,
|
|
13342
13514
|
minScore: min_score
|
|
13343
13515
|
});
|
|
13344
|
-
|
|
13516
|
+
const parsed = parseRecallPayload(recall2);
|
|
13517
|
+
if (parsed.rows.length === 0) {
|
|
13345
13518
|
return textResult("No relevant memories found.", {
|
|
13346
13519
|
count: 0
|
|
13347
13520
|
});
|
|
13348
13521
|
}
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
${text}`, {
|
|
13354
|
-
count: results.length,
|
|
13355
|
-
memories: results
|
|
13522
|
+
return textResult(formatRecallText(recall2), {
|
|
13523
|
+
count: parsed.rows.length,
|
|
13524
|
+
memories: parsed.rows,
|
|
13525
|
+
meta: parsed.meta
|
|
13356
13526
|
});
|
|
13357
13527
|
} catch (err) {
|
|
13358
13528
|
return textResult(`Memory search failed: ${String(err)}`, { error: String(err) });
|
|
@@ -13949,6 +14119,7 @@ export {
|
|
|
13949
14119
|
onCompactionComplete,
|
|
13950
14120
|
memoryStore,
|
|
13951
14121
|
memorySearch,
|
|
14122
|
+
memoryRecall,
|
|
13952
14123
|
memoryModify,
|
|
13953
14124
|
memoryList,
|
|
13954
14125
|
memoryGet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signetai/signet-memory-openclaw",
|
|
3
|
-
"version": "0.102.
|
|
3
|
+
"version": "0.102.5",
|
|
4
4
|
"description": "Signet adapter for OpenClaw — runtime plugin for AI agent memory",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@sinclair/typebox": "0.34.47"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@signet/core": "0.102.
|
|
39
|
+
"@signet/core": "0.102.5",
|
|
40
40
|
"@types/node": "^22.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|