@codemem/server 0.47.0-beta.2 → 0.47.0-beta.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACX,iCAAiC,EACjC,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAiB,OAAO,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAEN,KAAK,0BAA0B,EAC/B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,kBAAkB,EAAgB,MAAM,oBAAoB,CAAC;AAS3E,OAAO,EAAE,KAAK,iBAAiB,EAAkC,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAA0B,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EACN,KAAK,gCAAgC,EACrC,KAAK,uCAAuC,EAG5C,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACX,cAAc,EACd,oBAAoB,EACpB,2BAA2B,EAC3B,oBAAoB,EACpB,cAAc,EACd,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EACX,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,0B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CAAC,EAAE,UAAU,8EA8B9C"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync, statSync } from "node:fs";
2
2
  import { dirname, isAbsolute, join, posix, resolve, win32 } from "node:path";
3
- import { ACCESS_CLEANUP_OP_TYPE, CodememConfigMutationError, CoordinatorAccountLinkError, CoordinatorReciprocalApprovalRequestChangedError, DEFAULT_TIME_WINDOW_S, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, LOCAL_SYNC_FEATURES, LegacyTeamSetupAdditiveConvergenceError, LegacyTeamSetupRosterCapacityError, MEMORY_FILTER_FIELD_TYPES, MEMORY_FILTER_NAMES, MEMORY_KIND_DESCRIPTIONS, MemoryStore, ObserverClient, PROMPT_TRANSPORT_PROTOCOL_RANGE, REMEMBER_MEMORY_KINDS, RICH_TIER_ANTHROPIC_DEFAULTS, RICH_TIER_DEFAULTS, RawEventIngestValidationError, RecipientPolicyEdgeRequestError, RecipientPolicyTeamRenameError, RemoteCoordinatorRequestError, SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, SIMPLE_TIER_ANTHROPIC_DEFAULTS, SIMPLE_TIER_DEFAULTS, SYNC_AUTHORIZATION_REFRESH_HEADER, SYNC_CAPABILITY_HEADER, SYNC_FEATURES_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, VIEWER_IDENTITY_TARGET_KEYS, VIEWER_SERVICE_DISCRIMINATOR, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, analyzeProjectScopeMappingChangesGuardrails, analyzeProjectScopeMappingDeletionGuardrails, applyLegacyTeamSetupCompletionManifest, applyLegacyTeamSetupCompletionManifestAndReturnActivation, applyReplicationOps, areLegacyTeamSetupCompletionPolicyFactsAdditivelyCompatible, automaticRecallHealth, buildAuthHeaders, buildBaseUrl, buildDirectPeerAuthHeaders, buildDistillReport, buildFilterClausesWithContext, buildPiFlushSignalFromEvent, buildRawEventEnvelopeFromCodexHook, buildRawEventEnvelopeFromHook, buildRawEventEnvelopeFromPiEvent, buildViewerIdentityTarget, canonicalCoordinatorLegacyTeamCompletionManifestJson, canonicalMemoryKind, canonicalRepositoryProjectIdentity, canonicalWorkspaceIdentity, changeCoordinatorAccount, claimRecipientPolicyActorMutations, claimRecipientPolicyPublicationMutation, classifyRecordedSyncFailure, cleanupNonces, clearLegacyTeamSetupDeviceDecision, clonePromptPackAttempt, coerceObserverCommand, commitDeviceIdentityBindings, commitRecipientPolicyEdges, containLegacyTeamSetupCompletionConflict, coordinatorArchiveGroupAction, coordinatorCreateAddDeviceInviteAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateLegacyTeamCompletionAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGetLegacyTeamCompletionAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListConsumedTeamInvitesAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListLegacyTeamCompletionsAction, coordinatorListReviewedRecipientInviteEvidenceAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, countShareableProjectMemories, createCoordinatorReciprocalApproval, decodeInvitePayload, dedupeOrderedIds, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, deriveLegacyTeamSetupCompletionManifest, detectInstallKind, deterministicPolicyTeamId, diagnoseStalePeerReceivedRows, discoverLegacyTeamCandidates, ensureDeviceIdentity, executeShareProvisioning, extractInvitePayload, extractReplicationOps, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, friendlyDeviceName, fromJson, generateWithOpenCodeV2, getCodememConfigPath, getCodememEnvOverrideValues, getCodememEnvOverrides, getCoordinatorEnrollmentReconciliationIssueSummary, getCoordinatorGroupPreference, getEffectiveCachedScopeAuthorization, getLegacyTeamSetupDraft, getRecipientPolicyAuthorityState, getSemanticIndexDiagnostics, getSyncResetState, getUpdateStatus, ingestRawEvents, inspectFreshLegacyTeamSetupActivation, inspectLegacyTeamSetupActivation, inviteTokenDigest, isAutomaticRecallMeasurement, isLegacyTeamCandidateSelectable, isLegacyTeamSetupProjectMappingIdentity, isPeerTrustBindingCompatible, isProjectSyncEnablementError, isScopedSyncCapability, judgeDistillReport, legacyTeamCandidateId, legacyTeamCandidateProjectInventory, legacyTeamCanonicalProjectRef, legacyTeamDeviceRef, legacyTeamResolvedProjectRef, legacyTeamSetupApiErrorCode, linkCoordinatorAccount, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listDeviceIdentityInventory, listInboundScopeRejections, listLegacyRecipientPolicyProjections, listMaintenanceJobs, listObserverProviderOptions, listOpenCodeV2Models, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listRecipientPolicyIntent, listRecipientPolicyReview, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadPublicKey, loadReplicationOpsForPeer, loadRuntimeSigningPublicKey, lookupCoordinatorPeers, memoryFilterValueMatchesType, mergeAddresses, migrateRecipientPolicyIntent, mutateCodememConfigFile, negotiateSyncCapability, normalizeAddress, normalizeCoordinatorAccountLinkOrigin, normalizeHumanPresentationName, normalizeSyncCapability, normalizeSyncFeatures, normalizeTeammateName, parseAcceptedProjectIntent, parseBootstrapExpiry, parsePositiveMemoryId, parseReassignScopePayload, parseRecipientPolicyEdgeCommitRequest, parseStrictInteger, parseSyncScopeRequest, persistShareOperation, personalScopeGrantStatusForPeer, planShareOperation, previewDeviceIdentityBindings, previewLegacyTeamSetupActivation, previewRecipientPolicyEdges, previewRecipientPolicyOnboarding, previewRecipientPolicyOnboardingFromReviewedIntent, probeAvailableCredentials, projectMatchesFilter, projectShareLifecycle, promptPackArtifactFingerprint, readAccountLinkDevice, readCodememConfigFile, readCoordinatorAccountChangeCapabilities, readCoordinatorAccountLinkStatus, readCoordinatorSyncConfig, reassignProjectScopeInventoryProject, recipientInviteAuthoritativeIdentityId, recipientPolicyDigest, recipientReviewedIntentDigest, reconcileCoordinatorEnrollmentSnapshot, reconcileRecipientPolicyProject, reconcileShareOperationAcceptance, reconstructLegacyTeamSetupCompletionManifest, recordAutomaticRecall, recordHighestObservedDirectSignatureVersion, recordNonce, recordPromptPackArtifacts, recordPromptPackTerminal, refreshAuthorizedCoordinatorPeerTrust, refreshConfiguredScopeMembershipCache, refreshLegacyTeamCandidate, rejectInboundScopeFailures, renameRecipientPolicyTeam, replayLegacyTeamSetupActivation, repositoryIdentitiesByWorkspace, repositoryIdentityForWorkspace, requestJson, requireLegacyTeamSetupAccessDeltaWithinLimit, resolveCodememConfigPath, resolveDbPath, resolveObserverDefaultModel, resolveObserverRuntime, resolveProject, resolveProjectRoot, resolveRecipientPolicyReview, resolveRecipientPolicyReviewBulk, resolveVisibleScopeIds, runSyncPass, schema, scopeAuthorizationFailureReason, serializeRecipientPolicyCoordinatorGroupMutation, serializeRecipientPolicyPublicationMutation, serializeRecipientPolicyTeamMutation, setLegacyTeamSetupDeviceAssignment, setLegacyTeamSetupDeviceDecision, setLegacyTeamSetupProjectMapping, summarizeInboundScopeRejections, summaryLikeSqlPredicate, supportsSyncFeature, syncScopeResetRequiredPayload, toJson, tryUpdateRetrievalDelivery, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMappings, validateLegacyTeamSetupCompletionManifest, validateLegacyTeamSetupCompletionManifestBinding, validateRawEvents, verifyDirectPeerSignature, verifyRecipientReviewedIntent, verifySignature, wakeRecipientPoliciesForIdentities, wakeRecipientPoliciesForProjectIdentities } from "@codemem/core";
3
+ import { ACCESS_CLEANUP_OP_TYPE, CodememConfigMutationError, CoordinatorAccountLinkError, CoordinatorReciprocalApprovalRequestChangedError, DEFAULT_TIME_WINDOW_S, FILE_CONTEXT_TRANSPORT_MAX_BYTES, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, LOCAL_SYNC_FEATURES, LegacyTeamSetupAdditiveConvergenceError, LegacyTeamSetupRosterCapacityError, MEMORY_FILTER_FIELD_TYPES, MEMORY_FILTER_NAMES, MEMORY_KIND_DESCRIPTIONS, MemoryStore, ObserverClient, PROMPT_TRANSPORT_PROTOCOL_RANGE, REMEMBER_MEMORY_KINDS, RICH_TIER_ANTHROPIC_DEFAULTS, RICH_TIER_DEFAULTS, RawEventIngestValidationError, RecipientPolicyEdgeRequestError, RecipientPolicyTeamRenameError, RemoteCoordinatorRequestError, SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, SIMPLE_TIER_ANTHROPIC_DEFAULTS, SIMPLE_TIER_DEFAULTS, SYNC_AUTHORIZATION_REFRESH_HEADER, SYNC_CAPABILITY_HEADER, SYNC_FEATURES_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, VIEWER_IDENTITY_TARGET_KEYS, VIEWER_SERVICE_DISCRIMINATOR, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, analyzeProjectScopeMappingChangesGuardrails, analyzeProjectScopeMappingDeletionGuardrails, applyLegacyTeamSetupCompletionManifest, applyLegacyTeamSetupCompletionManifestAndReturnActivation, applyReplicationOps, areLegacyTeamSetupCompletionPolicyFactsAdditivelyCompatible, automaticRecallHealth, buildAuthHeaders, buildBaseUrl, buildDirectPeerAuthHeaders, buildDistillReport, buildFilterBranchesWithContext, buildFilterClausesWithContext, buildPiFlushSignalFromEvent, buildRawEventEnvelopeFromCodexHook, buildRawEventEnvelopeFromHook, buildRawEventEnvelopeFromPiEvent, buildViewerIdentityTarget, canonicalCoordinatorLegacyTeamCompletionManifestJson, canonicalMemoryKind, canonicalRepositoryProjectIdentity, canonicalWorkspaceIdentity, changeCoordinatorAccount, claimRecipientPolicyActorMutations, claimRecipientPolicyPublicationMutation, classifyRecordedSyncFailure, cleanupNonces, clearLegacyTeamSetupDeviceDecision, clonePromptPackAttempt, coerceObserverCommand, commitDeviceIdentityBindings, commitRecipientPolicyEdges, containLegacyTeamSetupCompletionConflict, coordinatorArchiveGroupAction, coordinatorCreateAddDeviceInviteAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateLegacyTeamCompletionAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGetLegacyTeamCompletionAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListConsumedTeamInvitesAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListLegacyTeamCompletionsAction, coordinatorListReviewedRecipientInviteEvidenceAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, countShareableProjectMemories, createCoordinatorReciprocalApproval, decodeInvitePayload, dedupeOrderedIds, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, deriveLegacyTeamSetupCompletionManifest, detectInstallKind, deterministicPolicyTeamId, diagnoseStalePeerReceivedRows, discoverLegacyTeamCandidates, dispatchFileContextTransport, ensureDeviceIdentity, executeShareProvisioning, extractInvitePayload, extractReplicationOps, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, friendlyDeviceName, fromJson, generateWithOpenCodeV2, getCodememConfigPath, getCodememEnvOverrideValues, getCodememEnvOverrides, getCoordinatorEnrollmentReconciliationIssueSummary, getCoordinatorGroupPreference, getEffectiveCachedScopeAuthorization, getLegacyTeamSetupDraft, getRecipientPolicyAuthorityState, getSemanticIndexDiagnostics, getSyncResetState, getUpdateStatus, ingestRawEvents, inspectFreshLegacyTeamSetupActivation, inspectLegacyTeamSetupActivation, inviteTokenDigest, isAutomaticRecallMeasurement, isLegacyTeamCandidateSelectable, isLegacyTeamSetupProjectMappingIdentity, isPeerTrustBindingCompatible, isProjectSyncEnablementError, isScopedSyncCapability, judgeDistillReport, legacyTeamCandidateId, legacyTeamCandidateProjectInventory, legacyTeamCanonicalProjectRef, legacyTeamDeviceRef, legacyTeamResolvedProjectRef, legacyTeamSetupApiErrorCode, linkCoordinatorAccount, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listDeviceIdentityInventory, listInboundScopeRejections, listLegacyRecipientPolicyProjections, listMaintenanceJobs, listObserverProviderOptions, listOpenCodeV2Models, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listRecipientPolicyIntent, listRecipientPolicyReview, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadPublicKey, loadReplicationOpsForPeer, loadRuntimeSigningPublicKey, lookupCoordinatorPeers, memoryFilterValueMatchesType, mergeAddresses, migrateRecipientPolicyIntent, mutateCodememConfigFile, negotiateSyncCapability, normalizeAddress, normalizeCoordinatorAccountLinkOrigin, normalizeHumanPresentationName, normalizeSyncCapability, normalizeSyncFeatures, normalizeTeammateName, parseAcceptedProjectIntent, parseBootstrapExpiry, parseFileContextTransportRequest, parsePositiveMemoryId, parseReassignScopePayload, parseRecipientPolicyEdgeCommitRequest, parseStrictInteger, parseSyncScopeRequest, persistShareOperation, personalScopeGrantStatusForPeer, planShareOperation, previewDeviceIdentityBindings, previewLegacyTeamSetupActivation, previewRecipientPolicyEdges, previewRecipientPolicyOnboarding, previewRecipientPolicyOnboardingFromReviewedIntent, probeAvailableCredentials, projectMatchesFilter, projectShareLifecycle, promptPackArtifactFingerprint, readAccountLinkDevice, readCodememConfigFile, readCoordinatorAccountChangeCapabilities, readCoordinatorAccountLinkStatus, readCoordinatorSyncConfig, reassignProjectScopeInventoryProject, recipientInviteAuthoritativeIdentityId, recipientPolicyDigest, recipientReviewedIntentDigest, reconcileCoordinatorEnrollmentSnapshot, reconcileRecipientPolicyProject, reconcileShareOperationAcceptance, reconstructLegacyTeamSetupCompletionManifest, recordAutomaticRecall, recordHighestObservedDirectSignatureVersion, recordNonce, recordPromptPackArtifacts, recordPromptPackTerminal, refreshAuthorizedCoordinatorPeerTrust, refreshConfiguredScopeMembershipCache, refreshLegacyTeamCandidate, rejectInboundScopeFailures, renameRecipientPolicyTeam, replayLegacyTeamSetupActivation, repositoryIdentitiesByWorkspace, repositoryIdentityForWorkspace, requestJson, requireLegacyTeamSetupAccessDeltaWithinLimit, resolveCodememConfigPath, resolveDbPath, resolveObserverDefaultModel, resolveObserverRuntime, resolveProject, resolveProjectRoot, resolveRecipientPolicyReview, resolveRecipientPolicyReviewBulk, resolveVisibleScopeIds, runSyncPass, schema, scopeAuthorizationFailureReason, serializeRecipientPolicyCoordinatorGroupMutation, serializeRecipientPolicyPublicationMutation, serializeRecipientPolicyTeamMutation, setLegacyTeamSetupDeviceAssignment, setLegacyTeamSetupDeviceDecision, setLegacyTeamSetupProjectMapping, summarizeInboundScopeRejections, summaryLikeSqlPredicate, supportsSyncFeature, syncScopeResetRequiredPayload, toJson, tryUpdateRetrievalDelivery, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMappings, validateLegacyTeamSetupCompletionManifest, validateLegacyTeamSetupCompletionManifestBinding, validateRawEvents, verifyDirectPeerSignature, verifyRecipientReviewedIntent, verifySignature, wakeRecipientPoliciesForIdentities, wakeRecipientPoliciesForProjectIdentities } from "@codemem/core";
4
4
  import { serveStatic } from "@hono/node-server/serve-static";
