compound-agent 1.6.2 → 1.6.4

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/dist/index.d.ts CHANGED
@@ -3477,14 +3477,14 @@ declare const AuditFindingSchema: z.ZodObject<{
3477
3477
  }, "strip", z.ZodTypeAny, {
3478
3478
  file: string;
3479
3479
  source: "lesson" | "pattern" | "rule";
3480
- severity: "warning" | "error" | "info";
3480
+ severity: "error" | "warning" | "info";
3481
3481
  issue: string;
3482
3482
  relatedLessonId?: string | undefined;
3483
3483
  suggestedFix?: string | undefined;
3484
3484
  }, {
3485
3485
  file: string;
3486
3486
  source: "lesson" | "pattern" | "rule";
3487
- severity: "warning" | "error" | "info";
3487
+ severity: "error" | "warning" | "info";
3488
3488
  issue: string;
3489
3489
  relatedLessonId?: string | undefined;
3490
3490
  suggestedFix?: string | undefined;
@@ -3501,14 +3501,14 @@ declare const AuditReportSchema: z.ZodObject<{
3501
3501
  }, "strip", z.ZodTypeAny, {
3502
3502
  file: string;
3503
3503
  source: "lesson" | "pattern" | "rule";
3504
- severity: "warning" | "error" | "info";
3504
+ severity: "error" | "warning" | "info";
3505
3505
  issue: string;
3506
3506
  relatedLessonId?: string | undefined;
3507
3507
  suggestedFix?: string | undefined;
3508
3508
  }, {
3509
3509
  file: string;
3510
3510
  source: "lesson" | "pattern" | "rule";
3511
- severity: "warning" | "error" | "info";
3511
+ severity: "error" | "warning" | "info";
3512
3512
  issue: string;
3513
3513
  relatedLessonId?: string | undefined;
3514
3514
  suggestedFix?: string | undefined;
@@ -3535,7 +3535,7 @@ declare const AuditReportSchema: z.ZodObject<{
3535
3535
  findings: {
3536
3536
  file: string;
3537
3537
  source: "lesson" | "pattern" | "rule";
3538
- severity: "warning" | "error" | "info";
3538
+ severity: "error" | "warning" | "info";
3539
3539
  issue: string;
3540
3540
  relatedLessonId?: string | undefined;
3541
3541
  suggestedFix?: string | undefined;
@@ -3551,7 +3551,7 @@ declare const AuditReportSchema: z.ZodObject<{
3551
3551
  findings: {
3552
3552
  file: string;
3553
3553
  source: "lesson" | "pattern" | "rule";
3554
- severity: "warning" | "error" | "info";
3554
+ severity: "error" | "warning" | "info";
3555
3555
  issue: string;
3556
3556
  relatedLessonId?: string | undefined;
3557
3557
  suggestedFix?: string | undefined;
package/dist/index.js CHANGED
@@ -888,23 +888,44 @@ async function getEmbedding() {
888
888
  })();
889
889
  return pendingInit;
890
890
  }
891
- function unloadEmbedding() {
892
- if (embeddingContext) {
893
- embeddingContext.dispose().catch(() => {
894
- });
895
- embeddingContext = null;
891
+ async function unloadEmbeddingResources() {
892
+ const pending = pendingInit;
893
+ if (pending) {
894
+ try {
895
+ await pending;
896
+ } catch {
897
+ }
896
898
  }
897
- if (modelInstance) {
898
- modelInstance.dispose().catch(() => {
899
- });
900
- modelInstance = null;
899
+ const context = embeddingContext;
900
+ const model = modelInstance;
901
+ const llama = llamaInstance;
902
+ embeddingContext = null;
903
+ modelInstance = null;
904
+ llamaInstance = null;
905
+ pendingInit = null;
906
+ const disposals = [];
907
+ if (context) {
908
+ disposals.push(context.dispose());
901
909
  }
902
- if (llamaInstance) {
903
- llamaInstance.dispose().catch(() => {
904
- });
905
- llamaInstance = null;
910
+ if (model) {
911
+ disposals.push(model.dispose());
912
+ }
913
+ if (llama) {
914
+ disposals.push(llama.dispose());
915
+ }
916
+ if (disposals.length > 0) {
917
+ await Promise.allSettled(disposals);
918
+ }
919
+ }
920
+ function unloadEmbedding() {
921
+ void unloadEmbeddingResources();
922
+ }
923
+ async function withEmbedding(fn) {
924
+ try {
925
+ return await fn();
926
+ } finally {
927
+ await unloadEmbeddingResources();
906
928
  }
907
- pendingInit = null;
908
929
  }
909
930
  async function embedText(text) {
910
931
  const ctx = await getEmbedding();
@@ -2105,7 +2126,7 @@ async function runBackgroundEmbed(repoRoot) {
2105
2126
  const start = Date.now();
2106
2127
  writeEmbedStatus(repoRoot, { state: "running", startedAt: (/* @__PURE__ */ new Date()).toISOString() });
2107
2128
  try {
2108
- const result = await embedChunks(repoRoot, { onlyMissing: true });
2129
+ const result = await withEmbedding(async () => embedChunks(repoRoot, { onlyMissing: true }));
2109
2130
  writeEmbedStatus(repoRoot, {
2110
2131
  state: "completed",
2111
2132
  chunksEmbedded: result.chunksEmbedded,
@@ -2120,7 +2141,6 @@ async function runBackgroundEmbed(repoRoot) {
2120
2141
  durationMs: Date.now() - start
2121
2142
  });
2122
2143
  } finally {
2123
- unloadEmbedding();
2124
2144
  closeKnowledgeDb();
2125
2145
  lock.release();
2126
2146
  }
@@ -2988,6 +3008,7 @@ var AuditReportSchema = z.object({
2988
3008
  });
2989
3009
 
2990
3010
  // src/commands/knowledge.ts
3011
+ init_embeddings();
2991
3012
  init_sqlite_knowledge();
2992
3013
 
2993
3014
  // src/commands/knowledge-index.ts
@@ -2998,6 +3019,7 @@ init_sqlite_knowledge();
2998
3019
  init_embeddings();
2999
3020
  init_search2();
3000
3021
  init_storage();
3022
+ init_embeddings();
3001
3023
  init_storage();
3002
3024
  init_search2();
3003
3025