@codemem/server 0.34.0 → 0.35.1
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 +42 -2
- package/dist/index.js.map +1 -1
- package/dist/routes/raw-events.d.ts +1 -1
- package/dist/routes/raw-events.d.ts.map +1 -1
- package/package.json +2 -2
- package/static/app.js +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
-
import { ACCESS_CLEANUP_OP_TYPE, CODEMEM_CONFIG_ENV_OVERRIDES, DEFAULT_TIME_WINDOW_S, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, MemoryStore, SYNC_CAPABILITY_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, applyReplicationOps, buildBaseUrl, buildFilterClausesWithContext, buildRawEventEnvelopeFromHook, canonicalMemoryKind, canonicalWorkspaceIdentity, cleanupNonces, coordinatorArchiveGroupAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, createCoordinatorReciprocalApproval, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, diagnoseStalePeerReceivedRows, ensureDeviceIdentity, extractReplicationOps, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, fromJson, getCodememConfigPath, getCodememEnvOverrides, getCoordinatorGroupPreference, getSemanticIndexDiagnostics, getSyncResetState, isScopedSyncCapability, isSummaryLikeMemory, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listInboundScopeRejections, listMaintenanceJobs, listObserverProviderOptions, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadReplicationOpsForPeer, lookupCoordinatorPeers, mergeAddresses, negotiateSyncCapability, normalizeAddress, normalizeSyncCapability, parseStrictInteger, parseSyncScopeRequest, personalScopeGrantStatusForPeer, probeAvailableCredentials, readCodememConfigFile, readCoordinatorSyncConfig, reassignProjectScopeInventoryProject, recordNonce, rejectInboundScopeFailures, requestJson, resolveDbPath, runSyncPass, schema, stripJsonComments, stripPrivateObj, stripTrailingCommas, summarizeInboundScopeRejections, syncScopeResetRequiredPayload, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMapping, verifySignature, writeCodememConfigFile } from "@codemem/core";
|
|
3
|
+
import { ACCESS_CLEANUP_OP_TYPE, CODEMEM_CONFIG_ENV_OVERRIDES, DEFAULT_TIME_WINDOW_S, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, MemoryStore, SYNC_CAPABILITY_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, applyReplicationOps, buildBaseUrl, buildFilterClausesWithContext, buildRawEventEnvelopeFromCodexHook, buildRawEventEnvelopeFromHook, canonicalMemoryKind, canonicalWorkspaceIdentity, cleanupNonces, coordinatorArchiveGroupAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, createCoordinatorReciprocalApproval, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, diagnoseStalePeerReceivedRows, ensureDeviceIdentity, extractReplicationOps, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, fromJson, getCodememConfigPath, getCodememEnvOverrides, getCoordinatorGroupPreference, getSemanticIndexDiagnostics, getSyncResetState, isScopedSyncCapability, isSummaryLikeMemory, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listInboundScopeRejections, listMaintenanceJobs, listObserverProviderOptions, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadReplicationOpsForPeer, lookupCoordinatorPeers, mergeAddresses, negotiateSyncCapability, normalizeAddress, normalizeSyncCapability, parseStrictInteger, parseSyncScopeRequest, personalScopeGrantStatusForPeer, probeAvailableCredentials, readCodememConfigFile, readCoordinatorSyncConfig, reassignProjectScopeInventoryProject, recordNonce, rejectInboundScopeFailures, requestJson, resolveDbPath, runSyncPass, schema, stripJsonComments, stripPrivateObj, stripTrailingCommas, summarizeInboundScopeRejections, syncScopeResetRequiredPayload, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMapping, verifySignature, writeCodememConfigFile } from "@codemem/core";
|
|
4
4
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
6
|
import { createMiddleware } from "hono/factory";
|
|
@@ -1090,7 +1090,7 @@ function observerStatusRoutes(deps) {
|
|
|
1090
1090
|
//#region src/routes/raw-events.ts
|
|
1091
1091
|
/**
|
|
1092
1092
|
* Raw events routes — GET & POST /api/raw-events, GET /api/raw-events/status,
|
|
1093
|
-
* POST /api/claude-hooks.
|
|
1093
|
+
* POST /api/claude-hooks, POST /api/codex-hooks.
|
|
1094
1094
|
*/
|
|
1095
1095
|
var MAX_RAW_EVENTS_BODY_BYTES = Number.parseInt(process.env.CODEMEM_RAW_EVENTS_MAX_BODY_BYTES ?? "", 10) || 1048576;
|
|
1096
1096
|
/** Keys to check (in priority order) when resolving a session stream id. */
|
|
@@ -1382,6 +1382,46 @@ function rawEventsRoutes(getStore, sweeper) {
|
|
|
1382
1382
|
return c.json(response, 500);
|
|
1383
1383
|
}
|
|
1384
1384
|
});
|
|
1385
|
+
app.post("/api/codex-hooks", async (c) => {
|
|
1386
|
+
const result = await parseJsonObjectBody(c, MAX_RAW_EVENTS_BODY_BYTES);
|
|
1387
|
+
if (result instanceof Response) return result;
|
|
1388
|
+
const envelope = buildRawEventEnvelopeFromCodexHook(result);
|
|
1389
|
+
if (envelope === null) return c.json({
|
|
1390
|
+
inserted: 0,
|
|
1391
|
+
skipped: 1
|
|
1392
|
+
});
|
|
1393
|
+
const store = getStore();
|
|
1394
|
+
try {
|
|
1395
|
+
const opencodeSessionId = envelope.opencode_session_id;
|
|
1396
|
+
const source = envelope.source;
|
|
1397
|
+
const strippedPayload = stripPrivateObj(envelope.payload);
|
|
1398
|
+
const inserted = store.recordRawEvent({
|
|
1399
|
+
opencodeSessionId,
|
|
1400
|
+
source,
|
|
1401
|
+
eventId: envelope.event_id,
|
|
1402
|
+
eventType: envelope.event_type,
|
|
1403
|
+
payload: strippedPayload,
|
|
1404
|
+
tsWallMs: envelope.ts_wall_ms
|
|
1405
|
+
});
|
|
1406
|
+
store.updateRawEventSessionMeta({
|
|
1407
|
+
opencodeSessionId,
|
|
1408
|
+
source,
|
|
1409
|
+
cwd: envelope.cwd,
|
|
1410
|
+
project: envelope.project,
|
|
1411
|
+
startedAt: envelope.started_at,
|
|
1412
|
+
lastSeenTsWallMs: envelope.ts_wall_ms
|
|
1413
|
+
});
|
|
1414
|
+
nudgeSweeper(sweeper, [opencodeSessionId], source);
|
|
1415
|
+
return c.json({
|
|
1416
|
+
inserted: inserted ? 1 : 0,
|
|
1417
|
+
skipped: 0
|
|
1418
|
+
});
|
|
1419
|
+
} catch (err) {
|
|
1420
|
+
const response = { error: "internal server error" };
|
|
1421
|
+
if (process.env.CODEMEM_VIEWER_DEBUG === "1") response.detail = err.message;
|
|
1422
|
+
return c.json(response, 500);
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1385
1425
|
return app;
|
|
1386
1426
|
}
|
|
1387
1427
|
//#endregion
|