5
5
  import { Hono } from "hono";
6
6
  import { createCipheriv, createDecipheriv, createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -1751,38 +1751,6 @@ function diagnosticsRoutes(getStore) {
1751
1751
  return app;
1752
1752
  }
1753
1753
  //#endregion
1754
- //#region src/routes/health.ts
1755
- function databaseReachable(getStore) {
1756
- try {
1757
- getStore().db.pragma("schema_version", { simple: true });
1758
- return true;
1759
- } catch {
1760
- return false;
1761
- }
1762
- }
1763
- function healthRoutes(getStore) {
1764
- const app = new Hono();
1765
- app.get("/api/viewer-status", (c) => {
1766
- const store = getStore();
1767
- store.db.pragma("schema_version", { simple: true });
1768
- c.header("Cache-Control", "no-store");
1769
- return c.json({ identity: { actor_id: store.actorId } });
1770
- });
1771
- app.get("/api/health", (c) => {
1772
- const reachable = databaseReachable(getStore);
1773
- c.header("Cache-Control", "no-store");
1774
- return c.json({
1775
- service: VIEWER_SERVICE_DISCRIMINATOR,
1776
- version: VERSION$1,
1777
- pid: process.pid,
1778
- uptime_ms: Math.max(0, Math.floor(process.uptime() * 1e3)),
1779
- ready: reachable,
1780
- database: { reachable }
1781
- });
1782
- });
1783
- return app;
1784
- }
1785
- //#endregion
1786
1754
  //#region src/helpers.ts
1787
1755
  /**
1788
1756
  * Shared helpers for viewer-server routes.
@@ -1876,6 +1844,181 @@ async function parseJsonObjectBody(c, maxBytes) {
1876
1844
  return parsed;
1877
1845
  }
1878
1846
  //#endregion
1847
+ //#region src/routes/target-validation.ts
1848
+ var IDENTITY_TARGET_KEYS = new Set(VIEWER_IDENTITY_TARGET_KEYS);
1849
+ var BOOLEAN_IDENTITY_TARGET_KEYS = /* @__PURE__ */ new Set([
1850
+ "actor_id_present",
1851
+ "embedding_disabled",
1852
+ "embedding_offline"
1853
+ ]);
1854
+ function invalidRequest$1(message) {
1855
+ return {
1856
+ ok: false,
1857
+ status: 400,
1858
+ body: { error: {
1859
+ code: "invalid_request",
1860
+ message
1861
+ } }
1862
+ };
1863
+ }
1864
+ function conflict(code, message) {
1865
+ return {
1866
+ ok: false,
1867
+ status: 409,
1868
+ body: { error: {
1869
+ code,
1870
+ message
1871
+ } }
1872
+ };
1873
+ }
1874
+ function isRecord$1(value) {
1875
+ return value != null && typeof value === "object" && !Array.isArray(value);
1876
+ }
1877
+ function currentIdentityTarget() {
1878
+ return buildViewerIdentityTarget();
1879
+ }
1880
+ function requestedDbMatches(store, value) {
1881
+ if (value == null) return true;
1882
+ if (typeof value !== "string" || !value.trim()) return null;
1883
+ return resolve(resolveDbPath(value.trim())) === resolve(store.dbPath);
1884
+ }
1885
+ function implicitConfigPath() {
1886
+ const { resolved, fallbackChain } = resolveCodememConfigPath();
1887
+ if (resolved.source !== "env-codemem-config") return resolve(resolved.path);
1888
+ const candidates = fallbackChain.filter((candidate) => candidate.valid);
1889
+ const implicit = candidates.find((candidate) => candidate.exists) ?? candidates[0];
1890
+ return implicit ? resolve(implicit.path) : null;
1891
+ }
1892
+ function identityFieldMatches(key, requested, expected) {
1893
+ if (requested === expected) return true;
1894
+ if (key !== "config_path" || requested !== null && expected !== null) return false;
1895
+ return (requested ?? expected) === implicitConfigPath();
1896
+ }
1897
+ function requestedIdentityMatches(value) {
1898
+ if (value == null) return true;
1899
+ if (!isRecord$1(value)) return null;
1900
+ if (Object.keys(value).length !== IDENTITY_TARGET_KEYS.size || Object.keys(value).some((key) => !IDENTITY_TARGET_KEYS.has(key))) return "unsupported";
1901
+ const expected = currentIdentityTarget();
1902
+ for (const key of VIEWER_IDENTITY_TARGET_KEYS) {
1903
+ const requested = value[key];
1904
+ if (BOOLEAN_IDENTITY_TARGET_KEYS.has(key)) {
1905
+ if (typeof requested !== "boolean") return null;
1906
+ } else if (requested !== null && typeof requested !== "string") return null;
1907
+ if (!identityFieldMatches(key, requested, expected[key])) return false;
1908
+ }
1909
+ return true;
1910
+ }
1911
+ function validateViewerTarget(store, payload, options = {}) {
1912
+ if (options.requirePairedTargets) {
1913
+ const hasDbPath = Object.hasOwn(payload, "db_path");
1914
+ if (hasDbPath !== Object.hasOwn(payload, "identity_target")) return invalidRequest$1("db_path and identity_target must be provided together");
1915
+ if (hasDbPath && (payload.db_path == null || payload.identity_target == null)) return invalidRequest$1("db_path and identity_target must be valid when provided");
1916
+ }
1917
+ const dbMatches = requestedDbMatches(store, payload.db_path);
1918
+ if (dbMatches == null) return invalidRequest$1("db_path must be a non-empty string");
1919
+ if (!dbMatches) return conflict("viewer_db_mismatch", "viewer database does not match request");
1920
+ const identityMatches = requestedIdentityMatches(payload.identity_target);
1921
+ if (identityMatches === "unsupported") return conflict("viewer_contract_unsupported", "viewer request contract is incompatible");
1922
+ if (identityMatches == null) return invalidRequest$1("identity_target is invalid");
1923
+ if (!identityMatches) return conflict("viewer_identity_mismatch", "viewer identity does not match request");
1924
+ if ((options.requireCurrentIdentity || payload.identity_target != null) && !store.hasCurrentIdentity()) return conflict("viewer_identity_mismatch", "viewer identity does not match request");
1925
+ return { ok: true };
1926
+ }
1927
+ /**
1928
+ * Middleware read of db_path / identity_target from the query string.
1929
+ * Native tools (pi extension) send targets as query params so a pre-handler
1930
+ * guard can reject a foreign viewer without consuming POST bodies. Lenient:
1931
+ * clients that omit targets (UI, MCP, curl) are unaffected.
1932
+ */
1933
+ function viewerTargetQueryGuard(getStore) {
1934
+ return async (c, next) => {
1935
+ const dbPath = c.req.query("db_path");
1936
+ const rawIdentity = c.req.query("identity_target");
1937
+ if (dbPath == null && rawIdentity == null) return next();
1938
+ let identityTarget;
1939
+ if (rawIdentity != null) try {
1940
+ identityTarget = JSON.parse(rawIdentity);
1941
+ } catch {
1942
+ return c.json({ error: {
1943
+ code: "invalid_request",
1944
+ message: "identity_target must be JSON"
1945
+ } }, 400);
1946
+ }
1947
+ const target = validateViewerTarget(getStore(), {
1948
+ db_path: dbPath ?? void 0,
1949
+ identity_target: identityTarget
1950
+ });
1951
+ if (!target.ok) return c.json(target.body, target.status);
1952
+ return next();
1953
+ };
1954
+ }
1955
+ //#endregion
1956
+ //#region src/routes/file-context.ts
1957
+ function fileContextRoutes(getStore) {
1958
+ const app = new Hono();
1959
+ app.post("/api/file-context", async (c) => {
1960
+ const body = await parseJsonObjectBody(c, FILE_CONTEXT_TRANSPORT_MAX_BYTES);
1961
+ if (body instanceof Response) return body;
1962
+ const parsed = parseFileContextTransportRequest(body);
1963
+ if (!parsed.success) return c.json({ error: {
1964
+ code: "invalid_request",
1965
+ message: "invalid file-context request"
1966
+ } }, 400);
1967
+ try {
1968
+ const store = getStore();
1969
+ const target = validateViewerTarget(store, body, {
1970
+ requireCurrentIdentity: true,
1971
+ requirePairedTargets: true
1972
+ });
1973
+ if (!target.ok) return c.json(target.body, target.status);
1974
+ const response = dispatchFileContextTransport(store, parsed.data);
1975
+ if (!response.ok) return c.json({ error: {
1976
+ code: "invalid_request",
1977
+ message: "delivery does not match attempt"
1978
+ } }, 400);
1979
+ return c.json(response);
1980
+ } catch {
1981
+ return c.json({ error: {
1982
+ code: "file_context_failed",
1983
+ message: "file context unavailable"
1984
+ } }, 503);
1985
+ }
1986
+ });
1987
+ return app;
1988
+ }
1989
+ //#endregion
1990
+ //#region src/routes/health.ts
1991
+ function databaseReachable(getStore) {
1992
+ try {
1993
+ getStore().db.pragma("schema_version", { simple: true });
1994
+ return true;
1995
+ } catch {
1996
+ return false;
1997
+ }
1998
+ }
1999
+ function healthRoutes(getStore) {
2000
+ const app = new Hono();
2001
+ app.get("/api/viewer-status", (c) => {
2002
+ const store = getStore();
2003
+ store.db.pragma("schema_version", { simple: true });
2004
+ c.header("Cache-Control", "no-store");
2005
+ return c.json({ identity: { actor_id: store.actorId } });
2006
+ });
2007
+ app.get("/api/health", (c) => {
2008
+ const reachable = databaseReachable(getStore);
2009
+ c.header("Cache-Control", "no-store");
2010
+ return c.json({
2011
+ service: VIEWER_SERVICE_DISCRIMINATOR,
2012
+ version: VERSION$1,
2013
+ pid: process.pid,
2014
+ uptime_ms: Math.max(0, Math.floor(process.uptime() * 1e3)),
2015
+ ready: reachable,
2016
+ database: { reachable }
2017
+ });
2018
+ });
2019
+ return app;
2020
+ }
2021
+ //#endregion
1879
2022
  //#region src/routes/memory.ts
1880
2023
  var MAX_FEED_QUERY_CODE_UNITS = 256;
1881
2024
  var searchFunctionsRegisteredStores = /* @__PURE__ */ new WeakSet();
@@ -2082,16 +2225,19 @@ function memorySearchSql(query) {
2082
2225
  params: [query]
2083
2226
  };
2084
2227
  }
