oh-my-opencode-kikokikok 2.15.2 → 2.15.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/cli/index.js CHANGED
@@ -2253,7 +2253,7 @@ var require_picocolors = __commonJS((exports, module) => {
2253
2253
  var require_package = __commonJS((exports, module) => {
2254
2254
  module.exports = {
2255
2255
  name: "oh-my-opencode-kikokikok",
2256
- version: "2.15.2",
2256
+ version: "2.15.4",
2257
2257
  description: "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
2258
2258
  main: "dist/index.js",
2259
2259
  types: "dist/index.d.ts",
@@ -3,7 +3,10 @@ export declare class LettaAdapter {
3
3
  private config;
4
4
  private endpoint;
5
5
  private agentCache;
6
+ private detectedEmbeddingModel;
7
+ private modelDetectionPromise;
6
8
  constructor(config: LettaConfig);
9
+ private detectEmbeddingModel;
7
10
  add(input: AddMemoryInput): Promise<Memory>;
8
11
  search(input: SearchMemoryInput): Promise<MemorySearchResult[]>;
9
12
  get(id: string): Promise<Memory | null>;
@@ -13,6 +16,8 @@ export declare class LettaAdapter {
13
16
  getStats(): Promise<MemoryStats>;
14
17
  isAvailable(): Promise<boolean>;
15
18
  private getOrCreateAgent;
19
+ private agentNeedsEmbeddingUpdate;
20
+ private recreateAgentWithCorrectEmbedding;
16
21
  private getAgent;
17
22
  private listAgents;
18
23
  private request;
@@ -26,8 +26,25 @@ export interface LettaConfig {
26
26
  agentPrefix?: string;
27
27
  /** LLM model for agent (e.g., "openai/gpt-4.1") */
28
28
  llmModel?: string;
29
- /** Embedding model for semantic search */
29
+ /**
30
+ * Embedding model for semantic search.
31
+ * Use format "provider/model" e.g.:
32
+ * - "openai/text-embedding-3-large" (best quality, 3072 dimensions)
33
+ * - "openai/text-embedding-3-small" (good balance, 1536 dimensions)
34
+ * - "openai/text-embedding-ada-002" (legacy)
35
+ * - "letta/letta-free" (default, requires Letta cloud auth)
36
+ *
37
+ * If not set, auto-detects local proxy models with "openai" provider.
38
+ */
30
39
  embeddingModel?: string;
40
+ /**
41
+ * Preferred embedding model for auto-detection.
42
+ * When embeddingModel is not set and multiple proxy models are available,
43
+ * this determines which one to prefer. Partial match on model name.
44
+ * Default: "text-embedding-3-small"
45
+ * Set to "text-embedding-3-large" for better quality.
46
+ */
47
+ preferredEmbeddingModel?: string;
31
48
  /** Auto-rehydrate memories on session start */
32
49
  autoRehydrate?: boolean;
33
50
  /** Layers to rehydrate */
@@ -43,6 +60,12 @@ export interface LettaAgent {
43
60
  metadata?: Record<string, unknown>;
44
61
  memory_blocks?: LettaBlock[];
45
62
  tools?: string[];
63
+ embedding?: string;
64
+ embedding_config?: {
65
+ handle?: string;
66
+ embedding_model?: string;
67
+ embedding_endpoint?: string;
68
+ };
46
69
  }
47
70
  /** Letta Memory Block (Core Memory - always in-context) */
48
71
  export interface LettaBlock {
@@ -131,9 +154,16 @@ export interface LettaApiResponse<T> {
131
154
  error?: string;
132
155
  message?: string;
133
156
  }
157
+ /** Letta search result item (different from passage) */
158
+ export interface LettaSearchResultItem {
159
+ timestamp: string;
160
+ content: string;
161
+ tags?: string[];
162
+ }
163
+ /** Letta search response */
134
164
  export interface LettaSearchResponse {
135
- passages: LettaPassage[];
136
- total?: number;
165
+ results: LettaSearchResultItem[];
166
+ count: number;
137
167
  }
138
168
  export interface LettaAgentListResponse {
139
169
  agents: LettaAgent[];
package/dist/index.js CHANGED
@@ -43788,10 +43788,46 @@ class LettaAdapter {
43788
43788
  config;
43789
43789
  endpoint;
43790
43790
  agentCache = new Map;
43791
+ detectedEmbeddingModel = null;
43792
+ modelDetectionPromise = null;
43791
43793
  constructor(config3) {
43792
43794
  this.config = config3;
43793
43795
  this.endpoint = config3.endpoint ?? DEFAULT_ENDPOINT2;
43794
43796
  }
43797
+ async detectEmbeddingModel() {
43798
+ if (this.config.embeddingModel) {
43799
+ return this.config.embeddingModel;
43800
+ }
43801
+ if (this.detectedEmbeddingModel) {
43802
+ return this.detectedEmbeddingModel;
43803
+ }
43804
+ if (this.modelDetectionPromise) {
43805
+ await this.modelDetectionPromise;
43806
+ return this.detectedEmbeddingModel ?? DEFAULT_EMBEDDING_MODEL;
43807
+ }
43808
+ this.modelDetectionPromise = (async () => {
43809
+ try {
43810
+ const response2 = await fetch(`${this.endpoint}/v1/models`, {
43811
+ method: "GET",
43812
+ redirect: "follow",
43813
+ signal: AbortSignal.timeout(1e4)
43814
+ });
43815
+ if (!response2.ok) {
43816
+ return;
43817
+ }
43818
+ const models = await response2.json();
43819
+ const proxyEmbeddingModels = models.filter((m) => m.name.includes("embedding") && m.model_endpoint.includes("host.docker.internal") && m.provider_name === "openai");
43820
+ if (proxyEmbeddingModels.length > 0) {
43821
+ const preferredName = this.config.preferredEmbeddingModel ?? "text-embedding-3-small";
43822
+ const preferred = proxyEmbeddingModels.find((m) => m.name.includes(preferredName));
43823
+ const model = preferred ?? proxyEmbeddingModels[0];
43824
+ this.detectedEmbeddingModel = `openai/${model.name}`;
43825
+ }
43826
+ } catch {}
43827
+ })();
43828
+ await this.modelDetectionPromise;
43829
+ return this.detectedEmbeddingModel ?? DEFAULT_EMBEDDING_MODEL;
43830
+ }
43795
43831
  async add(input) {
43796
43832
  if (!this.config.enabled) {
43797
43833
  throw new Error("Letta is not enabled");
@@ -43809,7 +43845,8 @@ class LettaAdapter {
43809
43845
  tags
43810
43846
  })
43811
43847
  });
43812
- const passage = await response2.json();
43848
+ const data = await response2.json();
43849
+ const passage = Array.isArray(data) ? data[0] : data;
43813
43850
  return this.passageToMemory(passage, input.layer, agent.id);
43814
43851
  }
43815
43852
  async search(input) {
@@ -43833,8 +43870,17 @@ class LettaAdapter {
43833
43870
  }
43834
43871
  const response2 = await this.request(`/v1/agents/${agent.id}/archival-memory/search?${params.toString()}`, { method: "GET" });
43835
43872
  const data = await response2.json();
43836
- const layerResults = data.map((passage, index) => ({
43837
- memory: this.passageToMemory(passage, layer, agent.id),
43873
+ const searchResults = data.results ?? [];
43874
+ const layerResults = searchResults.map((item, index) => ({
43875
+ memory: {
43876
+ id: `search-${agent.id}-${item.timestamp}-${index}`,
43877
+ content: item.content,
43878
+ layer,
43879
+ metadata: item.tags ? { tags: item.tags } : undefined,
43880
+ createdAt: item.timestamp,
43881
+ source: "passage",
43882
+ agentId: agent.id
43883
+ },
43838
43884
  score: 1 - index * 0.05
43839
43885
  }));
43840
43886
  results.push(...layerResults);
@@ -43956,15 +44002,60 @@ class LettaAdapter {
43956
44002
  }
43957
44003
  async getOrCreateAgent(layer) {
43958
44004
  const existing = await this.getAgent(layer);
43959
- if (existing)
44005
+ if (existing) {
44006
+ const needsUpdate = await this.agentNeedsEmbeddingUpdate(existing);
44007
+ if (needsUpdate) {
44008
+ return this.recreateAgentWithCorrectEmbedding(existing, layer);
44009
+ }
43960
44010
  return existing;
44011
+ }
44012
+ const embeddingModel = await this.detectEmbeddingModel();
44013
+ const agentName = this.getAgentName(layer);
44014
+ const response2 = await this.request("/v1/agents", {
44015
+ method: "POST",
44016
+ body: JSON.stringify({
44017
+ name: agentName,
44018
+ model: this.config.llmModel ?? DEFAULT_LLM_MODEL,
44019
+ embedding: embeddingModel,
44020
+ memory_blocks: [
44021
+ { label: "persona", value: `OpenCode memory agent for ${layer} layer` },
44022
+ { label: "human", value: this.getUserId(layer) }
44023
+ ],
44024
+ metadata: {
44025
+ layer,
44026
+ user_id: this.getUserId(layer),
44027
+ created_by: "oh-my-opencode"
44028
+ }
44029
+ })
44030
+ });
44031
+ const agent = await response2.json();
44032
+ this.agentCache.set(layer, agent);
44033
+ return agent;
44034
+ }
44035
+ async agentNeedsEmbeddingUpdate(agent) {
44036
+ if (this.config.embeddingModel) {
44037
+ return false;
44038
+ }
44039
+ const embeddingHandle = agent.embedding_config?.handle ?? agent.embedding;
44040
+ if (!embeddingHandle)
44041
+ return false;
44042
+ if (embeddingHandle === "letta/letta-free") {
44043
+ const detected = await this.detectEmbeddingModel();
44044
+ return detected !== "letta/letta-free";
44045
+ }
44046
+ return false;
44047
+ }
44048
+ async recreateAgentWithCorrectEmbedding(existingAgent, layer) {
44049
+ await this.request(`/v1/agents/${existingAgent.id}`, { method: "DELETE" }).catch(() => {});
44050
+ this.agentCache.delete(layer);
44051
+ const embeddingModel = await this.detectEmbeddingModel();
43961
44052
  const agentName = this.getAgentName(layer);
43962
44053
  const response2 = await this.request("/v1/agents", {
43963
44054
  method: "POST",
43964
44055
  body: JSON.stringify({
43965
44056
  name: agentName,
43966
44057
  model: this.config.llmModel ?? DEFAULT_LLM_MODEL,
43967
- embedding: this.config.embeddingModel ?? DEFAULT_EMBEDDING_MODEL,
44058
+ embedding: embeddingModel,
43968
44059
  memory_blocks: [
43969
44060
  { label: "persona", value: `OpenCode memory agent for ${layer} layer` },
43970
44061
  { label: "human", value: this.getUserId(layer) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode-kikokikok",
3
- "version": "2.15.2",
3
+ "version": "2.15.4",
4
4
  "description": "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",