@askexenow/exe-os 0.9.21 → 0.9.22

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.
Files changed (60) hide show
  1. package/dist/bin/backfill-conversations.js +17 -4
  2. package/dist/bin/backfill-responses.js +17 -4
  3. package/dist/bin/backfill-vectors.js +2 -2
  4. package/dist/bin/cleanup-stale-review-tasks.js +17 -4
  5. package/dist/bin/cli.js +378 -171
  6. package/dist/bin/exe-assign.js +17 -4
  7. package/dist/bin/exe-boot.js +2 -2
  8. package/dist/bin/exe-dispatch.js +17 -4
  9. package/dist/bin/exe-doctor.js +2 -2
  10. package/dist/bin/exe-export-behaviors.js +17 -4
  11. package/dist/bin/exe-forget.js +17 -4
  12. package/dist/bin/exe-gateway.js +17 -4
  13. package/dist/bin/exe-heartbeat.js +17 -4
  14. package/dist/bin/exe-kill.js +17 -4
  15. package/dist/bin/exe-launch-agent.js +17 -4
  16. package/dist/bin/exe-pending-messages.js +17 -4
  17. package/dist/bin/exe-pending-notifications.js +17 -4
  18. package/dist/bin/exe-pending-reviews.js +17 -4
  19. package/dist/bin/exe-review.js +17 -4
  20. package/dist/bin/exe-search.js +23 -8
  21. package/dist/bin/exe-session-cleanup.js +17 -4
  22. package/dist/bin/exe-start-codex.js +209 -32
  23. package/dist/bin/exe-start-opencode.js +17 -4
  24. package/dist/bin/exe-status.js +17 -4
  25. package/dist/bin/exe-team.js +17 -4
  26. package/dist/bin/git-sweep.js +17 -4
  27. package/dist/bin/graph-backfill.js +17 -4
  28. package/dist/bin/graph-export.js +17 -4
  29. package/dist/bin/install.js +42 -0
  30. package/dist/bin/intercom-check.js +17 -4
  31. package/dist/bin/scan-tasks.js +17 -4
  32. package/dist/bin/shard-migrate.js +17 -4
  33. package/dist/bin/update.js +187 -42
  34. package/dist/gateway/index.js +17 -4
  35. package/dist/hooks/bug-report-worker.js +793 -150
  36. package/dist/hooks/codex-stop-task-finalizer.js +3020 -2375
  37. package/dist/hooks/commit-complete.js +156 -6
  38. package/dist/hooks/error-recall.js +23 -8
  39. package/dist/hooks/ingest.js +17 -4
  40. package/dist/hooks/instructions-loaded.js +17 -4
  41. package/dist/hooks/notification.js +17 -4
  42. package/dist/hooks/post-compact.js +17 -4
  43. package/dist/hooks/post-tool-combined.js +23 -8
  44. package/dist/hooks/pre-compact.js +156 -8
  45. package/dist/hooks/pre-tool-use.js +21 -12
  46. package/dist/hooks/prompt-submit.js +23 -8
  47. package/dist/hooks/session-end.js +156 -8
  48. package/dist/hooks/session-start.js +23 -8
  49. package/dist/hooks/stop.js +306 -9
  50. package/dist/hooks/subagent-stop.js +306 -9
  51. package/dist/hooks/summary-worker.js +2 -2
  52. package/dist/index.js +17 -4
  53. package/dist/lib/exe-daemon.js +17 -4
  54. package/dist/lib/hybrid-search.js +23 -8
  55. package/dist/lib/schedules.js +2 -2
  56. package/dist/lib/store.js +17 -4
  57. package/dist/mcp/server.js +36 -10
  58. package/dist/runtime/index.js +17 -4
  59. package/dist/tui/App.js +17 -4
  60. package/package.json +1 -1
@@ -2746,8 +2746,8 @@ function getShardClient(projectName) {
2746
2746
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2747
2747
  }