2085
- function countVisibleObservationRows(store, filters) {
2086
- const filterResult = buildViewerMemoryFilters(store, filters);
2087
- const clauses = [
2088
- "memory_items.active = 1",
2089
- `NOT ${summaryLikeSqlPredicate()}`,
2090
- ...filterResult.clauses
2091
- ];
2092
- const from = filterResult.joinSessions ? "memory_items JOIN sessions ON sessions.id = memory_items.session_id" : "memory_items";
2093
- const row = store.db.prepare(`SELECT COUNT(*) AS total FROM ${from} WHERE ${clauses.join(" AND ")}`).get(...filterResult.params);
2094
- return Number(row?.total ?? 0);
2228
+ function countVisibleMemoryClassifications(store, filters) {
2229
+ const branches = buildFilterBranchesWithContext(filters, store.ownershipFilterContext());
2230
+ const source = branches.map((branch) => {
2231
+ const from = branch.joinSessions ? "memory_items JOIN sessions ON sessions.id = memory_items.session_id" : "memory_items";
2232
+ return `SELECT ${summaryLikeSqlPredicate()} AS is_summary FROM ${from}
2233
+ WHERE memory_items.active = 1 AND ${branch.clauses.join(" AND ") || "1 = 1"}`;
2234
+ }).join(" UNION ALL ");
2235
+ const row = store.db.prepare(`SELECT COUNT(*) AS memories,
2236
+ COUNT(CASE WHEN NOT is_summary THEN 1 END) AS observations FROM (${source})`).get(...branches.flatMap((branch) => branch.params));
2237
+ return {
2238
+ memories: Number(row?.memories ?? 0),
2239
+ observations: Number(row?.observations ?? 0)
2240
+ };
2095
2241
  }
2096
2242
  function sessionAllowsArtifactAccess(store, sessionId) {
2097
2243
  const visibleCount = countVisibleMemoryRows(store, { session_id: sessionId });
@@ -2267,18 +2413,13 @@ function memoryRoutes(getStore) {
2267
2413
  const project = c.req.query("project") || null;
2268
2414
  let prompts;
2269
2415
  let artifacts;
2270
- let memories;
2271
- let observations;
2416
+ const { memories, observations } = countVisibleMemoryClassifications(store, project ? { project } : void 0);
2272
2417
  if (project) {
2273
2418
  prompts = countVisiblePromptRows(store, project);
2274
2419
  artifacts = countVisibleArtifactRows(store, project);
2275
- memories = countVisibleMemoryRows(store, { project });
2276
- observations = countVisibleObservationRows(store, { project });
2277
2420
  } else {
2278
2421
  prompts = countVisiblePromptRows(store);
2279
2422
  artifacts = countVisibleArtifactRows(store);
2280
- memories = countVisibleMemoryRows(store);
2281
- observations = countVisibleObservationRows(store);
2282
2423
  }
2283
2424
  const total = prompts + artifacts + memories;
2284
2425
  return c.json({
@@ -3025,115 +3166,6 @@ function observerStatusRoutes(deps) {
3025
3166
  return app;
3026
3167
  }
3027
3168
  //#endregion
3028
- //#region src/routes/target-validation.ts
3029
- var IDENTITY_TARGET_KEYS = new Set(VIEWER_IDENTITY_TARGET_KEYS);
3030
- var BOOLEAN_IDENTITY_TARGET_KEYS = /* @__PURE__ */ new Set([
3031
- "actor_id_present",
3032
- "embedding_disabled",
3033
- "embedding_offline"
3034
- ]);
3035
- function invalidRequest$1(message) {
3036
- return {
3037
- ok: false,
3038
- status: 400,
3039
- body: { error: {
3040
- code: "invalid_request",
3041
- message
3042
- } }
3043
- };
3044
- }
3045
- function conflict(code, message) {
3046
- return {
3047
- ok: false,
3048
- status: 409,
3049
- body: { error: {
3050
- code,
3051
- message
3052
- } }
3053
- };
3054
- }
3055
- function isRecord$1(value) {
3056
- return value != null && typeof value === "object" && !Array.isArray(value);
3057
- }
3058
- function currentIdentityTarget() {
3059
- return buildViewerIdentityTarget();
3060
- }
3061
- function requestedDbMatches(store, value) {
3062
- if (value == null) return true;
3063
- if (typeof value !== "string" || !value.trim()) return null;
3064
- return resolve(resolveDbPath(value.trim())) === resolve(store.dbPath);
3065
- }
3066
- function implicitConfigPath() {
3067
- const { resolved, fallbackChain } = resolveCodememConfigPath();
3068
- if (resolved.source !== "env-codemem-config") return resolve(resolved.path);
3069
- const candidates = fallbackChain.filter((candidate) => candidate.valid);
3070
- const implicit = candidates.find((candidate) => candidate.exists) ?? candidates[0];
3071
- return implicit ? resolve(implicit.path) : null;
3072
- }
3073
- function identityFieldMatches(key, requested, expected) {
3074
- if (requested === expected) return true;
3075
- if (key !== "config_path" || requested !== null && expected !== null) return false;
3076
- return (requested ?? expected) === implicitConfigPath();
3077
- }
3078
- function requestedIdentityMatches(value) {
3079
- if (value == null) return true;
3080
- if (!isRecord$1(value)) return null;
3081
- if (Object.keys(value).length !== IDENTITY_TARGET_KEYS.size || Object.keys(value).some((key) => !IDENTITY_TARGET_KEYS.has(key))) return "unsupported";
3082
- const expected = currentIdentityTarget();
3083
- for (const key of VIEWER_IDENTITY_TARGET_KEYS) {
3084
- const requested = value[key];
3085
- if (BOOLEAN_IDENTITY_TARGET_KEYS.has(key)) {
3086
- if (typeof requested !== "boolean") return null;
3087
- } else if (requested !== null && typeof requested !== "string") return null;
3088
- if (!identityFieldMatches(key, requested, expected[key])) return false;
3089
- }
3090
- return true;
3091
- }
3092
- function validateViewerTarget(store, payload, options = {}) {
3093
- if (options.requirePairedTargets) {
3094
- const hasDbPath = Object.hasOwn(payload, "db_path");
3095
- if (hasDbPath !== Object.hasOwn(payload, "identity_target")) return invalidRequest$1("db_path and identity_target must be provided together");
3096
- if (hasDbPath && (payload.db_path == null || payload.identity_target == null)) return invalidRequest$1("db_path and identity_target must be valid when provided");
3097
- }
3098
- const dbMatches = requestedDbMatches(store, payload.db_path);
3099
- if (dbMatches == null) return invalidRequest$1("db_path must be a non-empty string");
3100
- if (!dbMatches) return conflict("viewer_db_mismatch", "viewer database does not match request");
3101
- const identityMatches = requestedIdentityMatches(payload.identity_target);
3102
- if (identityMatches === "unsupported") return conflict("viewer_contract_unsupported", "viewer request contract is incompatible");
3103
- if (identityMatches == null) return invalidRequest$1("identity_target is invalid");
3104
- if (!identityMatches) return conflict("viewer_identity_mismatch", "viewer identity does not match request");
3105
- if ((options.requireCurrentIdentity || payload.identity_target != null) && !store.hasCurrentIdentity()) return conflict("viewer_identity_mismatch", "viewer identity does not match request");
3106
- return { ok: true };
3107
- }
3108
- /**
3109
- * Middleware read of db_path / identity_target from the query string.
3110
- * Native tools (pi extension) send targets as query params so a pre-handler
3111
- * guard can reject a foreign viewer without consuming POST bodies. Lenient:
3112
- * clients that omit targets (UI, MCP, curl) are unaffected.
3113
- */
3114
- function viewerTargetQueryGuard(getStore) {
3115
- return async (c, next) => {
3116
- const dbPath = c.req.query("db_path");
3117
- const rawIdentity = c.req.query("identity_target");
3118
- if (dbPath == null && rawIdentity == null) return next();
3119
- let identityTarget;
3120
- if (rawIdentity != null) try {
3121
- identityTarget = JSON.parse(rawIdentity);
3122
- } catch {
3123
- return c.json({ error: {
3124
- code: "invalid_request",
3125
- message: "identity_target must be JSON"
3126
- } }, 400);
3127
- }
3128
- const target = validateViewerTarget(getStore(), {
3129
- db_path: dbPath ?? void 0,
3130
- identity_target: identityTarget
3131
- });
3132
- if (!target.ok) return c.json(target.body, target.status);
3133
- return next();
3134
- };
3135
- }
3136
- //#endregion
3137
3169
  //#region src/routes/pack.ts
3138
3170
  var MAX_LEDGER_PAYLOAD_BYTES = 16384;
3139
3171
  var MAX_METADATA_FIELD_CHARS = 512;
@@ -13758,6 +13790,7 @@ function createApp(opts) {
13758
13790
  app.route("/", memoryRoutes(storeFactory));
13759
13791
  app.route("/", memoryToolRoutes(storeFactory));
13760
13792
  app.route("/", packTransportRoutes(storeFactory));
13793
+ app.route("/", fileContextRoutes(storeFactory));
13761
13794
  app.route("/", observerStatusRoutes({
13762
13795
  getStore: storeFactory,
13763
13796
  getSweeper: () => sweeper,