From 3ffaa15e1654507ce618b429c750800f15bef1a3 Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Wed, 23 Sep 2026 22:31:42 -0700 Subject: [PATCH 1/4] chore(publish): dist build + .js specifiers (CL-8952) --- package.json | 36 +++++++++++--- scripts/db-setup.ts | 2 +- src/core/adapt-and-plan.test.ts | 4 +- src/core/adapt-and-plan.ts | 12 ++--- src/core/authority.test.ts | 2 +- src/core/authority.ts | 2 +- src/core/chunk/token-recursive.test.ts | 2 +- src/core/chunk/token-recursive.ts | 2 +- src/core/corroboration.test.ts | 4 +- src/core/corroboration.ts | 2 +- src/core/degrade-metrics.test.ts | 4 +- src/core/degrade-metrics.ts | 4 +- src/core/embed-client.test.ts | 4 +- src/core/embed-model-registry.test.ts | 4 +- src/core/embed-model-registry.ts | 4 +- src/core/embed-sql.ts | 2 +- src/core/embed-worker.ts | 4 +- src/core/engine-client-config.ts | 6 +-- src/core/enums.lockstep.test.ts | 6 +-- src/core/fts-language.test.ts | 4 +- src/core/hash.test.ts | 2 +- src/core/hybrid-search.test.ts | 2 +- src/core/merge-local-live.test.ts | 2 +- src/core/merge-local-live.ts | 2 +- src/core/mmr.test.ts | 2 +- src/core/rerank-client.test.ts | 4 +- src/core/schemas/adapted-document.test.ts | 4 +- src/core/schemas/adapted-document.ts | 6 +-- src/core/schemas/chunk.test.ts | 2 +- src/core/schemas/claim-bearing.test.ts | 6 +-- src/core/schemas/document.test.ts | 4 +- src/core/schemas/document.ts | 2 +- src/core/schemas/entity-edge.test.ts | 4 +- src/core/schemas/entity-edge.ts | 2 +- src/core/schemas/search.test.ts | 4 +- src/core/schemas/search.ts | 2 +- src/db/client.ts | 4 +- src/db/schema.test.ts | 2 +- src/distiller/claim.test.ts | 4 +- src/distiller/claim.ts | 2 +- src/distiller/index.ts | 8 +-- src/distiller/tick.test.ts | 6 +-- src/distiller/tick.ts | 6 +-- src/distiller/workflow.test.ts | 8 +-- src/distiller/workflow.ts | 6 +-- src/grant-requirements.test.ts | 2 +- src/grant-tags.test.ts | 2 +- src/http-bodies.ts | 4 +- src/http-client.ts | 2 +- src/index.ts | 56 ++++++++++----------- src/log.test.ts | 4 +- src/memory.test.ts | 42 ++++++++-------- src/memory.ts | 60 +++++++++++------------ src/migrations.ts | 10 ++-- src/mount-config.test.ts | 2 +- src/mount-config.ts | 4 +- src/ports/fakes.test.ts | 4 +- src/ports/fakes.ts | 4 +- src/ports/index.ts | 4 +- src/ports/memory-plane.test.ts | 2 +- src/ports/merge-plane.test.ts | 4 +- src/ports/mount-fakes.test.ts | 2 +- src/ports/types.ts | 6 +-- src/routes/add.ts | 12 ++--- src/routes/deps.test.ts | 2 +- src/routes/deps.ts | 6 +-- src/routes/feed.ts | 10 ++-- src/routes/list.ts | 10 ++-- src/routes/mount.ts | 14 +++--- src/routes/retention.ts | 10 ++-- src/routes/routes.test.ts | 8 +-- src/routes/search.ts | 10 ++-- src/services/capture.test.ts | 16 +++--- src/services/capture.ts | 32 ++++++------ src/services/feed.test.ts | 2 +- src/services/feed.ts | 6 +-- src/services/retention-ownership.test.ts | 4 +- src/services/retention-ownership.ts | 2 +- src/services/retention.ts | 6 +-- src/services/search.test.ts | 8 +-- src/services/search.ts | 32 ++++++------ src/services/share-grants.test.ts | 6 +-- src/services/share-grants.ts | 6 +-- src/services/timeline.test.ts | 2 +- src/services/timeline.ts | 10 ++-- src/services/transform.test.ts | 10 ++-- src/services/transform.ts | 30 ++++++------ src/sidecar-bundle.test.ts | 4 +- src/sidecar-bundle.ts | 2 +- src/tools.ts | 2 +- src/workflow-mount.test.ts | 6 +-- src/workflow-mount.ts | 8 +-- tsconfig.build.json | 19 +++++++ 93 files changed, 378 insertions(+), 337 deletions(-) create mode 100644 tsconfig.build.json diff --git a/package.json b/package.json index a37b8ae..51fe6ee 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,31 @@ "version": "0.1.3", "description": "Mountable memory add/search/list SDK for Interchange hubs — includes resident distiller", "exports": { - ".": "./src/index.ts", - "./migrations": "./src/migrations.ts", - "./config": "./src/mount-config.ts", - "./sidecar-bundle": "./src/sidecar-bundle.ts", - "./distiller": "./src/distiller/index.ts" + ".": { + "intx-src": "./src/index.ts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./migrations": { + "intx-src": "./src/migrations.ts", + "types": "./dist/migrations.d.ts", + "default": "./dist/migrations.js" + }, + "./config": { + "intx-src": "./src/mount-config.ts", + "types": "./dist/mount-config.d.ts", + "default": "./dist/mount-config.js" + }, + "./sidecar-bundle": { + "intx-src": "./src/sidecar-bundle.ts", + "types": "./dist/sidecar-bundle.d.ts", + "default": "./dist/sidecar-bundle.js" + }, + "./distiller": { + "intx-src": "./src/distiller/index.ts", + "types": "./dist/distiller/index.d.ts", + "default": "./dist/distiller/index.js" + } }, "interchange": { "grantRequirements": [ @@ -39,7 +59,6 @@ }, "license": "LGPL-2.1-only", "type": "module", - "module": "src/index.ts", "engines": { "bun": ">=1.2.0", "node": ">=24" @@ -47,6 +66,8 @@ "scripts": { "db:setup": "bun run scripts/db-setup.ts", "typecheck": "tsc --noEmit", + "build": "tsc -p tsconfig.build.json", + "prepack": "bun run build", "test": "bun test ./src", "test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text ./src" }, @@ -85,8 +106,7 @@ "hono" ], "files": [ - "src", - "!src/**/*.test.ts", + "dist", "migrations", "README.md", "LICENSE" diff --git a/scripts/db-setup.ts b/scripts/db-setup.ts index 7c3fc70..045a26f 100644 --- a/scripts/db-setup.ts +++ b/scripts/db-setup.ts @@ -1,4 +1,4 @@ -import { runMemoryMigrations } from "../src/migrations.ts"; +import { runMemoryMigrations } from "../src/migrations.js"; const url = process.env["DATABASE_URL"]; diff --git a/src/core/adapt-and-plan.test.ts b/src/core/adapt-and-plan.test.ts index 4d141f7..eb4dd04 100644 --- a/src/core/adapt-and-plan.test.ts +++ b/src/core/adapt-and-plan.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "bun:test"; -import { adaptAndPlan, InvalidAdaptedDocumentError } from "./adapt-and-plan.ts"; -import type { AdaptedDocument } from "./schemas/adapted-document.ts"; +import { adaptAndPlan, InvalidAdaptedDocumentError } from "./adapt-and-plan.js"; +import type { AdaptedDocument } from "./schemas/adapted-document.js"; function validAdaptedDocument( overrides: Partial = {}, diff --git a/src/core/adapt-and-plan.ts b/src/core/adapt-and-plan.ts index 8836077..83781b7 100644 --- a/src/core/adapt-and-plan.ts +++ b/src/core/adapt-and-plan.ts @@ -1,13 +1,13 @@ -import { DEFAULT_CHUNK_CAPS } from "./chunk/types.ts"; -import { chunkTokenRecursive } from "./chunk/token-recursive.ts"; -import type { Chunker } from "./chunk/types.ts"; -import { contentHash } from "./hash.ts"; +import { DEFAULT_CHUNK_CAPS } from "./chunk/types.js"; +import { chunkTokenRecursive } from "./chunk/token-recursive.js"; +import type { Chunker } from "./chunk/types.js"; +import { contentHash } from "./hash.js"; import type { AdaptedDocument, AdaptedDocumentChunk, EntityHint, -} from "./schemas/adapted-document.ts"; -import type { MemoryEdgeHint } from "./schemas/entity-edge.ts"; +} from "./schemas/adapted-document.js"; +import type { MemoryEdgeHint } from "./schemas/entity-edge.js"; /** * Thrown when an AdaptedDocument fails adaptAndPlan's own defensive checks diff --git a/src/core/authority.test.ts b/src/core/authority.test.ts index f445690..d7bf171 100644 --- a/src/core/authority.test.ts +++ b/src/core/authority.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "bun:test"; -import { computeAuthority, type AuthoritySignals } from "./authority.ts"; +import { computeAuthority, type AuthoritySignals } from "./authority.js"; function signals(overrides: Partial = {}): AuthoritySignals { return { diff --git a/src/core/authority.ts b/src/core/authority.ts index 81cfd91..60d16d5 100644 --- a/src/core/authority.ts +++ b/src/core/authority.ts @@ -1,5 +1,5 @@ import { type } from "arktype"; -import { CreatedByKindSchema, type CreatedByKind } from "./schemas/document.ts"; +import { CreatedByKindSchema, type CreatedByKind } from "./schemas/document.js"; // Corroboration-based authority weighting: retrieval ranks by how corroborated // a source is, not lexical relevance alone. `source_class` is the coarse bucket diff --git a/src/core/chunk/token-recursive.test.ts b/src/core/chunk/token-recursive.test.ts index 1865c61..4b16e9f 100644 --- a/src/core/chunk/token-recursive.test.ts +++ b/src/core/chunk/token-recursive.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "bun:test"; -import { chunkTokenRecursive } from "./token-recursive.ts"; +import { chunkTokenRecursive } from "./token-recursive.js"; function sentences(count: number): string { const parts: string[] = []; diff --git a/src/core/chunk/token-recursive.ts b/src/core/chunk/token-recursive.ts index 53ac9f6..33364dc 100644 --- a/src/core/chunk/token-recursive.ts +++ b/src/core/chunk/token-recursive.ts @@ -1,4 +1,4 @@ -import { DEFAULT_CHUNK_CAPS, type ChunkCaps, type TokenChunk } from "./types.ts"; +import { DEFAULT_CHUNK_CAPS, type ChunkCaps, type TokenChunk } from "./types.js"; // Separator ladder tried in order before falling back to a hard character // cut. Word/whitespace-based token counting diff --git a/src/core/corroboration.test.ts b/src/core/corroboration.test.ts index 3bcb7be..104196f 100644 --- a/src/core/corroboration.test.ts +++ b/src/core/corroboration.test.ts @@ -4,11 +4,11 @@ import { CORROBORATION_STRONG_FLOOR, effectiveAuthority, meetsStrongEvidenceGate, -} from "./corroboration.ts"; +} from "./corroboration.js"; import { BOOST_MULTIPLIER_MAX, BOOST_MULTIPLIER_MIN, -} from "./hybrid-search.ts"; +} from "./hybrid-search.js"; describe("corroborationFactor", () => { it("is neutral with no edges", () => { diff --git a/src/core/corroboration.ts b/src/core/corroboration.ts index 2c407bb..a07b409 100644 --- a/src/core/corroboration.ts +++ b/src/core/corroboration.ts @@ -11,7 +11,7 @@ import { BOOST_MULTIPLIER_MAX, BOOST_MULTIPLIER_MIN, clampBoostMultiplier, -} from "./hybrid-search.ts"; +} from "./hybrid-search.js"; /** Independent supports needed for evidence:strong (with authority floor). */ export const CORROBORATION_STRONG_FLOOR = 2; diff --git a/src/core/degrade-metrics.test.ts b/src/core/degrade-metrics.test.ts index 7e9cfb7..17617f6 100644 --- a/src/core/degrade-metrics.test.ts +++ b/src/core/degrade-metrics.test.ts @@ -6,8 +6,8 @@ import { getDegradeMetricsSnapshot, recordDegrade, resetDegradeMetrics, -} from "./degrade-metrics.ts"; -import { log } from "../log.ts"; +} from "./degrade-metrics.js"; +import { log } from "../log.js"; function captureLogs() { const calls: Array<{ level: "info" | "warn" | "error"; message: string; payload: unknown }> = []; diff --git a/src/core/degrade-metrics.ts b/src/core/degrade-metrics.ts index 2807d67..36cbf9d 100644 --- a/src/core/degrade-metrics.ts +++ b/src/core/degrade-metrics.ts @@ -1,5 +1,5 @@ -import { log } from "../log.ts"; -import type { DegradeFlag } from "./hybrid-search.ts"; +import { log } from "../log.js"; +import type { DegradeFlag } from "./hybrid-search.js"; // There is no metrics facility anywhere in this repo — no statsd, // prometheus, or otel dependency, and `@intx/log` exports no counter. This diff --git a/src/core/embed-client.test.ts b/src/core/embed-client.test.ts index b94899e..b31dfb7 100644 --- a/src/core/embed-client.test.ts +++ b/src/core/embed-client.test.ts @@ -5,8 +5,8 @@ import { EmbedTimeoutError, embedTexts, probeEmbedDims, -} from "./embed-client.ts"; -import type { EmbedClientConfig } from "./embed-client.ts"; +} from "./embed-client.js"; +import type { EmbedClientConfig } from "./embed-client.js"; function jsonResponse(body: unknown, status = 200): Response { return new Response(JSON.stringify(body), { diff --git a/src/core/embed-model-registry.test.ts b/src/core/embed-model-registry.test.ts index de26b05..086d45c 100644 --- a/src/core/embed-model-registry.test.ts +++ b/src/core/embed-model-registry.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, mock } from "bun:test"; -import type { EmbedClientConfig } from "./embed-client.ts"; +import type { EmbedClientConfig } from "./embed-client.js"; import { activateEmbedModel, activateEmbedModelByKey, @@ -16,7 +16,7 @@ import { resolveActiveEmbedTable, resolveEmbedTableByModelKey, VECTOR_INDEX_MAX_DIMS, -} from "./embed-model-registry.ts"; +} from "./embed-model-registry.js"; function jsonResponse(body: unknown): Response { return new Response(JSON.stringify(body), { diff --git a/src/core/embed-model-registry.ts b/src/core/embed-model-registry.ts index 10a04a0..d5e3637 100644 --- a/src/core/embed-model-registry.ts +++ b/src/core/embed-model-registry.ts @@ -1,6 +1,6 @@ import { createHash, randomUUID } from "node:crypto"; -import { type EmbedClientConfig, probeEmbedDims } from "./embed-client.ts"; -import { formatCaughtError, log } from "../log.ts"; +import { type EmbedClientConfig, probeEmbedDims } from "./embed-client.js"; +import { formatCaughtError, log } from "../log.js"; // pgvector's hnsw/ivfflat indexes on the `vector` type cap at 2000 dims; an // expression index over `halfvec` (half-precision) raises the cap to 4000. diff --git a/src/core/embed-sql.ts b/src/core/embed-sql.ts index 10da901..bbc60a4 100644 --- a/src/core/embed-sql.ts +++ b/src/core/embed-sql.ts @@ -1,5 +1,5 @@ import type postgres from "postgres"; -import type { EmbedRegistrySqlClient } from "./embed-model-registry.ts"; +import type { EmbedRegistrySqlClient } from "./embed-model-registry.js"; // Generic bridge from the engine's postgres-js handle to the minimal // `{ query(sql, params) }` seam several core modules take instead of a diff --git a/src/core/embed-worker.ts b/src/core/embed-worker.ts index 57787f2..60e758f 100644 --- a/src/core/embed-worker.ts +++ b/src/core/embed-worker.ts @@ -1,9 +1,9 @@ -import { embedTexts, type EmbedClientConfig } from "./embed-client.ts"; +import { embedTexts, type EmbedClientConfig } from "./embed-client.js"; import { EMBED_TABLE_NAME_PATTERN, type ActiveEmbedTable, type EmbedRegistrySqlClient, -} from "./embed-model-registry.ts"; +} from "./embed-model-registry.js"; export interface EmbeddableChunk { id: string; diff --git a/src/core/engine-client-config.ts b/src/core/engine-client-config.ts index 78ca6c1..fa0602c 100644 --- a/src/core/engine-client-config.ts +++ b/src/core/engine-client-config.ts @@ -5,9 +5,9 @@ * future caller) must go through these functions so operator overrides like * EMBED_TIMEOUT_MS / RERANK_TIMEOUT_MS reach every code path uniformly. */ -import type { EngineConfig } from "../config.ts"; -import type { EmbedClientConfig } from "./embed-client.ts"; -import type { RerankClientConfig } from "./rerank-client.ts"; +import type { EngineConfig } from "../config.js"; +import type { EmbedClientConfig } from "./embed-client.js"; +import type { RerankClientConfig } from "./rerank-client.js"; const VALID_EMBED_API_STYLES = new Set(["openai", "tei", "ollama"]); diff --git a/src/core/enums.lockstep.test.ts b/src/core/enums.lockstep.test.ts index 91f0eb8..aa58c31 100644 --- a/src/core/enums.lockstep.test.ts +++ b/src/core/enums.lockstep.test.ts @@ -8,14 +8,14 @@ import { PROVENANCE_MODES, RETENTION_CLASSES, TEMPORAL_CLASSES, -} from "./enums.ts"; -import { MemoryEdgeRelSchema, MemoryEdgeRefTypeSchema } from "./schemas/entity-edge.ts"; +} from "./enums.js"; +import { MemoryEdgeRelSchema, MemoryEdgeRefTypeSchema } from "./schemas/entity-edge.js"; import { LineageClassSchema, ProvenanceModeSchema, RetentionClassSchema, TemporalClassSchema, -} from "./schemas/document.ts"; +} from "./schemas/document.js"; import { type } from "arktype"; const MIGRATIONS_DIR = join(import.meta.dir, "../../migrations"); diff --git a/src/core/fts-language.test.ts b/src/core/fts-language.test.ts index 58d73fd..b1c295c 100644 --- a/src/core/fts-language.test.ts +++ b/src/core/fts-language.test.ts @@ -7,7 +7,7 @@ import { FTS_LANGUAGE_TOKEN, parseFtsLanguage, verifyFtsLanguage, -} from "./fts-language.ts"; +} from "./fts-language.js"; describe("parseFtsLanguage", () => { it("defaults when unset or empty", () => { @@ -46,7 +46,7 @@ describe("runMemoryMigrations language boundary", () => { it("falls back to the FTS_LANGUAGE env var when no option is passed", async () => { // Pin the boundary contract without a live database: the runner must // resolve exactly like the config loader, from the same env var. - const { runMemoryMigrations } = await import("../migrations.ts"); + const { runMemoryMigrations } = await import("../migrations.js"); process.env["FTS_LANGUAGE"] = "not a valid name"; try { await expect(runMemoryMigrations("postgres://unused")).rejects.toThrow( diff --git a/src/core/hash.test.ts b/src/core/hash.test.ts index ede2c20..f06dca1 100644 --- a/src/core/hash.test.ts +++ b/src/core/hash.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "bun:test"; -import { contentHash, stableStringify } from "./hash.ts"; +import { contentHash, stableStringify } from "./hash.js"; describe("stableStringify", () => { it("produces identical output regardless of key insertion order", () => { diff --git a/src/core/hybrid-search.test.ts b/src/core/hybrid-search.test.ts index 065b411..176da90 100644 --- a/src/core/hybrid-search.test.ts +++ b/src/core/hybrid-search.test.ts @@ -14,7 +14,7 @@ import { recencyBoostMultiplier, temporalRecencyMultiplier, toRankedCandidates, -} from "./hybrid-search.ts"; +} from "./hybrid-search.js"; describe("toRankedCandidates", () => { test("assigns 1-based rank in list order", () => { diff --git a/src/core/merge-local-live.test.ts b/src/core/merge-local-live.test.ts index e85b755..7c61e03 100644 --- a/src/core/merge-local-live.test.ts +++ b/src/core/merge-local-live.test.ts @@ -5,7 +5,7 @@ import { recencyPrior, withTimeout, type MergeChannelItem, -} from "./merge-local-live.ts"; +} from "./merge-local-live.js"; const NOW = Date.parse("2026-03-08T12:00:00.000Z"); diff --git a/src/core/merge-local-live.ts b/src/core/merge-local-live.ts index 601884f..afa23f6 100644 --- a/src/core/merge-local-live.ts +++ b/src/core/merge-local-live.ts @@ -10,7 +10,7 @@ * - Live timeout + allSettled fan-out are applied by the caller; this module * is pure merge over already-collected channel results */ -import type { SearchHitCitation } from "./schemas/search.ts"; +import type { SearchHitCitation } from "./schemas/search.js"; export const LIVE_TIMEOUT_MS = 800; diff --git a/src/core/mmr.test.ts b/src/core/mmr.test.ts index 67586f9..33521df 100644 --- a/src/core/mmr.test.ts +++ b/src/core/mmr.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "bun:test"; -import { mmrRerank } from "./mmr.ts"; +import { mmrRerank } from "./mmr.js"; describe("mmrRerank", () => { it("keeps the top-scoring item, then prefers a diverse item over a near-duplicate one", () => { diff --git a/src/core/rerank-client.test.ts b/src/core/rerank-client.test.ts index 26e7021..2d179d4 100644 --- a/src/core/rerank-client.test.ts +++ b/src/core/rerank-client.test.ts @@ -11,8 +11,8 @@ import { defaultMaxDocCharsForModel, rerankDocuments, validateRerankConfig, -} from "./rerank-client.ts"; -import type { RerankClientConfig } from "./rerank-client.ts"; +} from "./rerank-client.js"; +import type { RerankClientConfig } from "./rerank-client.js"; // The default env in .env.example ships RERANK_MODEL=bge-reranker-base with // RERANK_MAX_DOC_CHARS unset (-> defaultMaxDocCharsForModel's per-model diff --git a/src/core/schemas/adapted-document.test.ts b/src/core/schemas/adapted-document.test.ts index d059c92..b0c2840 100644 --- a/src/core/schemas/adapted-document.test.ts +++ b/src/core/schemas/adapted-document.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "bun:test"; import { type } from "arktype"; -import { AdaptedDocumentSchema } from "./adapted-document.ts"; -import type { AdaptedDocument } from "./adapted-document.ts"; +import { AdaptedDocumentSchema } from "./adapted-document.js"; +import type { AdaptedDocument } from "./adapted-document.js"; // T2 — a full AdaptedDocument fixture must parse with no errors. describe("AdaptedDocumentSchema", () => { diff --git a/src/core/schemas/adapted-document.ts b/src/core/schemas/adapted-document.ts index 1df3256..8ff1ab6 100644 --- a/src/core/schemas/adapted-document.ts +++ b/src/core/schemas/adapted-document.ts @@ -4,9 +4,9 @@ import { LineageClassSchema, ProvenanceModeSchema, TemporalClassSchema, -} from "./document.ts"; -import { MemoryEdgeHintSchema } from "./entity-edge.ts"; -import { AuthoritySourceClassSchema } from "../authority.ts"; +} from "./document.js"; +import { MemoryEdgeHintSchema } from "./entity-edge.js"; +import { AuthoritySourceClassSchema } from "../authority.js"; // A hint that a chunk/document mentions a real-world entity; the ingestion // engine resolves this against memory_entity, creating a row if none diff --git a/src/core/schemas/chunk.test.ts b/src/core/schemas/chunk.test.ts index 4ea3eb4..0ac8c52 100644 --- a/src/core/schemas/chunk.test.ts +++ b/src/core/schemas/chunk.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "bun:test"; import { type } from "arktype"; -import { MemoryChunkSchema } from "./chunk.ts"; +import { MemoryChunkSchema } from "./chunk.js"; describe("MemoryChunkSchema", () => { it("round-trips a full fixture", () => { diff --git a/src/core/schemas/claim-bearing.test.ts b/src/core/schemas/claim-bearing.test.ts index 3c02743..0f66cf4 100644 --- a/src/core/schemas/claim-bearing.test.ts +++ b/src/core/schemas/claim-bearing.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "bun:test"; import { type } from "arktype"; -import { AdaptedDocumentSchema } from "./adapted-document.ts"; -import { MemoryEdgeHintSchema } from "./entity-edge.ts"; -import type { AdaptedDocument } from "./adapted-document.ts"; +import { AdaptedDocumentSchema } from "./adapted-document.js"; +import { MemoryEdgeHintSchema } from "./entity-edge.js"; +import type { AdaptedDocument } from "./adapted-document.js"; /** * Claim-bearing write shape: a distilled claim is a normal AdaptedDocument diff --git a/src/core/schemas/document.test.ts b/src/core/schemas/document.test.ts index 6111b40..256c6bd 100644 --- a/src/core/schemas/document.test.ts +++ b/src/core/schemas/document.test.ts @@ -3,8 +3,8 @@ import { type } from "arktype"; import { MemoryDocumentSchema, MemoryVersionSchema, -} from "./document.ts"; -import type { MemoryDocument, MemoryVersion } from "./document.ts"; +} from "./document.js"; +import type { MemoryDocument, MemoryVersion } from "./document.js"; describe("MemoryDocumentSchema", () => { it("round-trips a full fixture", () => { diff --git a/src/core/schemas/document.ts b/src/core/schemas/document.ts index 5be9c89..5b5c856 100644 --- a/src/core/schemas/document.ts +++ b/src/core/schemas/document.ts @@ -5,7 +5,7 @@ import { RETENTION_CLASSES, TEMPORAL_CLASSES, arktypeStringUnion, -} from "../enums.ts"; +} from "../enums.js"; export const MemoryVersionStatusSchema = type( "'active'|'superseded'|'deprecated'|'archived'|'tombstoned'", diff --git a/src/core/schemas/entity-edge.test.ts b/src/core/schemas/entity-edge.test.ts index 439f158..769cac2 100644 --- a/src/core/schemas/entity-edge.test.ts +++ b/src/core/schemas/entity-edge.test.ts @@ -4,8 +4,8 @@ import { MemoryEdgeHintSchema, MemoryEdgeSchema, MemoryEntitySchema, -} from "./entity-edge.ts"; -import type { MemoryEdge } from "./entity-edge.ts"; +} from "./entity-edge.js"; +import type { MemoryEdge } from "./entity-edge.js"; describe("MemoryEntitySchema", () => { it("round-trips a full fixture", () => { diff --git a/src/core/schemas/entity-edge.ts b/src/core/schemas/entity-edge.ts index cd391f4..ea080dd 100644 --- a/src/core/schemas/entity-edge.ts +++ b/src/core/schemas/entity-edge.ts @@ -3,7 +3,7 @@ import { EDGE_RELS, EDGE_REF_TYPES_ADAPTER, arktypeStringUnion, -} from "../enums.ts"; +} from "../enums.js"; // A real-world thing (person, org, deal, ...) a document or chunk mentions. // Kept lightweight — identity keys only (email, domain, ...), not another diff --git a/src/core/schemas/search.test.ts b/src/core/schemas/search.test.ts index 79f45d3..5a4ab90 100644 --- a/src/core/schemas/search.test.ts +++ b/src/core/schemas/search.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "bun:test"; import { type } from "arktype"; -import { SearchHitSchema, SearchResponseSchema } from "./search.ts"; -import type { SearchHit, SearchResponse } from "./search.ts"; +import { SearchHitSchema, SearchResponseSchema } from "./search.js"; +import type { SearchHit, SearchResponse } from "./search.js"; function fullHitFixture(): SearchHit { return { diff --git a/src/core/schemas/search.ts b/src/core/schemas/search.ts index dc19ee7..7b38a96 100644 --- a/src/core/schemas/search.ts +++ b/src/core/schemas/search.ts @@ -5,7 +5,7 @@ import { MemoryVersionStatusSchema, ProvenanceModeSchema, TemporalClassSchema, -} from "./document.ts"; +} from "./document.js"; // The retrieval contract locked on day one. A SearchHit always pins a // version_id (a citation must be reproducible against the exact version it diff --git a/src/db/client.ts b/src/db/client.ts index 29bff29..712d14e 100644 --- a/src/db/client.ts +++ b/src/db/client.ts @@ -1,7 +1,7 @@ import { drizzle, type PostgresJsDatabase } from "drizzle-orm/postgres-js"; import postgres from "postgres"; -import type { EngineConfig } from "../config.ts"; -import * as schema from "./schema.ts"; +import type { EngineConfig } from "../config.js"; +import * as schema from "./schema.js"; export type Schema = typeof schema; export type Db = PostgresJsDatabase; diff --git a/src/db/schema.test.ts b/src/db/schema.test.ts index 36489f7..57a0567 100644 --- a/src/db/schema.test.ts +++ b/src/db/schema.test.ts @@ -15,7 +15,7 @@ import { rawCapture, transformConfig, transformRun, -} from "./schema.ts"; +} from "./schema.js"; const TABLES = [ memoryDocument, diff --git a/src/distiller/claim.test.ts b/src/distiller/claim.test.ts index d4e18be..96d9606 100644 --- a/src/distiller/claim.test.ts +++ b/src/distiller/claim.test.ts @@ -4,8 +4,8 @@ import { buildDistilledClaim, resolveNextCursor, shouldProcessFeedEntry, -} from "./claim.ts"; -import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.ts"; +} from "./claim.js"; +import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.js"; describe("buildDistilledClaim", () => { it("sets inferred/derived identity and copies access tags", () => { diff --git a/src/distiller/claim.ts b/src/distiller/claim.ts index 38c148f..9df86d9 100644 --- a/src/distiller/claim.ts +++ b/src/distiller/claim.ts @@ -1,4 +1,4 @@ -import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.ts"; +import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.js"; /** * Wire body fragment for a distilled claim write (memory_add / HTTP add). diff --git a/src/distiller/index.ts b/src/distiller/index.ts index 15f85fb..60f09fa 100644 --- a/src/distiller/index.ts +++ b/src/distiller/index.ts @@ -16,7 +16,7 @@ export { RESIDENT_DISTILLER_AGENT_ID, RESIDENT_DISTILLER_WORKFLOW_ID, -} from "./constants.ts"; +} from "./constants.js"; export { buildDistilledClaim, @@ -25,7 +25,7 @@ export { type BuildDistilledClaimArgs, type DistilledClaimWrite, type FeedEntryLike, -} from "./claim.ts"; +} from "./claim.js"; export { runDistillTick, @@ -34,10 +34,10 @@ export { type DistillTickPage, type DistillTickResult, type RunDistillTickArgs, -} from "./tick.ts"; +} from "./tick.js"; export { createResidentDistiller, type CreateResidentDistillerOpts, type ResidentDistiller, -} from "./workflow.ts"; +} from "./workflow.js"; diff --git a/src/distiller/tick.test.ts b/src/distiller/tick.test.ts index fde5044..a5ef3a4 100644 --- a/src/distiller/tick.test.ts +++ b/src/distiller/tick.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "bun:test"; -import type { MemoryHttpClient } from "../http-client.ts"; -import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.ts"; -import { runDistillTick } from "./tick.ts"; +import type { MemoryHttpClient } from "../http-client.js"; +import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.js"; +import { runDistillTick } from "./tick.js"; function fakeClient(opts: { page: unknown; diff --git a/src/distiller/tick.ts b/src/distiller/tick.ts index afcab30..51e54cc 100644 --- a/src/distiller/tick.ts +++ b/src/distiller/tick.ts @@ -2,13 +2,13 @@ * Imperative distill tick — for hosts that want a function, not a workflow. * Inference stays injected: host supplies `distill` (call your model). */ -import type { MemoryHttpClient } from "../http-client.ts"; +import type { MemoryHttpClient } from "../http-client.js"; import { buildDistilledClaim, shouldProcessFeedEntry, type DistilledClaimWrite, -} from "./claim.ts"; -import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.ts"; +} from "./claim.js"; +import { RESIDENT_DISTILLER_AGENT_ID } from "./constants.js"; export type DistillTickFeedEntry = { feedSeq: number; diff --git a/src/distiller/workflow.test.ts b/src/distiller/workflow.test.ts index 86c18a0..6064a4c 100644 --- a/src/distiller/workflow.test.ts +++ b/src/distiller/workflow.test.ts @@ -3,9 +3,9 @@ import { describe, expect, it } from "bun:test"; import { RESIDENT_DISTILLER_AGENT_ID, RESIDENT_DISTILLER_WORKFLOW_ID, -} from "./constants.ts"; -import { SIDECAR_BUNDLE_ID } from "../sidecar-bundle.ts"; -import { createResidentDistiller } from "./workflow.ts"; +} from "./constants.js"; +import { SIDECAR_BUNDLE_ID } from "../sidecar-bundle.js"; +import { createResidentDistiller } from "./workflow.js"; describe("createResidentDistiller", () => { it("returns a mail-triggered workflow with memory tools on the agent", () => { @@ -50,7 +50,7 @@ describe("createResidentDistiller", () => { }); it("does not carry a cron/schedule field in its public options", () => { - const opts: import("./workflow.ts").CreateResidentDistillerOpts = { + const opts: import("./workflow.js").CreateResidentDistillerOpts = { mailTo: "resident-distiller@tenant.example.com", inference: { sources: [{ provider: "openai", model: "gpt-4.1-mini" }] }, }; diff --git a/src/distiller/workflow.ts b/src/distiller/workflow.ts index 0013117..ff58836 100644 --- a/src/distiller/workflow.ts +++ b/src/distiller/workflow.ts @@ -22,12 +22,12 @@ import { } from "@intx/agent"; import { defineWorkflow, type WorkflowDefinition } from "@intx/workflow"; -import { memory } from "../sidecar-bundle.ts"; -import { capabilityIdsForSurface } from "../grant-requirements.ts"; +import { memory } from "../sidecar-bundle.js"; +import { capabilityIdsForSurface } from "../grant-requirements.js"; import { RESIDENT_DISTILLER_AGENT_ID, RESIDENT_DISTILLER_WORKFLOW_ID, -} from "./constants.ts"; +} from "./constants.js"; const DEFAULT_SYSTEM_PROMPT = (generatorAgentId: string) => `You are the resident memory distiller for a Corbits tenant. diff --git a/src/grant-requirements.test.ts b/src/grant-requirements.test.ts index 0860846..d6a206c 100644 --- a/src/grant-requirements.test.ts +++ b/src/grant-requirements.test.ts @@ -6,7 +6,7 @@ import { capabilityIdsForSurface, MEMORY_CAPABILITY_IDS, MEMORY_GRANT_REQUIREMENTS, -} from "./grant-requirements.ts"; +} from "./grant-requirements.js"; describe("MEMORY_GRANT_REQUIREMENTS", () => { test("covers add, search, forget, and purge on memory resource", () => { diff --git a/src/grant-tags.test.ts b/src/grant-tags.test.ts index 5e2e4d9..b9f12dc 100644 --- a/src/grant-tags.test.ts +++ b/src/grant-tags.test.ts @@ -7,7 +7,7 @@ import { ownerTag, resolveAccessTags, tenantTag, -} from "./grant-tags.ts"; +} from "./grant-tags.js"; describe("resolveAccessTags", () => { diff --git a/src/http-bodies.ts b/src/http-bodies.ts index 4b86b57..f21380b 100644 --- a/src/http-bodies.ts +++ b/src/http-bodies.ts @@ -12,8 +12,8 @@ import { LIST_LIMIT_MIN, SEARCH_LIMIT_MAX, SEARCH_LIMIT_MIN, -} from "./limits.ts"; -import { NonBlankId } from "./core/schemas/non-blank-id.ts"; +} from "./limits.js"; +import { NonBlankId } from "./core/schemas/non-blank-id.js"; export const ShareBody = type({ "tenant?": "boolean", diff --git a/src/http-client.ts b/src/http-client.ts index aa44e44..1e3c577 100644 --- a/src/http-client.ts +++ b/src/http-client.ts @@ -7,7 +7,7 @@ * Pass `signal` on each call so a hung hub can be cancelled; this client * does not invent a default timeout. */ -import type { AddRequest, SearchRequest } from "./http-bodies.ts"; +import type { AddRequest, SearchRequest } from "./http-bodies.js"; export type MemoryHttpConfig = { baseUrl: string; diff --git a/src/index.ts b/src/index.ts index 9b6f161..20a90b7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,18 +19,18 @@ import { resolveGrantConfig, type Memory, type MemoryOptions, -} from "./memory.ts"; +} from "./memory.js"; import { registerMemoryRoutes, type CallerResolver, type RouteDeps, -} from "./routes/mount.ts"; +} from "./routes/mount.js"; // Config -export type { MemoryConfig } from "./mount-config.ts"; -export { loadMemoryConfig } from "./mount-config.ts"; -export type { EngineConfig } from "./config.ts"; -export { RerankConfigError } from "./core/rerank-client.ts"; +export type { MemoryConfig } from "./mount-config.js"; +export { loadMemoryConfig } from "./mount-config.js"; +export type { EngineConfig } from "./config.js"; +export { RerankConfigError } from "./core/rerank-client.js"; // Memory plane — types from memory.ts; createMemory is defined below so it // can optionally register HTTP routes when `app` is passed. @@ -54,7 +54,7 @@ export type { SearchResult, TextExtractor, TimelineEvent, -} from "./memory.ts"; +} from "./memory.js"; export { MemoryError, resolveGrantConfig, @@ -62,7 +62,7 @@ export { SEARCH_LIMIT_MAX, LIST_LIMIT_MIN, LIST_LIMIT_MAX, -} from "./memory.ts"; +} from "./memory.js"; // Installer discovery — grant *requirements* (not live grants) export { @@ -72,7 +72,7 @@ export { type MemoryGrantRequirement, type MemoryGrantInstallHint, type MemoryGrantSurface, -} from "./grant-requirements.ts"; +} from "./grant-requirements.js"; // Ports — pluggable storage and live sources export type { @@ -87,18 +87,18 @@ export type { DocumentStoreListParams, LiveSearchItem, SourceProvider, -} from "./ports/types.ts"; +} from "./ports/types.js"; export { createFakeDocumentStore, createFakeSourceProvider, -} from "./ports/fakes.ts"; +} from "./ports/fakes.js"; -export type { WritableGrantStore } from "./ports/writable-grant-store.ts"; +export type { WritableGrantStore } from "./ports/writable-grant-store.js"; export { createInMemoryWritableGrantStore, isWritableGrantStore, -} from "./ports/writable-grant-store.ts"; +} from "./ports/writable-grant-store.js"; // Share materialization (CL-5873) export { @@ -112,7 +112,7 @@ export { type MaterializeShareGrantsInput, type MemoryShareCondition, type ShareWidenReceipt, -} from "./services/share-grants.ts"; +} from "./services/share-grants.js"; // Transform / replay surface (CL-5872) @@ -128,7 +128,7 @@ export { type GenerationSearchParams, type TransformConfigRow, type TransformRunRow, -} from "./services/transform.ts"; +} from "./services/transform.js"; // Capture feed (CL-5868) export { @@ -139,7 +139,7 @@ export { type FeedArgs, type FeedEntry, type FeedResult, -} from "./services/feed.ts"; +} from "./services/feed.js"; // Retention / forgetting (CL-5871) export { @@ -149,7 +149,7 @@ export { sweepEphemeral, tombstoneDocument, type RetentionMutationResult, -} from "./services/retention.ts"; +} from "./services/retention.js"; // Resident distiller (CL-5869) — also `@corbits/memory/distiller` export { @@ -170,7 +170,7 @@ export { type FeedEntryLike, type ResidentDistiller, type RunDistillTickArgs, -} from "./distiller/index.ts"; +} from "./distiller/index.js"; // Corroboration / living relevancy (CL-5867) export { @@ -181,7 +181,7 @@ export { meetsStrongEvidenceGate, type CorroborationCounts, type StrongEvidenceSignals, -} from "./core/corroboration.ts"; +} from "./core/corroboration.js"; // Embed model registry (ensure vs activate) export { @@ -191,20 +191,20 @@ export { ensureEmbedModel, resolveActiveEmbedTable, resolveEmbedTableByModelKey, -} from "./core/embed-model-registry.ts"; +} from "./core/embed-model-registry.js"; // Run-scoped routes for deployed agents (bearer + run address, no session). // The tools that call them ship at `@corbits/memory/sidecar-bundle`. -export { mountWorkflowMemory } from "./workflow-mount.ts"; +export { mountWorkflowMemory } from "./workflow-mount.js"; export type { AgentTokenAuth, AgentTokenIdentity, MountWorkflowMemoryOpts, ResolvedWorkflowRunScope, WorkflowMemoryEnv, -} from "./workflow-mount.ts"; -export { MEMORY_TOOL_DEFINITIONS, type MemoryToolDefinition } from "./tools.ts"; +} from "./workflow-mount.js"; +export { MEMORY_TOOL_DEFINITIONS, type MemoryToolDefinition } from "./tools.js"; // Host-side HTTP client for the tenant routes (the imperative distill tick). export { @@ -213,10 +213,10 @@ export { type MemoryHttpClient, type MemoryHttpConfig, type MemorySearchBody, -} from "./http-client.ts"; +} from "./http-client.js"; // Migrations -export { runMemoryMigrations } from "./migrations.ts"; +export { runMemoryMigrations } from "./migrations.js"; // Degrade metrics — no metrics dependency exists in this package (see // core/degrade-metrics.ts); a host with its own metrics backend polls this @@ -227,13 +227,13 @@ export { configureDegradeMetrics, type DegradeMetricsSnapshot, type DegradeMetricsConfig, -} from "./core/degrade-metrics.ts"; +} from "./core/degrade-metrics.js"; export { DEFAULT_FTS_LANGUAGE, type FtsVerifySqlClient, parseFtsLanguage, verifyFtsLanguage, -} from "./core/fts-language.ts"; +} from "./core/fts-language.js"; // Granular HTTP composition (most hosts use createMemory({ app, … }) instead) export { @@ -241,7 +241,7 @@ export { type CallerResolver, type GrantConfig, type ResolvedCaller, -} from "./routes/mount.ts"; +} from "./routes/mount.js"; export type CreateMemoryOptions = MemoryOptions & { /** diff --git a/src/log.test.ts b/src/log.test.ts index 8fad993..cc165cb 100644 --- a/src/log.test.ts +++ b/src/log.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "bun:test"; -import { formatCaughtError } from "./log.ts"; -import { RerankHttpError } from "./core/rerank-client.ts"; +import { formatCaughtError } from "./log.js"; +import { RerankHttpError } from "./core/rerank-client.js"; describe("formatCaughtError", () => { it("returns an Error's message, unchanged", () => { diff --git a/src/memory.test.ts b/src/memory.test.ts index 6d674c0..3bf4ac9 100644 --- a/src/memory.test.ts +++ b/src/memory.test.ts @@ -17,20 +17,20 @@ import { import { createInMemoryGrantStore } from "@intx/authz"; import type { GrantRule } from "@intx/authz"; -import { RerankConfigError } from "./core/rerank-client.ts"; -import type { SearchHit } from "./core/schemas/search.ts"; +import { RerankConfigError } from "./core/rerank-client.js"; +import type { SearchHit } from "./core/schemas/search.js"; import { createMemory, MemoryError, type MemoryAddParams, type SearchItem, type TextExtractor, -} from "./memory.ts"; -import type { MemoryConfig } from "./mount-config.ts"; -import * as realDb from "./db/client.ts"; -import * as realSearch from "./services/search.ts"; -import * as realCapture from "./services/capture.ts"; -import * as realRetention from "./services/retention.ts"; +} from "./memory.js"; +import type { MemoryConfig } from "./mount-config.js"; +import * as realDb from "./db/client.js"; +import * as realSearch from "./services/search.js"; +import * as realCapture from "./services/capture.js"; +import * as realRetention from "./services/retention.js"; // Bun's module registry is process-global and `mock.module()` rewrites live // bindings in place — including these `realX` namespaces — with no unmock @@ -42,7 +42,7 @@ const pristineDb = { ...realDb }; const pristineSearch = { ...realSearch }; const pristineCapture = { ...realCapture }; const pristineRetention = { ...realRetention }; -import type { HybridSearchResult } from "./services/search.ts"; +import type { HybridSearchResult } from "./services/search.js"; const PRINCIPAL = "p1"; const TENANT = "t1"; @@ -266,19 +266,19 @@ describe("createMemory.find — grant-tag post-filter wiring", () => { ); beforeAll(() => { - mock.module("./db/client.ts", () => ({ + mock.module("./db/client.js", () => ({ ...realDb, createDb: () => ({ db: {}, sql }), })); - mock.module("./services/search.ts", () => ({ + mock.module("./services/search.js", () => ({ ...realSearch, hybridSearch, })); }); afterAll(() => { - mock.module("./db/client.ts", () => pristineDb); - mock.module("./services/search.ts", () => pristineSearch); + mock.module("./db/client.js", () => pristineDb); + mock.module("./services/search.js", () => pristineSearch); }); it("keeps creator docs and drops others when grants are absent", async () => { @@ -528,19 +528,19 @@ describe("add() — documentId, content/file XOR, share", () => { }); beforeAll(() => { - mock.module("./db/client.ts", () => ({ + mock.module("./db/client.js", () => ({ ...realDb, createDb: () => ({ db: {}, sql }), })); - mock.module("./services/capture.ts", () => ({ + mock.module("./services/capture.js", () => ({ ...realCapture, captureDocument, })); }); afterAll(() => { - mock.module("./db/client.ts", () => pristineDb); - mock.module("./services/capture.ts", () => pristineCapture); + mock.module("./db/client.js", () => pristineDb); + mock.module("./services/capture.js", () => pristineCapture); }); async function freshPlane(opts?: { @@ -818,11 +818,11 @@ describe("retention writes — ownership gate (CL-6288)", () => { ); beforeAll(() => { - mock.module("./db/client.ts", () => ({ + mock.module("./db/client.js", () => ({ ...realDb, createDb: () => ({ db: {}, sql }), })); - mock.module("./services/retention.ts", () => ({ + mock.module("./services/retention.js", () => ({ ...realRetention, tombstoneDocument, hardDeleteDocument, @@ -831,8 +831,8 @@ describe("retention writes — ownership gate (CL-6288)", () => { }); afterAll(() => { - mock.module("./db/client.ts", () => pristineDb); - mock.module("./services/retention.ts", () => pristineRetention); + mock.module("./db/client.js", () => pristineDb); + mock.module("./services/retention.js", () => pristineRetention); }); async function freshPlane() { diff --git a/src/memory.ts b/src/memory.ts index 502063e..7f03611 100644 --- a/src/memory.ts +++ b/src/memory.ts @@ -6,32 +6,32 @@ import { resolveAccessTags, ownerTag, type ShareSugar, -} from "./grant-tags.ts"; - -import type { EngineConfig } from "./config.ts"; -import { formatCaughtError, log } from "./log.ts"; -import { createDb, type Db, type RawSql } from "./db/client.ts"; -import { createFtsVerification, parseFtsLanguage } from "./core/fts-language.ts"; -import { createRawSqlClient } from "./core/embed-sql.ts"; -import type { SearchHit } from "./core/schemas/search.ts"; -import { validateRerankConfig } from "./core/rerank-client.ts"; -import { captureDocument, type CaptureDegradedReason } from "./services/capture.ts"; +} from "./grant-tags.js"; + +import type { EngineConfig } from "./config.js"; +import { formatCaughtError, log } from "./log.js"; +import { createDb, type Db, type RawSql } from "./db/client.js"; +import { createFtsVerification, parseFtsLanguage } from "./core/fts-language.js"; +import { createRawSqlClient } from "./core/embed-sql.js"; +import type { SearchHit } from "./core/schemas/search.js"; +import { validateRerankConfig } from "./core/rerank-client.js"; +import { captureDocument, type CaptureDegradedReason } from "./services/capture.js"; import { hybridSearch, MemorySearchInputError, toRerankClientConfig, type HybridSearchResult, DEFAULT_HYBRID_TOP_K, -} from "./services/search.ts"; +} from "./services/search.js"; import { listTimelineEvents, type TimelineEvent, -} from "./services/timeline.ts"; +} from "./services/timeline.js"; import { fetchFeed, feedPageAfterAccessFilter, type FeedEntry, -} from "./services/feed.ts"; +} from "./services/feed.js"; import { createTransformConfig, @@ -41,65 +41,65 @@ import { runTransform, type TransformConfigRow, type TransformRunRow, -} from "./services/transform.ts"; +} from "./services/transform.js"; import { deprecateVersion, hardDeleteDocument, setRetentionClass, sweepEphemeral, tombstoneDocument, -} from "./services/retention.ts"; +} from "./services/retention.js"; import { isOwner, resolveDocumentOwner, resolveVersionOwner, -} from "./services/retention-ownership.ts"; +} from "./services/retention-ownership.js"; import { documentTag, materializeShareGrants, MEMORY_SHARE_CONDITION_REGISTRY, -} from "./services/share-grants.ts"; +} from "./services/share-grants.js"; import { isWritableGrantStore, -} from "./ports/writable-grant-store.ts"; -import type { TransformConfigParams, TransformScope } from "./core/schemas/transform.ts"; +} from "./ports/writable-grant-store.js"; +import type { TransformConfigParams, TransformScope } from "./core/schemas/transform.js"; import { LIVE_TIMEOUT_MS, mergeLocalLiveV1, withTimeout, type MergeChannelItem, type MergeDegradeFlag, -} from "./core/merge-local-live.ts"; -import type { DegradeFlag } from "./core/hybrid-search.ts"; -import type { MemoryConfig } from "./mount-config.ts"; -import type { GrantConfig } from "./routes/deps.ts"; +} from "./core/merge-local-live.js"; +import type { DegradeFlag } from "./core/hybrid-search.js"; +import type { MemoryConfig } from "./mount-config.js"; +import type { GrantConfig } from "./routes/deps.js"; import type { DocumentStore, DocumentStoreCapabilities, DocumentStoreSearchParams, SourceProvider, -} from "./ports/types.ts"; +} from "./ports/types.js"; import { LIST_LIMIT_MAX, LIST_LIMIT_MIN, SEARCH_LIMIT_MAX, SEARCH_LIMIT_MIN, -} from "./limits.ts"; +} from "./limits.js"; // (drizzle select was used briefly for grant-tag load; raw sql keeps unit-test // mocks simple and matches the rest of the engine store.) // Re-export so hosts typing plane results don't reach into services/. -export type { HybridSearchResult } from "./services/search.ts"; -export type { SearchHit } from "./core/schemas/search.ts"; +export type { HybridSearchResult } from "./services/search.js"; +export type { SearchHit } from "./core/schemas/search.js"; export type { DocumentStore, DocumentStoreAddParams, DocumentStoreCapabilities, LiveSearchItem, SourceProvider, -} from "./ports/types.ts"; +} from "./ports/types.js"; // Alias so hosts read `MemoryCapabilities` (the name on the `Memory` handle // they actually hold) rather than reaching for the port-level type name. export type MemoryCapabilities = DocumentStoreCapabilities; @@ -108,7 +108,7 @@ export { SEARCH_LIMIT_MAX, LIST_LIMIT_MIN, LIST_LIMIT_MAX, -} from "./limits.ts"; +} from "./limits.js"; export { resolveAccessTags, @@ -117,7 +117,7 @@ export { canAccessDocument, matchesVisibleTags, type ShareSugar, -} from "./grant-tags.ts"; +} from "./grant-tags.js"; /** * Optional host-supplied extractor for `add({ file })`. The engine never diff --git a/src/migrations.ts b/src/migrations.ts index ce3af03..bc78a54 100644 --- a/src/migrations.ts +++ b/src/migrations.ts @@ -11,11 +11,13 @@ import { FTS_LANGUAGE_TOKEN, parseFtsLanguage, verifyFtsLanguage, -} from "./core/fts-language.ts"; -import { createRawSqlClient } from "./core/embed-sql.ts"; -import { MEMORY_SCHEMA } from "./db/schema.ts"; +} from "./core/fts-language.js"; +import { createRawSqlClient } from "./core/embed-sql.js"; +import { MEMORY_SCHEMA } from "./db/schema.js"; -const MIGRATIONS_DIR = join(import.meta.dir, "..", "migrations"); +// dirname (not Bun-only `dir`): the packed dist/ layout keeps +// /migrations next to /dist, so this resolves in Node too. +const MIGRATIONS_DIR = join(import.meta.dirname, "..", "migrations"); export async function runMemoryMigrations( databaseUrl: string, diff --git a/src/mount-config.test.ts b/src/mount-config.test.ts index 2665b3e..735d18e 100644 --- a/src/mount-config.test.ts +++ b/src/mount-config.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it } from "bun:test"; -import { loadMemoryConfig } from "./mount-config.ts"; +import { loadMemoryConfig } from "./mount-config.js"; const REQUIRED_ENV = { DATABASE_URL: "postgres://localhost:5432/test", diff --git a/src/mount-config.ts b/src/mount-config.ts index b107406..ceb8c51 100644 --- a/src/mount-config.ts +++ b/src/mount-config.ts @@ -1,5 +1,5 @@ -import type { EngineConfig } from "./config.ts"; -import { parseFtsLanguage } from "./core/fts-language.ts"; +import type { EngineConfig } from "./config.js"; +import { parseFtsLanguage } from "./core/fts-language.js"; /** * SDK config — what `createMemory` consumes. diff --git a/src/ports/fakes.test.ts b/src/ports/fakes.test.ts index b3e15ed..f90bb6a 100644 --- a/src/ports/fakes.test.ts +++ b/src/ports/fakes.test.ts @@ -1,12 +1,12 @@ import { describe, expect, it } from "bun:test"; import { createInMemoryGrantStore } from "@intx/authz"; -import { ownerTag, tenantTag } from "../grant-tags.ts"; +import { ownerTag, tenantTag } from "../grant-tags.js"; import { createFakeDocumentStore, createFakeSourceProvider, -} from "./fakes.ts"; +} from "./fakes.js"; const TENANT = "t1"; const PRINCIPAL = "p1"; diff --git a/src/ports/fakes.ts b/src/ports/fakes.ts index 940d165..a15f026 100644 --- a/src/ports/fakes.ts +++ b/src/ports/fakes.ts @@ -6,7 +6,7 @@ * authorize(grants, …, tag, "search") allows when grants are provided. Without * grants, only creator access (safe default for unit tests). */ -import { canAccessDocument, matchesVisibleTags } from "../grant-tags.ts"; +import { canAccessDocument, matchesVisibleTags } from "../grant-tags.js"; import type { DocumentStore, @@ -17,7 +17,7 @@ import type { DocumentStoreListParams, LiveSearchItem, SourceProvider, -} from "./types.ts"; +} from "./types.js"; type StoredDoc = { documentId: string; diff --git a/src/ports/index.ts b/src/ports/index.ts index c8addc8..abf620a 100644 --- a/src/ports/index.ts +++ b/src/ports/index.ts @@ -3,8 +3,8 @@ export type { DocumentStoreAddParams, LiveSearchItem, SourceProvider, -} from "./types.ts"; +} from "./types.js"; export { createFakeDocumentStore, createFakeSourceProvider, -} from "./fakes.ts"; +} from "./fakes.js"; diff --git a/src/ports/memory-plane.test.ts b/src/ports/memory-plane.test.ts index f945311..7feb0ea 100644 --- a/src/ports/memory-plane.test.ts +++ b/src/ports/memory-plane.test.ts @@ -11,7 +11,7 @@ import { import { createFakeDocumentStore, createMemory, -} from "../index.ts"; +} from "../index.js"; const TENANT = "t_mem"; const PRINCIPAL = "p_mem"; diff --git a/src/ports/merge-plane.test.ts b/src/ports/merge-plane.test.ts index 6b86e4b..82b245d 100644 --- a/src/ports/merge-plane.test.ts +++ b/src/ports/merge-plane.test.ts @@ -7,8 +7,8 @@ import { createFakeDocumentStore, createFakeSourceProvider, createMemory, -} from "../index.ts"; -import type { LiveSearchItem } from "./types.ts"; +} from "../index.js"; +import type { LiveSearchItem } from "./types.js"; const TENANT = "t_merge"; const PRINCIPAL = "p_merge"; diff --git a/src/ports/mount-fakes.test.ts b/src/ports/mount-fakes.test.ts index 05369e0..def0c96 100644 --- a/src/ports/mount-fakes.test.ts +++ b/src/ports/mount-fakes.test.ts @@ -14,7 +14,7 @@ import { createFakeDocumentStore, createFakeSourceProvider, createMemory, -} from "../index.ts"; +} from "../index.js"; const TENANT = "tenant_fake"; const PRINCIPAL = "principal_fake"; diff --git a/src/ports/types.ts b/src/ports/types.ts index 43f88d3..f913c12 100644 --- a/src/ports/types.ts +++ b/src/ports/types.ts @@ -18,9 +18,9 @@ import type { SearchEvidence, SearchHit, SearchHitCitation, -} from "../core/schemas/search.ts"; -import type { DegradeFlag } from "../core/hybrid-search.ts"; -import type { CaptureDegradedReason } from "../core/embed-worker.ts"; +} from "../core/schemas/search.js"; +import type { DegradeFlag } from "../core/hybrid-search.js"; +import type { CaptureDegradedReason } from "../core/embed-worker.js"; /** Input the plane hands the store after content/file/share resolution. */ export type DocumentStoreAddParams = { diff --git a/src/routes/add.ts b/src/routes/add.ts index ab50244..fdc5a32 100644 --- a/src/routes/add.ts +++ b/src/routes/add.ts @@ -3,18 +3,18 @@ import type { TenantEnv } from "@intx/hub-api"; import { describeRoute, resolver, validator } from "hono-openapi"; import { type } from "arktype"; -import { formatCaughtError, log } from "../log.ts"; -import { resolveAccessTags, type ShareSugar } from "../grant-tags.ts"; -import { AddRequest } from "../http-bodies.ts"; +import { formatCaughtError, log } from "../log.js"; +import { resolveAccessTags, type ShareSugar } from "../grant-tags.js"; +import { AddRequest } from "../http-bodies.js"; -import { MemoryError } from "../memory.ts"; -import type { RouteDeps } from "./deps.ts"; +import { MemoryError } from "../memory.js"; +import type { RouteDeps } from "./deps.js"; import { caller, grantGuard, requirePrincipal, resolveCaller, -} from "./deps.ts"; +} from "./deps.js"; const AddResponse = type({ documentId: "string", diff --git a/src/routes/deps.test.ts b/src/routes/deps.test.ts index ae9cdc0..752e7ce 100644 --- a/src/routes/deps.test.ts +++ b/src/routes/deps.test.ts @@ -11,7 +11,7 @@ import { resolveCaller, type ResolvedCaller, type RouteDeps, -} from "./deps.ts"; +} from "./deps.js"; function grant(principalId: string, action: string): GrantRule { return { diff --git a/src/routes/deps.ts b/src/routes/deps.ts index 22d5684..687f6f2 100644 --- a/src/routes/deps.ts +++ b/src/routes/deps.ts @@ -8,9 +8,9 @@ import type { import type { ConditionRegistry, GrantStore } from "@intx/authz"; import { type } from "arktype"; -import { log } from "../log.ts"; -import type { Memory } from "../memory.ts"; -import { NonBlankId } from "../core/schemas/non-blank-id.ts"; +import { log } from "../log.js"; +import type { Memory } from "../memory.js"; +import { NonBlankId } from "../core/schemas/non-blank-id.js"; /** * The host's grant store + condition registry — the same pair it feeds diff --git a/src/routes/feed.ts b/src/routes/feed.ts index de9605b..358b37c 100644 --- a/src/routes/feed.ts +++ b/src/routes/feed.ts @@ -3,16 +3,16 @@ import type { TenantEnv } from "@intx/hub-api"; import { describeRoute, resolver, validator } from "hono-openapi"; import { type } from "arktype"; -import { formatCaughtError, log } from "../log.ts"; -import { FeedQuery, parseFeedQuery } from "../http-bodies.ts"; -import { MemoryError } from "../memory.ts"; -import type { RouteDeps } from "./deps.ts"; +import { formatCaughtError, log } from "../log.js"; +import { FeedQuery, parseFeedQuery } from "../http-bodies.js"; +import { MemoryError } from "../memory.js"; +import type { RouteDeps } from "./deps.js"; import { caller, grantGuard, requirePrincipal, resolveCaller, -} from "./deps.ts"; +} from "./deps.js"; const FeedResponse = type({ entries: type({ diff --git a/src/routes/list.ts b/src/routes/list.ts index 921d80e..4dbe7cd 100644 --- a/src/routes/list.ts +++ b/src/routes/list.ts @@ -3,20 +3,20 @@ import type { TenantEnv } from "@intx/hub-api"; import { describeRoute, resolver, validator } from "hono-openapi"; import { type } from "arktype"; -import { formatCaughtError, log } from "../log.ts"; -import { ListQuery, parseListLimitString } from "../http-bodies.ts"; +import { formatCaughtError, log } from "../log.js"; +import { ListQuery, parseListLimitString } from "../http-bodies.js"; import { MemoryError, LIST_LIMIT_MAX, LIST_LIMIT_MIN, -} from "../memory.ts"; -import type { RouteDeps } from "./deps.ts"; +} from "../memory.js"; +import type { RouteDeps } from "./deps.js"; import { caller, grantGuard, requirePrincipal, resolveCaller, -} from "./deps.ts"; +} from "./deps.js"; const ListResponse = type({ events: type({ diff --git a/src/routes/mount.ts b/src/routes/mount.ts index fd605d6..095d4d8 100644 --- a/src/routes/mount.ts +++ b/src/routes/mount.ts @@ -13,23 +13,23 @@ import type { Hono } from "hono"; import type { TenantEnv } from "@intx/hub-api"; -import type { RouteDeps } from "./deps.ts"; -import { mountAddRoute } from "./add.ts"; -import { mountSearchRoute } from "./search.ts"; -import { mountListRoute } from "./list.ts"; -import { mountFeedRoute } from "./feed.ts"; +import type { RouteDeps } from "./deps.js"; +import { mountAddRoute } from "./add.js"; +import { mountSearchRoute } from "./search.js"; +import { mountListRoute } from "./list.js"; +import { mountFeedRoute } from "./feed.js"; import { mountForgetRoute, mountPurgeRoute, mountSetRetentionClassRoute, -} from "./retention.ts"; +} from "./retention.js"; export type { CallerResolver, GrantConfig, ResolvedCaller, RouteDeps, -} from "./deps.ts"; +} from "./deps.js"; /** HTTP JSON routes: add, search, list, feed, forget, purge, retention-class. */ export function registerMemoryRoutes( diff --git a/src/routes/retention.ts b/src/routes/retention.ts index 179443c..d5fcdef 100644 --- a/src/routes/retention.ts +++ b/src/routes/retention.ts @@ -15,21 +15,21 @@ import type { TenantEnv } from "@intx/hub-api"; import { describeRoute, resolver, validator } from "hono-openapi"; import { type } from "arktype"; -import { formatCaughtError, log } from "../log.ts"; +import { formatCaughtError, log } from "../log.js"; import { DocumentIdParam, ForgetRequest, SetRetentionClassRequest, VersionIdParam, -} from "../http-bodies.ts"; -import { MemoryError } from "../memory.ts"; -import type { RouteDeps } from "./deps.ts"; +} from "../http-bodies.js"; +import { MemoryError } from "../memory.js"; +import type { RouteDeps } from "./deps.js"; import { caller, grantGuard, requirePrincipal, resolveCaller, -} from "./deps.ts"; +} from "./deps.js"; function respondRetentionError(err: unknown, action: string) { const errMessage = formatCaughtError(err); diff --git a/src/routes/routes.test.ts b/src/routes/routes.test.ts index 4278e8a..763188a 100644 --- a/src/routes/routes.test.ts +++ b/src/routes/routes.test.ts @@ -4,10 +4,10 @@ import { createInMemoryGrantStore } from "@intx/authz"; import type { GrantRule } from "@intx/authz"; import { createRequireGrant, type TenantEnv } from "@intx/hub-api"; -import type { Memory, TimelineEvent } from "../memory.ts"; -import { MemoryError } from "../memory.ts"; -import { registerMemoryRoutes } from "./mount.ts"; -import type { RouteDeps } from "./deps.ts"; +import type { Memory, TimelineEvent } from "../memory.js"; +import { MemoryError } from "../memory.js"; +import { registerMemoryRoutes } from "./mount.js"; +import type { RouteDeps } from "./deps.js"; function grant(principalId: string, action: string): GrantRule { return { diff --git a/src/routes/search.ts b/src/routes/search.ts index e08f68a..30814dd 100644 --- a/src/routes/search.ts +++ b/src/routes/search.ts @@ -3,16 +3,16 @@ import type { TenantEnv } from "@intx/hub-api"; import { describeRoute, resolver, validator } from "hono-openapi"; import { type } from "arktype"; -import { formatCaughtError, log } from "../log.ts"; -import { SearchRequest } from "../http-bodies.ts"; -import { MemoryError } from "../memory.ts"; -import type { RouteDeps } from "./deps.ts"; +import { formatCaughtError, log } from "../log.js"; +import { SearchRequest } from "../http-bodies.js"; +import { MemoryError } from "../memory.js"; +import type { RouteDeps } from "./deps.js"; import { caller, grantGuard, requirePrincipal, resolveCaller, -} from "./deps.ts"; +} from "./deps.js"; // `kinds`/`entity_ids` scope every retrieval channel — see the // `kinds`/`entityIds` doc comments on MemorySearchParams (memory.ts) diff --git a/src/services/capture.test.ts b/src/services/capture.test.ts index 489c8f1..d9b6a5b 100644 --- a/src/services/capture.test.ts +++ b/src/services/capture.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it, mock } from "bun:test"; -import { embedInsertedChunksWithConfig, toEmbedClientConfig } from "./capture.ts"; -import type { CaptureInput } from "./capture.ts"; -import type { Db, RawSql } from "../db/client.ts"; -import type { EngineConfig } from "../config.ts"; -import type { EmbedClientConfig } from "../core/embed-client.ts"; -import type { EmbeddableChunk } from "../core/embed-worker.ts"; +import { embedInsertedChunksWithConfig, toEmbedClientConfig } from "./capture.js"; +import type { CaptureInput } from "./capture.js"; +import type { Db, RawSql } from "../db/client.js"; +import type { EngineConfig } from "../config.js"; +import type { EmbedClientConfig } from "../core/embed-client.js"; +import type { EmbeddableChunk } from "../core/embed-worker.js"; // Regression for the capture path silently timing out at embed-client.ts's // default (10000ms) even when EMBED_TIMEOUT_MS was set: capture.ts used to @@ -124,13 +124,13 @@ function unreachableRawSql(): RawSql { // memory.test.ts uses `mock.module("./services/capture.ts", ...)` around its // own describe blocks; Bun's module registry is process-global, so a static -// `import { captureDocument } from "./capture.ts"` here can end up bound to +// `import { captureDocument } from "./capture.js"` here can end up bound to // that mock's fixture data when the whole suite runs (the same leak // services/search.test.ts documents for hybridSearch). A cache-busted // dynamic import — the same trick memory.test.ts itself uses for // `./memory.ts` — sidesteps this: a fresh module specifier is never the one // any mock.module call replaced. -async function loadRealCapture(): Promise { +async function loadRealCapture(): Promise { return import(`./capture.ts?cl-8615-real=${Date.now()}-${Math.random()}`); } diff --git a/src/services/capture.ts b/src/services/capture.ts index 26b717e..46ac08b 100644 --- a/src/services/capture.ts +++ b/src/services/capture.ts @@ -1,11 +1,11 @@ import { createHash } from "node:crypto"; import { and, desc, eq } from "drizzle-orm"; -import type { Db, RawSql } from "../db/client.ts"; -import type { EngineConfig } from "../config.ts"; -import { newId } from "../core/id.ts"; -import { formatCaughtError, log } from "../log.ts"; -import { stableStringify } from "../core/hash.ts"; -import { LIVE_GENERATION } from "../core/generation.ts"; +import type { Db, RawSql } from "../db/client.js"; +import type { EngineConfig } from "../config.js"; +import { newId } from "../core/id.js"; +import { formatCaughtError, log } from "../log.js"; +import { stableStringify } from "../core/hash.js"; +import { LIVE_GENERATION } from "../core/generation.js"; import { memoryChunk, memoryDocument, @@ -13,33 +13,33 @@ import { memoryEntity, memoryVersion, rawCapture, -} from "../db/schema.ts"; +} from "../db/schema.js"; import { adaptAndPlan, type AdaptAndPlanOptions, type CapturePlan, -} from "../core/adapt-and-plan.ts"; -import { computeAuthority, type AuthoritySignals } from "../core/authority.ts"; +} from "../core/adapt-and-plan.js"; +import { computeAuthority, type AuthoritySignals } from "../core/authority.js"; import type { AdaptedDocument, EntityHint, -} from "../core/schemas/adapted-document.ts"; -import type { MemoryEdgeHint } from "../core/schemas/entity-edge.ts"; -import { createRawSqlClient } from "../core/embed-sql.ts"; +} from "../core/schemas/adapted-document.js"; +import type { MemoryEdgeHint } from "../core/schemas/entity-edge.js"; +import { createRawSqlClient } from "../core/embed-sql.js"; import { activateEmbedModel, EMBED_TABLE_NAME_PATTERN, ensureEmbedModel, type ActiveEmbedTable, type EmbedRegistrySqlClient, -} from "../core/embed-model-registry.ts"; -import type { EmbedClientConfig } from "../core/embed-client.ts"; +} from "../core/embed-model-registry.js"; +import type { EmbedClientConfig } from "../core/embed-client.js"; import { embedChunks, type CaptureDegradedReason, type EmbeddableChunk, -} from "../core/embed-worker.ts"; -import { toEmbedClientConfig } from "../core/engine-client-config.ts"; +} from "../core/embed-worker.js"; +import { toEmbedClientConfig } from "../core/engine-client-config.js"; type Tx = Parameters[0]>[0]; diff --git a/src/services/feed.test.ts b/src/services/feed.test.ts index 4d16264..9747dee 100644 --- a/src/services/feed.test.ts +++ b/src/services/feed.test.ts @@ -5,7 +5,7 @@ import { FEED_LIMIT_MIN, FeedInputError, feedPageAfterAccessFilter, -} from "./feed.ts"; +} from "./feed.js"; describe("feed constants", () => { it("keeps the default page size within bounds", () => { diff --git a/src/services/feed.ts b/src/services/feed.ts index f46ff2c..3959410 100644 --- a/src/services/feed.ts +++ b/src/services/feed.ts @@ -4,12 +4,12 @@ */ import { and, asc, eq, gt, isNull, ne, or, sql } from "drizzle-orm"; -import type { Db } from "../db/client.ts"; +import type { Db } from "../db/client.js"; import { memoryDocument, memoryVersion, -} from "../db/schema.ts"; -import { LIVE_GENERATION } from "../core/generation.ts"; +} from "../db/schema.js"; +import { LIVE_GENERATION } from "../core/generation.js"; export const FEED_LIMIT_MIN = 1; export const FEED_LIMIT_MAX = 100; diff --git a/src/services/retention-ownership.test.ts b/src/services/retention-ownership.test.ts index 52a8bbd..2470415 100644 --- a/src/services/retention-ownership.test.ts +++ b/src/services/retention-ownership.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it, mock } from "bun:test"; -import type { RawSql } from "../db/client.ts"; +import type { RawSql } from "../db/client.js"; import { isOwner, resolveDocumentOwner, resolveVersionOwner, -} from "./retention-ownership.ts"; +} from "./retention-ownership.js"; const TENANT = "t1"; const OTHER_TENANT = "t2"; diff --git a/src/services/retention-ownership.ts b/src/services/retention-ownership.ts index 8717413..262595b 100644 --- a/src/services/retention-ownership.ts +++ b/src/services/retention-ownership.ts @@ -9,7 +9,7 @@ * Raw `sql` (not the Drizzle `Db`) so unit tests can mock the query * directly, matching the ACL-load pattern in memory.ts's search path. */ -import type { RawSql } from "../db/client.ts"; +import type { RawSql } from "../db/client.js"; export type OwnerLookup = { /** False when no matching document/version row exists. */ diff --git a/src/services/retention.ts b/src/services/retention.ts index 719f4d7..c9290db 100644 --- a/src/services/retention.ts +++ b/src/services/retention.ts @@ -4,9 +4,9 @@ */ import { and, eq, inArray, isNotNull, lt, or, sql } from "drizzle-orm"; -import type { Db } from "../db/client.ts"; -import { memoryChunk, memoryDocument, memoryVersion } from "../db/schema.ts"; -import type { RetentionClass } from "../core/enums.ts"; +import type { Db } from "../db/client.js"; +import { memoryChunk, memoryDocument, memoryVersion } from "../db/schema.js"; +import type { RetentionClass } from "../core/enums.js"; export type RetentionMutationResult = { versionId: string; diff --git a/src/services/search.test.ts b/src/services/search.test.ts index 29c7a8b..e051502 100644 --- a/src/services/search.test.ts +++ b/src/services/search.test.ts @@ -9,10 +9,10 @@ import { snippet, toHit, type CandidateRow, -} from "./search.ts"; -import { memoryChunk, memoryEdge } from "../db/schema.ts"; -import type { Db, RawSql } from "../db/client.ts"; -import type { EngineConfig } from "../config.ts"; +} from "./search.js"; +import { memoryChunk, memoryEdge } from "../db/schema.js"; +import type { Db, RawSql } from "../db/client.js"; +import type { EngineConfig } from "../config.js"; function candidate(overrides: Partial = {}): CandidateRow { return { diff --git a/src/services/search.ts b/src/services/search.ts index 270b348..50e3c42 100644 --- a/src/services/search.ts +++ b/src/services/search.ts @@ -1,14 +1,14 @@ import { and, desc, eq, inArray, sql } from "drizzle-orm"; -import type { Db, RawSql } from "../db/client.ts"; -import type { EngineConfig } from "../config.ts"; -import { LIVE_GENERATION } from "../core/generation.ts"; +import type { Db, RawSql } from "../db/client.js"; +import type { EngineConfig } from "../config.js"; +import { LIVE_GENERATION } from "../core/generation.js"; import { memoryChunk, memoryDocument, memoryEdge, memoryVersion, -} from "../db/schema.ts"; -import { createRawSqlClient } from "../core/embed-sql.ts"; +} from "../db/schema.js"; +import { createRawSqlClient } from "../core/embed-sql.js"; import { cosineDistanceExpr, computeModelKey, @@ -16,21 +16,21 @@ import { resolveActiveEmbedTable, resolveEmbedTableByModelKey, type ActiveEmbedTable, -} from "../core/embed-model-registry.ts"; -import { embedTexts, type EmbedClientConfig } from "../core/embed-client.ts"; +} from "../core/embed-model-registry.js"; +import { embedTexts, type EmbedClientConfig } from "../core/embed-client.js"; import { toEmbedClientConfig, toRerankClientConfig, -} from "../core/engine-client-config.ts"; +} from "../core/engine-client-config.js"; import { rerankDocuments, RerankConfigError, RerankQueryTooLongError, validateRerankConfig, type RerankClientConfig, -} from "../core/rerank-client.ts"; -import { mmrRerank, type MmrItem } from "../core/mmr.ts"; -import { recordDegrade } from "../core/degrade-metrics.ts"; +} from "../core/rerank-client.js"; +import { mmrRerank, type MmrItem } from "../core/mmr.js"; +import { recordDegrade } from "../core/degrade-metrics.js"; import { authorityBoostMultiplier, clampOverfetchMultiplier, @@ -41,20 +41,20 @@ import { RECENCY_HALF_LIFE_MS, toRankedCandidates, type DegradeFlag, -} from "../core/hybrid-search.ts"; +} from "../core/hybrid-search.js"; import { corroborationFactor, effectiveAuthority, meetsStrongEvidenceGate, type CorroborationCounts, -} from "../core/corroboration.ts"; -import { formatCaughtError, log } from "../log.ts"; -import { resolveGenerationSearchParams } from "./transform.ts"; +} from "../core/corroboration.js"; +import { formatCaughtError, log } from "../log.js"; +import { resolveGenerationSearchParams } from "./transform.js"; import type { SearchChannel, SearchHit, SearchResponse, -} from "../core/schemas/search.ts"; +} from "../core/schemas/search.js"; // The single doorway every retrieval read passes through. Every query below // filters `tenant_id` first, unconditionally. Per-document access is **not** diff --git a/src/services/share-grants.test.ts b/src/services/share-grants.test.ts index 57c9177..e763027 100644 --- a/src/services/share-grants.test.ts +++ b/src/services/share-grants.test.ts @@ -8,9 +8,9 @@ import { MEMORY_SHARE_CONDITION_REGISTRY, shareWidenReceipt, splitAudienceWiden, -} from "./share-grants.ts"; -import { createInMemoryWritableGrantStore } from "../ports/writable-grant-store.ts"; -import { canAccessDocument } from "../grant-tags.ts"; +} from "./share-grants.js"; +import { createInMemoryWritableGrantStore } from "../ports/writable-grant-store.js"; +import { canAccessDocument } from "../grant-tags.js"; describe("documentTag", () => { it("scopes resource to the document id", () => { diff --git a/src/services/share-grants.ts b/src/services/share-grants.ts index 2a88f31..c187324 100644 --- a/src/services/share-grants.ts +++ b/src/services/share-grants.ts @@ -12,9 +12,9 @@ * use `MEMORY_SHARE_CONDITION_REGISTRY` (merged automatically in resolveGrantConfig). */ import type { ConditionRegistry, GrantRule } from "@intx/authz"; -import { newId } from "../core/id.ts"; -import type { ShareSugar } from "../grant-tags.ts"; -import type { WritableGrantStore } from "../ports/writable-grant-store.ts"; +import { newId } from "../core/id.js"; +import type { ShareSugar } from "../grant-tags.js"; +import type { WritableGrantStore } from "../ports/writable-grant-store.js"; /** Document-scoped resource tag for peer share grants. */ export function documentTag(documentId: string): string { diff --git a/src/services/timeline.test.ts b/src/services/timeline.test.ts index 5967c6d..072568a 100644 --- a/src/services/timeline.test.ts +++ b/src/services/timeline.test.ts @@ -7,7 +7,7 @@ import { filterTimelineRows, timelineWhere, type TimelineRow, -} from "./timeline.ts"; +} from "./timeline.js"; const dialect = new PgDialect(); diff --git a/src/services/timeline.ts b/src/services/timeline.ts index b3291fe..3f3a967 100644 --- a/src/services/timeline.ts +++ b/src/services/timeline.ts @@ -9,12 +9,12 @@ */ import { and, desc, eq, sql } from "drizzle-orm"; import type { ConditionRegistry, GrantStore } from "@intx/authz"; -import { canAccessDocument, matchesVisibleTags } from "../grant-tags.ts"; -import { LIVE_GENERATION } from "../core/generation.ts"; +import { canAccessDocument, matchesVisibleTags } from "../grant-tags.js"; +import { LIVE_GENERATION } from "../core/generation.js"; -import type { Db } from "../db/client.ts"; -import { memoryDocument, memoryVersion } from "../db/schema.ts"; -import { log } from "../log.ts"; +import type { Db } from "../db/client.js"; +import { memoryDocument, memoryVersion } from "../db/schema.js"; +import { log } from "../log.js"; export type TimelineEvent = { at: string; diff --git a/src/services/transform.test.ts b/src/services/transform.test.ts index ad040fc..1a0c3e9 100644 --- a/src/services/transform.test.ts +++ b/src/services/transform.test.ts @@ -6,11 +6,11 @@ import { promoteGeneration, runTransform, TransformPromoteError, -} from "./transform.ts"; -import { TransformConfigParamsSchema } from "../core/schemas/transform.ts"; -import { rawCapture, transformConfig, transformRun } from "../db/schema.ts"; -import type { Db, RawSql } from "../db/client.ts"; -import type { EngineConfig } from "../config.ts"; +} from "./transform.js"; +import { TransformConfigParamsSchema } from "../core/schemas/transform.js"; +import { rawCapture, transformConfig, transformRun } from "../db/schema.js"; +import type { Db, RawSql } from "../db/client.js"; +import type { EngineConfig } from "../config.js"; describe("buildRerankClientConfig", () => { it("returns undefined when no baseUrl is configured (falls through to engine defaults)", () => { diff --git a/src/services/transform.ts b/src/services/transform.ts index e53e62a..f2fe99f 100644 --- a/src/services/transform.ts +++ b/src/services/transform.ts @@ -1,29 +1,29 @@ import { type } from "arktype"; import { and, desc, eq, gte, lte } from "drizzle-orm"; -import type { Db, RawSql } from "../db/client.ts"; -import type { EngineConfig } from "../config.ts"; -import { newId } from "../core/id.ts"; -import { formatCaughtError, log } from "../log.ts"; +import type { Db, RawSql } from "../db/client.js"; +import type { EngineConfig } from "../config.js"; +import { newId } from "../core/id.js"; +import { formatCaughtError, log } from "../log.js"; import { rawCapture, transformConfig, transformRun, -} from "../db/schema.ts"; +} from "../db/schema.js"; import { TransformConfigParamsSchema, type TransformConfigParams, type TransformRerankParams, type TransformScope, -} from "../core/schemas/transform.ts"; -import { AdaptedDocumentSchema } from "../core/schemas/adapted-document.ts"; -import { chunkTokenRecursive } from "../core/chunk/token-recursive.ts"; -import type { Chunker } from "../core/chunk/types.ts"; -import { EmbedClientConfigSchema, type EmbedClientConfig } from "../core/embed-client.ts"; -import type { RerankClientConfig } from "../core/rerank-client.ts"; -import { deriveFromRawCapture, type CaptureInput } from "./capture.ts"; -import { LIVE_GENERATION } from "../core/generation.ts"; -import { activateEmbedModel, activateEmbedModelByKey, clearActiveEmbedModels, resolveActiveEmbedTable } from "../core/embed-model-registry.ts"; -import { createRawSqlClient } from "../core/embed-sql.ts"; +} from "../core/schemas/transform.js"; +import { AdaptedDocumentSchema } from "../core/schemas/adapted-document.js"; +import { chunkTokenRecursive } from "../core/chunk/token-recursive.js"; +import type { Chunker } from "../core/chunk/types.js"; +import { EmbedClientConfigSchema, type EmbedClientConfig } from "../core/embed-client.js"; +import type { RerankClientConfig } from "../core/rerank-client.js"; +import { deriveFromRawCapture, type CaptureInput } from "./capture.js"; +import { LIVE_GENERATION } from "../core/generation.js"; +import { activateEmbedModel, activateEmbedModelByKey, clearActiveEmbedModels, resolveActiveEmbedTable } from "../core/embed-model-registry.js"; +import { createRawSqlClient } from "../core/embed-sql.js"; export class TransformConfigNotFoundError extends Error { constructor(configId: string) { diff --git a/src/sidecar-bundle.test.ts b/src/sidecar-bundle.test.ts index 05637c7..9f8668e 100644 --- a/src/sidecar-bundle.test.ts +++ b/src/sidecar-bundle.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { MEMORY_TOOL_DEFINITIONS } from "./tools.ts"; -import { HUB_CREDENTIAL_HANDLE, memory, SIDECAR_BUNDLE_ID } from "./sidecar-bundle.ts"; +import { MEMORY_TOOL_DEFINITIONS } from "./tools.js"; +import { HUB_CREDENTIAL_HANDLE, memory, SIDECAR_BUNDLE_ID } from "./sidecar-bundle.js"; type Recorded = { url: string; init?: RequestInit }; diff --git a/src/sidecar-bundle.ts b/src/sidecar-bundle.ts index f073a71..e3e2057 100644 --- a/src/sidecar-bundle.ts +++ b/src/sidecar-bundle.ts @@ -11,7 +11,7 @@ import { defineTool, type BaseEnv } from "@intx/agent"; import type { ToolCall, ToolResult } from "@intx/types/runtime"; -import { MEMORY_TOOL_DEFINITIONS } from "./tools.ts"; +import { MEMORY_TOOL_DEFINITIONS } from "./tools.js"; /** Where a host mounts `mountWorkflowMemory`. The bundle has no options of * its own — the loader constructs it — so the path is a shared constant diff --git a/src/tools.ts b/src/tools.ts index 188ba8d..31ed825 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -4,7 +4,7 @@ * stays free of any agent-SDK dependency, and `sidecar-bundle.ts` binds each * name to the run-scoped route that performs it. */ -import { LIST_LIMIT_MAX, LIST_LIMIT_MIN, SEARCH_LIMIT_MAX, SEARCH_LIMIT_MIN } from "./limits.ts"; +import { LIST_LIMIT_MAX, LIST_LIMIT_MIN, SEARCH_LIMIT_MAX, SEARCH_LIMIT_MIN } from "./limits.js"; export type MemoryToolDefinition = { name: string; diff --git a/src/workflow-mount.test.ts b/src/workflow-mount.test.ts index b94cc75..7a02046 100644 --- a/src/workflow-mount.test.ts +++ b/src/workflow-mount.test.ts @@ -1,14 +1,14 @@ import { describe, expect, test } from "bun:test"; import { Hono } from "hono"; -import { createMemory, type Memory } from "./memory.ts"; -import { createFakeDocumentStore } from "./ports/fakes.ts"; +import { createMemory, type Memory } from "./memory.js"; +import { createFakeDocumentStore } from "./ports/fakes.js"; import { mountWorkflowMemory, type AgentTokenAuth, type ResolvedWorkflowRunScope, type WorkflowMemoryEnv, -} from "./workflow-mount.ts"; +} from "./workflow-mount.js"; const RUN_SCOPE: ResolvedWorkflowRunScope = { tenantId: "acme", diff --git a/src/workflow-mount.ts b/src/workflow-mount.ts index 3d05930..85764c6 100644 --- a/src/workflow-mount.ts +++ b/src/workflow-mount.ts @@ -20,10 +20,10 @@ import { parseFeedQuery, parseListLimitString, SearchRequest, -} from "./http-bodies.ts"; -import { formatCaughtError, log } from "./log.ts"; -import { MemoryError, type Memory } from "./memory.ts"; -import { tenantTag, type ShareSugar } from "./grant-tags.ts"; +} from "./http-bodies.js"; +import { formatCaughtError, log } from "./log.js"; +import { MemoryError, type Memory } from "./memory.js"; +import { tenantTag, type ShareSugar } from "./grant-tags.js"; /** * The tags a verified run already proves: the token is minted for exactly one diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..2f00c9f --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,19 @@ +{ + // Publish build: emits dist/ (js + d.ts) for the packed tarball. + // Source stays the dev surface (bun test, typecheck); dist is what + // the `default`/`types` export conditions resolve to once packed. + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "allowImportingTsExtensions": false, + "noEmit": false, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src"], + "exclude": ["src/**/*.test.ts", "dist", "node_modules"] +} From d53599b4a4505eca2168e97de9ab19afa65df9da Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Thu, 24 Sep 2026 09:06:13 -0700 Subject: [PATCH 2/4] chore(publish): dist-only exports + main/types, maps off (CL-8952) Drop intx-src conditions from all 5 exports subpaths (types+default only), add top-level main/types pointing at dist, and disable declarationMap/sourceMap in tsconfig.build.json (NodeNext kept). Also annotate src/log.ts logger with ReturnType: the unannotated inference is not portable under declaration emit (TS2742), which broke bun run build on this branch. --- package.json | 7 ++----- src/log.ts | 2 +- tsconfig.build.json | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 51fe6ee..327cb97 100644 --- a/package.json +++ b/package.json @@ -2,29 +2,26 @@ "name": "@corbits/memory", "version": "0.1.3", "description": "Mountable memory add/search/list SDK for Interchange hubs — includes resident distiller", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { - "intx-src": "./src/index.ts", "types": "./dist/index.d.ts", "default": "./dist/index.js" }, "./migrations": { - "intx-src": "./src/migrations.ts", "types": "./dist/migrations.d.ts", "default": "./dist/migrations.js" }, "./config": { - "intx-src": "./src/mount-config.ts", "types": "./dist/mount-config.d.ts", "default": "./dist/mount-config.js" }, "./sidecar-bundle": { - "intx-src": "./src/sidecar-bundle.ts", "types": "./dist/sidecar-bundle.d.ts", "default": "./dist/sidecar-bundle.js" }, "./distiller": { - "intx-src": "./src/distiller/index.ts", "types": "./dist/distiller/index.d.ts", "default": "./dist/distiller/index.js" } diff --git a/src/log.ts b/src/log.ts index cd2d9d1..19bd957 100644 --- a/src/log.ts +++ b/src/log.ts @@ -1,7 +1,7 @@ import { getLogger } from "@intx/log"; /** Category-bound logger for the memory engine (uses the host's sinks). */ -export const log = getLogger(["memory"]); +export const log: ReturnType = getLogger(["memory"]); // Some `@intx/log` sinks do not render a call's context object into the // terminal/aggregator output — only the message string is guaranteed to diff --git a/tsconfig.build.json b/tsconfig.build.json index 2f00c9f..1c10705 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -9,8 +9,8 @@ "allowImportingTsExtensions": false, "noEmit": false, "declaration": true, - "declarationMap": true, - "sourceMap": true, + "declarationMap": false, + "sourceMap": false, "outDir": "dist", "rootDir": "src" }, From daebc0f53cc05fa951872e1634801b026887ce3a Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Thu, 24 Sep 2026 09:23:19 -0700 Subject: [PATCH 3/4] chore(publish): composite false for canonical build config (CL-8952) --- tsconfig.build.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.build.json b/tsconfig.build.json index 1c10705..13b956e 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -12,7 +12,8 @@ "declarationMap": false, "sourceMap": false, "outDir": "dist", - "rootDir": "src" + "rootDir": "src", + "composite": false }, "include": ["src"], "exclude": ["src/**/*.test.ts", "dist", "node_modules"] From f10aa0fce6d7d6cf46a9b8b29a29f79867ee5916 Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Thu, 24 Sep 2026 20:18:56 -0700 Subject: [PATCH 4/4] chore(publish): bun-free prepack via npm run build (CL-8952) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 327cb97..d7bd863 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "db:setup": "bun run scripts/db-setup.ts", "typecheck": "tsc --noEmit", "build": "tsc -p tsconfig.build.json", - "prepack": "bun run build", + "prepack": "npm run build", "test": "bun test ./src", "test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text ./src" },