codemem 0.25.2 → 0.25.3
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 +16 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { DEFAULT_COORDINATOR_DB_PATH, DedupKeyBackfillRunner, MemoryStore, ObserverClient, RawEventSweeper, SyncRetentionRunner, VERSION, VectorModelMigrationRunner, aiBackfillStructuredContent, applyBootstrapSnapshot, backfillMemoryDedupKeys, backfillNarrativeFromBody, backfillTagsText, backfillVectors, buildAuthHeaders, buildBaseUrl, buildRawEventEnvelopeFromHook, compareMemoryRoleReports, connect, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorDisableDeviceAction, coordinatorEnrollDeviceAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, createBetterSqliteCoordinatorApp, deactivateLowSignalMemories, deactivateLowSignalObservations, dedupNearDuplicateMemories, ensureDeviceIdentity, exportMemories, fetchAllSnapshotPages, fingerprintPublicKey, flushRawEvents, getExtractionBenchmarkProfile, getInjectionEvalScenarioPack, getInjectionEvalScenarioPrompts, getMemoryRoleReport, getRawEventRelinkPlan, getRawEventRelinkReport, getRawEventStatus, getSessionExtractionEval, getSessionExtractionEvalScenario, getWorkspaceCodememConfigPath, hasPendingDedupKeyBackfill, hasUnsyncedSharedMemoryChanges, importMemories, initDatabase, isEmbeddingDisabled, loadObserverConfig, loadPublicKey, loadSqliteVec, planReplicationOpsAgePrune, pruneReplicationOpsUntilCaughtUp, rawEventsGate, readCodememConfigFile, readCodememConfigFileAtPath, readCoordinatorSyncConfig, readImportPayload, replayBatchExtraction, replayBatchExtractionWithTierRouting, requestJson, resolveCodememConfigPath, resolveDbPath, resolveHookProject, resolveProject, retryRawEventFailures, runSyncDaemon, runSyncPass, schema, setPeerProjectFilter, stripJsonComments, stripPrivateObj, stripTrailingCommas, syncPassPreflight, updatePeerAddresses, vacuumDatabase, writeCodememConfigFile } from "@codemem/core";
|
|
2
|
+
import { DEFAULT_COORDINATOR_DB_PATH, DedupKeyBackfillRunner, MemoryStore, ObserverClient, RawEventSweeper, SyncRetentionRunner, VERSION, VectorModelMigrationRunner, aiBackfillStructuredContent, applyBootstrapSnapshot, backfillMemoryDedupKeys, backfillNarrativeFromBody, backfillTagsText, backfillVectors, buildAuthHeaders, buildBaseUrl, buildRawEventEnvelopeFromHook, compareMemoryRoleReports, connect, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorDisableDeviceAction, coordinatorEnrollDeviceAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, createBetterSqliteCoordinatorApp, deactivateLowSignalMemories, deactivateLowSignalObservations, dedupNearDuplicateMemories, ensureDeviceIdentity, ensureSchemaBootstrapped, exportMemories, fetchAllSnapshotPages, fingerprintPublicKey, flushRawEvents, getExtractionBenchmarkProfile, getInjectionEvalScenarioPack, getInjectionEvalScenarioPrompts, getMemoryRoleReport, getRawEventRelinkPlan, getRawEventRelinkReport, getRawEventStatus, getSessionExtractionEval, getSessionExtractionEvalScenario, getWorkspaceCodememConfigPath, hasPendingDedupKeyBackfill, hasUnsyncedSharedMemoryChanges, importMemories, initDatabase, isEmbeddingDisabled, loadObserverConfig, loadPublicKey, loadSqliteVec, planReplicationOpsAgePrune, pruneReplicationOpsUntilCaughtUp, rawEventsGate, readCodememConfigFile, readCodememConfigFileAtPath, readCoordinatorSyncConfig, readImportPayload, replayBatchExtraction, replayBatchExtractionWithTierRouting, requestJson, resolveCodememConfigPath, resolveDbPath, resolveHookProject, resolveProject, retryRawEventFailures, runSyncDaemon, runSyncPass, schema, setPeerProjectFilter, stripJsonComments, stripPrivateObj, stripTrailingCommas, syncPassPreflight, updatePeerAddresses, vacuumDatabase, writeCodememConfigFile } from "@codemem/core";
|
|
3
3
|
import { Command, Option } from "commander";
|
|
4
4
|
import omelette from "omelette";
|
|
5
5
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -771,11 +771,19 @@ function emitStructuredError$1(errorCode, message) {
|
|
|
771
771
|
}
|
|
772
772
|
/** Try to POST the hook payload to the running viewer server.
|
|
773
773
|
*
|
|
774
|
-
* Returns `ok: true`
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
774
|
+
* Returns `ok: true` whenever the viewer accepts the request and
|
|
775
|
+
* returns a well-shaped JSON body with numeric `inserted` / `skipped`
|
|
776
|
+
* fields. That includes the `{inserted: 0, skipped: 1}` response the
|
|
777
|
+
* viewer emits when the payload maps to a null envelope (Stop with no
|
|
778
|
+
* assistant text, UserPromptSubmit with empty prompt, etc.) — that
|
|
779
|
+
* determination is deterministic, so retrying via the direct fallback
|
|
780
|
+
* would produce the exact same null envelope and the same skip. We
|
|
781
|
+
* accept those as benign no-ops instead of triggering the durability
|
|
782
|
+
* dance pointlessly.
|
|
783
|
+
*
|
|
784
|
+
* If a future server change adds a new `skipped` reason that IS
|
|
785
|
+
* transient, we'll need a reason field in the response and updated
|
|
786
|
+
* client handling — not an unconditional fail-over.
|
|
779
787
|
*/
|
|
780
788
|
async function tryHttpIngest(payload, host, port) {
|
|
781
789
|
const url = `http://${host}:${port}/api/claude-hooks`;
|
|
@@ -821,14 +829,6 @@ async function tryHttpIngest(payload, host, port) {
|
|
|
821
829
|
skipped: 0
|
|
822
830
|
};
|
|
823
831
|
}
|
|
824
|
-
if (obj.skipped > 0) {
|
|
825
|
-
logHookFailure("codemem claude-hook-ingest HTTP accepted but skipped payload");
|
|
826
|
-
return {
|
|
827
|
-
ok: false,
|
|
828
|
-
inserted: obj.inserted,
|
|
829
|
-
skipped: obj.skipped
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
832
|
return {
|
|
833
833
|
ok: true,
|
|
834
834
|
inserted: obj.inserted,
|
|
@@ -856,6 +856,7 @@ function directEnqueue(payload, dbPath) {
|
|
|
856
856
|
try {
|
|
857
857
|
loadSqliteVec(db);
|
|
858
858
|
} catch {}
|
|
859
|
+
ensureSchemaBootstrapped(db);
|
|
859
860
|
const strippedPayload = stripPrivateObj(envelope.payload);
|
|
860
861
|
if (db.prepare("SELECT 1 FROM raw_events WHERE source = ? AND stream_id = ? AND event_id = ? LIMIT 1").get(envelope.source, envelope.session_stream_id, envelope.event_id)) return {
|
|
861
862
|
inserted: 0,
|
|
@@ -3460,7 +3461,7 @@ function resolveLegacyServeInvocation(opts) {
|
|
|
3460
3461
|
configPath: opts.config ?? null,
|
|
3461
3462
|
host: opts.host,
|
|
3462
3463
|
port: parsePort(opts.port),
|
|
3463
|
-
background: opts.restart
|
|
3464
|
+
background: Boolean(opts.restart || opts.background)
|
|
3464
3465
|
};
|
|
3465
3466
|
}
|
|
3466
3467
|
function resolveServeInvocation(action, opts) {
|