@remnic/core 9.16.3 → 9.17.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/access-admin-ops-surface.d.ts +8 -8
- package/dist/access-admin-ops-surface.js +2 -2
- package/dist/access-boundary.d.ts +8 -8
- package/dist/access-boundary.js +2 -2
- package/dist/access-cli.js +14 -14
- package/dist/access-http.d.ts +8 -8
- package/dist/access-http.js +6 -6
- package/dist/access-identity-continuity-surface.d.ts +6 -6
- package/dist/access-identity-continuity-surface.js +2 -2
- package/dist/access-lcm-surface.d.ts +8 -8
- package/dist/access-lcm-surface.js +2 -2
- package/dist/access-mcp.d.ts +8 -8
- package/dist/access-mcp.js +5 -5
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-DwhEFYy3.d.ts → access-namespace-preflight-_yxq3PYy.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +2 -2
- package/dist/access-observe-write-surface.d.ts +8 -8
- package/dist/access-observe-write-surface.js +2 -2
- package/dist/access-operations-batch.js +3 -3
- package/dist/access-operations.d.ts +8 -8
- package/dist/access-operations.js +4 -4
- package/dist/access-recall-concurrency.d.ts +8 -8
- package/dist/access-recall-concurrency.js +2 -2
- package/dist/access-recall-response.d.ts +8 -8
- package/dist/access-recall-response.js +2 -2
- package/dist/access-recall-surface.d.ts +8 -8
- package/dist/access-recall-surface.js +2 -2
- package/dist/{access-service-CSq1Wp2Z.d.ts → access-service-CSm242ks.d.ts} +6 -6
- package/dist/access-service.d.ts +8 -8
- package/dist/access-service.js +2 -2
- package/dist/access-surface-catalog.d.ts +8 -8
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +2 -2
- package/dist/{auto-sync-UZG3XQZ5.js → auto-sync-IH3G25MT.js} +2 -2
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +6 -6
- package/dist/briefing.d.ts +2 -2
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-B9uga4sG.d.ts → catalog-9qLG_2OV.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-YHURQ3M5.js → chunk-52EFQMQC.js} +269 -6
- package/dist/chunk-52EFQMQC.js.map +1 -0
- package/dist/{chunk-GEDBTSYU.js → chunk-7O2C2OOF.js} +4 -4
- package/dist/{chunk-OXT5TQDS.js → chunk-B6P3QDBF.js} +2 -2
- package/dist/{chunk-5EKOBRCA.js → chunk-BCNVNUQG.js} +2 -2
- package/dist/{chunk-TUNI4GB3.js → chunk-BGBPDAIN.js} +2 -2
- package/dist/{chunk-V6LYAXGW.js → chunk-F7BWFIDK.js} +2 -2
- package/dist/{chunk-BTK2PIFL.js → chunk-GBT4TFV7.js} +2 -2
- package/dist/{chunk-JOCXI2O5.js → chunk-K2B2TMF3.js} +2 -2
- package/dist/{chunk-VLIY55Q5.js → chunk-KQED7RCV.js} +7 -7
- package/dist/{chunk-GSQASASV.js → chunk-MONWCSVL.js} +65 -4
- package/dist/chunk-MONWCSVL.js.map +1 -0
- package/dist/{chunk-5SB7SC2G.js → chunk-UX3ZXN34.js} +3 -1
- package/dist/{chunk-M6TZQDTX.js → chunk-VZC7ORJE.js} +2 -2
- package/dist/{chunk-ANGUOE2N.js → chunk-WIUYMCPL.js} +2 -2
- package/dist/{chunk-DETNBTZS.js → chunk-XSBUROEB.js} +20 -4
- package/dist/chunk-XSBUROEB.js.map +1 -0
- package/dist/{cli-DYLGXxuu.d.ts → cli-BLZHYY2A.d.ts} +5 -5
- package/dist/cli.d.ts +10 -10
- package/dist/cli.js +11 -11
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +6 -6
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +98 -23
- package/dist/index.js +20 -14
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/mcp-memory-inspector-app.d.ts +8 -8
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +1 -1
- package/dist/operator-toolkit.d.ts +2 -2
- package/dist/operator-toolkit.js +3 -3
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +3 -3
- package/dist/orchestration/maintenance.js +2 -2
- package/dist/{orchestrator-BHx-DWCa.d.ts → orchestrator-CplS9U3U.d.ts} +5 -5
- package/dist/orchestrator.d.ts +6 -6
- package/dist/orchestrator.js +14 -14
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-DDHSE876.d.ts → pipeline-DB4CbFqo.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-C4WVh6BM.d.ts → qmd-BxZmOLHq.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray.d.ts +1 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +3 -3
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/{scope-profiles-EqMXwzCz.d.ts → scope-profiles-NsQQo1Lt.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-CYpvwmQc.d.ts → semantic-consolidation-DW85h30n.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/{storage-Dxd7zVZH.d.ts → storage-o5BTAa8d.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-OUCJALBK.d.ts → types-V3dT-pen.d.ts} +14 -2
- package/dist/types.d.ts +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/activity/config.test.ts +42 -4
- package/src/activity/config.ts +83 -8
- package/src/activity/index.ts +5 -3
- package/src/activity/memory-gen.test.ts +436 -0
- package/src/activity/memory-gen.ts +409 -0
- package/src/activity/runner.test.ts +3 -0
- package/src/activity/scheduler.test.ts +3 -0
- package/src/activity/sync-registration.test.ts +2 -1
- package/src/activity/types.ts +15 -1
- package/src/config.test.ts +7 -0
- package/src/offline-sync-impression-drain.test.ts +54 -0
- package/src/offline-sync-impression-drain.ts +35 -3
- package/dist/chunk-DETNBTZS.js.map +0 -1
- package/dist/chunk-GSQASASV.js.map +0 -1
- package/dist/chunk-YHURQ3M5.js.map +0 -1
- /package/dist/{auto-sync-UZG3XQZ5.js.map → auto-sync-IH3G25MT.js.map} +0 -0
- /package/dist/{chunk-GEDBTSYU.js.map → chunk-7O2C2OOF.js.map} +0 -0
- /package/dist/{chunk-OXT5TQDS.js.map → chunk-B6P3QDBF.js.map} +0 -0
- /package/dist/{chunk-5EKOBRCA.js.map → chunk-BCNVNUQG.js.map} +0 -0
- /package/dist/{chunk-TUNI4GB3.js.map → chunk-BGBPDAIN.js.map} +0 -0
- /package/dist/{chunk-V6LYAXGW.js.map → chunk-F7BWFIDK.js.map} +0 -0
- /package/dist/{chunk-BTK2PIFL.js.map → chunk-GBT4TFV7.js.map} +0 -0
- /package/dist/{chunk-JOCXI2O5.js.map → chunk-K2B2TMF3.js.map} +0 -0
- /package/dist/{chunk-VLIY55Q5.js.map → chunk-KQED7RCV.js.map} +0 -0
- /package/dist/{chunk-5SB7SC2G.js.map → chunk-UX3ZXN34.js.map} +0 -0
- /package/dist/{chunk-M6TZQDTX.js.map → chunk-VZC7ORJE.js.map} +0 -0
- /package/dist/{chunk-ANGUOE2N.js.map → chunk-WIUYMCPL.js.map} +0 -0
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
processChatMessage,
|
|
17
17
|
sessionBelongsToPrincipal,
|
|
18
18
|
subscribeChatTranscript
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-B6P3QDBF.js";
|
|
20
20
|
import {
|
|
21
21
|
RelayMissionStoreError
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-VZC7ORJE.js";
|
|
23
23
|
import {
|
|
24
24
|
executeResolution,
|
|
25
25
|
isValidResolutionVerb
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
CorrectionContractError,
|
|
37
37
|
getOperation,
|
|
38
38
|
resolveQueryNamespaceWritablePreflight
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-WIUYMCPL.js";
|
|
40
40
|
import {
|
|
41
41
|
isTrustZoneName
|
|
42
42
|
} from "./chunk-JGSKJHF7.js";
|
|
@@ -3132,4 +3132,4 @@ function positiveIntQueryParam(value, label) {
|
|
|
3132
3132
|
export {
|
|
3133
3133
|
EngramAccessHttpServer
|
|
3134
3134
|
};
|
|
3135
|
-
//# sourceMappingURL=chunk-
|
|
3135
|
+
//# sourceMappingURL=chunk-7O2C2OOF.js.map
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "./chunk-5RUE3GHQ.js";
|
|
19
19
|
import {
|
|
20
20
|
getOperation
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-WIUYMCPL.js";
|
|
22
22
|
import {
|
|
23
23
|
assertOperationAllowed,
|
|
24
24
|
capabilityAllowsOp,
|
|
@@ -3789,4 +3789,4 @@ export {
|
|
|
3789
3789
|
MCP_SUPPORTED_PROTOCOL_VERSIONS,
|
|
3790
3790
|
EngramMcpServer
|
|
3791
3791
|
};
|
|
3792
|
-
//# sourceMappingURL=chunk-
|
|
3792
|
+
//# sourceMappingURL=chunk-B6P3QDBF.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-NDAH7BJ5.js";
|
|
5
5
|
import {
|
|
6
6
|
parseActivityConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MONWCSVL.js";
|
|
8
8
|
import {
|
|
9
9
|
cloneDefaultSessionObserverBands
|
|
10
10
|
} from "./chunk-Z5LAYHGJ.js";
|
|
@@ -3620,4 +3620,4 @@ export {
|
|
|
3620
3620
|
VALID_MEMORY_CATEGORIES,
|
|
3621
3621
|
parseConfig
|
|
3622
3622
|
};
|
|
3623
|
-
//# sourceMappingURL=chunk-
|
|
3623
|
+
//# sourceMappingURL=chunk-BCNVNUQG.js.map
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
defineOperation,
|
|
29
29
|
parseNamespacePreflightWriteOp,
|
|
30
30
|
resolveAuthorizedNamespaceWritablePreflight
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-WIUYMCPL.js";
|
|
32
32
|
import {
|
|
33
33
|
projectTagProjectId
|
|
34
34
|
} from "./chunk-7VZWZVYG.js";
|
|
@@ -473,4 +473,4 @@ defineOperation({ name: "graph_events", description: "SSE graph events.", schema
|
|
|
473
473
|
defineOperation({ name: "chat_message", description: "Chat message.", schema: strictSchema({ message: S.str, chatSessionId: S.str }), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
|
|
474
474
|
defineOperation({ name: "chat_events", description: "SSE chat events.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { stream: "sse" } }) });
|
|
475
475
|
defineOperation({ name: "adapters_status", description: "Adapter registry metadata (issue #1850 round 5). Marker op: the HTTP transport builds the response from its own adapterRegistry, but the op still must be registered so it appears in listRegisteredOperations and enforceTokenOp can gate it for scoped tokens.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
|
|
476
|
-
//# sourceMappingURL=chunk-
|
|
476
|
+
//# sourceMappingURL=chunk-BGBPDAIN.js.map
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
isValidActivityDate,
|
|
23
23
|
serializeActivityDigest,
|
|
24
24
|
validateActivityBaseUrl
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-MONWCSVL.js";
|
|
26
26
|
import {
|
|
27
27
|
STATE_FILE_MAX_DECRYPT_BYTES,
|
|
28
28
|
drainPendingLifecycleLedgerIfAny,
|
|
@@ -1647,4 +1647,4 @@ export {
|
|
|
1647
1647
|
ActivitySyncScheduler,
|
|
1648
1648
|
MaintenanceScheduler
|
|
1649
1649
|
};
|
|
1650
|
-
//# sourceMappingURL=chunk-
|
|
1650
|
+
//# sourceMappingURL=chunk-F7BWFIDK.js.map
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from "./chunk-YBPYIAA5.js";
|
|
39
39
|
import {
|
|
40
40
|
parseConfig
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-BCNVNUQG.js";
|
|
42
42
|
import {
|
|
43
43
|
listMemoryGovernanceRuns,
|
|
44
44
|
readMemoryGovernanceRunArtifact
|
|
@@ -1671,4 +1671,4 @@ export {
|
|
|
1671
1671
|
runBenchmarkRecall,
|
|
1672
1672
|
runOperatorRepair
|
|
1673
1673
|
};
|
|
1674
|
-
//# sourceMappingURL=chunk-
|
|
1674
|
+
//# sourceMappingURL=chunk-GBT4TFV7.js.map
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-LMDRGRJ2.js";
|
|
12
12
|
import {
|
|
13
13
|
parseConfig
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BCNVNUQG.js";
|
|
15
15
|
import {
|
|
16
16
|
resolveObjectiveStateStoreDir,
|
|
17
17
|
validateObjectiveStateSnapshot
|
|
@@ -268,4 +268,4 @@ export {
|
|
|
268
268
|
recordResumeBundle,
|
|
269
269
|
getResumeBundleStatus
|
|
270
270
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
271
|
+
//# sourceMappingURL=chunk-K2B2TMF3.js.map
|
|
@@ -102,7 +102,7 @@ import {
|
|
|
102
102
|
buildResumeBundleFromState,
|
|
103
103
|
getResumeBundleStatus,
|
|
104
104
|
recordResumeBundle
|
|
105
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-K2B2TMF3.js";
|
|
106
106
|
import {
|
|
107
107
|
getWorkProductLedgerStatus,
|
|
108
108
|
recordWorkProductLedgerEntry,
|
|
@@ -126,7 +126,7 @@ import {
|
|
|
126
126
|
runOperatorInventory,
|
|
127
127
|
runOperatorRepair,
|
|
128
128
|
runOperatorSetup
|
|
129
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-GBT4TFV7.js";
|
|
130
130
|
import {
|
|
131
131
|
listNamespaces,
|
|
132
132
|
runNamespaceMigration,
|
|
@@ -207,10 +207,10 @@ import {
|
|
|
207
207
|
} from "./chunk-UQ7RN5HK.js";
|
|
208
208
|
import {
|
|
209
209
|
parseConfig
|
|
210
|
-
} from "./chunk-
|
|
210
|
+
} from "./chunk-BCNVNUQG.js";
|
|
211
211
|
import {
|
|
212
212
|
EngramAccessHttpServer
|
|
213
|
-
} from "./chunk-
|
|
213
|
+
} from "./chunk-7O2C2OOF.js";
|
|
214
214
|
import {
|
|
215
215
|
WearablesInputError
|
|
216
216
|
} from "./chunk-V7IZKJI3.js";
|
|
@@ -223,13 +223,13 @@ import {
|
|
|
223
223
|
createProductionChatLlmAdapter,
|
|
224
224
|
loadChatSession,
|
|
225
225
|
sessionBelongsToPrincipal
|
|
226
|
-
} from "./chunk-
|
|
226
|
+
} from "./chunk-B6P3QDBF.js";
|
|
227
227
|
import {
|
|
228
228
|
getAbstractionNodeStoreStatus
|
|
229
229
|
} from "./chunk-OADWQ5CR.js";
|
|
230
230
|
import {
|
|
231
231
|
EngramAccessService
|
|
232
|
-
} from "./chunk-
|
|
232
|
+
} from "./chunk-WIUYMCPL.js";
|
|
233
233
|
import {
|
|
234
234
|
WorkStorage
|
|
235
235
|
} from "./chunk-GDB4J2H3.js";
|
|
@@ -7650,4 +7650,4 @@ export {
|
|
|
7650
7650
|
listMemoryMarkdownFilePaths,
|
|
7651
7651
|
registerCli
|
|
7652
7652
|
};
|
|
7653
|
-
//# sourceMappingURL=chunk-
|
|
7653
|
+
//# sourceMappingURL=chunk-KQED7RCV.js.map
|
|
@@ -326,6 +326,25 @@ function parseMachinesList(raw) {
|
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
// src/activity/config.ts
|
|
329
|
+
var EXTRACTION_MODES = ["off", "smart"];
|
|
330
|
+
var IMPORTANCE_LEVELS = ["critical", "high", "normal", "low", "trivial"];
|
|
331
|
+
var LOOPBACK_HOSTS = { localhost: true, "127.0.0.1": true, "::1": true };
|
|
332
|
+
function defaultActivityConfig() {
|
|
333
|
+
return {
|
|
334
|
+
enabled: false,
|
|
335
|
+
timezone: "UTC",
|
|
336
|
+
syncDays: 1,
|
|
337
|
+
autoSyncIntervalMinutes: 15,
|
|
338
|
+
sources: [],
|
|
339
|
+
extractionMode: "off",
|
|
340
|
+
sourceTrust: 0.6,
|
|
341
|
+
autoApproveTrust: 0.8,
|
|
342
|
+
reviewTrust: 0.5,
|
|
343
|
+
minConfidence: 0.7,
|
|
344
|
+
minImportance: "normal",
|
|
345
|
+
maxMemoriesPerDay: 0
|
|
346
|
+
};
|
|
347
|
+
}
|
|
329
348
|
function asRecord(value, name) {
|
|
330
349
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
331
350
|
throw new TypeError(`${name} must be an object`);
|
|
@@ -337,7 +356,14 @@ function optionalString(value, name) {
|
|
|
337
356
|
if (typeof value !== "string" || value.length === 0) throw new TypeError(`${name} must be a non-empty string`);
|
|
338
357
|
return value;
|
|
339
358
|
}
|
|
340
|
-
|
|
359
|
+
function parseUnitInterval(value, key, fallback) {
|
|
360
|
+
if (value === void 0) return fallback;
|
|
361
|
+
const parsed = coerceNumber(value);
|
|
362
|
+
if (parsed === void 0 || !Number.isFinite(parsed) || parsed < 0 || parsed > 1) {
|
|
363
|
+
throw new RangeError(`activity.${key} must be a number in [0, 1]`);
|
|
364
|
+
}
|
|
365
|
+
return parsed;
|
|
366
|
+
}
|
|
341
367
|
function validateActivityBaseUrl(baseUrl) {
|
|
342
368
|
let parsed;
|
|
343
369
|
try {
|
|
@@ -369,8 +395,9 @@ function parseSource(value) {
|
|
|
369
395
|
return { machineLabel, baseUrl, ...token === void 0 ? {} : { token } };
|
|
370
396
|
}
|
|
371
397
|
function parseActivityConfig(raw) {
|
|
398
|
+
const defaults = defaultActivityConfig();
|
|
372
399
|
if (raw === void 0 || raw === null) {
|
|
373
|
-
return {
|
|
400
|
+
return { ...defaults };
|
|
374
401
|
}
|
|
375
402
|
const config = asRecord(raw, "activity");
|
|
376
403
|
const enabledValue = coerceBooleanLike(config.enabled, "activity.enabled");
|
|
@@ -408,7 +435,40 @@ function parseActivityConfig(raw) {
|
|
|
408
435
|
}
|
|
409
436
|
const enabled = enabledValue ?? false;
|
|
410
437
|
if (enabled && sources.length === 0) throw new RangeError("activity.enabled requires at least one source");
|
|
411
|
-
|
|
438
|
+
const extractionMode = config.extractionMode === void 0 ? defaults.extractionMode : config.extractionMode;
|
|
439
|
+
if (typeof extractionMode !== "string" || !EXTRACTION_MODES.includes(extractionMode)) {
|
|
440
|
+
throw new RangeError(`activity.extractionMode must be one of: ${EXTRACTION_MODES.join(", ")}`);
|
|
441
|
+
}
|
|
442
|
+
const minImportance = config.minImportance === void 0 ? defaults.minImportance : config.minImportance;
|
|
443
|
+
if (typeof minImportance !== "string" || !IMPORTANCE_LEVELS.includes(minImportance)) {
|
|
444
|
+
throw new RangeError(`activity.minImportance must be one of: ${IMPORTANCE_LEVELS.join(", ")}`);
|
|
445
|
+
}
|
|
446
|
+
const rawMaxMemoriesPerDay = config.maxMemoriesPerDay === void 0 ? defaults.maxMemoriesPerDay : config.maxMemoriesPerDay;
|
|
447
|
+
const maxMemoriesPerDay = coerceNumber(rawMaxMemoriesPerDay);
|
|
448
|
+
if (maxMemoriesPerDay === void 0 || !Number.isInteger(maxMemoriesPerDay) || maxMemoriesPerDay < 0) {
|
|
449
|
+
throw new RangeError("activity.maxMemoriesPerDay must be a non-negative integer");
|
|
450
|
+
}
|
|
451
|
+
const autoApproveTrust = parseUnitInterval(config.autoApproveTrust, "autoApproveTrust", defaults.autoApproveTrust);
|
|
452
|
+
const reviewTrust = parseUnitInterval(config.reviewTrust, "reviewTrust", defaults.reviewTrust);
|
|
453
|
+
if (reviewTrust >= autoApproveTrust) {
|
|
454
|
+
throw new RangeError(
|
|
455
|
+
`activity.reviewTrust (${reviewTrust}) must be below autoApproveTrust (${autoApproveTrust})`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
enabled,
|
|
460
|
+
timezone,
|
|
461
|
+
syncDays,
|
|
462
|
+
autoSyncIntervalMinutes,
|
|
463
|
+
sources,
|
|
464
|
+
extractionMode,
|
|
465
|
+
sourceTrust: parseUnitInterval(config.sourceTrust, "sourceTrust", defaults.sourceTrust),
|
|
466
|
+
autoApproveTrust,
|
|
467
|
+
reviewTrust,
|
|
468
|
+
minConfidence: parseUnitInterval(config.minConfidence, "minConfidence", defaults.minConfidence),
|
|
469
|
+
minImportance,
|
|
470
|
+
maxMemoriesPerDay
|
|
471
|
+
};
|
|
412
472
|
}
|
|
413
473
|
|
|
414
474
|
export {
|
|
@@ -423,7 +483,8 @@ export {
|
|
|
423
483
|
composeActivityDigestMeta,
|
|
424
484
|
serializeActivityDigest,
|
|
425
485
|
parseActivityDigest,
|
|
486
|
+
defaultActivityConfig,
|
|
426
487
|
validateActivityBaseUrl,
|
|
427
488
|
parseActivityConfig
|
|
428
489
|
};
|
|
429
|
-
//# sourceMappingURL=chunk-
|
|
490
|
+
//# sourceMappingURL=chunk-MONWCSVL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/activity/digest.ts","../src/activity/config.ts"],"sourcesContent":["/**\n * Deterministic screen-activity day-digest renderer (issue #1899).\n *\n * Renders a day's snapshots into markdown with YAML frontmatter, placed at\n * `<memoryDir>/activity/<date>.md` — outside the memory scan roots but inside\n * the QMD collection root (searchable, never auto-recalled). No LLM: the body\n * is a pure, byte-identical function of its inputs so an unchanged day skips\n * rewrite by contentHash. Day bucketing is DST-aware and half-open\n * [start, end) (AGENTS.md §23); sort keys are total with stable tiebreakers\n * (§12).\n */\n\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\n\nimport type { ActivityDayDigest, ActivityDayMeta, ActivitySnapshot } from \"./types.js\";\n\nexport const ACTIVITY_DIGEST_FORMAT_VERSION = 1;\nexport const ACTIVITY_DIR_NAME = \"activity\";\n\n/** Attribute at most this much dwell to a single snapshot (idle gaps capped). */\nconst MAX_DWELL_MS = 15 * 60_000;\n/** Notable-excerpt caps. */\nconst NOTABLE_MAX_WINDOWS = 10;\nconst NOTABLE_EXCERPT_CHARS = 280;\n\nconst DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nexport function isValidActivityDate(date: string): boolean {\n if (typeof date !== \"string\" || !DATE_PATTERN.test(date)) return false;\n // Reject impossible calendar days (e.g. 2026-02-30, 2026-13-01): the UTC\n // round-trip must reproduce the same Y-M-D, else Date normalized an overflow.\n const parsed = new Date(`${date}T00:00:00Z`);\n return Number.isFinite(parsed.getTime()) && parsed.toISOString().slice(0, 10) === date;\n}\n\nexport function activityDigestPath(memoryDir: string, date: string): string {\n if (!isValidActivityDate(date)) {\n // Never interpolate an unvalidated date into a filesystem path (a `../`\n // would escape <memoryDir>/activity/). Reject loudly.\n throw new RangeError(`Invalid activity date \"${date}\"; expected YYYY-MM-DD.`);\n }\n return path.join(memoryDir, ACTIVITY_DIR_NAME, `${date}.md`);\n}\n\n// ── DST-aware local-day window ──────────────────────────────────────────────\n\nfunction timezoneOffsetIso(instant: Date, timezone: string): string {\n const parts = new Intl.DateTimeFormat(\"en-US\", {\n timeZone: timezone,\n timeZoneName: \"longOffset\",\n }).formatToParts(instant);\n const name = parts.find((part) => part.type === \"timeZoneName\")?.value ?? \"GMT\";\n const match = name.match(/GMT([+-]\\d{2}:\\d{2})?/);\n return match?.[1] ?? \"+00:00\";\n}\n\nexport function assertValidTimezone(timezone: string): void {\n try {\n new Intl.DateTimeFormat(\"en-US\", { timeZone: timezone });\n } catch {\n throw new RangeError(`Invalid IANA timezone \"${timezone}\".`);\n }\n}\n\nfunction zonedDayStartIso(date: string, timezone: string): string {\n // The first UTC instant whose local wall-clock is this date at 00:00. Probe\n // several instants across the day to collect every offset in play; keep an\n // offset only if constructing local midnight with it lands back on that same\n // offset (so it is genuinely local midnight, not a wall-clock that never\n // occurred), then take the EARLIEST such instant — the FIRST 00:00 across a\n // DST fall-back that repeats local midnight.\n // Probe the previous UTC day too: for zones east of UTC the requested date's\n // UTC instants all fall after local midnight, so the pre-transition offset\n // valid at the real local 00:00 is only observable on the prior UTC day.\n const prevDate = shiftIsoDate(date, -1);\n const probeOffsets = new Set(\n [\n `${prevDate}T12:00:00Z`,\n `${prevDate}T23:00:00Z`,\n `${date}T00:00:00Z`,\n `${date}T12:00:00Z`,\n `${date}T23:00:00Z`,\n ].map((iso) => timezoneOffsetIso(new Date(iso), timezone)),\n );\n let best: number | null = null;\n for (const offset of probeOffsets) {\n const candidate = Date.parse(`${date}T00:00:00${offset}`);\n if (!Number.isFinite(candidate)) continue;\n // Reject an offset whose local midnight does not actually occur (the wall\n // clock skipped by a spring-forward): the offset in effect at the candidate\n // instant must be the same offset we used to build it.\n if (timezoneOffsetIso(new Date(candidate), timezone) !== offset) continue;\n if (best === null || candidate < best) best = candidate;\n }\n if (best === null) {\n // Local midnight was skipped by a spring-forward at 00:00. Advance to the\n // first local wall-clock minute on this date that actually exists (never\n // backdating to a 00:00 that never occurred), scanning forward up to 3h.\n for (let minute = 1; minute <= 180 && best === null; minute++) {\n const hh = String(Math.floor(minute / 60)).padStart(2, \"0\");\n const mm = String(minute % 60).padStart(2, \"0\");\n for (const offset of probeOffsets) {\n const candidate = Date.parse(`${date}T${hh}:${mm}:00${offset}`);\n if (!Number.isFinite(candidate)) continue;\n if (timezoneOffsetIso(new Date(candidate), timezone) !== offset) continue;\n if (best === null || candidate < best) best = candidate;\n }\n }\n }\n if (best === null) {\n // Degenerate safety net: use the noon-derived offset for a deterministic start.\n const noon = timezoneOffsetIso(new Date(`${date}T12:00:00Z`), timezone);\n best = Date.parse(`${date}T00:00:00${noon}`);\n }\n if (best === null || !Number.isFinite(best)) {\n throw new RangeError(`activity: could not resolve a local day start for \"${date}\" in \"${timezone}\".`);\n }\n return new Date(best).toISOString();\n}\n\nfunction shiftIsoDate(date: string, days: number): string {\n const parsed = new Date(`${date}T00:00:00Z`);\n parsed.setUTCDate(parsed.getUTCDate() + days);\n return parsed.toISOString().slice(0, 10);\n}\n\nfunction nextIsoDate(date: string): string {\n return shiftIsoDate(date, 1);\n}\n\n/** Half-open [start, end) UTC ISO bounds of a local day. */\nexport function activityDayWindow(date: string, timezone: string): { startUtc: string; endUtc: string } {\n if (!isValidActivityDate(date)) {\n throw new RangeError(`Invalid activity date \"${date}\"; expected a real YYYY-MM-DD day.`);\n }\n assertValidTimezone(timezone);\n return {\n startUtc: new Date(zonedDayStartIso(date, timezone)).toISOString(),\n endUtc: new Date(zonedDayStartIso(nextIsoDate(date), timezone)).toISOString(),\n };\n}\n\n// ── Rendering ───────────────────────────────────────────────────────────────\n\nfunction sortedByTime(snapshots: ActivitySnapshot[]): ActivitySnapshot[] {\n return [...snapshots].sort((a, b) => {\n // Compare by parsed instant, not raw string, so mixed valid ISO forms\n // (Z vs offset, varying precision) still order chronologically.\n const at = Date.parse(a.capturedAtUtc);\n const bt = Date.parse(b.capturedAtUtc);\n if (at !== bt && Number.isFinite(at) && Number.isFinite(bt)) return at < bt ? -1 : 1;\n const aid = a.id ?? 0;\n const bid = b.id ?? 0;\n if (aid < bid) return -1;\n if (aid > bid) return 1;\n // Unsaved snapshots (pre-store) both default to id 0; fall back to the\n // content hash (their dedup identity), then app/window, for a total order.\n if (a.contentHash !== b.contentHash) return a.contentHash < b.contentHash ? -1 : 1;\n if (a.app !== b.app) return a.app < b.app ? -1 : 1;\n if (a.windowTitle !== b.windowTitle) return a.windowTitle < b.windowTitle ? -1 : 1;\n return 0;\n });\n}\n\n/**\n * Per-snapshot dwell (gap to that machine's next snapshot, capped), scoped per\n * capture machine so an interleaved snapshot from another machine can't steal\n * or truncate a snapshot's dwell (multi-machine days).\n */\nfunction computeDwell(snapshots: ActivitySnapshot[]): Map<ActivitySnapshot, number> {\n const byMachine = new Map<string, ActivitySnapshot[]>();\n for (const snapshot of snapshots) {\n const list = byMachine.get(snapshot.machine);\n if (list === undefined) byMachine.set(snapshot.machine, [snapshot]);\n else list.push(snapshot);\n }\n const dwell = new Map<ActivitySnapshot, number>();\n for (const list of byMachine.values()) {\n const ordered = sortedByTime(list);\n for (let index = 0; index < ordered.length; index++) {\n const current = ordered[index];\n if (current === undefined) continue;\n const next = ordered[index + 1];\n let value = 0;\n if (next !== undefined) {\n const delta = Date.parse(next.capturedAtUtc) - Date.parse(current.capturedAtUtc);\n if (Number.isFinite(delta) && delta > 0) value = Math.min(delta, MAX_DWELL_MS);\n }\n dwell.set(current, value);\n }\n }\n return dwell;\n}\n\nfunction formatDurationMinutes(ms: number): string {\n return `${Math.round(ms / 60_000)}m`;\n}\n\nfunction clockHhMm(iso: string, timezone: string): string {\n const ms = Date.parse(iso);\n if (!Number.isFinite(ms)) return \"??:??\";\n const parts = new Intl.DateTimeFormat(\"en-GB\", {\n timeZone: timezone,\n hour: \"2-digit\",\n minute: \"2-digit\",\n hour12: false,\n }).formatToParts(new Date(ms));\n const hour = parts.find((p) => p.type === \"hour\")?.value ?? \"00\";\n const minute = parts.find((p) => p.type === \"minute\")?.value ?? \"00\";\n return `${hour}:${minute}`;\n}\n\nfunction collapseWhitespace(text: string): string {\n return text.replace(/\\s+/g, \" \").trim();\n}\n\nfunction perAppSection(ordered: ActivitySnapshot[], dwell: Map<ActivitySnapshot, number>): string {\n const totals = new Map<string, number>();\n for (const snapshot of ordered) {\n totals.set(snapshot.app, (totals.get(snapshot.app) ?? 0) + (dwell.get(snapshot) ?? 0));\n }\n const rows = [...totals.entries()].sort((a, b) => {\n if (b[1] !== a[1]) return b[1] - a[1];\n if (a[0] < b[0]) return -1;\n if (a[0] > b[0]) return 1;\n return 0;\n });\n const lines = [\"## Per-app time\", \"\"];\n if (rows.length === 0) {\n lines.push(\"_No activity recorded._\");\n } else {\n for (const [app, ms] of rows) {\n lines.push(`- ${app}: ${formatDurationMinutes(ms)}`);\n }\n }\n return lines.join(\"\\n\");\n}\n\ninterface TimelineSpan {\n startIso: string;\n machine: string;\n app: string;\n windowTitle: string;\n browserUrl?: string;\n}\n\nfunction timelineSpans(ordered: ActivitySnapshot[]): TimelineSpan[] {\n const spans: TimelineSpan[] = [];\n for (const snapshot of ordered) {\n const last = spans[spans.length - 1];\n if (\n last !== undefined &&\n last.machine === snapshot.machine &&\n last.app === snapshot.app &&\n last.windowTitle === snapshot.windowTitle &&\n last.browserUrl === snapshot.browserUrl\n ) {\n continue;\n }\n spans.push({\n startIso: snapshot.capturedAtUtc,\n machine: snapshot.machine,\n app: snapshot.app,\n windowTitle: snapshot.windowTitle,\n ...(snapshot.browserUrl !== undefined ? { browserUrl: snapshot.browserUrl } : {}),\n });\n }\n return spans;\n}\n\nfunction timelineSection(ordered: ActivitySnapshot[], timezone: string): string {\n const lines = [\"## Timeline\", \"\"];\n const spans = timelineSpans(ordered);\n if (spans.length === 0) {\n lines.push(\"_No activity recorded._\");\n return lines.join(\"\\n\");\n }\n for (const span of spans) {\n const clock = clockHhMm(span.startIso, timezone);\n const window = collapseWhitespace(span.windowTitle);\n const url = span.browserUrl !== undefined ? ` (${collapseWhitespace(span.browserUrl)})` : \"\";\n lines.push(`- [${clock}] ${span.app}${window.length > 0 ? ` — ${window}` : \"\"}${url}`);\n }\n return lines.join(\"\\n\");\n}\n\nfunction notableSection(ordered: ActivitySnapshot[], dwell: Map<ActivitySnapshot, number>): string {\n const withDwell = ordered.map((snapshot) => ({ snapshot, dwell: dwell.get(snapshot) ?? 0 }));\n const ranked = withDwell\n .filter((entry) => collapseWhitespace(entry.snapshot.text).length > 0)\n .sort((a, b) => {\n if (b.dwell !== a.dwell) return b.dwell - a.dwell;\n const at = Date.parse(a.snapshot.capturedAtUtc);\n const bt = Date.parse(b.snapshot.capturedAtUtc);\n if (at !== bt && Number.isFinite(at) && Number.isFinite(bt)) return at < bt ? -1 : 1;\n const idDelta = (a.snapshot.id ?? 0) - (b.snapshot.id ?? 0);\n if (idDelta !== 0) return idDelta;\n if (a.snapshot.contentHash !== b.snapshot.contentHash) {\n return a.snapshot.contentHash < b.snapshot.contentHash ? -1 : 1;\n }\n return 0;\n })\n .slice(0, NOTABLE_MAX_WINDOWS);\n const lines = [\"## Notable\", \"\"];\n if (ranked.length === 0) {\n lines.push(\"_No notable text captured._\");\n return lines.join(\"\\n\");\n }\n for (const { snapshot } of ranked) {\n const excerpt = collapseWhitespace(snapshot.text).slice(0, NOTABLE_EXCERPT_CHARS);\n lines.push(`- **${snapshot.app}** — ${excerpt}`);\n }\n return lines.join(\"\\n\");\n}\n\nexport function composeActivityDigestBody(\n date: string,\n timezone: string,\n snapshots: ActivitySnapshot[],\n): string {\n assertValidTimezone(timezone);\n const ordered = sortedByTime(snapshots);\n const dwell = computeDwell(ordered);\n return [\n `# Activity — ${date}`,\n \"\",\n perAppSection(ordered, dwell),\n \"\",\n timelineSection(ordered, timezone),\n \"\",\n notableSection(ordered, dwell),\n \"\",\n ].join(\"\\n\");\n}\n\nexport function hashActivityBody(body: string): string {\n return createHash(\"sha256\").update(body, \"utf8\").digest(\"hex\");\n}\n\nexport function composeActivityDigestMeta(\n date: string,\n machines: string[],\n snapshots: ActivitySnapshot[],\n body: string,\n): ActivityDayMeta {\n const uniqueMachines = [...new Set(machines)].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n return {\n kind: \"activity-digest\",\n date,\n machines: uniqueMachines,\n snapshotCount: snapshots.length,\n contentHash: hashActivityBody(body),\n formatVersion: ACTIVITY_DIGEST_FORMAT_VERSION,\n };\n}\n\nexport function serializeActivityDigest(meta: ActivityDayMeta, body: string): string {\n const frontmatter = [\n \"---\",\n `kind: ${meta.kind}`,\n `date: ${meta.date}`,\n `machines: ${JSON.stringify(meta.machines)}`,\n `snapshotCount: ${meta.snapshotCount}`,\n `contentHash: ${meta.contentHash}`,\n `formatVersion: ${meta.formatVersion}`,\n \"---\",\n \"\",\n ].join(\"\\n\");\n return `${frontmatter}${body}`;\n}\n\nexport function parseActivityDigest(raw: string): ActivityDayDigest | null {\n if (typeof raw !== \"string\" || !raw.startsWith(\"---\\n\")) return null;\n const end = raw.indexOf(\"\\n---\\n\", 4);\n if (end === -1) return null;\n const frontmatter = raw.slice(4, end);\n const body = raw.slice(end + 5).replace(/^\\n/, \"\");\n const fields = new Map<string, string>();\n for (const line of frontmatter.split(\"\\n\")) {\n const idx = line.indexOf(\":\");\n if (idx === -1) continue;\n fields.set(line.slice(0, idx).trim(), line.slice(idx + 1).trim());\n }\n const date = fields.get(\"date\");\n const contentHash = fields.get(\"contentHash\");\n if (date === undefined || !isValidActivityDate(date) || contentHash === undefined) return null;\n if (fields.get(\"kind\") !== \"activity-digest\") return null;\n const machines = parseMachinesList(fields.get(\"machines\") ?? \"[]\");\n const snapshotCount = parseNonNegativeInt(fields.get(\"snapshotCount\"));\n const formatVersion = parseNonNegativeInt(fields.get(\"formatVersion\"));\n if (snapshotCount === null || formatVersion === null) return null;\n return {\n meta: {\n kind: \"activity-digest\",\n date,\n machines,\n snapshotCount,\n contentHash,\n formatVersion,\n },\n body,\n };\n}\n\nfunction parseNonNegativeInt(value: string | undefined): number | null {\n if (value === undefined) return null;\n const trimmed = value.trim();\n if (!/^\\d+$/.test(trimmed)) return null;\n const parsed = Number(trimmed);\n return Number.isSafeInteger(parsed) ? parsed : null;\n}\n\nfunction parseMachinesList(raw: string): string[] {\n try {\n const parsed: unknown = JSON.parse(raw);\n if (Array.isArray(parsed)) {\n return parsed.filter((entry): entry is string => typeof entry === \"string\");\n }\n } catch {\n // Legacy unquoted inline form (`[a, b]`) — fall through to the split parse.\n }\n return raw\n .replace(/^\\[/, \"\")\n .replace(/\\]$/, \"\")\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n}\n","import { coerceBooleanLike, coerceNumber } from \"../connectors/coerce.js\";\nimport { assertValidTimezone } from \"./digest.js\";\nimport type { ImportanceLevel } from \"../types.js\";\nimport type { ActivityConfig, ActivityExtractionMode, ActivitySourceConfig } from \"./types.js\";\n\nconst EXTRACTION_MODES: readonly ActivityExtractionMode[] = [\"off\", \"smart\"];\nconst IMPORTANCE_LEVELS: readonly ImportanceLevel[] = [\"critical\", \"high\", \"normal\", \"low\", \"trivial\"];\nconst LOOPBACK_HOSTS: Record<string, true> = { localhost: true, \"127.0.0.1\": true, \"::1\": true };\n\n/** The inert default: disabled, search-only, no sources, no extraction. */\nexport function defaultActivityConfig(): ActivityConfig {\n return {\n enabled: false,\n timezone: \"UTC\",\n syncDays: 1,\n autoSyncIntervalMinutes: 15,\n sources: [],\n extractionMode: \"off\",\n sourceTrust: 0.6,\n autoApproveTrust: 0.8,\n reviewTrust: 0.5,\n minConfidence: 0.7,\n minImportance: \"normal\",\n maxMemoriesPerDay: 0,\n };\n}\n\nfunction asRecord(value: unknown, name: string): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(`${name} must be an object`);\n }\n return value as Record<string, unknown>;\n}\n\nfunction optionalString(value: unknown, name: string): string | undefined {\n if (value === undefined) return undefined;\n if (typeof value !== \"string\" || value.length === 0) throw new TypeError(`${name} must be a non-empty string`);\n return value;\n}\n\nfunction parseUnitInterval(value: unknown, key: string, fallback: number): number {\n if (value === undefined) return fallback;\n const parsed = coerceNumber(value);\n if (parsed === undefined || !Number.isFinite(parsed) || parsed < 0 || parsed > 1) {\n throw new RangeError(`activity.${key} must be a number in [0, 1]`);\n }\n return parsed;\n}\n\n/**\n * Parse, protocol-check, and confine an activity source base URL to a local\n * loopback host. Shared with ActivityHttpSourceClient so config-load and client\n * construction reject the exact same shapes with the same prefixed message. The\n * bearer token travels in an Authorization header, so a non-loopback baseUrl\n * would exfiltrate it; the subsystem contract is local capture daemons only.\n */\nexport function validateActivityBaseUrl(baseUrl: string): URL {\n let parsed: URL;\n try {\n parsed = new URL(baseUrl);\n } catch {\n throw new RangeError(`activity source baseUrl must be a valid URL: ${baseUrl}`);\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new RangeError(\"activity source baseUrl must use HTTP or HTTPS\");\n }\n // URL keeps IPv6 hosts bracketed (e.g. \"[::1]\"); normalize before the lookup.\n const host = parsed.hostname.replace(/^\\[|\\]$/g, \"\");\n if (LOOPBACK_HOSTS[host] !== true && !/^127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/.test(host)) {\n throw new RangeError(`activity source baseUrl must target a loopback host (got ${parsed.hostname})`);\n }\n return parsed;\n}\n\nfunction parseSource(value: unknown): ActivitySourceConfig {\n const raw = asRecord(value, \"activity source\");\n const machineLabel = optionalString(raw.machineLabel, \"activity source machineLabel\");\n const baseUrl = optionalString(raw.baseUrl, \"activity source baseUrl\");\n if (machineLabel === undefined || baseUrl === undefined) {\n throw new TypeError(\"activity source requires machineLabel and baseUrl\");\n }\n // Reject whitespace-only labels here so config-load fails loudly rather than\n // parsing clean and then failing on the first sync (the client and pipeline\n // both reject a blank label via trim()).\n if (machineLabel.trim().length === 0) {\n throw new RangeError(\"activity source machineLabel must not be blank\");\n }\n validateActivityBaseUrl(baseUrl);\n const token = optionalString(raw.token, \"activity source token\");\n return { machineLabel, baseUrl, ...(token === undefined ? {} : { token }) };\n}\n\n/**\n * Parse the unified `activity.*` block. `enabled` gates source ingestion (and\n * requires at least one source); `extractionMode` independently gates durable\n * trust-gated memory extraction (default `off`, i.e. search-only).\n */\nexport function parseActivityConfig(raw: unknown): ActivityConfig {\n const defaults = defaultActivityConfig();\n if (raw === undefined || raw === null) {\n return { ...defaults };\n }\n const config = asRecord(raw, \"activity\");\n const enabledValue = coerceBooleanLike(config.enabled, \"activity.enabled\");\n if (config.enabled !== undefined && enabledValue === undefined) {\n throw new TypeError(\"activity.enabled must be a boolean\");\n }\n const timezone = optionalString(config.timezone, \"activity.timezone\") ?? \"UTC\";\n // Validate the IANA zone at parse so a typo fails before any daemon is\n // contacted; otherwise activityDayWindow() throws mid-sync after snapshot\n // pages may already be persisted, and every retry replays the same window.\n assertValidTimezone(timezone);\n const syncDaysValue = coerceNumber(config.syncDays, \"activity.syncDays\");\n if (config.syncDays !== undefined && syncDaysValue === undefined) {\n throw new TypeError(\"activity.syncDays must be a finite number\");\n }\n const syncDays = syncDaysValue ?? 1;\n if (!Number.isInteger(syncDays) || syncDays < 1 || syncDays > 90) {\n throw new RangeError(\"activity.syncDays must be an integer from 1 to 90\");\n }\n const intervalValue = coerceNumber(config.autoSyncIntervalMinutes, \"activity.autoSyncIntervalMinutes\");\n if (config.autoSyncIntervalMinutes !== undefined && intervalValue === undefined) {\n throw new TypeError(\"activity.autoSyncIntervalMinutes must be a finite number\");\n }\n const autoSyncIntervalMinutes = intervalValue ?? 15;\n if (!Number.isInteger(autoSyncIntervalMinutes) || autoSyncIntervalMinutes < 1 || autoSyncIntervalMinutes > 1440) {\n throw new RangeError(\"activity.autoSyncIntervalMinutes must be an integer from 1 to 1440\");\n }\n if (config.sources !== undefined && !Array.isArray(config.sources)) {\n throw new TypeError(\"activity.sources must be an array\");\n }\n const sources = (config.sources ?? []).map(parseSource);\n // Cursors and row dedup are keyed on machineLabel alone; two sources sharing\n // a label would share a cursor and dedup namespace, silently skipping or\n // conflating snapshots. Reject the collision at parse.\n const labels = new Set<string>();\n for (const source of sources) {\n if (labels.has(source.machineLabel)) {\n throw new RangeError(`activity source machineLabel must be unique: ${source.machineLabel}`);\n }\n labels.add(source.machineLabel);\n }\n const enabled = enabledValue ?? false;\n if (enabled && sources.length === 0) throw new RangeError(\"activity.enabled requires at least one source\");\n\n // Extraction gate (independent of `enabled` ingestion). Default `off`.\n // Default only for a missing key; an explicit null/non-string is a malformed\n // enum and must fail rather than silently disabling extraction.\n const extractionMode = config.extractionMode === undefined ? defaults.extractionMode : config.extractionMode;\n if (typeof extractionMode !== \"string\" || !EXTRACTION_MODES.includes(extractionMode as ActivityExtractionMode)) {\n throw new RangeError(`activity.extractionMode must be one of: ${EXTRACTION_MODES.join(\", \")}`);\n }\n const minImportance = config.minImportance === undefined ? defaults.minImportance : config.minImportance;\n if (typeof minImportance !== \"string\" || !IMPORTANCE_LEVELS.includes(minImportance as ImportanceLevel)) {\n throw new RangeError(`activity.minImportance must be one of: ${IMPORTANCE_LEVELS.join(\", \")}`);\n }\n // Default only for a missing key; an explicit null/unparseable value must fail\n // rather than silently uncapping (parity with the enum/unit-interval fields).\n const rawMaxMemoriesPerDay =\n config.maxMemoriesPerDay === undefined ? defaults.maxMemoriesPerDay : config.maxMemoriesPerDay;\n const maxMemoriesPerDay = coerceNumber(rawMaxMemoriesPerDay);\n if (maxMemoriesPerDay === undefined || !Number.isInteger(maxMemoriesPerDay) || maxMemoriesPerDay < 0) {\n throw new RangeError(\"activity.maxMemoriesPerDay must be a non-negative integer\");\n }\n const autoApproveTrust = parseUnitInterval(config.autoApproveTrust, \"autoApproveTrust\", defaults.autoApproveTrust);\n const reviewTrust = parseUnitInterval(config.reviewTrust, \"reviewTrust\", defaults.reviewTrust);\n if (reviewTrust >= autoApproveTrust) {\n throw new RangeError(\n `activity.reviewTrust (${reviewTrust}) must be below autoApproveTrust (${autoApproveTrust})`,\n );\n }\n return {\n enabled,\n timezone,\n syncDays,\n autoSyncIntervalMinutes,\n sources,\n extractionMode: extractionMode as ActivityExtractionMode,\n sourceTrust: parseUnitInterval(config.sourceTrust, \"sourceTrust\", defaults.sourceTrust),\n autoApproveTrust,\n reviewTrust,\n minConfidence: parseUnitInterval(config.minConfidence, \"minConfidence\", defaults.minConfidence),\n minImportance: minImportance as ImportanceLevel,\n maxMemoriesPerDay,\n };\n}\n"],"mappings":";;;;;;AAYA,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AAIV,IAAM,iCAAiC;AACvC,IAAM,oBAAoB;AAGjC,IAAM,eAAe,KAAK;AAE1B,IAAM,sBAAsB;AAC5B,IAAM,wBAAwB;AAE9B,IAAM,eAAe;AAEd,SAAS,oBAAoB,MAAuB;AACzD,MAAI,OAAO,SAAS,YAAY,CAAC,aAAa,KAAK,IAAI,EAAG,QAAO;AAGjE,QAAM,SAAS,oBAAI,KAAK,GAAG,IAAI,YAAY;AAC3C,SAAO,OAAO,SAAS,OAAO,QAAQ,CAAC,KAAK,OAAO,YAAY,EAAE,MAAM,GAAG,EAAE,MAAM;AACpF;AAEO,SAAS,mBAAmB,WAAmB,MAAsB;AAC1E,MAAI,CAAC,oBAAoB,IAAI,GAAG;AAG9B,UAAM,IAAI,WAAW,0BAA0B,IAAI,yBAAyB;AAAA,EAC9E;AACA,SAAO,KAAK,KAAK,WAAW,mBAAmB,GAAG,IAAI,KAAK;AAC7D;AAIA,SAAS,kBAAkB,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yncState,
|
|
1202
1202
|
updateSourceSyncState,
|
|
1203
|
+
computeTrustScore,
|
|
1204
|
+
decideSmart,
|
|
1203
1205
|
memoryStatusForMode,
|
|
1204
1206
|
WEARABLE_SOURCE_PREFIX,
|
|
1205
1207
|
wearableSourceLabel,
|
|
@@ -1213,4 +1215,4 @@ export {
|
|
|
1213
1215
|
syncWearableSource,
|
|
1214
1216
|
defaultTimezone
|
|
1215
1217
|
};
|
|
1216
|
-
//# sourceMappingURL=chunk-
|
|
1218
|
+
//# sourceMappingURL=chunk-UX3ZXN34.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
DELTA_SUBCOMMANDS,
|
|
8
8
|
defineOperation,
|
|
9
9
|
isCodegraphToolName
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WIUYMCPL.js";
|
|
11
11
|
import {
|
|
12
12
|
serializeMutations,
|
|
13
13
|
withHeldFileLock
|
|
@@ -1805,4 +1805,4 @@ export {
|
|
|
1805
1805
|
codegraphIngestTracesOperation,
|
|
1806
1806
|
REGISTERED_OPERATIONS
|
|
1807
1807
|
};
|
|
1808
|
-
//# sourceMappingURL=chunk-
|
|
1808
|
+
//# sourceMappingURL=chunk-VZC7ORJE.js.map
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
} from "./chunk-6HMYUWXR.js";
|
|
59
59
|
import {
|
|
60
60
|
offlineSyncStorageForSnapshot
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-XSBUROEB.js";
|
|
62
62
|
import {
|
|
63
63
|
combineNamespaces,
|
|
64
64
|
defaultGitInvoker,
|
|
@@ -12385,4 +12385,4 @@ export {
|
|
|
12385
12385
|
EngramAccessService,
|
|
12386
12386
|
AccessAdminOpsSurface
|
|
12387
12387
|
};
|
|
12388
|
-
//# sourceMappingURL=chunk-
|
|
12388
|
+
//# sourceMappingURL=chunk-WIUYMCPL.js.map
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
drainPendingLifecycleForSyncOrThrow,
|
|
9
9
|
drainPendingLifecycleLedgerForSync
|
|
10
10
|
} from "./chunk-XKGPIWGI.js";
|
|
11
|
+
import {
|
|
12
|
+
namespaceIdentityFromToken
|
|
13
|
+
} from "./chunk-EGGE52UU.js";
|
|
11
14
|
import {
|
|
12
15
|
assertPathInsideRoot,
|
|
13
16
|
pathIsInside
|
|
@@ -15,6 +18,9 @@ import {
|
|
|
15
18
|
import {
|
|
16
19
|
displayErrorDetail
|
|
17
20
|
} from "./chunk-RL6NEVXT.js";
|
|
21
|
+
import {
|
|
22
|
+
isSafeRouteNamespace
|
|
23
|
+
} from "./chunk-U3PN77QT.js";
|
|
18
24
|
import {
|
|
19
25
|
isErrnoCode
|
|
20
26
|
} from "./chunk-5UZXUTVO.js";
|
|
@@ -54,7 +60,13 @@ async function getOfflineSyncStorage(orchestrator, namespace) {
|
|
|
54
60
|
if (path.resolve(storage.dir) === memoryRoot && orchestrator.listOfflineSyncNamespaces) {
|
|
55
61
|
const drained = /* @__PURE__ */ new Set([memoryRoot]);
|
|
56
62
|
for (const ns of await orchestrator.listOfflineSyncNamespaces()) {
|
|
57
|
-
|
|
63
|
+
let nsStorage;
|
|
64
|
+
try {
|
|
65
|
+
nsStorage = await orchestrator.getStorage(ns);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
log.debug(`offline-sync root drain: skipping namespace ${ns} (non-fatal): ${err}`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
58
70
|
const nsDir = path.resolve(nsStorage.dir);
|
|
59
71
|
if (drained.has(nsDir)) continue;
|
|
60
72
|
drained.add(nsDir);
|
|
@@ -68,8 +80,12 @@ async function listOfflineSyncNamespaces(host) {
|
|
|
68
80
|
try {
|
|
69
81
|
for (const ledgerPath of await offlineSyncLifecycleLedgerPaths(host.config.memoryDir)) {
|
|
70
82
|
const namespaceDir = path.dirname(path.dirname(ledgerPath));
|
|
71
|
-
if (path.basename(path.dirname(namespaceDir))
|
|
72
|
-
|
|
83
|
+
if (path.basename(path.dirname(namespaceDir)) !== "namespaces") continue;
|
|
84
|
+
const dirName = path.basename(namespaceDir);
|
|
85
|
+
const decoded = namespaceIdentityFromToken(dirName);
|
|
86
|
+
const name = decoded === null ? dirName : decoded.length > 0 ? decoded : host.config.defaultNamespace;
|
|
87
|
+
if (isSafeRouteNamespace(name)) {
|
|
88
|
+
names.add(name);
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
91
|
} catch {
|
|
@@ -165,4 +181,4 @@ export {
|
|
|
165
181
|
offlineSyncStorageForSnapshot,
|
|
166
182
|
drainPendingLifecycleForOfflineSync
|
|
167
183
|
};
|
|
168
|
-
//# sourceMappingURL=chunk-
|
|
184
|
+
//# sourceMappingURL=chunk-XSBUROEB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/offline-sync-impression-drain.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { lstat, realpath } from \"node:fs/promises\";\nimport {\n drainPendingLifecycleForSyncOrThrow,\n drainPendingLifecycleLedgerForSync,\n type LifecyclePendingIo,\n} from \"./storage/memory-lifecycle-ledger-access.js\";\nimport { writeFileAtomically } from \"./maintenance/atomic-file.js\";\nimport { log } from \"./logger.js\";\nimport { isErrnoCode } from \"./utils/errno.js\";\nimport { assertPathInsideRoot, pathIsInside } from \"./utils/path-containment.js\";\nimport { displayErrorDetail } from \"./runtime/better-sqlite.js\";\nimport { getConfiguredNamespaces } from \"./scopes/scope-plan.js\";\nimport { isSafeRouteNamespace } from \"./routing/engine.js\";\nimport { namespaceIdentityFromToken } from \"./namespaces/identity.js\";\nimport type { PluginConfig } from \"./types.js\";\n\ntype PendingImpressionDrain = () => Promise<{ pendingDeferred: boolean }>;\n\ntype PendingLifecycleDrain = {\n drainPendingMemoryLifecycleEventsForSync(): Promise<{ folded: boolean; pendingDeferred: boolean }>;\n};\n\ntype LifecycleDrainAtPath = (\n ledgerPath: string,\n) => Promise<{ folded: boolean; pendingDeferred: boolean }>;\n\ntype PendingImpressionHost = {\n drainPendingRecallImpressions(): Promise<{ pendingDeferred: boolean }>;\n};\n/**\n * Fold pending recall-impression spills before building an offline-sync snapshot.\n * A deferred or failed drain must abort the snapshot rather than silently omit\n * durable rows from the sync payload.\n */\nexport async function drainPendingImpressionsForOfflineSync(\n host: PendingImpressionDrain,\n): Promise<void> {\n const maxAttempts = 3;\n let lastError: unknown;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n const result = await host();\n if (!result.pendingDeferred) return;\n lastError = undefined;\n } catch (error) {\n lastError = error;\n }\n }\n const detail = lastError\n ? `: ${displayErrorDetail(lastError) || \"unknown error\"}`\n : \" (rotation lock held by a peer)\";\n throw new Error(\n `offline-sync impression drain could not fold pending recall impressions after ${maxAttempts} attempts${detail}; aborting snapshot so the pending rows are not silently excluded (#2033)`,\n );\n}\n\n\nexport async function getOfflineSyncStorage<T extends PendingLifecycleDrain & { dir: string }>(\n orchestrator: PendingImpressionHost & {\n config: { memoryDir: string };\n getStorage(namespace: string): Promise<T>;\n listOfflineSyncNamespaces?(): Promise<string[]>;\n },\n namespace: string,\n): Promise<T> {\n const storage = await orchestrator.getStorage(namespace);\n const memoryRoot = path.resolve(orchestrator.config.memoryDir);\n // Recall impressions are global: the orchestrator's single LastRecallStore\n // roots at config.memoryDir, so the active recall_impressions.jsonl lives at\n // <memoryDir>/state/. Fold the global pending queue ONLY when THIS snapshot's\n // root actually contains that active file - a root snapshot. A namespace\n // snapshot (storage.dir under namespaces/<token>/) cannot carry it, so\n // draining there would empty the durable pending queue into a file this\n // snapshot omits and strand the row until a root sync; leave it pending for\n // the root sync instead (#2033).\n const impressionsFile = path.join(memoryRoot, \"state\", \"recall_impressions.jsonl\");\n if (pathIsInside(path.resolve(storage.dir), impressionsFile)) {\n await drainPendingImpressionsForOfflineSync(() => orchestrator.drainPendingRecallImpressions());\n }\n await drainPendingLifecycleForSyncOrThrow(() => storage.drainPendingMemoryLifecycleEventsForSync());\n // Root snapshot: buildOfflineSyncSnapshot walks `namespaces/<ns>/state/` for\n // every namespace under the memory root and INCLUDES each namespace's active\n // lifecycle ledger, but the per-namespace pending spill dirs are offline-sync\n // EXCLUDED. Draining only the root ledger above would let a root snapshot omit\n // append-only rows still sitting in a namespace's spill queue, so fold every\n // namespace ledger too - each through its OWN namespace storage so secure-store\n // AAD stays namespace-scoped (#2033, matching the CLI all-ledger drain). A\n // namespace snapshot folds only its own ledger, already done above.\n if (path.resolve(storage.dir) === memoryRoot && orchestrator.listOfflineSyncNamespaces) {\n const drained = new Set<string>([memoryRoot]);\n for (const ns of await orchestrator.listOfflineSyncNamespaces()) {\n // A single unresolvable namespace (e.g. a legacy canonical token dir whose\n // name exceeds the route-namespace length cap) must not abort the whole root\n // snapshot — degrade to draining the rest. listOfflineSyncNamespaces already\n // normalizes token dirs, so this is defense-in-depth.\n let nsStorage: T;\n try {\n nsStorage = await orchestrator.getStorage(ns);\n } catch (err) {\n log.debug(`offline-sync root drain: skipping namespace ${ns} (non-fatal): ${err}`);\n continue;\n }\n const nsDir = path.resolve(nsStorage.dir);\n if (drained.has(nsDir)) continue;\n drained.add(nsDir);\n await drainPendingLifecycleForSyncOrThrow(() => nsStorage.drainPendingMemoryLifecycleEventsForSync());\n }\n }\n return storage;\n}\n\ntype OfflineSyncNamespaceHost = {\n config: PluginConfig;\n namespaceCatalog: { listNamespaces(): Promise<Array<{ namespace: string }>> };\n};\n\n/**\n * Every namespace whose lifecycle ledger a ROOT offline snapshot enumerates.\n * Configured namespaces plus catalog-discovered ones; the catalog is queried\n * best-effort so a catalog read failure still drains the configured set (#2033).\n */\nexport async function listOfflineSyncNamespaces(host: OfflineSyncNamespaceHost): Promise<string[]> {\n const names = new Set<string>(getConfiguredNamespaces(host.config));\n try {\n for (const ledgerPath of await offlineSyncLifecycleLedgerPaths(host.config.memoryDir)) {\n const namespaceDir = path.dirname(path.dirname(ledgerPath));\n if (path.basename(path.dirname(namespaceDir)) !== \"namespaces\") continue;\n // A namespace is stored under its canonical token dir `ns-<hex>`. Decode the\n // token back to the namespace NAME so the drain fanout resolves the SAME\n // storage the token dir belongs to (the catalog rebuild scanner decodes the\n // same way, catalog.ts finishRebuild). A raw dir already named as a plain\n // namespace is used verbatim. Skip any name the router would reject — e.g. a\n // canonical token dir whose decoded-or-raw name exceeds isSafeRouteNamespace's\n // 64-char cap — because getStorage() would throw `unsafe namespace` and 500\n // the whole root snapshot-stream (the offline-sync regression this fixes).\n const dirName = path.basename(namespaceDir);\n // namespaceIdentityFromToken returns \"\" for the ns-default token (the\n // default-namespace identity) — map that to the configured default\n // namespace instead of skipping the directory as an unsafe empty name.\n const decoded = namespaceIdentityFromToken(dirName);\n const name =\n decoded === null\n ? dirName\n : decoded.length > 0\n ? decoded\n : host.config.defaultNamespace;\n if (isSafeRouteNamespace(name)) {\n names.add(name);\n }\n }\n } catch {\n // best-effort: a filesystem scan failure must not block configured/catalog namespaces\n }\n try {\n for (const record of await host.namespaceCatalog.listNamespaces()) {\n names.add(record.namespace);\n }\n } catch {\n // best-effort: fall back to the configured and filesystem namespace sets\n }\n return [...names];\n}\n\n/**\n * Resolve the offline-sync storage for a snapshot, folding pending spills first.\n * For a root snapshot this also folds every namespace lifecycle ledger the\n * snapshot will enumerate, so append-only rows in a namespace spill queue are\n * never omitted (#2033).\n */\nexport function offlineSyncStorageForSnapshot<T extends PendingLifecycleDrain & { dir: string }>(\n host: PendingImpressionHost &\n OfflineSyncNamespaceHost & {\n getStorage(namespace: string): Promise<T>;\n },\n namespace: string,\n): Promise<T> {\n return getOfflineSyncStorage(\n {\n config: { memoryDir: host.config.memoryDir },\n drainPendingRecallImpressions: () => host.drainPendingRecallImpressions(),\n getStorage: (ns: string) => host.getStorage(ns),\n listOfflineSyncNamespaces: () => listOfflineSyncNamespaces(host),\n },\n namespace,\n );\n}\n\nconst LIFECYCLE_LEDGER_FILE = \"memory-lifecycle-ledger.jsonl\";\n\n/**\n * Plaintext filesystem IO for a standalone (CLI) offline-sync lifecycle drain.\n * A standalone offline cache is plaintext - exactly like its LastRecallStore\n * impression drain - so spills read/append as UTF-8. `writeSecure` keeps the\n * atomic temp+rename the pending contract requires (#2033); a pure drain never\n * spills a new event, but the interface demands an atomic writer.\n */\nfunction plaintextLifecyclePendingIo(): LifecyclePendingIo {\n return {\n writeSecure: async (filePath, payload) => {\n await writeFileAtomically(filePath, payload);\n },\n readSecure: (filePath) => fs.promises.readFile(filePath, \"utf8\"),\n };\n}\n\n/**\n * Lifecycle ledger paths under a standalone memory dir: the root `state/` ledger\n * plus every per-namespace `namespaces/<ns>/state/` ledger (#2033). Offline sync\n * pushes the whole memory dir, so every namespace's ledger can carry pending\n * spills that must be folded first.\n */\nasync function offlineSyncLifecycleLedgerPaths(memoryDir: string): Promise<string[]> {\n const paths = [path.join(memoryDir, \"state\", LIFECYCLE_LEDGER_FILE)];\n const namespacesBase = path.join(memoryDir, \"namespaces\");\n // Symlink/traversal containment (#2033): a symlinked <memoryDir>/namespaces\n // (or a symlinked child) must not redirect the pre-sync drain - and the\n // ledger appends/mkdirs it drives - outside memoryDir. Resolve the memory\n // root and the scan base through realpath, reject a symlinked/escaping/\n // non-directory base, and skip any symlinked/escaping child, mirroring the\n // lifecycle-compaction scanner (orchestration/maintenance.ts) and the\n // memory-store walkers (utils/path-containment). A rejected base is\n // non-fatal: drain the root ledger only, never through the poisoned link.\n let memoryDirReal: string;\n try {\n memoryDirReal = await realpath(memoryDir);\n const baseStat = await lstat(namespacesBase);\n if (baseStat.isSymbolicLink() || !baseStat.isDirectory()) {\n throw new Error(\"namespaces base is a symlink or not a directory\");\n }\n assertPathInsideRoot(memoryDirReal, await realpath(namespacesBase), namespacesBase);\n } catch (err) {\n if (!isErrnoCode(err, \"ENOENT\")) {\n log.debug(`offline-sync lifecycle drain: namespaces base rejected (non-fatal): ${err}`);\n }\n return paths;\n }\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(namespacesBase, { withFileTypes: true });\n } catch (err) {\n if (!isErrnoCode(err, \"ENOENT\")) {\n log.debug(`offline-sync lifecycle drain: namespaces dir scan failed (non-fatal): ${err}`);\n }\n return paths;\n }\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n if (!entry.isDirectory() || entry.isSymbolicLink()) continue;\n const childPath = path.join(namespacesBase, entry.name);\n try {\n assertPathInsideRoot(memoryDirReal, await realpath(childPath), childPath);\n } catch (err) {\n log.debug(`offline-sync lifecycle drain: skipping out-of-root namespace dir ${childPath}: ${err}`);\n continue;\n }\n paths.push(path.join(childPath, \"state\", LIFECYCLE_LEDGER_FILE));\n }\n return paths;\n}\n\n/**\n * Fold pending memory-lifecycle spills into each active ledger under `memoryDir`\n * before a standalone (CLI) offline-sync snapshot (#2033). Mirrors the\n * access-service snapshot entrypoints, which drain lifecycle pending first: the\n * default sync exclude globs keep `memory-lifecycle-ledger.jsonl.pending.d` out\n * of the push, so an append-only row (promotion/import/explicit capture) that\n * spilled while the ledger lock was held would be silently dropped if the local\n * node were discarded before maintenance folds it. A deferred drain (lock held\n * by a peer) or a repeatedly failing fold ABORTS via\n * {@link drainPendingLifecycleForSyncOrThrow} rather than building/pushing a\n * snapshot that omits durable rows. Fast no-op per ledger with no pending dir.\n */\nexport async function drainPendingLifecycleForOfflineSync(\n memoryDir: string,\n drainAtPath: LifecycleDrainAtPath = (ledgerPath) => {\n const io = plaintextLifecyclePendingIo();\n const stateDir = path.dirname(ledgerPath);\n return drainPendingLifecycleLedgerForSync(\n ledgerPath,\n io,\n (payload) => fs.promises.appendFile(ledgerPath, payload),\n async () => {\n await fs.promises.mkdir(stateDir, { recursive: true });\n },\n );\n },\n): Promise<void> {\n for (const ledgerPath of await offlineSyncLifecycleLedgerPaths(memoryDir)) {\n await drainPendingLifecycleForSyncOrThrow(() => drainAtPath(ledgerPath));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,OAAO,gB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AAA,IACL;AAAA,IACA;AAAA,IACA,CAAC,YAAY,GAAG,SAAS,WAAW,YAAY,OAAO;AAAA,IACvD,YAAY;AACV,YAAM,GAAG,SAAS,MAAM,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,IACvD;AAAA,EACF;AACF,GACe;AACf,aAAW,cAAc,MAAM,gCAAgC,SAAS,GAAG;AACzE,UAAM,oCAAoC,MAAM,YAAY,UAAU,CAAC;AAAA,EACzE;AACF;","names":[]}
|
|
@@ -2,22 +2,22 @@ import { CompoundingPromotionReport } from './compounding/engine.js';
|
|
|
2
2
|
import { ConversationIndexBackendInspection } from './conversation-index/backend.js';
|
|
3
3
|
import { MigrateObservationsResult } from './maintenance/migrate-observations.js';
|
|
4
4
|
import { MemoryGovernanceRunResult, MemoryGovernanceSummary, MemoryGovernanceMetrics, MemoryGovernanceQualityScore, MemoryGovernanceReviewQueueEntry, MemoryGovernanceAppliedAction, MemoryGovernanceTransitionReport, MemoryGovernanceManifest, MemoryGovernanceRestoreManifest, RestoreMemoryGovernanceRunResult } from './maintenance/memory-governance.js';
|
|
5
|
-
import { x as MemoryStatus, M as MemoryFile, $ as BehaviorSignalEvent, Q as QmdSearchResult, a4 as BulkImportResult, ab as MemoryActionEvent, z as MemoryLifecycleEvent } from './types-
|
|
5
|
+
import { x as MemoryStatus, M as MemoryFile, $ as BehaviorSignalEvent, Q as QmdSearchResult, a4 as BulkImportResult, ab as MemoryActionEvent, z as MemoryLifecycleEvent } from './types-V3dT-pen.js';
|
|
6
6
|
import { RebuildMemoryProjectionResult, RepairMemoryProjectionResult, VerifyMemoryProjectionResult } from './maintenance/rebuild-memory-projection.js';
|
|
7
7
|
import { RebuildObservationsResult } from './maintenance/rebuild-observations.js';
|
|
8
8
|
import { ArchiveObservationsResult } from './maintenance/archive-observations.js';
|
|
9
9
|
import { Writable, Readable } from 'node:stream';
|
|
10
|
-
import { C as ConversationIndexCoordinator, T as TierMigrationCoordinator, O as Orchestrator } from './orchestrator-
|
|
10
|
+
import { C as ConversationIndexCoordinator, T as TierMigrationCoordinator, O as Orchestrator } from './orchestrator-CplS9U3U.js';
|
|
11
11
|
import { ReplayRunSummary } from './replay/runner.js';
|
|
12
12
|
import { ReplaySource, ReplayTurn } from './replay/types.js';
|
|
13
|
-
import { P as ProcessBatchFn } from './pipeline-
|
|
14
|
-
import { S as StorageManager } from './storage-
|
|
13
|
+
import { P as ProcessBatchFn } from './pipeline-DB4CbFqo.js';
|
|
14
|
+
import { S as StorageManager } from './storage-o5BTAa8d.js';
|
|
15
15
|
import { RebuildMemoryLifecycleLedgerResult } from './maintenance/rebuild-memory-lifecycle-ledger.js';
|
|
16
16
|
import { WorkProjectStatus, WorkTaskStatus, WorkTaskPriority } from './work/types.js';
|
|
17
17
|
import { RoutePatternType } from './routing/engine.js';
|
|
18
18
|
import { TailscaleSyncOptions } from './network/tailscale.js';
|
|
19
19
|
import { DashboardStatus } from './dashboard-runtime.js';
|
|
20
|
-
import { F as EngramAccessService } from './access-service-
|
|
20
|
+
import { F as EngramAccessService } from './access-service-CSm242ks.js';
|
|
21
21
|
import { ResolveSecretRefFn } from './resolve-auth-token.js';
|
|
22
22
|
import { CompatRunner, CompatReport } from './compat/types.js';
|
|
23
23
|
import { EvalBaselineDeltaReport, EvalBaselineSnapshot, EvalCiGateReport, EvalBenchmarkPackSummary, EvalHarnessStatus, EvalStoredBaselineCiGateReport } from './evals.js';
|