@vectorize-io/hindsight-all 0.1.0

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 ADDED
@@ -0,0 +1,80 @@
1
+ # @vectorize-io/hindsight-all
2
+
3
+ Node.js equivalent of the Python [`hindsight-all`](https://pypi.org/project/hindsight-all/) package — programmatic lifecycle manager for a local Hindsight daemon. Use this when you want to embed Hindsight in a Node application without hand-rolling subprocess management.
4
+
5
+ This package deliberately does **not** ship an HTTP client. Once the daemon is running, talk to it with [`@vectorize-io/hindsight-client`](https://www.npmjs.com/package/@vectorize-io/hindsight-client) against `server.getBaseUrl()`. The two packages compose — one owns the daemon process, the other owns the HTTP API surface.
6
+
7
+ ## Requirements
8
+
9
+ - **Node.js >= 22** — uses global `fetch` and `AbortSignal.timeout`.
10
+ - **`uv` / `uvx`** on `PATH` — used to download and run the underlying `hindsight-embed` daemon on first use. Install via <https://docs.astral.sh/uv/>.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install @vectorize-io/hindsight-all @vectorize-io/hindsight-client
16
+ ```
17
+
18
+ ## Example
19
+
20
+ ```ts
21
+ import { HindsightServer, consoleLogger } from '@vectorize-io/hindsight-all';
22
+ import { HindsightClient } from '@vectorize-io/hindsight-client';
23
+
24
+ const server = new HindsightServer({
25
+ profile: 'my-app',
26
+ port: 9077,
27
+ env: {
28
+ HINDSIGHT_API_LLM_PROVIDER: 'anthropic',
29
+ HINDSIGHT_API_LLM_API_KEY: process.env.ANTHROPIC_API_KEY,
30
+ HINDSIGHT_API_LLM_MODEL: 'claude-sonnet-4-20250514',
31
+ HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT: '0',
32
+ },
33
+ logger: consoleLogger,
34
+ });
35
+
36
+ await server.start();
37
+
38
+ const client = new HindsightClient({ baseUrl: server.getBaseUrl() });
39
+
40
+ await client.retain('user-123', 'User prefers dark mode and concise answers.', {
41
+ documentId: 'pref-2026-04-01',
42
+ });
43
+
44
+ const recall = await client.recall('user-123', 'what are the user preferences?');
45
+ console.log(recall.results);
46
+
47
+ await server.stop();
48
+ ```
49
+
50
+ For a remote Hindsight API, skip `HindsightServer` entirely and just point `HindsightClient` at the remote URL.
51
+
52
+ ## Open config — forward-compatible with new daemon flags
53
+
54
+ `HindsightServerOptions` is designed so every new environment variable or CLI flag in the underlying Hindsight daemon can be used without waiting for a wrapper release:
55
+
56
+ - **`env`** accepts an arbitrary `Record<string, string>`. Every entry is exported into the daemon process and written into the profile config via `--env KEY=VALUE`.
57
+ - **`extraProfileCreateArgs`** / **`extraDaemonStartArgs`** append raw args to the respective commands.
58
+
59
+ ## Development against a local checkout
60
+
61
+ If you're hacking on the Python `hindsight-embed` package in the same monorepo, point the server at the local path — it'll use `uv run --directory <path>` instead of `uvx`:
62
+
63
+ ```ts
64
+ new HindsightServer({
65
+ embedPackagePath: '/path/to/hindsight-embed',
66
+ // ...
67
+ });
68
+ ```
69
+
70
+ ## API surface
71
+
72
+ - `HindsightServer` — daemon lifecycle (`start`, `stop`, `checkHealth`, `getBaseUrl`, `getProfile`).
73
+ - `Logger` interface plus `silentLogger` (default) and `consoleLogger` helpers.
74
+ - `getEmbedCommand(opts)` — low-level helper that returns the `[cmd, ...args]` tuple used to invoke the underlying Python CLI.
75
+
76
+ For memory operations (retain, recall, reflect, bank management, stats) use [`@vectorize-io/hindsight-client`](https://www.npmjs.com/package/@vectorize-io/hindsight-client).
77
+
78
+ ## License
79
+
80
+ MIT
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Pluggable logger interface.
3
+ *
4
+ * This package does not own any logging infrastructure — consumers inject
5
+ * whatever they want (console, pino, openclaw's logger, a no-op). The default
6
+ * is silent so embedding this package never adds noise to an unrelated app.
7
+ */
8
+ interface Logger {
9
+ debug(msg: string): void;
10
+ info(msg: string): void;
11
+ warn(msg: string): void;
12
+ error(msg: string): void;
13
+ }
14
+ /** Logger that drops every call. Used when no logger is passed. */
15
+ declare const silentLogger: Logger;
16
+ /** Logger that writes to the standard console. Handy for CLIs and tests. */
17
+ declare const consoleLogger: Logger;
18
+
19
+ /**
20
+ * Options for {@link HindsightServer}.
21
+ *
22
+ * The server is intentionally thin and pass-through: anything configurable
23
+ * on the daemon side (env vars or CLI flags) can be set here without needing
24
+ * a new dedicated option. Use {@link env} for `HINDSIGHT_*` / `OPENAI_API_KEY` /
25
+ * custom provider settings, and the two `extra*` arrays to append raw CLI
26
+ * args to `profile create` or `daemon start`.
27
+ *
28
+ * For talking to the daemon after `start()`, use `@vectorize-io/hindsight-client`
29
+ * against `server.getBaseUrl()`. This package does not ship its own HTTP
30
+ * client.
31
+ */
32
+ interface HindsightServerOptions {
33
+ /** Profile name used for `--profile <name>` on every sub-command. Default: `"default"`. */
34
+ profile?: string;
35
+ /** TCP port the daemon listens on. Default: `8888`. */
36
+ port?: number;
37
+ /** Hostname the daemon binds to (for health checks). Default: `127.0.0.1`. */
38
+ host?: string;
39
+ /** Version of the underlying `hindsight-embed` PyPI package to run via `uvx`. Default: `"latest"`. */
40
+ embedVersion?: string;
41
+ /** Local path to a `hindsight-embed` checkout — takes precedence over `embedVersion`. */
42
+ embedPackagePath?: string;
43
+ /**
44
+ * Environment variables passed to the daemon process AND written into the
45
+ * profile via repeated `--env KEY=VALUE` flags. This is the preferred way
46
+ * to surface any `HINDSIGHT_API_*` / `HINDSIGHT_EMBED_*` setting — adding a
47
+ * new daemon env var never requires a wrapper update.
48
+ *
49
+ * Values of `undefined` are dropped (so you can spread conditionally).
50
+ */
51
+ env?: Record<string, string | undefined>;
52
+ /** Extra args appended verbatim to `hindsight-embed profile create <name> --merge ...`. */
53
+ extraProfileCreateArgs?: string[];
54
+ /** Extra args appended verbatim to `hindsight-embed daemon --profile <name> start ...`. */
55
+ extraDaemonStartArgs?: string[];
56
+ /**
57
+ * On macOS, automatically set
58
+ * `HINDSIGHT_API_EMBEDDINGS_LOCAL_FORCE_CPU=1` and
59
+ * `HINDSIGHT_API_RERANKER_LOCAL_FORCE_CPU=1` to avoid Metal/MPS crashes in
60
+ * daemon mode. Default: `true` on `darwin`, ignored elsewhere. Any value set
61
+ * explicitly in {@link env} wins over the auto-applied value.
62
+ */
63
+ platformCpuWorkaround?: boolean;
64
+ /** Max time (ms) to wait for `/health` to return 200. Default: `30_000`. */
65
+ readyTimeoutMs?: number;
66
+ /** Polling interval (ms) while waiting for `/health`. Default: `1_000`. */
67
+ readyPollIntervalMs?: number;
68
+ /** Optional pluggable logger. Default: silent. */
69
+ logger?: Logger;
70
+ }
71
+
72
+ /**
73
+ * Manages the lifecycle of a local Hindsight daemon from a Node.js process.
74
+ *
75
+ * On {@link start}, this class:
76
+ * 1. Resolves the `hindsight-embed` command (via `uvx` or a local `uv run`).
77
+ * 2. Runs `profile create <name> --merge --port <port> [--env K=V ...]`
78
+ * with every entry in {@link HindsightServerOptions.env} forwarded as
79
+ * an `--env` flag.
80
+ * 3. Runs `daemon --profile <name> start` and waits for the start command
81
+ * to exit.
82
+ * 4. Polls `http://host:port/health` until it returns `200` or the
83
+ * `readyTimeoutMs` budget is exhausted.
84
+ *
85
+ * On {@link stop}, it runs `daemon --profile <name> stop` and returns once
86
+ * the command exits (or after a short grace period).
87
+ *
88
+ * This is the Node.js equivalent of the Python `hindsight-all` package's
89
+ * `HindsightServer`: a thin programmatic lifecycle wrapper around the
90
+ * Hindsight daemon. It does NOT ship an HTTP client — once `start()`
91
+ * resolves, use `@vectorize-io/hindsight-client` against `getBaseUrl()` for
92
+ * retain / recall / reflect.
93
+ *
94
+ * The class is deliberately transparent about the daemon: new CLI flags or
95
+ * environment variables never require a code change here — callers can pass
96
+ * them via `env`, `extraProfileCreateArgs`, or `extraDaemonStartArgs`.
97
+ */
98
+ declare class HindsightServer {
99
+ private readonly profile;
100
+ private readonly port;
101
+ private readonly host;
102
+ private readonly baseUrl;
103
+ private readonly embedVersion;
104
+ private readonly embedPackagePath;
105
+ private readonly userEnv;
106
+ private readonly extraProfileCreateArgs;
107
+ private readonly extraDaemonStartArgs;
108
+ private readonly platformCpuWorkaround;
109
+ private readonly readyTimeoutMs;
110
+ private readonly readyPollIntervalMs;
111
+ private readonly logger;
112
+ constructor(opts?: HindsightServerOptions);
113
+ /** The base URL the daemon listens on (`http://host:port`). */
114
+ getBaseUrl(): string;
115
+ /** The profile name this server operates on. */
116
+ getProfile(): string;
117
+ /**
118
+ * Ensure the daemon is configured and running. Idempotent — the underlying
119
+ * `profile create --merge` and `daemon start` commands tolerate re-runs.
120
+ */
121
+ start(): Promise<void>;
122
+ /** Stop the daemon. Never throws — logs and resolves even on failure. */
123
+ stop(): Promise<void>;
124
+ /** Probe `/health` once with a short timeout. */
125
+ checkHealth(): Promise<boolean>;
126
+ /**
127
+ * Merge the process env, the caller-supplied `env`, and (on macOS) the
128
+ * embeddings CPU workaround. Caller-supplied values always win over the
129
+ * workaround; undefined values are dropped.
130
+ */
131
+ private buildEnv;
132
+ /**
133
+ * Run `profile create <name> --merge --port <port> [--env K=V ...]`.
134
+ * Every entry in the merged env that was passed via {@link userEnv} (or
135
+ * auto-applied by the CPU workaround) is forwarded as `--env`.
136
+ */
137
+ private configureProfile;
138
+ /** Collect only the env vars that should be written into the profile file. */
139
+ private collectProfileEnv;
140
+ private startDaemon;
141
+ /**
142
+ * Spawn `cmd` with `args`, pipe its output through the logger, and resolve
143
+ * once it exits with code 0. Rejects on non-zero exit or spawn error.
144
+ */
145
+ private runCommand;
146
+ /** Stream a spawned child's stdout/stderr through the logger without blocking. */
147
+ private pipeOutput;
148
+ /** Poll `/health` until it succeeds or `readyTimeoutMs` elapses. */
149
+ private waitForReady;
150
+ }
151
+
152
+ /**
153
+ * Resolve the command that invokes the `hindsight-embed` Python CLI.
154
+ *
155
+ * - If `embedPackagePath` is set, runs the package from a local checkout via
156
+ * `uv run --directory <path> hindsight-embed`. Used for in-repo development.
157
+ * - Otherwise runs it via `uvx hindsight-embed@<version>` so no global install
158
+ * is required.
159
+ *
160
+ * Returns the argv as `[command, ...baseArgs]` suitable for `spawn()` /
161
+ * `execFile()` (never shell-interpolated).
162
+ */
163
+ interface EmbedCommandOptions {
164
+ /** Version spec passed to uvx (e.g. "latest", "0.5.0"). Default: "latest". */
165
+ embedVersion?: string;
166
+ /** Local checkout path. When set, overrides `embedVersion` and uses `uv run`. */
167
+ embedPackagePath?: string;
168
+ }
169
+ declare function getEmbedCommand(opts?: EmbedCommandOptions): string[];
170
+
171
+ export { type EmbedCommandOptions, HindsightServer, type HindsightServerOptions, type Logger, consoleLogger, getEmbedCommand, silentLogger };
package/dist/index.js ADDED
@@ -0,0 +1,284 @@
1
+ // src/server.ts
2
+ import { spawn } from "child_process";
3
+
4
+ // src/command.ts
5
+ function getEmbedCommand(opts = {}) {
6
+ if (opts.embedPackagePath) {
7
+ return ["uv", "run", "--directory", opts.embedPackagePath, "hindsight-embed"];
8
+ }
9
+ const version = opts.embedVersion && opts.embedVersion.length > 0 ? opts.embedVersion : "latest";
10
+ return ["uvx", `hindsight-embed@${version}`];
11
+ }
12
+
13
+ // src/logger.ts
14
+ var silentLogger = {
15
+ debug: () => {
16
+ },
17
+ info: () => {
18
+ },
19
+ warn: () => {
20
+ },
21
+ error: () => {
22
+ }
23
+ };
24
+ var consoleLogger = {
25
+ debug: (msg) => console.debug(msg),
26
+ info: (msg) => console.log(msg),
27
+ warn: (msg) => console.warn(msg),
28
+ error: (msg) => console.error(msg)
29
+ };
30
+
31
+ // src/server.ts
32
+ var DEFAULT_PORT = 8888;
33
+ var DEFAULT_HOST = "127.0.0.1";
34
+ var DEFAULT_PROFILE = "default";
35
+ var DEFAULT_READY_TIMEOUT_MS = 3e4;
36
+ var DEFAULT_READY_POLL_INTERVAL_MS = 1e3;
37
+ var HindsightServer = class {
38
+ profile;
39
+ port;
40
+ host;
41
+ baseUrl;
42
+ embedVersion;
43
+ embedPackagePath;
44
+ userEnv;
45
+ extraProfileCreateArgs;
46
+ extraDaemonStartArgs;
47
+ platformCpuWorkaround;
48
+ readyTimeoutMs;
49
+ readyPollIntervalMs;
50
+ logger;
51
+ constructor(opts = {}) {
52
+ this.profile = opts.profile ?? DEFAULT_PROFILE;
53
+ this.port = opts.port ?? DEFAULT_PORT;
54
+ this.host = opts.host ?? DEFAULT_HOST;
55
+ this.baseUrl = `http://${this.host}:${this.port}`;
56
+ this.embedVersion = opts.embedVersion;
57
+ this.embedPackagePath = opts.embedPackagePath;
58
+ this.userEnv = opts.env ?? {};
59
+ this.extraProfileCreateArgs = opts.extraProfileCreateArgs ?? [];
60
+ this.extraDaemonStartArgs = opts.extraDaemonStartArgs ?? [];
61
+ this.platformCpuWorkaround = opts.platformCpuWorkaround ?? process.platform === "darwin";
62
+ this.readyTimeoutMs = opts.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS;
63
+ this.readyPollIntervalMs = opts.readyPollIntervalMs ?? DEFAULT_READY_POLL_INTERVAL_MS;
64
+ this.logger = opts.logger ?? silentLogger;
65
+ }
66
+ /** The base URL the daemon listens on (`http://host:port`). */
67
+ getBaseUrl() {
68
+ return this.baseUrl;
69
+ }
70
+ /** The profile name this server operates on. */
71
+ getProfile() {
72
+ return this.profile;
73
+ }
74
+ /**
75
+ * Ensure the daemon is configured and running. Idempotent — the underlying
76
+ * `profile create --merge` and `daemon start` commands tolerate re-runs.
77
+ */
78
+ async start() {
79
+ this.logger.info(`[hindsight] starting daemon for profile "${this.profile}"`);
80
+ const env = this.buildEnv();
81
+ await this.configureProfile(env);
82
+ await this.startDaemon(env);
83
+ await this.waitForReady();
84
+ this.logger.info(`[hindsight] daemon ready at ${this.baseUrl}`);
85
+ }
86
+ /** Stop the daemon. Never throws — logs and resolves even on failure. */
87
+ async stop() {
88
+ this.logger.info(`[hindsight] stopping daemon for profile "${this.profile}"`);
89
+ const [cmd, ...baseArgs] = getEmbedCommand({
90
+ embedVersion: this.embedVersion,
91
+ embedPackagePath: this.embedPackagePath
92
+ });
93
+ const args = [...baseArgs, "daemon", "--profile", this.profile, "stop"];
94
+ const child = spawn(cmd, args, { stdio: "pipe" });
95
+ this.pipeOutput(child, "daemon.stop");
96
+ await new Promise((resolve) => {
97
+ const timeout = setTimeout(() => {
98
+ this.logger.warn(`[hindsight] daemon stop timed out after 5s`);
99
+ resolve();
100
+ }, 5e3);
101
+ child.on("exit", () => {
102
+ clearTimeout(timeout);
103
+ this.logger.info(`[hindsight] daemon stopped`);
104
+ resolve();
105
+ });
106
+ child.on("error", (err) => {
107
+ clearTimeout(timeout);
108
+ this.logger.warn(`[hindsight] error stopping daemon: ${err.message}`);
109
+ resolve();
110
+ });
111
+ });
112
+ }
113
+ /** Probe `/health` once with a short timeout. */
114
+ async checkHealth() {
115
+ try {
116
+ const res = await fetch(`${this.baseUrl}/health`, {
117
+ signal: AbortSignal.timeout(2e3)
118
+ });
119
+ return res.ok;
120
+ } catch {
121
+ return false;
122
+ }
123
+ }
124
+ // -------------------------------------------------------------------------
125
+ // Internal
126
+ // -------------------------------------------------------------------------
127
+ /**
128
+ * Merge the process env, the caller-supplied `env`, and (on macOS) the
129
+ * embeddings CPU workaround. Caller-supplied values always win over the
130
+ * workaround; undefined values are dropped.
131
+ */
132
+ buildEnv() {
133
+ const merged = { ...process.env };
134
+ if (this.platformCpuWorkaround && process.platform === "darwin") {
135
+ merged["HINDSIGHT_API_EMBEDDINGS_LOCAL_FORCE_CPU"] = "1";
136
+ merged["HINDSIGHT_API_RERANKER_LOCAL_FORCE_CPU"] = "1";
137
+ }
138
+ for (const [key, value] of Object.entries(this.userEnv)) {
139
+ if (value !== void 0) {
140
+ merged[key] = value;
141
+ }
142
+ }
143
+ return merged;
144
+ }
145
+ /**
146
+ * Run `profile create <name> --merge --port <port> [--env K=V ...]`.
147
+ * Every entry in the merged env that was passed via {@link userEnv} (or
148
+ * auto-applied by the CPU workaround) is forwarded as `--env`.
149
+ */
150
+ async configureProfile(env) {
151
+ this.logger.info(`[hindsight] configuring profile "${this.profile}"`);
152
+ const [cmd, ...baseArgs] = getEmbedCommand({
153
+ embedVersion: this.embedVersion,
154
+ embedPackagePath: this.embedPackagePath
155
+ });
156
+ const createArgs = [
157
+ ...baseArgs,
158
+ "profile",
159
+ "create",
160
+ this.profile,
161
+ "--merge",
162
+ "--port",
163
+ String(this.port)
164
+ ];
165
+ const envForProfile = this.collectProfileEnv(env);
166
+ for (const [key, value] of Object.entries(envForProfile)) {
167
+ createArgs.push("--env", `${key}=${value}`);
168
+ }
169
+ createArgs.push(...this.extraProfileCreateArgs);
170
+ await this.runCommand(cmd, createArgs, env, "profile.create");
171
+ }
172
+ /** Collect only the env vars that should be written into the profile file. */
173
+ collectProfileEnv(env) {
174
+ const out = {};
175
+ for (const [key, value] of Object.entries(this.userEnv)) {
176
+ if (value !== void 0) {
177
+ out[key] = value;
178
+ }
179
+ }
180
+ if (this.platformCpuWorkaround && process.platform === "darwin") {
181
+ const cpuKeys = [
182
+ "HINDSIGHT_API_EMBEDDINGS_LOCAL_FORCE_CPU",
183
+ "HINDSIGHT_API_RERANKER_LOCAL_FORCE_CPU"
184
+ ];
185
+ for (const key of cpuKeys) {
186
+ if (!(key in out) && env[key] !== void 0) {
187
+ out[key] = env[key];
188
+ }
189
+ }
190
+ }
191
+ return out;
192
+ }
193
+ async startDaemon(env) {
194
+ const [cmd, ...baseArgs] = getEmbedCommand({
195
+ embedVersion: this.embedVersion,
196
+ embedPackagePath: this.embedPackagePath
197
+ });
198
+ const args = [
199
+ ...baseArgs,
200
+ "daemon",
201
+ "--profile",
202
+ this.profile,
203
+ "start",
204
+ ...this.extraDaemonStartArgs
205
+ ];
206
+ await this.runCommand(cmd, args, env, "daemon.start");
207
+ }
208
+ /**
209
+ * Spawn `cmd` with `args`, pipe its output through the logger, and resolve
210
+ * once it exits with code 0. Rejects on non-zero exit or spawn error.
211
+ */
212
+ async runCommand(cmd, args, env, label) {
213
+ const child = spawn(cmd, args, { stdio: "pipe", env });
214
+ let output = "";
215
+ child.stdout?.on("data", (data) => {
216
+ const text = data.toString();
217
+ output += text;
218
+ for (const line of text.trimEnd().split("\n")) {
219
+ if (line) this.logger.info(`[hindsight:${label}] ${line}`);
220
+ }
221
+ });
222
+ child.stderr?.on("data", (data) => {
223
+ const text = data.toString();
224
+ output += text;
225
+ for (const line of text.trimEnd().split("\n")) {
226
+ if (line) this.logger.warn(`[hindsight:${label}] ${line}`);
227
+ }
228
+ });
229
+ await new Promise((resolve, reject) => {
230
+ child.on("exit", (code) => {
231
+ if (code === 0) {
232
+ resolve();
233
+ } else {
234
+ reject(new Error(`${label} failed with code ${code}: ${output.trim()}`));
235
+ }
236
+ });
237
+ child.on("error", (err) => {
238
+ reject(new Error(`${label} failed to spawn: ${err.message}`, { cause: err }));
239
+ });
240
+ });
241
+ }
242
+ /** Stream a spawned child's stdout/stderr through the logger without blocking. */
243
+ pipeOutput(child, label) {
244
+ child.stdout?.on("data", (data) => {
245
+ for (const line of data.toString().trimEnd().split("\n")) {
246
+ if (line) this.logger.info(`[hindsight:${label}] ${line}`);
247
+ }
248
+ });
249
+ child.stderr?.on("data", (data) => {
250
+ for (const line of data.toString().trimEnd().split("\n")) {
251
+ if (line) this.logger.warn(`[hindsight:${label}] ${line}`);
252
+ }
253
+ });
254
+ }
255
+ /** Poll `/health` until it succeeds or `readyTimeoutMs` elapses. */
256
+ async waitForReady() {
257
+ const deadline = Date.now() + this.readyTimeoutMs;
258
+ let attempt = 0;
259
+ while (Date.now() < deadline) {
260
+ attempt++;
261
+ try {
262
+ const res = await fetch(`${this.baseUrl}/health`, {
263
+ signal: AbortSignal.timeout(this.readyPollIntervalMs)
264
+ });
265
+ if (res.ok) {
266
+ this.logger.debug(`[hindsight] health check passed (attempt ${attempt})`);
267
+ return;
268
+ }
269
+ } catch {
270
+ }
271
+ await new Promise((resolve) => setTimeout(resolve, this.readyPollIntervalMs));
272
+ }
273
+ throw new Error(
274
+ `Hindsight daemon did not become ready within ${this.readyTimeoutMs}ms at ${this.baseUrl}`
275
+ );
276
+ }
277
+ };
278
+ export {
279
+ HindsightServer,
280
+ consoleLogger,
281
+ getEmbedCommand,
282
+ silentLogger
283
+ };
284
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server.ts","../src/command.ts","../src/logger.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport { getEmbedCommand } from './command.js';\nimport { silentLogger } from './logger.js';\nimport type { Logger } from './logger.js';\nimport type { HindsightServerOptions } from './types.js';\n\nconst DEFAULT_PORT = 8888;\nconst DEFAULT_HOST = '127.0.0.1';\nconst DEFAULT_PROFILE = 'default';\nconst DEFAULT_READY_TIMEOUT_MS = 30_000;\nconst DEFAULT_READY_POLL_INTERVAL_MS = 1_000;\n\n/**\n * Manages the lifecycle of a local Hindsight daemon from a Node.js process.\n *\n * On {@link start}, this class:\n * 1. Resolves the `hindsight-embed` command (via `uvx` or a local `uv run`).\n * 2. Runs `profile create <name> --merge --port <port> [--env K=V ...]`\n * with every entry in {@link HindsightServerOptions.env} forwarded as\n * an `--env` flag.\n * 3. Runs `daemon --profile <name> start` and waits for the start command\n * to exit.\n * 4. Polls `http://host:port/health` until it returns `200` or the\n * `readyTimeoutMs` budget is exhausted.\n *\n * On {@link stop}, it runs `daemon --profile <name> stop` and returns once\n * the command exits (or after a short grace period).\n *\n * This is the Node.js equivalent of the Python `hindsight-all` package's\n * `HindsightServer`: a thin programmatic lifecycle wrapper around the\n * Hindsight daemon. It does NOT ship an HTTP client — once `start()`\n * resolves, use `@vectorize-io/hindsight-client` against `getBaseUrl()` for\n * retain / recall / reflect.\n *\n * The class is deliberately transparent about the daemon: new CLI flags or\n * environment variables never require a code change here — callers can pass\n * them via `env`, `extraProfileCreateArgs`, or `extraDaemonStartArgs`.\n */\nexport class HindsightServer {\n private readonly profile: string;\n private readonly port: number;\n private readonly host: string;\n private readonly baseUrl: string;\n private readonly embedVersion: string | undefined;\n private readonly embedPackagePath: string | undefined;\n private readonly userEnv: Record<string, string | undefined>;\n private readonly extraProfileCreateArgs: string[];\n private readonly extraDaemonStartArgs: string[];\n private readonly platformCpuWorkaround: boolean;\n private readonly readyTimeoutMs: number;\n private readonly readyPollIntervalMs: number;\n private readonly logger: Logger;\n\n constructor(opts: HindsightServerOptions = {}) {\n this.profile = opts.profile ?? DEFAULT_PROFILE;\n this.port = opts.port ?? DEFAULT_PORT;\n this.host = opts.host ?? DEFAULT_HOST;\n this.baseUrl = `http://${this.host}:${this.port}`;\n this.embedVersion = opts.embedVersion;\n this.embedPackagePath = opts.embedPackagePath;\n this.userEnv = opts.env ?? {};\n this.extraProfileCreateArgs = opts.extraProfileCreateArgs ?? [];\n this.extraDaemonStartArgs = opts.extraDaemonStartArgs ?? [];\n this.platformCpuWorkaround = opts.platformCpuWorkaround ?? (process.platform === 'darwin');\n this.readyTimeoutMs = opts.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS;\n this.readyPollIntervalMs = opts.readyPollIntervalMs ?? DEFAULT_READY_POLL_INTERVAL_MS;\n this.logger = opts.logger ?? silentLogger;\n }\n\n /** The base URL the daemon listens on (`http://host:port`). */\n getBaseUrl(): string {\n return this.baseUrl;\n }\n\n /** The profile name this server operates on. */\n getProfile(): string {\n return this.profile;\n }\n\n /**\n * Ensure the daemon is configured and running. Idempotent — the underlying\n * `profile create --merge` and `daemon start` commands tolerate re-runs.\n */\n async start(): Promise<void> {\n this.logger.info(`[hindsight] starting daemon for profile \"${this.profile}\"`);\n\n const env = this.buildEnv();\n await this.configureProfile(env);\n await this.startDaemon(env);\n await this.waitForReady();\n\n this.logger.info(`[hindsight] daemon ready at ${this.baseUrl}`);\n }\n\n /** Stop the daemon. Never throws — logs and resolves even on failure. */\n async stop(): Promise<void> {\n this.logger.info(`[hindsight] stopping daemon for profile \"${this.profile}\"`);\n\n const [cmd, ...baseArgs] = getEmbedCommand({\n embedVersion: this.embedVersion,\n embedPackagePath: this.embedPackagePath,\n });\n const args = [...baseArgs, 'daemon', '--profile', this.profile, 'stop'];\n\n const child = spawn(cmd, args, { stdio: 'pipe' });\n this.pipeOutput(child, 'daemon.stop');\n\n await new Promise<void>((resolve) => {\n const timeout = setTimeout(() => {\n this.logger.warn(`[hindsight] daemon stop timed out after 5s`);\n resolve();\n }, 5_000);\n child.on('exit', () => {\n clearTimeout(timeout);\n this.logger.info(`[hindsight] daemon stopped`);\n resolve();\n });\n child.on('error', (err) => {\n clearTimeout(timeout);\n this.logger.warn(`[hindsight] error stopping daemon: ${err.message}`);\n resolve();\n });\n });\n }\n\n /** Probe `/health` once with a short timeout. */\n async checkHealth(): Promise<boolean> {\n try {\n const res = await fetch(`${this.baseUrl}/health`, {\n signal: AbortSignal.timeout(2_000),\n });\n return res.ok;\n } catch {\n return false;\n }\n }\n\n // -------------------------------------------------------------------------\n // Internal\n // -------------------------------------------------------------------------\n\n /**\n * Merge the process env, the caller-supplied `env`, and (on macOS) the\n * embeddings CPU workaround. Caller-supplied values always win over the\n * workaround; undefined values are dropped.\n */\n private buildEnv(): NodeJS.ProcessEnv {\n const merged: NodeJS.ProcessEnv = { ...process.env };\n\n if (this.platformCpuWorkaround && process.platform === 'darwin') {\n merged['HINDSIGHT_API_EMBEDDINGS_LOCAL_FORCE_CPU'] = '1';\n merged['HINDSIGHT_API_RERANKER_LOCAL_FORCE_CPU'] = '1';\n }\n\n for (const [key, value] of Object.entries(this.userEnv)) {\n if (value !== undefined) {\n merged[key] = value;\n }\n }\n\n return merged;\n }\n\n /**\n * Run `profile create <name> --merge --port <port> [--env K=V ...]`.\n * Every entry in the merged env that was passed via {@link userEnv} (or\n * auto-applied by the CPU workaround) is forwarded as `--env`.\n */\n private async configureProfile(env: NodeJS.ProcessEnv): Promise<void> {\n this.logger.info(`[hindsight] configuring profile \"${this.profile}\"`);\n\n const [cmd, ...baseArgs] = getEmbedCommand({\n embedVersion: this.embedVersion,\n embedPackagePath: this.embedPackagePath,\n });\n const createArgs = [\n ...baseArgs,\n 'profile',\n 'create',\n this.profile,\n '--merge',\n '--port',\n String(this.port),\n ];\n\n // Forward every env var that the caller intended for the daemon as --env.\n // We only forward keys the caller explicitly set (userEnv) plus the CPU\n // workaround values — not the entire process.env, to avoid leaking random\n // host state into profile config.\n const envForProfile = this.collectProfileEnv(env);\n for (const [key, value] of Object.entries(envForProfile)) {\n createArgs.push('--env', `${key}=${value}`);\n }\n\n createArgs.push(...this.extraProfileCreateArgs);\n\n await this.runCommand(cmd, createArgs, env, 'profile.create');\n }\n\n /** Collect only the env vars that should be written into the profile file. */\n private collectProfileEnv(env: NodeJS.ProcessEnv): Record<string, string> {\n const out: Record<string, string> = {};\n\n // 1. User-supplied env — always forwarded.\n for (const [key, value] of Object.entries(this.userEnv)) {\n if (value !== undefined) {\n out[key] = value;\n }\n }\n\n // 2. CPU workaround — only if auto-applied and not already overridden.\n if (this.platformCpuWorkaround && process.platform === 'darwin') {\n const cpuKeys = [\n 'HINDSIGHT_API_EMBEDDINGS_LOCAL_FORCE_CPU',\n 'HINDSIGHT_API_RERANKER_LOCAL_FORCE_CPU',\n ];\n for (const key of cpuKeys) {\n if (!(key in out) && env[key] !== undefined) {\n out[key] = env[key] as string;\n }\n }\n }\n\n return out;\n }\n\n private async startDaemon(env: NodeJS.ProcessEnv): Promise<void> {\n const [cmd, ...baseArgs] = getEmbedCommand({\n embedVersion: this.embedVersion,\n embedPackagePath: this.embedPackagePath,\n });\n const args = [\n ...baseArgs,\n 'daemon',\n '--profile',\n this.profile,\n 'start',\n ...this.extraDaemonStartArgs,\n ];\n\n await this.runCommand(cmd, args, env, 'daemon.start');\n }\n\n /**\n * Spawn `cmd` with `args`, pipe its output through the logger, and resolve\n * once it exits with code 0. Rejects on non-zero exit or spawn error.\n */\n private async runCommand(\n cmd: string,\n args: string[],\n env: NodeJS.ProcessEnv,\n label: string,\n ): Promise<void> {\n const child = spawn(cmd, args, { stdio: 'pipe', env });\n let output = '';\n child.stdout?.on('data', (data: Buffer) => {\n const text = data.toString();\n output += text;\n for (const line of text.trimEnd().split('\\n')) {\n if (line) this.logger.info(`[hindsight:${label}] ${line}`);\n }\n });\n child.stderr?.on('data', (data: Buffer) => {\n const text = data.toString();\n output += text;\n for (const line of text.trimEnd().split('\\n')) {\n if (line) this.logger.warn(`[hindsight:${label}] ${line}`);\n }\n });\n\n await new Promise<void>((resolve, reject) => {\n child.on('exit', (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(`${label} failed with code ${code}: ${output.trim()}`));\n }\n });\n child.on('error', (err) => {\n reject(new Error(`${label} failed to spawn: ${err.message}`, { cause: err }));\n });\n });\n }\n\n /** Stream a spawned child's stdout/stderr through the logger without blocking. */\n private pipeOutput(child: ReturnType<typeof spawn>, label: string): void {\n child.stdout?.on('data', (data: Buffer) => {\n for (const line of data.toString().trimEnd().split('\\n')) {\n if (line) this.logger.info(`[hindsight:${label}] ${line}`);\n }\n });\n child.stderr?.on('data', (data: Buffer) => {\n for (const line of data.toString().trimEnd().split('\\n')) {\n if (line) this.logger.warn(`[hindsight:${label}] ${line}`);\n }\n });\n }\n\n /** Poll `/health` until it succeeds or `readyTimeoutMs` elapses. */\n private async waitForReady(): Promise<void> {\n const deadline = Date.now() + this.readyTimeoutMs;\n let attempt = 0;\n while (Date.now() < deadline) {\n attempt++;\n try {\n const res = await fetch(`${this.baseUrl}/health`, {\n signal: AbortSignal.timeout(this.readyPollIntervalMs),\n });\n if (res.ok) {\n this.logger.debug(`[hindsight] health check passed (attempt ${attempt})`);\n return;\n }\n } catch {\n // expected while the daemon is still booting\n }\n await new Promise((resolve) => setTimeout(resolve, this.readyPollIntervalMs));\n }\n throw new Error(\n `Hindsight daemon did not become ready within ${this.readyTimeoutMs}ms at ${this.baseUrl}`,\n );\n }\n}\n","/**\n * Resolve the command that invokes the `hindsight-embed` Python CLI.\n *\n * - If `embedPackagePath` is set, runs the package from a local checkout via\n * `uv run --directory <path> hindsight-embed`. Used for in-repo development.\n * - Otherwise runs it via `uvx hindsight-embed@<version>` so no global install\n * is required.\n *\n * Returns the argv as `[command, ...baseArgs]` suitable for `spawn()` /\n * `execFile()` (never shell-interpolated).\n */\nexport interface EmbedCommandOptions {\n /** Version spec passed to uvx (e.g. \"latest\", \"0.5.0\"). Default: \"latest\". */\n embedVersion?: string;\n /** Local checkout path. When set, overrides `embedVersion` and uses `uv run`. */\n embedPackagePath?: string;\n}\n\nexport function getEmbedCommand(opts: EmbedCommandOptions = {}): string[] {\n if (opts.embedPackagePath) {\n return ['uv', 'run', '--directory', opts.embedPackagePath, 'hindsight-embed'];\n }\n const version = opts.embedVersion && opts.embedVersion.length > 0 ? opts.embedVersion : 'latest';\n return ['uvx', `hindsight-embed@${version}`];\n}\n","/**\n * Pluggable logger interface.\n *\n * This package does not own any logging infrastructure — consumers inject\n * whatever they want (console, pino, openclaw's logger, a no-op). The default\n * is silent so embedding this package never adds noise to an unrelated app.\n */\nexport interface Logger {\n debug(msg: string): void;\n info(msg: string): void;\n warn(msg: string): void;\n error(msg: string): void;\n}\n\n/** Logger that drops every call. Used when no logger is passed. */\nexport const silentLogger: Logger = {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n};\n\n/** Logger that writes to the standard console. Handy for CLIs and tests. */\nexport const consoleLogger: Logger = {\n debug: (msg) => console.debug(msg),\n info: (msg) => console.log(msg),\n warn: (msg) => console.warn(msg),\n error: (msg) => console.error(msg),\n};\n"],"mappings":";AAAA,SAAS,aAAa;;;ACkBf,SAAS,gBAAgB,OAA4B,CAAC,GAAa;AACxE,MAAI,KAAK,kBAAkB;AACzB,WAAO,CAAC,MAAM,OAAO,eAAe,KAAK,kBAAkB,iBAAiB;AAAA,EAC9E;AACA,QAAM,UAAU,KAAK,gBAAgB,KAAK,aAAa,SAAS,IAAI,KAAK,eAAe;AACxF,SAAO,CAAC,OAAO,mBAAmB,OAAO,EAAE;AAC7C;;;ACTO,IAAM,eAAuB;AAAA,EAClC,OAAO,MAAM;AAAA,EAAC;AAAA,EACd,MAAM,MAAM;AAAA,EAAC;AAAA,EACb,MAAM,MAAM;AAAA,EAAC;AAAA,EACb,OAAO,MAAM;AAAA,EAAC;AAChB;AAGO,IAAM,gBAAwB;AAAA,EACnC,OAAO,C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,WAAW,SAAS,KAAK,mBAAmB,CAAC;AAAA,IAC9E;AACA,UAAM,IAAI;AAAA,MACR,gDAAgD,KAAK,cAAc,SAAS,KAAK,OAAO;AAAA,IAC1F;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@vectorize-io/hindsight-all",
3
+ "version": "0.1.0",
4
+ "description": "Node.js programmatic lifecycle manager for Hindsight — embeds a local hindsight daemon in a Node application. Pair with @vectorize-io/hindsight-client for memory operations.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "keywords": [
15
+ "hindsight",
16
+ "hindsight-all",
17
+ "memory",
18
+ "ai",
19
+ "agent",
20
+ "long-term-memory",
21
+ "llm",
22
+ "embedded-server"
23
+ ],
24
+ "author": "Vectorize <support@vectorize.io>",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/vectorize-io/hindsight.git",
29
+ "directory": "hindsight-all-npm"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "README.md"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "dev": "tsup --watch",
38
+ "clean": "rm -rf dist",
39
+ "test": "vitest run src",
40
+ "test:watch": "vitest src",
41
+ "prepublishOnly": "npm run clean && npm run build"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^22.0.0",
45
+ "tsup": "^8.5.1",
46
+ "typescript": "^5.7.0",
47
+ "vitest": "^4.1.2"
48
+ },
49
+ "engines": {
50
+ "node": ">=22"
51
+ },
52
+ "overrides": {
53
+ "rollup": "^4.59.0",
54
+ "picomatch": ">=2.3.2 <3.0.0 || >=4.0.4",
55
+ "vite": ">=8.0.5"
56
+ }
57
+ }