@dikolab/kbdb 0.4.0 → 0.4.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/README.md +13 -5
- package/dist/{chunk-BJPSPNGX.mjs → chunk-BJXEVALU.mjs} +115 -1
- package/dist/chunk-BJXEVALU.mjs.map +7 -0
- package/dist/cli.cjs +462 -79
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.mjs +356 -79
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +413 -53
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +230 -54
- package/dist/mod.cjs.map +4 -4
- package/dist/mod.mjs +229 -53
- package/dist/mod.mjs.map +4 -4
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +5 -0
- package/dist/src/shared/embedding/classes/tfidf-embedding-provider.class.d.ts +28 -0
- package/dist/src/shared/embedding/constants/tfidf-defaults.constant.d.ts +4 -0
- package/dist/src/shared/embedding/functions/create-embedding-provider.function.d.ts +5 -2
- package/dist/src/shared/embedding/index.d.ts +2 -0
- package/dist/src/shared/log/constants/log-colors.constant.d.ts +5 -0
- package/dist/src/shared/log/constants/log-defaults.constant.d.ts +3 -0
- package/dist/src/shared/log/constants/log-icons.constant.d.ts +3 -0
- package/dist/src/shared/log/functions/configure-log.function.d.ts +12 -0
- package/dist/src/shared/log/functions/log.function.d.ts +28 -0
- package/dist/src/shared/log/functions/parse-log-level.function.d.ts +10 -0
- package/dist/src/shared/log/functions/resolve-log-level.function.d.ts +12 -0
- package/dist/src/shared/log/functions/write-stderr.function.d.ts +10 -0
- package/dist/src/shared/log/index.d.ts +10 -0
- package/dist/src/shared/log/typings/log-config.interface.d.ts +7 -0
- package/dist/src/shared/log/typings/log-level.type.d.ts +7 -0
- package/dist/src/shared/log/typings/log-output.interface.d.ts +4 -0
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +7 -0
- package/dist/src/shared/worker-client/functions/retry-on-timeout.function.d.ts +1 -0
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +1 -0
- package/dist/src/shared/worker-daemon/functions/run-worker.function.d.ts +6 -1
- package/dist/src/shared/worker-daemon/typings/wasm-modules.interface.d.ts +5 -0
- package/dist/wasm/default-embedding/kbdb_default_embedding.d.ts +55 -0
- package/dist/wasm/default-embedding/kbdb_default_embedding.js +156 -0
- package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm +0 -0
- package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm.d.ts +12 -0
- package/dist/wasm/default-embedding/package.json +13 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/fs-migration/kbdb_fs_migration.d.ts +38 -0
- package/dist/wasm/fs-migration/kbdb_fs_migration.js +130 -0
- package/dist/wasm/fs-migration/kbdb_fs_migration_bg.wasm +0 -0
- package/dist/wasm/fs-migration/kbdb_fs_migration_bg.wasm.d.ts +9 -0
- package/dist/wasm/fs-migration/package.json +13 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/dist/worker.mjs +306 -54
- package/dist/worker.mjs.map +4 -4
- package/docs/details/agent-tooling.md +10 -0
- package/docs/details/cli.md +29 -13
- package/docs/details/knowledge-base.md +15 -8
- package/docs/details/mcp-server.md +16 -1
- package/docs/details/search-and-ranking.md +6 -2
- package/docs/goals/cli.md +33 -4
- package/docs/goals/content-parser.md +1 -1
- package/docs/goals/hybrid-search.md +71 -42
- package/docs/goals/mcp.md +3 -1
- package/docs/goals/overview.md +1 -1
- package/docs/goals/query-parser.md +1 -1
- package/docs/goals/semantic-dedup.md +7 -3
- package/docs/goals/worker-daemon.md +31 -20
- package/docs/modules/overview.md +43 -22
- package/docs/modules/rust/embedding/module.md +91 -0
- package/docs/modules/rust/overview.md +56 -21
- package/docs/modules/rust/query-parser/functions/module.md +7 -5
- package/docs/modules/rust/query-parser/functions/pipeline.md +6 -138
- package/docs/modules/rust/query-parser/module.md +16 -22
- package/docs/modules/rust/query-parser/types/module.md +5 -4
- package/docs/modules/rust/query-parser/types/token.md +5 -1
- package/docs/modules/rust/shared/content-parser/functions.md +1 -1
- package/docs/modules/rust/shared/memory/module.md +1 -1
- package/docs/modules/rust/shared/module.md +33 -5
- package/docs/modules/rust/shared/pipeline/functions.md +141 -0
- package/docs/modules/rust/shared/pipeline/module.md +62 -0
- package/docs/modules/rust/shared/pipeline/types.md +43 -0
- package/docs/modules/rust/shared/section/module.md +1 -1
- package/docs/modules/rust/shared/section/types.md +1 -1
- package/docs/modules/typescript/cli.md +4 -2
- package/docs/modules/typescript/kbdb-worker.md +20 -5
- package/docs/modules/typescript/overview.md +28 -6
- package/docs/modules/typescript/shared/cli/functions.md +15 -4
- package/docs/modules/typescript/shared/cli/typings.md +21 -0
- package/docs/modules/typescript/shared/embedding/functions.md +30 -3
- package/docs/modules/typescript/shared/embedding/module.md +10 -4
- package/docs/modules/typescript/shared/embedding/typings.md +7 -5
- package/docs/modules/typescript/shared/log/constants.md +82 -0
- package/docs/modules/typescript/shared/log/functions.md +131 -0
- package/docs/modules/typescript/shared/log/module.md +153 -0
- package/docs/modules/typescript/shared/log/typings.md +82 -0
- package/docs/modules/typescript/shared/module.md +22 -6
- package/docs/modules/typescript/shared/worker-daemon/functions.md +19 -6
- package/docs/modules/typescript/shared/worker-daemon/module.md +5 -2
- package/docs/modules/typescript/shared/worker-daemon/typings.md +13 -7
- package/docs/release-notes/0.4.1.md +149 -0
- package/package.json +2 -2
- package/dist/chunk-BJPSPNGX.mjs.map +0 -7
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# 0.4.1
|
|
2
|
+
|
|
3
|
+
*Patch release -- 2026-06-26*
|
|
4
|
+
|
|
5
|
+
Built-in TF-IDF embedding provider so hybrid search
|
|
6
|
+
works out of the box with zero configuration.
|
|
7
|
+
Structured logging across the entire TypeScript
|
|
8
|
+
layer with configurable verbosity. Daemon lifecycle
|
|
9
|
+
fixes for reliable shutdown on bare Linux TTY.
|
|
10
|
+
Non-interactive mode for scripts, CI, and automated
|
|
11
|
+
testing.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Engine
|
|
16
|
+
|
|
17
|
+
- **New WASM crate: `kbdb-default-embedding`** --
|
|
18
|
+
computes 256-dimensional feature-hashed sublinear
|
|
19
|
+
TF vectors using FNV-1a with the sign trick
|
|
20
|
+
(Weinberger et al., 2009). Pure computation, no
|
|
21
|
+
host imports.
|
|
22
|
+
- **Pipeline moved to `kbdb-shared`** -- the 9-stage
|
|
23
|
+
tokenization pipeline (NFC normalization, Unicode
|
|
24
|
+
segmentation, camelCase splitting, stop-word
|
|
25
|
+
removal, synonym expansion, Snowball stemming)
|
|
26
|
+
moved from `kbdb-query-parser` to `kbdb-shared`.
|
|
27
|
+
Both `kbdb-query-parser` and
|
|
28
|
+
`kbdb-default-embedding` now share a single source
|
|
29
|
+
of truth, keeping TF-IDF vectors token-consistent
|
|
30
|
+
with the lexical index.
|
|
31
|
+
|
|
32
|
+
## Daemon
|
|
33
|
+
|
|
34
|
+
- **Loads `default-embedding.wasm` at startup** --
|
|
35
|
+
the worker daemon loads the new standalone WASM
|
|
36
|
+
module alongside the existing `kb-worker.wasm`.
|
|
37
|
+
If the module is missing, the daemon gracefully
|
|
38
|
+
falls back to `NullEmbeddingProvider`.
|
|
39
|
+
- **Daemon lifecycle fixes** -- socket-level
|
|
40
|
+
connection tracking replaces the broken
|
|
41
|
+
server-level `close` handler, so the idle timer
|
|
42
|
+
fires correctly. `stop()` force-closes lingering
|
|
43
|
+
sockets. `worker stop` polls until the daemon
|
|
44
|
+
actually exits (5 s cap) instead of fire-and-forget
|
|
45
|
+
SIGTERM. `retryOnTimeout` kills a stuck daemon
|
|
46
|
+
before spawning a fresh one.
|
|
47
|
+
- **Accepts `--log-level`** -- the daemon parses an
|
|
48
|
+
optional `--log-level <level>` argument forwarded
|
|
49
|
+
by the spawner from the `KBDB_LOG_LEVEL` env var.
|
|
50
|
+
|
|
51
|
+
## CLI
|
|
52
|
+
|
|
53
|
+
- **`--non-interactive` flag** -- suppresses
|
|
54
|
+
interactive prompts and uses default values.
|
|
55
|
+
When set, data commands that find no `.kbdb`
|
|
56
|
+
directory return an error instead of prompting
|
|
57
|
+
to create one.
|
|
58
|
+
- **`KBDB_NON_INTERACTIVE` env var** -- same effect
|
|
59
|
+
as `--non-interactive`. Accepts `1` or `true`.
|
|
60
|
+
CLI flag takes priority.
|
|
61
|
+
- **Deprecation warnings fixed** -- `--init` and
|
|
62
|
+
`--migrate` deprecation messages now emit at all
|
|
63
|
+
log levels. Previously they fired before log
|
|
64
|
+
configuration and were suppressed.
|
|
65
|
+
|
|
66
|
+
## Embedding
|
|
67
|
+
|
|
68
|
+
- **`TfidfEmbeddingProvider`** -- new provider backed
|
|
69
|
+
by the `kbdb-default-embedding` WASM module.
|
|
70
|
+
Returns 256-dimensional L2-normalized vectors.
|
|
71
|
+
Model name: `tfidf-v1`.
|
|
72
|
+
- **New factory default** -- when no `[embedding]`
|
|
73
|
+
section is present in `worker.toml`, the factory
|
|
74
|
+
returns `TfidfEmbeddingProvider` instead of
|
|
75
|
+
`NullEmbeddingProvider`. Hybrid and vector search
|
|
76
|
+
work without configuration.
|
|
77
|
+
- **Explicit disable** -- setting `provider = "none"`
|
|
78
|
+
in `worker.toml` still returns
|
|
79
|
+
`NullEmbeddingProvider`, which rejects hybrid and
|
|
80
|
+
vector search with a structured error.
|
|
81
|
+
|
|
82
|
+
## Logging
|
|
83
|
+
|
|
84
|
+
- **New `log` module** (`src/shared/log/`) --
|
|
85
|
+
structured logging with four levels (`DEBUG`,
|
|
86
|
+
`INFO`, `WARNING`, `ERROR`), per-level Unicode
|
|
87
|
+
icons (▸ℹ⚠✖), per-level ANSI colors, and
|
|
88
|
+
configurable output targets. Default level is
|
|
89
|
+
`ERROR` (errors only).
|
|
90
|
+
- **CLI verbose flags** -- `-v` (warnings), `-vv`
|
|
91
|
+
(info), `-vvv` (debug). `-v` is reassigned from
|
|
92
|
+
`--version` to `--verbose`; `--version` has no
|
|
93
|
+
short alias.
|
|
94
|
+
- **`KBDB_LOG_LEVEL` env var** -- accepts `debug`,
|
|
95
|
+
`info`, `warning`, `error` (case-insensitive).
|
|
96
|
+
CLI flags take priority over the env var.
|
|
97
|
+
- **Comprehensive lifecycle logging** -- milestone
|
|
98
|
+
logging at key process points across CLI command
|
|
99
|
+
runners, MCP server lifecycle, worker daemon IPC
|
|
100
|
+
dispatch, embedding providers, worker client
|
|
101
|
+
discovery, and auto-capture. Full IPC lifecycle
|
|
102
|
+
coverage: daemon startup/shutdown, socket
|
|
103
|
+
connections, request dispatch, retry logic,
|
|
104
|
+
daemon discovery, write lock events, and idle
|
|
105
|
+
timer. Pre-throw error logging at all throw
|
|
106
|
+
sites. All `console.error` calls replaced with
|
|
107
|
+
`log()`.
|
|
108
|
+
|
|
109
|
+
## Documentation
|
|
110
|
+
|
|
111
|
+
- **Hybrid search docs aligned** -- updated
|
|
112
|
+
architecture, CLI/MCP surface, and design
|
|
113
|
+
constraint sections to reflect the new WASM crate
|
|
114
|
+
and `--algo` flag.
|
|
115
|
+
- **Worker daemon docs updated** -- WASM module
|
|
116
|
+
count, loading diagram, and distribution section
|
|
117
|
+
now describe four modules.
|
|
118
|
+
- **Factory docs corrected** -- `type:` references
|
|
119
|
+
fixed to `provider:`, factory mapping table
|
|
120
|
+
updated for the new default.
|
|
121
|
+
- **Log module docs added** -- module overview,
|
|
122
|
+
functions reference, typings reference, and
|
|
123
|
+
constants reference under
|
|
124
|
+
`docs/modules/typescript/shared/log/`.
|
|
125
|
+
- **CLI and worker daemon docs updated** -- verbose
|
|
126
|
+
flags (`-v`/`-vv`/`-vvv`), `--log-level` arg,
|
|
127
|
+
`KBDB_LOG_LEVEL` env var documented across CLI,
|
|
128
|
+
worker daemon, and shared module pages.
|
|
129
|
+
- **E2E test harness hardened** -- `run_kbdb`
|
|
130
|
+
wrapper wraps all `kbdb` calls in `timeout -k 5`
|
|
131
|
+
with SIGKILL fallback. Timeouts report as test
|
|
132
|
+
failures. GNU `coreutils` added to Docker image.
|
|
133
|
+
Non-interactive mode enabled for all E2E tests.
|
|
134
|
+
- **Completed todos and issues archived** -- three
|
|
135
|
+
todo docs (pipeline move, TF-IDF provider, default
|
|
136
|
+
wiring) and two issue docs (daemon lifecycle hang,
|
|
137
|
+
hybrid search errors) moved to `archived/`.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Upgrade
|
|
142
|
+
|
|
143
|
+
```sh
|
|
144
|
+
# Node.js
|
|
145
|
+
npm install -g @dikolab/kbdb@0.4.1
|
|
146
|
+
|
|
147
|
+
# Deno
|
|
148
|
+
deno install -Agf jsr:@dikolab/kbdb/cli
|
|
149
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dikolab/kbdb",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "CLI tool and MCP server for a file-based knowledge base database -- index documents, search with ranked results, and recall context for AI agents",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"lint:fix": "eslint --fix",
|
|
71
71
|
"test": "vitest --run",
|
|
72
72
|
"build": "node esbuild.config.js",
|
|
73
|
-
"build:wasm": "cd engine && wasm-pack build crates/query-parser --target no-modules --out-dir ../../../src/wasm/query-parser && wasm-pack build crates/fs-database --target no-modules --out-dir ../../../src/wasm/fs-database && wasm-pack build crates/kb-worker --target no-modules --out-dir ../../../src/wasm/kb-worker",
|
|
73
|
+
"build:wasm": "cd engine && wasm-pack build crates/query-parser --target no-modules --out-dir ../../../src/wasm/query-parser && wasm-pack build crates/fs-database --target no-modules --out-dir ../../../src/wasm/fs-database && wasm-pack build crates/default-embedding --target no-modules --out-dir ../../../src/wasm/default-embedding && wasm-pack build crates/kb-worker --target no-modules --out-dir ../../../src/wasm/kb-worker",
|
|
74
74
|
"build:all": "npm run build:wasm && npm run build"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/shared/runtime/functions/detect-runtime.ts", "../src/shared/runtime/functions/get-args.ts", "../src/shared/dir-resolver/functions/resolve-base-dir.function.ts", "../src/shared/dir-resolver/functions/join-path.function.ts", "../src/shared/dir-resolver/functions/resolve-worker-script.function.ts", "../src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts", "../src/shared/worker-daemon/constants/daemon-defaults.constant.ts", "../src/shared/worker-daemon/functions/parse-embedding-section.function.ts", "../src/shared/auto-capture/constants/auto-capture-defaults.constant.ts", "../src/shared/worker-daemon/functions/parse-auto-capture-section.function.ts", "../src/shared/worker-daemon/functions/parse-worker-toml.function.ts", "../src/shared/hash/functions/compute-sha256.ts", "../src/shared/platform/functions/get-ipc-path.function.ts", "../src/shared/platform/functions/get-tmpdir.function.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Runtime } from '../typings/runtime.ts';\n\n/**\n * Detects the current JavaScript runtime environment.\n *\n * Returns `'deno'` when the global `Deno` object is present,\n * otherwise returns `'node'`.\n */\nexport function detectRuntime(): Runtime {\n if (typeof globalThis !== 'undefined' && 'Deno' in globalThis) {\n return 'deno';\n }\n return 'node';\n}\n", "import { detectRuntime } from './detect-runtime.ts';\n\n/**\n * Returns the command-line arguments for the current runtime.\n *\n * In Deno, reads `Deno.args`; in Node.js, slices `process.argv`\n * past the interpreter and script entries.\n */\nexport function getArgs(): string[] {\n if (detectRuntime() === 'deno') {\n const g = globalThis as Record<string, unknown>;\n const deno = g['Deno'] as { args: string[] } | undefined;\n return deno?.args ?? [];\n }\n return process.argv.slice(2);\n}\n", "import { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { BaseDir } from '../typings/base-dir.interface.ts';\n\nexport function resolveScriptDir(\n entryUrl: string,\n entryDirname?: string,\n): string {\n if (entryDirname) return entryDirname;\n if (entryUrl.startsWith('file:'))\n return dirname(fileURLToPath(entryUrl));\n return dirname(entryUrl);\n}\n\nexport function resolveBaseDir(\n entryUrl: string,\n entryDirname?: string,\n): BaseDir {\n const scriptDir =\n typeof __dirname !== 'undefined'\n ? __dirname\n : resolveScriptDir(entryUrl, entryDirname);\n return { scriptDir, cwd: process.cwd() };\n}\n", "import { join } from 'node:path';\n\nexport function isRemoteUrl(path: string): boolean {\n return path.startsWith('http://') || path.startsWith('https://');\n}\n\nexport function joinPath(base: string, ...segments: string[]): string {\n if (isRemoteUrl(base)) {\n const trailing = base.endsWith('/') ? '' : '/';\n return base + trailing + segments.join('/');\n }\n return join(base, ...segments);\n}\n", "import { joinPath } from './join-path.function.ts';\n\nimport type { Runtime } from '../../runtime/typings/runtime.ts';\n\nexport function resolveWorkerScript(\n scriptDir: string,\n runtime: Runtime,\n): string {\n if (runtime === 'deno') {\n return joinPath(scriptDir, 'worker.ts');\n }\n return joinPath(scriptDir, 'kbdb-worker.cjs');\n}\n", "import { joinPath } from './join-path.function.ts';\n\nexport function resolveWasmDir(scriptDir: string): string {\n return joinPath(scriptDir, 'wasm');\n}\n", "/** Default maximum number of items held in daemon memory. */\nexport const DEFAULT_ITEM_LIMIT = 1000;\n\n/** Default maximum number of index entries held in daemon memory. */\nexport const DEFAULT_INDEX_LIMIT = 100;\n\n/**\n * Default idle timeout in milliseconds before the daemon shuts\n * down automatically (5 minutes).\n */\nexport const DEFAULT_TIMEOUT_MS = 300_000;\n\n/**\n * Default time-to-live in milliseconds for each cached item\n * (1 minute).\n */\nexport const DEFAULT_ITEM_TTL_MS = 60_000;\n\n/** Filename of the daemon configuration file inside `.kbdb/`. */\nexport const WORKER_TOML_FILENAME = 'worker.toml';\n\n/**\n * Database format version the daemon supports.\n *\n * Read from `catalog.toml` at startup. If the catalog version\n * differs, the daemon prints a structured error to stderr and\n * exits with code 1 before loading any WASM modules.\n */\nexport const DB_FORMAT_VERSION = 1;\n", "import type { EmbeddingConfig } from '../../embedding/typings/embedding-config.interface.ts';\n\n/**\n * Parses key-value pairs from a `[embedding]` TOML section into an\n * `EmbeddingConfig`.\n *\n * Recognises: `provider`, `model`, `endpoint`, `dimensions`.\n * Unknown keys are silently ignored. Returns `undefined` when the\n * `provider` key is absent from the supplied entries.\n *\n * @param entries - key-value pairs from inside the `[embedding]`\n * section\n */\nexport function parseEmbeddingSection(\n entries: ReadonlyMap<string, string>,\n): EmbeddingConfig | undefined {\n const provider = entries.get('provider') as\n | EmbeddingConfig['provider']\n | undefined;\n\n if (!provider) {\n return undefined;\n }\n\n const model = entries.get('model');\n const endpoint = entries.get('endpoint');\n const dimensionsRaw = entries.get('dimensions');\n const dimensions = dimensionsRaw\n ? parseInt(dimensionsRaw, 10) || undefined\n : undefined;\n\n return {\n provider,\n ...(model !== undefined ? { model } : {}),\n ...(endpoint !== undefined ? { endpoint } : {}),\n ...(dimensions !== undefined ? { dimensions } : {}),\n };\n}\n", "import type { AutoCaptureConfig } from '../typings/auto-capture-config.interface.ts';\n\n/**\n * Default configuration for the auto-capture feature.\n *\n * Auto-capture is disabled by default. Enable it in\n * `worker.toml` under `[auto_capture]`.\n */\nexport const AUTO_CAPTURE_DEFAULTS: AutoCaptureConfig = {\n enabled: false,\n triggerAfterToolCalls: 5,\n minIntervalMs: 60_000,\n maxCapturesPerSession: 10,\n dryRun: false,\n};\n", "import type { AutoCaptureConfig } from '../../auto-capture/typings/auto-capture-config.interface.ts';\nimport { AUTO_CAPTURE_DEFAULTS } from '../../auto-capture/constants/auto-capture-defaults.constant.ts';\n\n/**\n * Parses key-value pairs from an `[auto_capture]` TOML section\n * into an `AutoCaptureConfig`.\n *\n * Recognised keys: `enabled`, `trigger_after_tool_calls`,\n * `min_interval_ms`, `max_captures_per_session`, `dry_run`.\n * Unknown keys are silently ignored. Falls back to\n * `AUTO_CAPTURE_DEFAULTS` for any absent key.\n *\n * @param entries - key-value pairs from inside the\n * `[auto_capture]` section\n */\nexport function parseAutoCaptureSection(\n entries: ReadonlyMap<string, string>,\n): AutoCaptureConfig {\n const enabled = entries.has('enabled')\n ? entries.get('enabled') === 'true'\n : AUTO_CAPTURE_DEFAULTS.enabled;\n\n const dryRun = entries.has('dry_run')\n ? entries.get('dry_run') === 'true'\n : AUTO_CAPTURE_DEFAULTS.dryRun;\n\n const triggerRaw = entries.get('trigger_after_tool_calls');\n const triggerAfterToolCalls = triggerRaw\n ? parseInt(triggerRaw, 10) ||\n AUTO_CAPTURE_DEFAULTS.triggerAfterToolCalls\n : AUTO_CAPTURE_DEFAULTS.triggerAfterToolCalls;\n\n const intervalRaw = entries.get('min_interval_ms');\n const minIntervalMs = intervalRaw\n ? parseInt(intervalRaw, 10) || AUTO_CAPTURE_DEFAULTS.minIntervalMs\n : AUTO_CAPTURE_DEFAULTS.minIntervalMs;\n\n const capRaw = entries.get('max_captures_per_session');\n const maxCapturesPerSession = capRaw\n ? parseInt(capRaw, 10) ||\n AUTO_CAPTURE_DEFAULTS.maxCapturesPerSession\n : AUTO_CAPTURE_DEFAULTS.maxCapturesPerSession;\n\n return {\n enabled,\n triggerAfterToolCalls,\n minIntervalMs,\n maxCapturesPerSession,\n dryRun,\n };\n}\n", "import type { DaemonConfig } from '../typings/daemon-config.interface.ts';\nimport {\n DEFAULT_ITEM_LIMIT,\n DEFAULT_INDEX_LIMIT,\n DEFAULT_TIMEOUT_MS,\n DEFAULT_ITEM_TTL_MS,\n} from '../constants/daemon-defaults.constant.ts';\nimport { parseEmbeddingSection } from './parse-embedding-section.function.ts';\nimport { parseAutoCaptureSection } from './parse-auto-capture-section.function.ts';\n\ninterface RootAccum {\n itemLimit: number;\n indexLimit: number;\n timeoutMs: number;\n itemTtlMs: number;\n}\n\nfunction applyRootKey(\n acc: RootAccum,\n key: string,\n value: string,\n): void {\n switch (key) {\n case 'item_limit':\n acc.itemLimit = parseInt(value, 10) || DEFAULT_ITEM_LIMIT;\n break;\n case 'index_limit':\n acc.indexLimit = parseInt(value, 10) || DEFAULT_INDEX_LIMIT;\n break;\n case 'timeout_ms':\n acc.timeoutMs = parseInt(value, 10) || DEFAULT_TIMEOUT_MS;\n break;\n case 'item_ttl_ms':\n acc.itemTtlMs = parseInt(value, 10) || DEFAULT_ITEM_TTL_MS;\n break;\n default:\n break;\n }\n}\n\n/**\n * Parses a `worker.toml` file body into a partial `DaemonConfig`.\n *\n * Handles `[embedding]` sub-sections and root key-value pairs.\n * Unknown keys are silently ignored.\n *\n * @param text - raw content of `worker.toml`\n * @param contextPath - daemon context directory path\n */\nexport function parseWorkerToml(\n text: string,\n contextPath: string,\n): DaemonConfig {\n let section = '';\n const embeddingEntries = new Map<string, string>();\n const autoCaptureEntries = new Map<string, string>();\n const acc: RootAccum = {\n itemLimit: DEFAULT_ITEM_LIMIT,\n indexLimit: DEFAULT_INDEX_LIMIT,\n timeoutMs: DEFAULT_TIMEOUT_MS,\n itemTtlMs: DEFAULT_ITEM_TTL_MS,\n };\n\n for (const line of text.split('\\n')) {\n const trimmed = line.trim();\n if (trimmed === '[embedding]') {\n section = 'embedding';\n continue;\n }\n if (trimmed === '[auto_capture]') {\n section = 'auto_capture';\n continue;\n }\n if (trimmed.startsWith('[')) {\n section = '';\n continue;\n }\n if (trimmed.startsWith('#') || !trimmed.includes('=')) continue;\n const eqIdx = trimmed.indexOf('=');\n const key = trimmed.slice(0, eqIdx).trim();\n const value = trimmed.slice(eqIdx + 1).trim();\n if (section === 'embedding') {\n embeddingEntries.set(key, value);\n continue;\n }\n if (section === 'auto_capture') {\n autoCaptureEntries.set(key, value);\n continue;\n }\n applyRootKey(acc, key, value);\n }\n\n const embedding = parseEmbeddingSection(embeddingEntries);\n const autoCapture =\n autoCaptureEntries.size > 0\n ? parseAutoCaptureSection(autoCaptureEntries)\n : undefined;\n return {\n contextPath,\n ...acc,\n ...(embedding !== undefined ? { embedding } : {}),\n ...(autoCapture !== undefined ? { autoCapture } : {}),\n };\n}\n", "/**\n * Computes the SHA-256 hash of a UTF-8 string.\n *\n * Uses the Web Crypto API (`crypto.subtle`), which is available\n * in both Deno and Node.js >= 20 without additional imports.\n *\n * @param input - the string to hash\n * @returns lowercase hex-encoded SHA-256 digest (64 characters)\n */\nexport async function computeSha256(input: string): Promise<string> {\n const data = new TextEncoder().encode(input);\n const hash = await crypto.subtle.digest('SHA-256', data);\n const bytes = new Uint8Array(hash);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n", "import { join } from 'node:path';\nimport { getTmpdir } from './get-tmpdir.function.ts';\n\n/**\n * Returns the platform-appropriate IPC socket path for a given\n * context identifier.\n *\n * On Windows, returns a named pipe path (`\\\\.\\pipe\\kbdb-<ctx>`).\n * On POSIX systems, returns a Unix domain socket path under the\n * system temp directory (`<tmpdir>/kbdb-<ctx>.sock`).\n *\n * @param ctx - unique context identifier embedded in the path\n */\nexport function getIpcPath(ctx: string): string {\n if (process.platform === 'win32') {\n return `\\\\\\\\.\\\\pipe\\\\kbdb-${ctx}`;\n }\n return join(getTmpdir(), `kbdb-${ctx}.sock`);\n}\n", "import { tmpdir } from 'node:os';\n\n/**\n * Returns the operating system's default temporary directory path.\n */\nexport function getTmpdir(): string {\n return tmpdir();\n}\n"],
|
|
5
|
-
"mappings": ";AAQO,SAAS,gBAAyB;AACtC,MAAI,OAAO,eAAe,eAAe,UAAU,YAAY;AAC5D,WAAO;AAAA,EACV;AACA,SAAO;AACV;;;ACLO,SAAS,UAAoB;AACjC,MAAI,cAAc,MAAM,QAAQ;AAC7B,UAAM,IAAI;AACV,UAAM,OAAO,EAAE,MAAM;AACrB,WAAO,MAAM,QAAQ,CAAC;AAAA,EACzB;AACA,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC9B;;;ACfA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAIvB,SAAS,iBACb,UACA,cAC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