@remnic/plugin-openclaw 1.0.54 → 9.3.515
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 +510 -2106
- package/openclaw.plugin.json +3 -3
- package/package.json +4 -3
- package/scripts/faiss_index.py +141 -29
- package/dist/calibration-RKL2LRW4.js +0 -250
- package/dist/capsule-cli-EHZPMXBC.js +0 -33
- package/dist/capsule-crypto-JS67OSWM.js +0 -17
- package/dist/capsule-export-DX53CPIT.js +0 -17
- package/dist/capsule-import-4OXCPHOT.js +0 -16
- package/dist/capsule-merge-25AUN33Q.js +0 -195
- package/dist/causal-chain-BVTOWZKC.js +0 -23
- package/dist/causal-consolidation-IAIX53NV.js +0 -233
- package/dist/causal-retrieval-XAP6QKHZ.js +0 -182
- package/dist/causal-trajectory-graph-ZWQWZ7N5.js +0 -59
- package/dist/chunk-25J4PXDH.js +0 -30
- package/dist/chunk-2RQU6GVD.js +0 -453
- package/dist/chunk-3A5ELHTT.js +0 -61
- package/dist/chunk-3G7FAF6S.js +0 -60
- package/dist/chunk-3IKMUNW5.js +0 -177
- package/dist/chunk-4XDQ3KEC.js +0 -4048
- package/dist/chunk-5ZW5XJQ6.js +0 -128
- package/dist/chunk-6IWEAUN6.js +0 -148
- package/dist/chunk-7JOLBJJ5.js +0 -874
- package/dist/chunk-AJECKGY2.js +0 -896
- package/dist/chunk-B52XADV3.js +0 -244
- package/dist/chunk-BQZ7JACP.js +0 -389
- package/dist/chunk-BU5KJVWF.js +0 -78
- package/dist/chunk-BZ4EYURA.js +0 -181
- package/dist/chunk-CEL5ZLKP.js +0 -233
- package/dist/chunk-EH4AXGRO.js +0 -48
- package/dist/chunk-FDK3VJVE.js +0 -1295
- package/dist/chunk-I2KLQ2HA.js +0 -22
- package/dist/chunk-IO5WWY6A.js +0 -156
- package/dist/chunk-JC3FCKYL.js +0 -516
- package/dist/chunk-JZBOXOUC.js +0 -259
- package/dist/chunk-KC7KSQR4.js +0 -302
- package/dist/chunk-LZCGPRHS.js +0 -228
- package/dist/chunk-MBIFE6SA.js +0 -250
- package/dist/chunk-MXFJXUHC.js +0 -292
- package/dist/chunk-NUWDSTP7.js +0 -233
- package/dist/chunk-QCCP4RU5.js +0 -190
- package/dist/chunk-QMUQV5NP.js +0 -146
- package/dist/chunk-QQXJODFL.js +0 -328
- package/dist/chunk-SWOYEQN2.js +0 -1005
- package/dist/chunk-TH5FF5SC.js +0 -16
- package/dist/chunk-TXOEHSVP.js +0 -275
- package/dist/chunk-UFU5GGGA.js +0 -47
- package/dist/chunk-USSDZQKJ.js +0 -6533
- package/dist/chunk-UZJ7EERS.js +0 -272
- package/dist/chunk-VUZEEGP5.js +0 -725
- package/dist/chunk-W6EEFUCJ.js +0 -349
- package/dist/chunk-YGGGUTG3.js +0 -125
- package/dist/chunk-YJYZMLD5.js +0 -360
- package/dist/chunk-YKV4EFUI.js +0 -199
- package/dist/chunk-ZS6VABML.js +0 -185
- package/dist/cipher-E23BHBSO.js +0 -27
- package/dist/consolidation-undo-FKJZCJHS.js +0 -426
- package/dist/contradiction-review-WJRWNQ5N.js +0 -29
- package/dist/contradiction-scan-5X423QGT.js +0 -12
- package/dist/dreams-ledger-KDX44I7R.js +0 -290
- package/dist/engine-O46ZX4EZ.js +0 -16
- package/dist/extraction-judge-telemetry-O4ZVGLTU.js +0 -14
- package/dist/fallback-llm-43UMEXNJ.js +0 -10
- package/dist/first-start-migration-H2SAXAGR.js +0 -263
- package/dist/forget-ZECIDNL5.js +0 -68
- package/dist/fs-utils-OYXSZSVV.js +0 -39
- package/dist/graph-edge-decay-24ZKD5QL.js +0 -202
- package/dist/kdf-RXKIWHRU.js +0 -25
- package/dist/logger-XG7JKLPS.js +0 -9
- package/dist/memory-governance-6BCH6SZ5.js +0 -25
- package/dist/metadata-WK2TRPYZ.js +0 -20
- package/dist/migrate-from-identity-anchor-SNDNKHZD.js +0 -7
- package/dist/path-ZKO74XXC.js +0 -7
- package/dist/peers-W53WSDXG.js +0 -43
- package/dist/purge-IKJISXEQ.js +0 -204
- package/dist/resolution-BN35OXDS.js +0 -11
- package/dist/secure-store-6RWYM6GK.js +0 -155
- package/dist/state-4ITLYMAU.js +0 -7
- package/dist/state-store-ET3ADVY5.js +0 -14
- package/dist/storage-VEGU76NN.js +0 -27
- package/dist/tier-stats-ZRQBV6G2.js +0 -147
- package/dist/trace-IL2Y34EH.js +0 -289
- package/dist/tui-7KRDCMYK.js +0 -12
- package/dist/types-MBUINTB2.js +0 -30
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MIN_PASSPHRASE_LENGTH,
|
|
3
|
-
createPassphraseReader,
|
|
4
|
-
renderDisableReport,
|
|
5
|
-
renderInitReport,
|
|
6
|
-
renderLockReport,
|
|
7
|
-
renderMigrateReport,
|
|
8
|
-
renderStatusReport,
|
|
9
|
-
renderUnlockReport,
|
|
10
|
-
runSecureStoreDisable,
|
|
11
|
-
runSecureStoreInit,
|
|
12
|
-
runSecureStoreLock,
|
|
13
|
-
runSecureStoreMigrate,
|
|
14
|
-
runSecureStoreStatus,
|
|
15
|
-
runSecureStoreUnlock
|
|
16
|
-
} from "./chunk-2RQU6GVD.js";
|
|
17
|
-
import {
|
|
18
|
-
HEADER_FILENAME,
|
|
19
|
-
HEADER_FORMAT,
|
|
20
|
-
HEADER_FORMAT_VERSION,
|
|
21
|
-
SECURE_STORE_DIR_NAME,
|
|
22
|
-
buildHeader,
|
|
23
|
-
buildHeaderFromPassphrase,
|
|
24
|
-
deriveKeyFromHeader,
|
|
25
|
-
headerPath,
|
|
26
|
-
keyring_exports,
|
|
27
|
-
parseHeader,
|
|
28
|
-
readHeader,
|
|
29
|
-
secureStoreDir,
|
|
30
|
-
serializeHeader,
|
|
31
|
-
validateHeader,
|
|
32
|
-
verifyKey,
|
|
33
|
-
writeHeader
|
|
34
|
-
} from "./chunk-MXFJXUHC.js";
|
|
35
|
-
import {
|
|
36
|
-
METADATA_FORMAT,
|
|
37
|
-
METADATA_FORMAT_VERSION,
|
|
38
|
-
buildMetadata,
|
|
39
|
-
decodeMetadataSalt,
|
|
40
|
-
parseMetadata,
|
|
41
|
-
serializeMetadata,
|
|
42
|
-
validateMetadata
|
|
43
|
-
} from "./chunk-JZBOXOUC.js";
|
|
44
|
-
import {
|
|
45
|
-
DEFAULT_ARGON2ID_PARAMS,
|
|
46
|
-
DEFAULT_SCRYPT_PARAMS,
|
|
47
|
-
KDF_KEY_LENGTH,
|
|
48
|
-
KDF_SALT_LENGTH,
|
|
49
|
-
constantTimeEqual,
|
|
50
|
-
deriveKey,
|
|
51
|
-
deriveKeyScrypt,
|
|
52
|
-
validateScryptParams
|
|
53
|
-
} from "./chunk-6IWEAUN6.js";
|
|
54
|
-
import {
|
|
55
|
-
FILE_FORMAT_FLAGS,
|
|
56
|
-
FILE_FORMAT_VERSION,
|
|
57
|
-
MAGIC_BYTES,
|
|
58
|
-
MAGIC_HEADER_SIZE,
|
|
59
|
-
SecureStoreDecryptError,
|
|
60
|
-
SecureStoreLockedError,
|
|
61
|
-
decryptFileBody,
|
|
62
|
-
decryptMemoryDirToPlaintext,
|
|
63
|
-
encryptFileBody,
|
|
64
|
-
filePathAad,
|
|
65
|
-
isEncryptedFile,
|
|
66
|
-
migrateMemoryDirToEncrypted,
|
|
67
|
-
readMaybeEncryptedFile,
|
|
68
|
-
writeMaybeEncryptedFile
|
|
69
|
-
} from "./chunk-BQZ7JACP.js";
|
|
70
|
-
import {
|
|
71
|
-
AES_KEY_LENGTH,
|
|
72
|
-
AUTH_TAG_LENGTH,
|
|
73
|
-
ENVELOPE_HEADER_SIZE,
|
|
74
|
-
ENVELOPE_LAYOUT,
|
|
75
|
-
ENVELOPE_SALT_LENGTH,
|
|
76
|
-
ENVELOPE_VERSION,
|
|
77
|
-
IV_LENGTH,
|
|
78
|
-
generateSalt,
|
|
79
|
-
open,
|
|
80
|
-
parseEnvelope,
|
|
81
|
-
seal
|
|
82
|
-
} from "./chunk-YGGGUTG3.js";
|
|
83
|
-
import "./chunk-I2KLQ2HA.js";
|
|
84
|
-
export {
|
|
85
|
-
AES_KEY_LENGTH,
|
|
86
|
-
AUTH_TAG_LENGTH,
|
|
87
|
-
DEFAULT_ARGON2ID_PARAMS,
|
|
88
|
-
DEFAULT_SCRYPT_PARAMS,
|
|
89
|
-
ENVELOPE_HEADER_SIZE,
|
|
90
|
-
ENVELOPE_LAYOUT,
|
|
91
|
-
ENVELOPE_SALT_LENGTH,
|
|
92
|
-
ENVELOPE_VERSION,
|
|
93
|
-
FILE_FORMAT_FLAGS,
|
|
94
|
-
FILE_FORMAT_VERSION,
|
|
95
|
-
HEADER_FILENAME,
|
|
96
|
-
HEADER_FORMAT,
|
|
97
|
-
HEADER_FORMAT_VERSION,
|
|
98
|
-
IV_LENGTH,
|
|
99
|
-
KDF_KEY_LENGTH,
|
|
100
|
-
KDF_SALT_LENGTH,
|
|
101
|
-
MAGIC_BYTES,
|
|
102
|
-
MAGIC_HEADER_SIZE,
|
|
103
|
-
METADATA_FORMAT,
|
|
104
|
-
METADATA_FORMAT_VERSION,
|
|
105
|
-
MIN_PASSPHRASE_LENGTH,
|
|
106
|
-
SECURE_STORE_DIR_NAME,
|
|
107
|
-
SecureStoreDecryptError,
|
|
108
|
-
SecureStoreLockedError,
|
|
109
|
-
buildHeader,
|
|
110
|
-
buildHeaderFromPassphrase,
|
|
111
|
-
buildMetadata,
|
|
112
|
-
constantTimeEqual,
|
|
113
|
-
createPassphraseReader,
|
|
114
|
-
decodeMetadataSalt,
|
|
115
|
-
decryptFileBody,
|
|
116
|
-
decryptMemoryDirToPlaintext,
|
|
117
|
-
deriveKey,
|
|
118
|
-
deriveKeyFromHeader,
|
|
119
|
-
deriveKeyScrypt,
|
|
120
|
-
encryptFileBody,
|
|
121
|
-
filePathAad,
|
|
122
|
-
generateSalt,
|
|
123
|
-
headerPath,
|
|
124
|
-
isEncryptedFile,
|
|
125
|
-
keyring_exports as keyring,
|
|
126
|
-
migrateMemoryDirToEncrypted,
|
|
127
|
-
open,
|
|
128
|
-
parseEnvelope,
|
|
129
|
-
parseHeader,
|
|
130
|
-
parseMetadata,
|
|
131
|
-
readHeader,
|
|
132
|
-
readMaybeEncryptedFile,
|
|
133
|
-
renderDisableReport,
|
|
134
|
-
renderInitReport,
|
|
135
|
-
renderLockReport,
|
|
136
|
-
renderMigrateReport,
|
|
137
|
-
renderStatusReport,
|
|
138
|
-
renderUnlockReport,
|
|
139
|
-
runSecureStoreDisable,
|
|
140
|
-
runSecureStoreInit,
|
|
141
|
-
runSecureStoreLock,
|
|
142
|
-
runSecureStoreMigrate,
|
|
143
|
-
runSecureStoreStatus,
|
|
144
|
-
runSecureStoreUnlock,
|
|
145
|
-
seal,
|
|
146
|
-
secureStoreDir,
|
|
147
|
-
serializeHeader,
|
|
148
|
-
serializeMetadata,
|
|
149
|
-
validateHeader,
|
|
150
|
-
validateMetadata,
|
|
151
|
-
validateScryptParams,
|
|
152
|
-
verifyKey,
|
|
153
|
-
writeHeader,
|
|
154
|
-
writeMaybeEncryptedFile
|
|
155
|
-
};
|
package/dist/state-4ITLYMAU.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
_connectorStatePathForTest,
|
|
3
|
-
listConnectorStates,
|
|
4
|
-
readConnectorState,
|
|
5
|
-
writeConnectorState
|
|
6
|
-
} from "./chunk-NUWDSTP7.js";
|
|
7
|
-
import "./chunk-EH4AXGRO.js";
|
|
8
|
-
import "./chunk-I2KLQ2HA.js";
|
|
9
|
-
export {
|
|
10
|
-
_connectorStatePathForTest,
|
|
11
|
-
listConnectorStates,
|
|
12
|
-
readConnectorState,
|
|
13
|
-
writeConnectorState
|
|
14
|
-
};
|
package/dist/storage-VEGU76NN.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ContentHashIndex,
|
|
3
|
-
StorageManager,
|
|
4
|
-
compareEntityTimestamps,
|
|
5
|
-
fingerprintEntityStructuredFacts,
|
|
6
|
-
isEntitySynthesisStale,
|
|
7
|
-
normalizeAttributePairs,
|
|
8
|
-
normalizeEntityName,
|
|
9
|
-
parseEntityFile,
|
|
10
|
-
serializeEntityFile
|
|
11
|
-
} from "./chunk-USSDZQKJ.js";
|
|
12
|
-
import "./chunk-QMUQV5NP.js";
|
|
13
|
-
import "./chunk-BQZ7JACP.js";
|
|
14
|
-
import "./chunk-UFU5GGGA.js";
|
|
15
|
-
import "./chunk-YGGGUTG3.js";
|
|
16
|
-
import "./chunk-I2KLQ2HA.js";
|
|
17
|
-
export {
|
|
18
|
-
ContentHashIndex,
|
|
19
|
-
StorageManager,
|
|
20
|
-
compareEntityTimestamps,
|
|
21
|
-
fingerprintEntityStructuredFacts,
|
|
22
|
-
isEntitySynthesisStale,
|
|
23
|
-
normalizeAttributePairs,
|
|
24
|
-
normalizeEntityName,
|
|
25
|
-
parseEntityFile,
|
|
26
|
-
serializeEntityFile
|
|
27
|
-
};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyUtilityPromotionRuntimePolicy,
|
|
3
|
-
computeTierValueScore,
|
|
4
|
-
decideTierTransition,
|
|
5
|
-
loadUtilityRuntimeValues
|
|
6
|
-
} from "./chunk-LZCGPRHS.js";
|
|
7
|
-
import {
|
|
8
|
-
computeLifecycleValueInputs
|
|
9
|
-
} from "./chunk-BZ4EYURA.js";
|
|
10
|
-
import "./chunk-3G7FAF6S.js";
|
|
11
|
-
import "./chunk-25J4PXDH.js";
|
|
12
|
-
import "./chunk-I2KLQ2HA.js";
|
|
13
|
-
|
|
14
|
-
// ../remnic-core/src/maintenance/tier-stats.ts
|
|
15
|
-
async function readTierVisibleMemories(storage) {
|
|
16
|
-
const [hotMemories, coldMemories] = await Promise.all([
|
|
17
|
-
storage.readAllMemories(),
|
|
18
|
-
storage.readAllColdMemories()
|
|
19
|
-
]);
|
|
20
|
-
return [
|
|
21
|
-
...hotMemories.map((memory) => ({ memory, tier: "hot" })),
|
|
22
|
-
...coldMemories.map((memory) => ({ memory, tier: "cold" }))
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
async function tierRoutingPolicyFromConfig(config) {
|
|
26
|
-
const basePolicy = {
|
|
27
|
-
enabled: config.qmdTierMigrationEnabled,
|
|
28
|
-
demotionMinAgeDays: config.qmdTierDemotionMinAgeDays,
|
|
29
|
-
demotionValueThreshold: config.qmdTierDemotionValueThreshold,
|
|
30
|
-
promotionValueThreshold: config.qmdTierPromotionValueThreshold
|
|
31
|
-
};
|
|
32
|
-
const runtime = await loadUtilityRuntimeValues({
|
|
33
|
-
memoryDir: config.memoryDir,
|
|
34
|
-
memoryUtilityLearningEnabled: config.memoryUtilityLearningEnabled,
|
|
35
|
-
promotionByOutcomeEnabled: config.promotionByOutcomeEnabled
|
|
36
|
-
});
|
|
37
|
-
return applyUtilityPromotionRuntimePolicy(basePolicy, runtime);
|
|
38
|
-
}
|
|
39
|
-
async function summarizeTiers(storage) {
|
|
40
|
-
const all = await readTierVisibleMemories(storage);
|
|
41
|
-
const summary = {
|
|
42
|
-
total: all.length,
|
|
43
|
-
byTier: { hot: 0, cold: 0 },
|
|
44
|
-
byStatus: {},
|
|
45
|
-
forgottenCount: 0,
|
|
46
|
-
byCategory: {}
|
|
47
|
-
};
|
|
48
|
-
for (const { memory: m, tier } of all) {
|
|
49
|
-
summary.byTier[tier] += 1;
|
|
50
|
-
const status = m.frontmatter.status ?? "active";
|
|
51
|
-
summary.byStatus[status] = (summary.byStatus[status] ?? 0) + 1;
|
|
52
|
-
if (status === "forgotten") summary.forgottenCount += 1;
|
|
53
|
-
const cat = m.frontmatter.category ?? "(uncategorized)";
|
|
54
|
-
summary.byCategory[cat] = (summary.byCategory[cat] ?? 0) + 1;
|
|
55
|
-
}
|
|
56
|
-
return summary;
|
|
57
|
-
}
|
|
58
|
-
async function explainTierForMemory(storage, id, config) {
|
|
59
|
-
const trimmed = typeof id === "string" ? id.trim() : "";
|
|
60
|
-
if (trimmed.length === 0) {
|
|
61
|
-
throw new Error("tier explain: memory id is required and must be non-empty");
|
|
62
|
-
}
|
|
63
|
-
const all = await readTierVisibleMemories(storage);
|
|
64
|
-
const entry = all.find(({ memory: m }) => m.frontmatter.id === trimmed);
|
|
65
|
-
if (!entry) {
|
|
66
|
-
throw new Error(`tier explain: memory not found: ${trimmed}`);
|
|
67
|
-
}
|
|
68
|
-
const { memory, tier: currentTier } = entry;
|
|
69
|
-
const now = /* @__PURE__ */ new Date();
|
|
70
|
-
const valueInputs = computeLifecycleValueInputs(memory, now);
|
|
71
|
-
const valueScore = computeTierValueScore(memory, now);
|
|
72
|
-
const policy = await tierRoutingPolicyFromConfig(config);
|
|
73
|
-
const decision = decideTierTransition(memory, currentTier, policy, now);
|
|
74
|
-
const fm = memory.frontmatter;
|
|
75
|
-
return {
|
|
76
|
-
id: trimmed,
|
|
77
|
-
path: memory.path,
|
|
78
|
-
currentTier,
|
|
79
|
-
status: typeof fm.status === "string" ? fm.status : "active",
|
|
80
|
-
category: typeof fm.category === "string" ? fm.category : "",
|
|
81
|
-
valueScore,
|
|
82
|
-
decision,
|
|
83
|
-
signals: {
|
|
84
|
-
confidence: valueInputs.confidence,
|
|
85
|
-
accessCount: typeof fm.accessCount === "number" ? fm.accessCount : 0,
|
|
86
|
-
lastAccessed: typeof fm.lastAccessed === "string" ? fm.lastAccessed : null,
|
|
87
|
-
created: typeof fm.created === "string" ? fm.created : "",
|
|
88
|
-
updated: typeof fm.updated === "string" ? fm.updated : "",
|
|
89
|
-
importance: valueInputs.importance,
|
|
90
|
-
feedback: valueInputs.feedback
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function formatTierSummaryText(summary) {
|
|
95
|
-
const lines = [];
|
|
96
|
-
lines.push("=== Memory Tier Distribution ===");
|
|
97
|
-
lines.push(`Total memories: ${summary.total}`);
|
|
98
|
-
lines.push("");
|
|
99
|
-
lines.push("Tier:");
|
|
100
|
-
lines.push(` hot: ${summary.byTier.hot}`);
|
|
101
|
-
lines.push(` cold: ${summary.byTier.cold}`);
|
|
102
|
-
lines.push("");
|
|
103
|
-
lines.push("Status:");
|
|
104
|
-
const statusEntries = Object.entries(summary.byStatus).sort(
|
|
105
|
-
(a, b) => b[1] - a[1] || a[0].localeCompare(b[0])
|
|
106
|
-
);
|
|
107
|
-
for (const [status, count] of statusEntries) {
|
|
108
|
-
lines.push(` ${status}: ${count}`);
|
|
109
|
-
}
|
|
110
|
-
lines.push("");
|
|
111
|
-
lines.push("Top categories:");
|
|
112
|
-
const categoryEntries = Object.entries(summary.byCategory).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 8);
|
|
113
|
-
for (const [cat, count] of categoryEntries) {
|
|
114
|
-
lines.push(` ${cat}: ${count}`);
|
|
115
|
-
}
|
|
116
|
-
return lines.join("\n");
|
|
117
|
-
}
|
|
118
|
-
function formatTierExplainText(explain) {
|
|
119
|
-
const lines = [];
|
|
120
|
-
lines.push(`=== Tier Explain: ${explain.id} ===`);
|
|
121
|
-
lines.push(`path: ${explain.path}`);
|
|
122
|
-
lines.push(`current tier: ${explain.currentTier}`);
|
|
123
|
-
lines.push(`status: ${explain.status}`);
|
|
124
|
-
lines.push(`category: ${explain.category}`);
|
|
125
|
-
lines.push(`value score: ${explain.valueScore.toFixed(3)}`);
|
|
126
|
-
lines.push("");
|
|
127
|
-
lines.push("Tier-transition decision:");
|
|
128
|
-
lines.push(` next tier: ${explain.decision.nextTier}`);
|
|
129
|
-
lines.push(` changed: ${explain.decision.changed}`);
|
|
130
|
-
lines.push(` reason: ${explain.decision.reason}`);
|
|
131
|
-
lines.push("");
|
|
132
|
-
lines.push("Signals:");
|
|
133
|
-
lines.push(` confidence: ${explain.signals.confidence}`);
|
|
134
|
-
lines.push(` accessCount: ${explain.signals.accessCount}`);
|
|
135
|
-
lines.push(` lastAccessed: ${explain.signals.lastAccessed ?? "(never)"}`);
|
|
136
|
-
lines.push(` created: ${explain.signals.created}`);
|
|
137
|
-
lines.push(` updated: ${explain.signals.updated}`);
|
|
138
|
-
lines.push(` importance: ${explain.signals.importance}`);
|
|
139
|
-
lines.push(` feedback: ${explain.signals.feedback}`);
|
|
140
|
-
return lines.join("\n");
|
|
141
|
-
}
|
|
142
|
-
export {
|
|
143
|
-
explainTierForMemory,
|
|
144
|
-
formatTierExplainText,
|
|
145
|
-
formatTierSummaryText,
|
|
146
|
-
summarizeTiers
|
|
147
|
-
};
|
package/dist/trace-IL2Y34EH.js
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
renderFrame
|
|
3
|
-
} from "./chunk-B52XADV3.js";
|
|
4
|
-
import "./chunk-MBIFE6SA.js";
|
|
5
|
-
import "./chunk-I2KLQ2HA.js";
|
|
6
|
-
|
|
7
|
-
// ../remnic-core/src/console/trace.ts
|
|
8
|
-
import { promises as fs } from "fs";
|
|
9
|
-
import path from "path";
|
|
10
|
-
import readline from "readline";
|
|
11
|
-
import { createReadStream } from "fs";
|
|
12
|
-
var ANSI_CLEAR_HOME = "\x1B[2J\x1B[H";
|
|
13
|
-
var ANSI_HIDE_CURSOR = "\x1B[?25l";
|
|
14
|
-
var ANSI_SHOW_CURSOR = "\x1B[?25h";
|
|
15
|
-
var DEFAULT_REPLAY_DELAY_MS = 2e3;
|
|
16
|
-
var MAX_REPLAY_DELAY_MS = 6e4;
|
|
17
|
-
var MIN_REPLAY_DELAY_MS = 0;
|
|
18
|
-
async function openTraceRecorder(filePath, options = {}) {
|
|
19
|
-
const ensureParentDir = options.ensureParentDir ?? true;
|
|
20
|
-
if (ensureParentDir) {
|
|
21
|
-
const parent = path.dirname(filePath);
|
|
22
|
-
if (parent && parent !== "." && parent !== "/") {
|
|
23
|
-
await fs.mkdir(parent, { recursive: true });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const handle = await fs.open(filePath, "a");
|
|
27
|
-
let closed = false;
|
|
28
|
-
let lastError = null;
|
|
29
|
-
let writeChain = Promise.resolve();
|
|
30
|
-
const queueWrite = (line) => {
|
|
31
|
-
const next = writeChain.then(async () => {
|
|
32
|
-
if (closed) return;
|
|
33
|
-
try {
|
|
34
|
-
await handle.write(line);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
const msg = describeError(err);
|
|
37
|
-
lastError = msg;
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
writeChain = next.catch(() => {
|
|
42
|
-
});
|
|
43
|
-
return next;
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
append: async (snapshot) => {
|
|
47
|
-
if (closed) return;
|
|
48
|
-
let line;
|
|
49
|
-
try {
|
|
50
|
-
line = JSON.stringify(snapshot) + "\n";
|
|
51
|
-
} catch (err) {
|
|
52
|
-
lastError = `serialize failed: ${describeError(err)}`;
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
await queueWrite(line);
|
|
57
|
-
} catch {
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
close: async (signal) => {
|
|
61
|
-
if (closed) return;
|
|
62
|
-
try {
|
|
63
|
-
if (signal) {
|
|
64
|
-
await Promise.race([
|
|
65
|
-
writeChain,
|
|
66
|
-
new Promise((_, reject) => {
|
|
67
|
-
if (signal.aborted) {
|
|
68
|
-
reject(makeAbortError());
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
signal.addEventListener("abort", () => reject(makeAbortError()), {
|
|
72
|
-
once: true
|
|
73
|
-
});
|
|
74
|
-
})
|
|
75
|
-
]);
|
|
76
|
-
} else {
|
|
77
|
-
await writeChain;
|
|
78
|
-
}
|
|
79
|
-
} catch {
|
|
80
|
-
}
|
|
81
|
-
closed = true;
|
|
82
|
-
try {
|
|
83
|
-
await handle.close();
|
|
84
|
-
} catch (err) {
|
|
85
|
-
lastError = describeError(err);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
getLastError: () => lastError
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
async function replayTrace(filePath, options = {}) {
|
|
92
|
-
const output = options.output ?? process.stdout;
|
|
93
|
-
const speed = normalizeSpeed(options.speed);
|
|
94
|
-
const sleep = options.sleep ?? ((ms) => sleepAbortable(ms, options.signal));
|
|
95
|
-
const manageCursor = options.manageCursor ?? true;
|
|
96
|
-
const nowFn = options.now ?? ((snapshot) => {
|
|
97
|
-
const ms = Date.parse(snapshot.capturedAt);
|
|
98
|
-
return Number.isFinite(ms) ? ms : Date.now();
|
|
99
|
-
});
|
|
100
|
-
const stream = createReadStream(filePath, { encoding: "utf-8" });
|
|
101
|
-
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
|
|
102
|
-
let framesRendered = 0;
|
|
103
|
-
let framesSkipped = 0;
|
|
104
|
-
let lastSnapshot = null;
|
|
105
|
-
let prevCapturedMs = null;
|
|
106
|
-
if (manageCursor) safeWrite(output, ANSI_HIDE_CURSOR);
|
|
107
|
-
try {
|
|
108
|
-
for await (const rawLine of rl) {
|
|
109
|
-
if (options.signal?.aborted) break;
|
|
110
|
-
const line = rawLine.trim();
|
|
111
|
-
if (line.length === 0) continue;
|
|
112
|
-
const snapshot = parseSnapshotLine(line);
|
|
113
|
-
if (snapshot === null) {
|
|
114
|
-
framesSkipped += 1;
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const capturedMs = Date.parse(snapshot.capturedAt);
|
|
118
|
-
let waitMs = 0;
|
|
119
|
-
if (prevCapturedMs !== null && Number.isFinite(capturedMs)) {
|
|
120
|
-
const rawDelta = capturedMs - prevCapturedMs;
|
|
121
|
-
waitMs = computeReplayDelay(rawDelta, speed);
|
|
122
|
-
} else if (prevCapturedMs !== null) {
|
|
123
|
-
waitMs = computeReplayDelay(DEFAULT_REPLAY_DELAY_MS, speed);
|
|
124
|
-
}
|
|
125
|
-
if (waitMs > 0) {
|
|
126
|
-
try {
|
|
127
|
-
await sleep(waitMs);
|
|
128
|
-
} catch (err) {
|
|
129
|
-
if (isAbortError(err) || options.signal?.aborted) break;
|
|
130
|
-
throw err;
|
|
131
|
-
}
|
|
132
|
-
if (options.signal?.aborted) break;
|
|
133
|
-
}
|
|
134
|
-
let frame;
|
|
135
|
-
try {
|
|
136
|
-
frame = renderFrame({
|
|
137
|
-
snapshot,
|
|
138
|
-
renderError: null,
|
|
139
|
-
now: () => nowFn(snapshot, framesRendered)
|
|
140
|
-
});
|
|
141
|
-
} catch (err) {
|
|
142
|
-
frame = `remnic console replay: render failed: ${describeError(err)}
|
|
143
|
-
`;
|
|
144
|
-
}
|
|
145
|
-
safeWrite(output, ANSI_CLEAR_HOME);
|
|
146
|
-
safeWrite(output, frame);
|
|
147
|
-
framesRendered += 1;
|
|
148
|
-
lastSnapshot = snapshot;
|
|
149
|
-
if (Number.isFinite(capturedMs)) prevCapturedMs = capturedMs;
|
|
150
|
-
}
|
|
151
|
-
} finally {
|
|
152
|
-
rl.close();
|
|
153
|
-
stream.close();
|
|
154
|
-
if (manageCursor) safeWrite(output, ANSI_SHOW_CURSOR);
|
|
155
|
-
}
|
|
156
|
-
return { framesRendered, framesSkipped, lastSnapshot };
|
|
157
|
-
}
|
|
158
|
-
function parseSnapshotLine(line) {
|
|
159
|
-
let parsed;
|
|
160
|
-
try {
|
|
161
|
-
parsed = JSON.parse(line);
|
|
162
|
-
} catch {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
return parsed;
|
|
169
|
-
}
|
|
170
|
-
function computeReplayDelay(rawDeltaMs, speed) {
|
|
171
|
-
if (!Number.isFinite(rawDeltaMs)) return 0;
|
|
172
|
-
if (rawDeltaMs <= 0) return 0;
|
|
173
|
-
if (!Number.isFinite(speed)) return 0;
|
|
174
|
-
const adjusted = rawDeltaMs / speed;
|
|
175
|
-
if (!Number.isFinite(adjusted)) return 0;
|
|
176
|
-
if (adjusted <= MIN_REPLAY_DELAY_MS) return MIN_REPLAY_DELAY_MS;
|
|
177
|
-
if (adjusted > MAX_REPLAY_DELAY_MS) return MAX_REPLAY_DELAY_MS;
|
|
178
|
-
return adjusted;
|
|
179
|
-
}
|
|
180
|
-
function parseSpeedFlag(raw) {
|
|
181
|
-
if (raw === void 0 || raw === null) return 1;
|
|
182
|
-
const num = typeof raw === "number" ? raw : Number(raw);
|
|
183
|
-
if (!Number.isFinite(num) && num !== Infinity) {
|
|
184
|
-
throw new Error(
|
|
185
|
-
`invalid --speed value: ${JSON.stringify(raw)} (must be a positive number)`
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
if (num <= 0) {
|
|
189
|
-
throw new Error(
|
|
190
|
-
`invalid --speed value: ${JSON.stringify(raw)} (must be > 0)`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
return num;
|
|
194
|
-
}
|
|
195
|
-
function normalizeSpeed(speed) {
|
|
196
|
-
if (speed === void 0) return 1;
|
|
197
|
-
if (!Number.isFinite(speed) && speed !== Infinity) return 1;
|
|
198
|
-
if (speed <= 0) return 1;
|
|
199
|
-
return speed;
|
|
200
|
-
}
|
|
201
|
-
function sleepAbortable(ms, signal) {
|
|
202
|
-
return new Promise((resolve, reject) => {
|
|
203
|
-
if (signal?.aborted) {
|
|
204
|
-
reject(makeAbortError());
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const timer = setTimeout(() => {
|
|
208
|
-
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
209
|
-
resolve();
|
|
210
|
-
}, ms);
|
|
211
|
-
let onAbort = null;
|
|
212
|
-
if (signal) {
|
|
213
|
-
onAbort = () => {
|
|
214
|
-
clearTimeout(timer);
|
|
215
|
-
reject(makeAbortError());
|
|
216
|
-
};
|
|
217
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function makeAbortError() {
|
|
222
|
-
if (typeof DOMException !== "undefined") {
|
|
223
|
-
return new DOMException("aborted", "AbortError");
|
|
224
|
-
}
|
|
225
|
-
const err = new Error("aborted");
|
|
226
|
-
err.name = "AbortError";
|
|
227
|
-
return err;
|
|
228
|
-
}
|
|
229
|
-
function isAbortError(err) {
|
|
230
|
-
return typeof err === "object" && err !== null && "name" in err && err.name === "AbortError";
|
|
231
|
-
}
|
|
232
|
-
async function flushWithTimeout(flush, timeoutMs) {
|
|
233
|
-
const TIMEOUT_SENTINEL = /* @__PURE__ */ Symbol("flush-timeout");
|
|
234
|
-
let error = null;
|
|
235
|
-
let timeoutHandle = null;
|
|
236
|
-
const ac = new AbortController();
|
|
237
|
-
const flushPromise = flush(ac.signal).then(
|
|
238
|
-
() => void 0,
|
|
239
|
-
(err) => {
|
|
240
|
-
error = err;
|
|
241
|
-
return void 0;
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
const timeoutPromise = new Promise((resolve) => {
|
|
245
|
-
timeoutHandle = setTimeout(() => resolve(TIMEOUT_SENTINEL), timeoutMs);
|
|
246
|
-
if (typeof timeoutHandle.unref === "function") {
|
|
247
|
-
timeoutHandle.unref();
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
try {
|
|
251
|
-
const winner = await Promise.race([
|
|
252
|
-
flushPromise,
|
|
253
|
-
timeoutPromise
|
|
254
|
-
]);
|
|
255
|
-
if (winner === TIMEOUT_SENTINEL) {
|
|
256
|
-
ac.abort();
|
|
257
|
-
return { flushed: false, timedOut: true, error: null };
|
|
258
|
-
}
|
|
259
|
-
return { flushed: true, timedOut: false, error };
|
|
260
|
-
} finally {
|
|
261
|
-
if (timeoutHandle !== null) {
|
|
262
|
-
clearTimeout(timeoutHandle);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
function safeWrite(output, chunk) {
|
|
267
|
-
try {
|
|
268
|
-
output.write(chunk);
|
|
269
|
-
} catch {
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function describeError(err) {
|
|
273
|
-
if (err instanceof Error) return err.message;
|
|
274
|
-
try {
|
|
275
|
-
return String(err);
|
|
276
|
-
} catch {
|
|
277
|
-
return "unknown error";
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
export {
|
|
281
|
-
computeReplayDelay,
|
|
282
|
-
flushWithTimeout,
|
|
283
|
-
isAbortError,
|
|
284
|
-
openTraceRecorder,
|
|
285
|
-
parseSnapshotLine,
|
|
286
|
-
parseSpeedFlag,
|
|
287
|
-
replayTrace,
|
|
288
|
-
sleepAbortable
|
|
289
|
-
};
|
package/dist/tui-7KRDCMYK.js
DELETED
package/dist/types-MBUINTB2.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CAPSULE_ID_PATTERN,
|
|
3
|
-
CapsuleBlockSchema,
|
|
4
|
-
CapsuleIncludesSchema,
|
|
5
|
-
CapsuleParentSchema,
|
|
6
|
-
CapsuleRetrievalPolicySchema,
|
|
7
|
-
ExportBundleV1Schema,
|
|
8
|
-
ExportBundleV2Schema,
|
|
9
|
-
ExportManifestV1Schema,
|
|
10
|
-
ExportManifestV2Schema,
|
|
11
|
-
ExportMemoryRecordV1Schema,
|
|
12
|
-
parseExportBundle,
|
|
13
|
-
parseExportManifest
|
|
14
|
-
} from "./chunk-QCCP4RU5.js";
|
|
15
|
-
import "./chunk-4XDQ3KEC.js";
|
|
16
|
-
import "./chunk-I2KLQ2HA.js";
|
|
17
|
-
export {
|
|
18
|
-
CAPSULE_ID_PATTERN,
|
|
19
|
-
CapsuleBlockSchema,
|
|
20
|
-
CapsuleIncludesSchema,
|
|
21
|
-
CapsuleParentSchema,
|
|
22
|
-
CapsuleRetrievalPolicySchema,
|
|
23
|
-
ExportBundleV1Schema,
|
|
24
|
-
ExportBundleV2Schema,
|
|
25
|
-
ExportManifestV1Schema,
|
|
26
|
-
ExportManifestV2Schema,
|
|
27
|
-
ExportMemoryRecordV1Schema,
|
|
28
|
-
parseExportBundle,
|
|
29
|
-
parseExportManifest
|
|
30
|
-
};
|