@vectorize-io/hindsight-coding-agents 0.0.3 → 0.0.5

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.
@@ -49,10 +49,24 @@ function seedControl(command2, args) {
49
49
 
50
50
  // src/core/config.ts
51
51
  var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join2(homedir(), ".hindsight", "coding-agent.json");
52
+ var DEFAULT_DAEMON_PORT = 9077;
53
+ var DEFAULT_DAEMON_IDLE_TIMEOUT = 300;
54
+ var DEFAULT_DAEMON_PROFILE = "coding-agent";
52
55
  function resolveConfig(raw = {}) {
56
+ const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
57
+ const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
53
58
  return {
54
- apiUrl: raw.apiUrl ?? "https://api.hindsight.vectorize.io",
59
+ serverMode,
60
+ // Daemon mode resolves the URL HERE rather than at each call site: every entry point already
61
+ // builds its client from cfg.apiUrl, so collapsing the mode into that one field means the
62
+ // daemon needs no plumbing through eight separate constructors.
63
+ apiUrl: serverMode === "daemon" ? `http://127.0.0.1:${apiPort}` : raw.apiUrl ?? "https://api.hindsight.vectorize.io",
55
64
  apiToken: raw.apiToken || void 0,
65
+ apiPort,
66
+ daemonIdleTimeout: raw.daemonIdleTimeout ?? DEFAULT_DAEMON_IDLE_TIMEOUT,
67
+ daemonProfile: raw.daemonProfile || DEFAULT_DAEMON_PROFILE,
68
+ embedVersion: raw.embedVersion || void 0,
69
+ embedPackagePath: raw.embedPackagePath || void 0,
56
70
  bankId: raw.bankId,
57
71
  dynamicBankId: raw.dynamicBankId,
58
72
  bankIdTemplate: raw.bankIdTemplate,
@@ -98,8 +112,16 @@ function applyLayer(raw, layer, harness) {
98
112
  return out;
99
113
  }
100
114
  var ENV_KEYS = {
115
+ serverMode: "HINDSIGHT_SERVER_MODE",
101
116
  apiUrl: "HINDSIGHT_API_URL",
102
117
  apiToken: "HINDSIGHT_API_TOKEN",
118
+ // These four keep the names the old per-agent Claude Code plugin used, so a user migrating from
119
+ // it can carry their existing environment over unchanged.
120
+ apiPort: "HINDSIGHT_API_PORT",
121
+ daemonIdleTimeout: "HINDSIGHT_DAEMON_IDLE_TIMEOUT",
122
+ embedVersion: "HINDSIGHT_EMBED_VERSION",
123
+ embedPackagePath: "HINDSIGHT_EMBED_PACKAGE_PATH",
124
+ daemonProfile: "HINDSIGHT_DAEMON_PROFILE",
103
125
  bankId: "HINDSIGHT_BANK_ID",
104
126
  dynamicBankId: "HINDSIGHT_DYNAMIC_BANK_ID",
105
127
  bankIdTemplate: "HINDSIGHT_BANK_ID_TEMPLATE",
@@ -130,6 +152,8 @@ var ENV_BOOLEANS = /* @__PURE__ */ new Set([
130
152
  "codebaseSurvey"
131
153
  ]);
132
154
  var ENV_NUMBERS = /* @__PURE__ */ new Set([
155
+ "apiPort",
156
+ "daemonIdleTimeout",
133
157
  "retainEveryTurns",
134
158
  "reflectTimeoutMs",
135
159
  "pageRefreshEveryTurns",
package/dist/index.js CHANGED
@@ -110,10 +110,24 @@ function startBackgroundSeed(repoDir, opts = {}) {
110
110
 
111
111
  // src/core/config.ts
112
112
  var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join3(homedir2(), ".hindsight", "coding-agent.json");
113
+ var DEFAULT_DAEMON_PORT = 9077;
114
+ var DEFAULT_DAEMON_IDLE_TIMEOUT = 300;
115
+ var DEFAULT_DAEMON_PROFILE = "coding-agent";
113
116
  function resolveConfig(raw = {}) {
117
+ const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
118
+ const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
114
119
  return {
115
- apiUrl: raw.apiUrl ?? "https://api.hindsight.vectorize.io",
120
+ serverMode,
121
+ // Daemon mode resolves the URL HERE rather than at each call site: every entry point already
122
+ // builds its client from cfg.apiUrl, so collapsing the mode into that one field means the
123
+ // daemon needs no plumbing through eight separate constructors.
124
+ apiUrl: serverMode === "daemon" ? `http://127.0.0.1:${apiPort}` : raw.apiUrl ?? "https://api.hindsight.vectorize.io",
116
125
  apiToken: raw.apiToken || void 0,
126
+ apiPort,
127
+ daemonIdleTimeout: raw.daemonIdleTimeout ?? DEFAULT_DAEMON_IDLE_TIMEOUT,
128
+ daemonProfile: raw.daemonProfile || DEFAULT_DAEMON_PROFILE,
129
+ embedVersion: raw.embedVersion || void 0,
130
+ embedPackagePath: raw.embedPackagePath || void 0,
117
131
  bankId: raw.bankId,
118
132
  dynamicBankId: raw.dynamicBankId,
119
133
  bankIdTemplate: raw.bankIdTemplate,
@@ -159,8 +173,16 @@ function applyLayer(raw, layer, harness) {
159
173
  return out;
160
174
  }
161
175
  var ENV_KEYS = {
176
+ serverMode: "HINDSIGHT_SERVER_MODE",
162
177
  apiUrl: "HINDSIGHT_API_URL",
163
178
  apiToken: "HINDSIGHT_API_TOKEN",
179
+ // These four keep the names the old per-agent Claude Code plugin used, so a user migrating from
180
+ // it can carry their existing environment over unchanged.
181
+ apiPort: "HINDSIGHT_API_PORT",
182
+ daemonIdleTimeout: "HINDSIGHT_DAEMON_IDLE_TIMEOUT",
183
+ embedVersion: "HINDSIGHT_EMBED_VERSION",
184
+ embedPackagePath: "HINDSIGHT_EMBED_PACKAGE_PATH",
185
+ daemonProfile: "HINDSIGHT_DAEMON_PROFILE",
164
186
  bankId: "HINDSIGHT_BANK_ID",
165
187
  dynamicBankId: "HINDSIGHT_DYNAMIC_BANK_ID",
166
188
  bankIdTemplate: "HINDSIGHT_BANK_ID_TEMPLATE",
@@ -191,6 +213,8 @@ var ENV_BOOLEANS = /* @__PURE__ */ new Set([
191
213
  "codebaseSurvey"
192
214
  ]);
193
215
  var ENV_NUMBERS = /* @__PURE__ */ new Set([
216
+ "apiPort",
217
+ "daemonIdleTimeout",
194
218
  "retainEveryTurns",
195
219
  "reflectTimeoutMs",
196
220
  "pageRefreshEveryTurns",
@@ -15808,6 +15832,11 @@ import { homedir as homedir5 } from "os";
15808
15832
  import { dirname as dirname5, join as join7 } from "path";
15809
15833
  import { fileURLToPath as fileURLToPath3 } from "url";
15810
15834
 
15835
+ // src/core/daemon.ts
15836
+ import { execFileSync as execFileSync4, spawn as realSpawn3 } from "child_process";
15837
+ import { dirname as dirname6, join as join8 } from "path";
15838
+ import { fileURLToPath as fileURLToPath4 } from "url";
15839
+
15811
15840
  // src/core/brand.ts
15812
15841
  function brandWord() {
15813
15842
  const start = [0, 116, 217];
@@ -15825,9 +15854,9 @@ function brandWord() {
15825
15854
  // src/core/session-cache.ts
15826
15855
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
15827
15856
  import { tmpdir as tmpdir2 } from "os";
15828
- import { dirname as dirname6, join as join8 } from "path";
15857
+ import { dirname as dirname7, join as join9 } from "path";
15829
15858
  function sessionCacheFile(harness, sessionId) {
15830
- return join8(tmpdir2(), `hindsight-${harness}`, `${sessionId}.json`);
15859
+ return join9(tmpdir2(), `hindsight-${harness}`, `${sessionId}.json`);
15831
15860
  }
15832
15861
  function readSessionCache(cacheFile) {
15833
15862
  try {
@@ -15838,7 +15867,7 @@ function readSessionCache(cacheFile) {
15838
15867
  }
15839
15868
  function writeSessionCache(cacheFile, cache) {
15840
15869
  try {
15841
- mkdirSync2(dirname6(cacheFile), { recursive: true });
15870
+ mkdirSync2(dirname7(cacheFile), { recursive: true });
15842
15871
  writeFileSync(cacheFile, JSON.stringify(cache));
15843
15872
  } catch {
15844
15873
  }
@@ -15862,9 +15891,9 @@ async function gitSyncNote(args) {
15862
15891
  const deepened = [...gitIds].filter((id) => id.startsWith("git:")).length;
15863
15892
  let target = DEEPEN_DIFF_TARGET;
15864
15893
  try {
15865
- const { execFileSync: execFileSync4 } = await import("child_process");
15894
+ const { execFileSync: execFileSync5 } = await import("child_process");
15866
15895
  const n = Number(
15867
- execFileSync4("git", ["-C", cwd, "rev-list", "--count", "HEAD"], { encoding: "utf8" }).trim()
15896
+ execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], { encoding: "utf8" }).trim()
15868
15897
  );
15869
15898
  if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
15870
15899
  } catch {