2748
2748
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2749
- if (!safeName) {
2750
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2749
+ if (!safeName || safeName === "unknown") {
2750
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2751
2751
  }
2752
2752
  const cached = _shards.get(safeName);
2753
2753
  if (cached) {
@@ -3860,19 +3860,32 @@ async function flushBatch() {
3860
3860
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
3861
3861
  if (isShardingEnabled2()) {
3862
3862
  const byProject = /* @__PURE__ */ new Map();
3863
+ let skippedUnknown = 0;
3863
3864
  for (const row of batch) {
3864
- const proj = row.project_name || "unknown";
3865
+ const proj = row.project_name?.trim();
3866
+ if (!proj) {
3867
+ skippedUnknown++;
3868
+ continue;
3869
+ }
3865
3870
  if (!byProject.has(proj)) byProject.set(proj, []);
3866
3871
  byProject.get(proj).push(row);
3867
3872
  }
3873
+ if (skippedUnknown > 0) {
3874
+ process.stderr.write(
3875
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
3876
+ `
3877
+ );
3878
+ }
3868
3879
  for (const [project, rows] of byProject) {
3869
3880
  try {
3870
3881
  const shardClient = await getReadyShardClient2(project);
3871
3882
  const shardStmts = rows.map(buildStmt);
3872
3883
  await shardClient.batch(shardStmts, "write");
3873
3884
  } catch (err) {
3885
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
3886
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
3874
3887
  process.stderr.write(
3875
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
3888
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
3876
3889
  `
3877
3890
  );
3878
3891
  }
@@ -3315,8 +3315,8 @@ function getShardClient(projectName) {
3315
3315
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3316
3316
  }
3317
3317
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3318
- if (!safeName) {
3319
- throw new Error(`Invalid project name for shard: "${projectName}"`);
3318
+ if (!safeName || safeName === "unknown") {
3319
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3320
3320
  }
3321
3321
  const cached = _shards.get(safeName);
3322
3322
  if (cached) {
@@ -6603,8 +6603,8 @@ function getShardClient(projectName) {
6603
6603
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
6604
6604
  }
6605
6605
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
6606
- if (!safeName) {
6607
- throw new Error(`Invalid project name for shard: "${projectName}"`);
6606
+ if (!safeName || safeName === "unknown") {
6607
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
6608
6608
  }
6609
6609
  const cached = _shards.get(safeName);
6610
6610
  if (cached) {
@@ -7473,19 +7473,32 @@ async function flushBatch() {
7473
7473
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
7474
7474
  if (isShardingEnabled2()) {
7475
7475
  const byProject = /* @__PURE__ */ new Map();
7476
+ let skippedUnknown = 0;
7476
7477
  for (const row of batch) {
7477
- const proj = row.project_name || "unknown";
7478
+ const proj = row.project_name?.trim();
7479
+ if (!proj) {
7480
+ skippedUnknown++;
7481
+ continue;
7482
+ }
7478
7483
  if (!byProject.has(proj)) byProject.set(proj, []);
7479
7484
  byProject.get(proj).push(row);
7480
7485
  }
7486
+ if (skippedUnknown > 0) {
7487
+ process.stderr.write(
7488
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
7489
+ `
7490
+ );
7491
+ }
7481
7492
  for (const [project, rows] of byProject) {
7482
7493
  try {
7483
7494
  const shardClient = await getReadyShardClient2(project);
7484
7495
  const shardStmts = rows.map(buildStmt);
7485
7496
  await shardClient.batch(shardStmts, "write");
7486
7497
  } catch (err) {
7498
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
7499
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
7487
7500
  process.stderr.write(
7488
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
7501
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
7489
7502
  `
7490
7503
  );
7491
7504
  }
@@ -2596,8 +2596,8 @@ function getShardClient(projectName) {
2596
2596
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2597
2597
  }
2598
2598
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2599
- if (!safeName) {
2600
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2599
+ if (!safeName || safeName === "unknown") {
2600
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2601
2601
  }
2602
2602
  const cached = _shards.get(safeName);
2603
2603
  if (cached) {
@@ -2923,8 +2923,8 @@ function getShardClient(projectName2) {
2923
2923
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2924
2924
  }
2925
2925
  const safeName = projectName2.replace(/[^a-zA-Z0-9_-]/g, "_");
2926
- if (!safeName) {
2927
- throw new Error(`Invalid project name for shard: "${projectName2}"`);
2926
+ if (!safeName || safeName === "unknown") {
2927
+ throw new Error(`Invalid project name for shard: "${projectName2}" (resolved to "${safeName}")`);
2928
2928
  }
2929
2929
  const cached = _shards.get(safeName);
2930
2930
  if (cached) {
@@ -3793,19 +3793,32 @@ async function flushBatch() {
3793
3793
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
3794
3794
  if (isShardingEnabled2()) {
3795
3795
  const byProject = /* @__PURE__ */ new Map();
3796
+ let skippedUnknown = 0;
3796
3797
  for (const row of batch) {
3797
- const proj = row.project_name || "unknown";
3798
+ const proj = row.project_name?.trim();
3799
+ if (!proj) {
3800
+ skippedUnknown++;
3801
+ continue;
3802
+ }
3798
3803
  if (!byProject.has(proj)) byProject.set(proj, []);
3799
3804
  byProject.get(proj).push(row);
3800
3805
  }
3806
+ if (skippedUnknown > 0) {
3807
+ process.stderr.write(
3808
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
3809
+ `
3810
+ );
3811
+ }
3801
3812
  for (const [project, rows] of byProject) {
3802
3813
  try {
3803
3814
  const shardClient = await getReadyShardClient2(project);
3804
3815
  const shardStmts = rows.map(buildStmt);
3805
3816
  await shardClient.batch(shardStmts, "write");
3806
3817
  } catch (err) {
3818
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
3819
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
3807
3820
  process.stderr.write(
3808
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
3821
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
3809
3822
  `
3810
3823
  );
3811
3824
  }
@@ -2923,8 +2923,8 @@ function getShardClient(projectName) {
2923
2923
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2924
2924
  }
2925
2925
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2926
- if (!safeName) {
2927
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2926
+ if (!safeName || safeName === "unknown") {
2927
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2928
2928
  }
2929
2929
  const cached = _shards.get(safeName);
2930
2930
  if (cached) {
@@ -3793,19 +3793,32 @@ async function flushBatch() {
3793
3793
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
3794
3794
  if (isShardingEnabled2()) {
3795
3795
  const byProject = /* @__PURE__ */ new Map();
3796
+ let skippedUnknown = 0;
3796
3797
  for (const row of batch) {
3797
- const proj = row.project_name || "unknown";
3798
+ const proj = row.project_name?.trim();
3799
+ if (!proj) {
3800
+ skippedUnknown++;
3801
+ continue;
3802
+ }
3798
3803
  if (!byProject.has(proj)) byProject.set(proj, []);
3799
3804
  byProject.get(proj).push(row);
3800
3805
  }
3806
+ if (skippedUnknown > 0) {
3807
+ process.stderr.write(
3808
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
3809
+ `
3810
+ );
3811
+ }
3801
3812
  for (const [project, rows] of byProject) {
3802
3813
  try {
3803
3814
  const shardClient = await getReadyShardClient2(project);
3804
3815
  const shardStmts = rows.map(buildStmt);
3805
3816
  await shardClient.batch(shardStmts, "write");
3806
3817
  } catch (err) {
3818
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
3819
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
3807
3820
  process.stderr.write(
3808
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
3821
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
3809
3822
  `
3810
3823
  );
3811
3824
  }
@@ -3581,8 +3581,8 @@ function getShardClient(projectName) {
3581
3581
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3582
3582
  }
3583
3583
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3584
- if (!safeName) {
3585
- throw new Error(`Invalid project name for shard: "${projectName}"`);
3584
+ if (!safeName || safeName === "unknown") {
3585
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3586
3586
  }
3587
3587
  const cached = _shards.get(safeName);
3588
3588
  if (cached) {
@@ -4451,19 +4451,32 @@ async function flushBatch() {
4451
4451
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
4452
4452
  if (isShardingEnabled2()) {
4453
4453
  const byProject = /* @__PURE__ */ new Map();
4454
+ let skippedUnknown = 0;
4454
4455
  for (const row of batch) {
4455
- const proj = row.project_name || "unknown";
4456
+ const proj = row.project_name?.trim();
4457
+ if (!proj) {
4458
+ skippedUnknown++;
4459
+ continue;
4460
+ }
4456
4461
  if (!byProject.has(proj)) byProject.set(proj, []);
4457
4462
  byProject.get(proj).push(row);
4458
4463
  }
4464
+ if (skippedUnknown > 0) {
4465
+ process.stderr.write(
4466
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
4467
+ `
4468
+ );
4469
+ }
4459
4470
  for (const [project, rows] of byProject) {
4460
4471
  try {
4461
4472
  const shardClient = await getReadyShardClient2(project);
4462
4473
  const shardStmts = rows.map(buildStmt);
4463
4474
  await shardClient.batch(shardStmts, "write");
4464
4475
  } catch (err) {
4476
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
4477
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
4465
4478
  process.stderr.write(
4466
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
4479
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
4467
4480
  `
4468
4481
  );
4469
4482
  }
@@ -2953,8 +2953,8 @@ function getShardClient(projectName) {
2953
2953
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2954
2954
  }
2955
2955
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2956
- if (!safeName) {
2957
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2956
+ if (!safeName || safeName === "unknown") {
2957
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2958
2958
  }
2959
2959
  const cached = _shards.get(safeName);
2960
2960
  if (cached) {
@@ -3823,19 +3823,32 @@ async function flushBatch() {
3823
3823
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
3824
3824
  if (isShardingEnabled2()) {
3825
3825
  const byProject = /* @__PURE__ */ new Map();
3826
+ let skippedUnknown = 0;
3826
3827
  for (const row of batch) {
3827
- const proj = row.project_name || "unknown";
3828
+ const proj = row.project_name?.trim();
3829
+ if (!proj) {
3830
+ skippedUnknown++;
3831
+ continue;
3832
+ }
3828
3833
  if (!byProject.has(proj)) byProject.set(proj, []);
3829
3834
  byProject.get(proj).push(row);
3830
3835
  }
3836
+ if (skippedUnknown > 0) {
3837
+ process.stderr.write(
3838
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
3839
+ `
3840
+ );
3841
+ }
3831
3842
  for (const [project, rows] of byProject) {
3832
3843
  try {
3833
3844
  const shardClient = await getReadyShardClient2(project);
3834
3845
  const shardStmts = rows.map(buildStmt);
3835
3846
  await shardClient.batch(shardStmts, "write");
3836
3847
  } catch (err) {
3848
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
3849
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
3837
3850
  process.stderr.write(
3838
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
3851
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
3839
3852
  `
3840
3853
  );
3841
3854
  }
@@ -2923,8 +2923,8 @@ function getShardClient(projectName) {
2923
2923
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2924
2924
  }
2925
2925
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2926
- if (!safeName) {
2927
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2926
+ if (!safeName || safeName === "unknown") {
2927
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2928
2928
  }
2929
2929
  const cached = _shards.get(safeName);
2930
2930
  if (cached) {
@@ -3793,19 +3793,32 @@ async function flushBatch() {
3793
3793
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
3794
3794
  if (isShardingEnabled2()) {
3795
3795
  const byProject = /* @__PURE__ */ new Map();
3796
+ let skippedUnknown = 0;
3796
3797
  for (const row of batch) {
3797
- const proj = row.project_name || "unknown";
3798
+ const proj = row.project_name?.trim();
3799
+ if (!proj) {
3800
+ skippedUnknown++;
3801
+ continue;
3802
+ }
3798
3803
  if (!byProject.has(proj)) byProject.set(proj, []);
3799
3804
  byProject.get(proj).push(row);
3800
3805
  }
3806
+ if (skippedUnknown > 0) {
3807
+ process.stderr.write(
3808
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
3809
+ `
3810
+ );
3811
+ }
3801
3812
  for (const [project, rows] of byProject) {
3802
3813
  try {
3803
3814
  const shardClient = await getReadyShardClient2(project);
3804
3815
  const shardStmts = rows.map(buildStmt);
3805
3816
  await shardClient.batch(shardStmts, "write");
3806
3817
  } catch (err) {
3818
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
3819
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
3807
3820
  process.stderr.write(
3808
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
3821
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
3809
3822
  `
3810
3823
  );
3811
3824
  }
@@ -2930,8 +2930,8 @@ function getShardClient(projectName) {
2930
2930
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2931
2931
  }
2932
2932
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2933
- if (!safeName) {
2934
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2933
+ if (!safeName || safeName === "unknown") {
2934
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2935
2935
  }
2936
2936
  const cached = _shards.get(safeName);
2937
2937
  if (cached) {
@@ -4641,19 +4641,32 @@ async function flushBatch() {
4641
4641
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
4642
4642
  if (isShardingEnabled2()) {
4643
4643
  const byProject = /* @__PURE__ */ new Map();
4644
+ let skippedUnknown = 0;
4644
4645
  for (const row of batch) {
4645
- const proj = row.project_name || "unknown";
4646
+ const proj = row.project_name?.trim();
4647
+ if (!proj) {
4648
+ skippedUnknown++;
4649
+ continue;
4650
+ }
4646
4651
  if (!byProject.has(proj)) byProject.set(proj, []);
4647
4652
  byProject.get(proj).push(row);
4648
4653
  }
4654
+ if (skippedUnknown > 0) {
4655
+ process.stderr.write(
4656
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
4657
+ `
4658
+ );
4659
+ }
4649
4660
  for (const [project, rows] of byProject) {
4650
4661
  try {
4651
4662
  const shardClient = await getReadyShardClient2(project);
4652
4663
  const shardStmts = rows.map(buildStmt);
4653
4664
  await shardClient.batch(shardStmts, "write");
4654
4665
  } catch (err) {
4666
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
4667
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
4655
4668
  process.stderr.write(
4656
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
4669
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
4657
4670
  `
4658
4671
  );
4659
4672
  }
@@ -3342,8 +3342,8 @@ function getShardClient(projectName) {
3342
3342
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3343
3343
  }
3344
3344
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3345
- if (!safeName) {
3346
- throw new Error(`Invalid project name for shard: "${projectName}"`);
3345
+ if (!safeName || safeName === "unknown") {
3346
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3347
3347
  }
3348
3348
  const cached = _shards.get(safeName);
3349
3349
  if (cached) {
@@ -4212,19 +4212,32 @@ async function flushBatch() {
4212
4212
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
4213
4213
  if (isShardingEnabled2()) {
4214
4214
  const byProject = /* @__PURE__ */ new Map();
4215
+ let skippedUnknown = 0;
4215
4216
  for (const row of batch) {
4216
- const proj = row.project_name || "unknown";
4217
+ const proj = row.project_name?.trim();
4218
+ if (!proj) {
4219
+ skippedUnknown++;
4220
+ continue;
4221
+ }
4217
4222
  if (!byProject.has(proj)) byProject.set(proj, []);
4218
4223
  byProject.get(proj).push(row);
4219
4224
  }
4225
+ if (skippedUnknown > 0) {
4226
+ process.stderr.write(
4227
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
4228
+ `
4229
+ );
4230
+ }
4220
4231
  for (const [project, rows] of byProject) {
4221
4232
  try {
4222
4233
  const shardClient = await getReadyShardClient2(project);
4223
4234
  const shardStmts = rows.map(buildStmt);
4224
4235
  await shardClient.batch(shardStmts, "write");
4225
4236
  } catch (err) {
4237
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
4238
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
4226
4239
  process.stderr.write(
4227
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
4240
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
4228
4241
  `
4229
4242
  );
4230
4243
  }
@@ -3408,8 +3408,8 @@ function getShardClient(projectName) {
3408
3408
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3409
3409
  }
3410
3410
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3411
- if (!safeName) {
3412
- throw new Error(`Invalid project name for shard: "${projectName}"`);
3411
+ if (!safeName || safeName === "unknown") {
3412
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3413
3413
  }
3414
3414
  const cached = _shards.get(safeName);
3415
3415
  if (cached) {
@@ -4278,19 +4278,32 @@ async function flushBatch() {
4278
4278
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
4279
4279
  if (isShardingEnabled2()) {
4280
4280
  const byProject = /* @__PURE__ */ new Map();
4281
+ let skippedUnknown = 0;
4281
4282
  for (const row of batch) {
4282
- const proj = row.project_name || "unknown";
4283
+ const proj = row.project_name?.trim();
4284
+ if (!proj) {
4285
+ skippedUnknown++;
4286
+ continue;
4287
+ }
4283
4288
  if (!byProject.has(proj)) byProject.set(proj, []);
4284
4289
  byProject.get(proj).push(row);
4285
4290
  }
4291
+ if (skippedUnknown > 0) {
4292
+ process.stderr.write(
4293
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
4294
+ `
4295
+ );
4296
+ }
4286
4297
  for (const [project, rows] of byProject) {
4287
4298
  try {
4288
4299
  const shardClient = await getReadyShardClient2(project);
4289
4300
  const shardStmts = rows.map(buildStmt);
4290
4301
  await shardClient.batch(shardStmts, "write");
4291
4302
  } catch (err) {
4303
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
4304
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
4292
4305
  process.stderr.write(
4293
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
4306
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
4294
4307
  `
4295
4308
  );
4296
4309
  }
@@ -3447,8 +3447,8 @@ function getShardClient(projectName) {
3447
3447
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3448
3448
  }
3449
3449
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3450
- if (!safeName) {
3451
- throw new Error(`Invalid project name for shard: "${projectName}"`);
3450
+ if (!safeName || safeName === "unknown") {
3451
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3452
3452
  }
3453
3453
  const cached = _shards.get(safeName);
3454
3454
  if (cached) {
@@ -4317,19 +4317,32 @@ async function flushBatch() {
4317
4317
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
4318
4318
  if (isShardingEnabled2()) {
4319
4319
  const byProject = /* @__PURE__ */ new Map();
4320
+ let skippedUnknown = 0;
4320
4321
  for (const row of batch) {
4321
- const proj = row.project_name || "unknown";
4322
+ const proj = row.project_name?.trim();
4323
+ if (!proj) {
4324
+ skippedUnknown++;
4325
+ continue;
4326
+ }
4322
4327
  if (!byProject.has(proj)) byProject.set(proj, []);
4323
4328
  byProject.get(proj).push(row);
4324
4329
  }
4330
+ if (skippedUnknown > 0) {
4331
+ process.stderr.write(
4332
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
4333
+ `
4334
+ );
4335
+ }
4325
4336
  for (const [project, rows] of byProject) {
4326
4337
  try {
4327
4338
  const shardClient = await getReadyShardClient2(project);
4328
4339
  const shardStmts = rows.map(buildStmt);
4329
4340
  await shardClient.batch(shardStmts, "write");
4330
4341
  } catch (err) {
4342
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
4343
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
4331
4344
  process.stderr.write(
4332
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
4345
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
4333
4346
  `
4334
4347
  );
4335
4348
  }
@@ -2937,8 +2937,8 @@ function getShardClient(projectName) {
2937
2937
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2938
2938
  }
2939
2939
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2940
- if (!safeName) {
2941
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2940
+ if (!safeName || safeName === "unknown") {
2941
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2942
2942
  }
2943
2943
  const cached = _shards.get(safeName);
2944
2944
  if (cached) {
@@ -3807,19 +3807,32 @@ async function flushBatch() {
3807
3807
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
3808
3808
  if (isShardingEnabled2()) {
3809
3809
  const byProject = /* @__PURE__ */ new Map();
3810
+ let skippedUnknown = 0;
3810
3811
  for (const row of batch) {
3811
- const proj = row.project_name || "unknown";
3812
+ const proj = row.project_name?.trim();
3813
+ if (!proj) {
3814
+ skippedUnknown++;
3815
+ continue;
3816
+ }
3812
3817
  if (!byProject.has(proj)) byProject.set(proj, []);
3813
3818
  byProject.get(proj).push(row);
3814
3819
  }
3820
+ if (skippedUnknown > 0) {
3821
+ process.stderr.write(
3822
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
3823
+ `
3824
+ );
3825
+ }
3815
3826
  for (const [project, rows] of byProject) {
3816
3827
  try {
3817
3828
  const shardClient = await getReadyShardClient2(project);
3818
3829
  const shardStmts = rows.map(buildStmt);
3819
3830
  await shardClient.batch(shardStmts, "write");
3820
3831
  } catch (err) {
3832
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
3833
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
3821
3834
  process.stderr.write(
3822
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
3835
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
3823
3836
  `
3824
3837
  );
3825
3838
  }
@@ -2912,8 +2912,8 @@ function getShardClient(projectName) {
2912
2912
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2913
2913
  }
2914
2914
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2915
- if (!safeName) {
2916
- throw new Error(`Invalid project name for shard: "${projectName}"`);
2915
+ if (!safeName || safeName === "unknown") {
2916
+ throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2917
2917
  }
2918
2918
  const cached = _shards.get(safeName);
2919
2919
  if (cached) {
@@ -3782,19 +3782,32 @@ async function flushBatch() {
3782
3782
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
3783
3783
  if (isShardingEnabled2()) {
3784
3784
  const byProject = /* @__PURE__ */ new Map();
3785
+ let skippedUnknown = 0;
3785
3786
  for (const row of batch) {
3786
- const proj = row.project_name || "unknown";
3787
+ const proj = row.project_name?.trim();
3788
+ if (!proj) {
3789
+ skippedUnknown++;
3790
+ continue;
3791
+ }
3787
3792
  if (!byProject.has(proj)) byProject.set(proj, []);
3788
3793
  byProject.get(proj).push(row);
3789
3794
  }
3795
+ if (skippedUnknown > 0) {
3796
+ process.stderr.write(
3797
+ `[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
3798
+ `
3799
+ );
3800
+ }
3790
3801
  for (const [project, rows] of byProject) {
3791
3802
  try {
3792
3803
  const shardClient = await getReadyShardClient2(project);
3793
3804
  const shardStmts = rows.map(buildStmt);
3794
3805
  await shardClient.batch(shardStmts, "write");
3795
3806
  } catch (err) {
3807
+ const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
3808
+ ${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
3796
3809
  process.stderr.write(
3797
- `[store] Shard write failed for ${project}: ${err instanceof Error ? err.message : String(err)}
3810
+ `[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
3798
3811
  `
3799
3812
  );
3800
3813
  }
@@ -5213,10 +5226,12 @@ async function hybridSearch(queryText, agentId, options) {
5213
5226
  );
5214
5227
  }
5215
5228
  let rerankerAvailable = false;
5216
- try {
5217
- const { isRerankerAvailable: isRerankerAvailable2 } = await Promise.resolve().then(() => (init_reranker(), reranker_exports));
5218
- rerankerAvailable = isRerankerAvailable2();
5219
- } catch {
5229
+ if (process.env.EXE_IS_DAEMON === "1") {
5230
+ try {
5231
+ const { isRerankerAvailable: isRerankerAvailable2 } = await Promise.resolve().then(() => (init_reranker(), reranker_exports));
5232
+ rerankerAvailable = isRerankerAvailable2();
5233
+ } catch {
5234
+ }
5220
5235
  }
5221
5236
  const broadFetchTopK = config.scalingRoadmap?.rerankerAutoTrigger?.fetchTopK ?? 150;
5222
5237
  const fetchLimit = effectiveIsBroad ? Math.max(limit * 5, broadFetchTopK) : rerankerAvailable ? Math.max(limit * 4, 60) : Math.max(limit * 3, 30);