oh-my-opencode-kikokikok 2.15.1 → 2.15.3

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.1",
2256
+ version: "2.15.3",
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;
@@ -43,6 +43,12 @@ export interface LettaAgent {
43
43
  metadata?: Record<string, unknown>;
44
44
  memory_blocks?: LettaBlock[];
45
45
  tools?: string[];
46
+ embedding?: string;
47
+ embedding_config?: {
48
+ handle?: string;
49
+ embedding_model?: string;
50
+ embedding_endpoint?: string;
51
+ };
46
52
  }
47
53
  /** Letta Memory Block (Core Memory - always in-context) */
48
54
  export interface LettaBlock {
package/dist/index.js CHANGED
@@ -43781,17 +43781,51 @@ class Mem0Adapter {
43781
43781
  // src/features/letta-memory/adapter.ts
43782
43782
  var DEFAULT_ENDPOINT2 = "http://localhost:8283";
43783
43783
  var DEFAULT_AGENT_PREFIX = "opencode";
43784
- var DEFAULT_LLM_MODEL = "openai/gpt-4.1";
43785
- var DEFAULT_EMBEDDING_MODEL = "openai/text-embedding-3-small";
43784
+ var DEFAULT_LLM_MODEL = "letta/letta-free";
43785
+ var DEFAULT_EMBEDDING_MODEL = "letta/letta-free";
43786
43786
 
43787
43787
  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 embeddingModels = models.filter((m) => m.name.includes("embedding") && m.model_endpoint.includes("host.docker.internal"));
43820
+ if (embeddingModels.length > 0) {
43821
+ const preferred = embeddingModels.find((m) => m.name.includes("text-embedding-3-small"));
43822
+ this.detectedEmbeddingModel = preferred?.handle ?? embeddingModels[0].handle;
43823
+ }
43824
+ } catch {}
43825
+ })();
43826
+ await this.modelDetectionPromise;
43827
+ return this.detectedEmbeddingModel ?? DEFAULT_EMBEDDING_MODEL;
43828
+ }
43795
43829
  async add(input) {
43796
43830
  if (!this.config.enabled) {
43797
43831
  throw new Error("Letta is not enabled");
@@ -43946,6 +43980,7 @@ class LettaAdapter {
43946
43980
  try {
43947
43981
  const response2 = await fetch(`${this.endpoint}/v1/health`, {
43948
43982
  method: "GET",
43983
+ redirect: "follow",
43949
43984
  signal: AbortSignal.timeout(5000)
43950
43985
  });
43951
43986
  return response2.ok;
@@ -43955,15 +43990,60 @@ class LettaAdapter {
43955
43990
  }
43956
43991
  async getOrCreateAgent(layer) {
43957
43992
  const existing = await this.getAgent(layer);
43958
- if (existing)
43993
+ if (existing) {
43994
+ const needsUpdate = await this.agentNeedsEmbeddingUpdate(existing);
43995
+ if (needsUpdate) {
43996
+ return this.recreateAgentWithCorrectEmbedding(existing, layer);
43997
+ }
43959
43998
  return existing;
43999
+ }
44000
+ const embeddingModel = await this.detectEmbeddingModel();
44001
+ const agentName = this.getAgentName(layer);
44002
+ const response2 = await this.request("/v1/agents", {
44003
+ method: "POST",
44004
+ body: JSON.stringify({
44005
+ name: agentName,
44006
+ model: this.config.llmModel ?? DEFAULT_LLM_MODEL,
44007
+ embedding: embeddingModel,
44008
+ memory_blocks: [
44009
+ { label: "persona", value: `OpenCode memory agent for ${layer} layer` },
44010
+ { label: "human", value: this.getUserId(layer) }
44011
+ ],
44012
+ metadata: {
44013
+ layer,
44014
+ user_id: this.getUserId(layer),
44015
+ created_by: "oh-my-opencode"
44016
+ }
44017
+ })
44018
+ });
44019
+ const agent = await response2.json();
44020
+ this.agentCache.set(layer, agent);
44021
+ return agent;
44022
+ }
44023
+ async agentNeedsEmbeddingUpdate(agent) {
44024
+ if (this.config.embeddingModel) {
44025
+ return false;
44026
+ }
44027
+ const embeddingHandle = agent.embedding_config?.handle ?? agent.embedding;
44028
+ if (!embeddingHandle)
44029
+ return false;
44030
+ if (embeddingHandle === "letta/letta-free") {
44031
+ const detected = await this.detectEmbeddingModel();
44032
+ return detected !== "letta/letta-free";
44033
+ }
44034
+ return false;
44035
+ }
44036
+ async recreateAgentWithCorrectEmbedding(existingAgent, layer) {
44037
+ await this.request(`/v1/agents/${existingAgent.id}`, { method: "DELETE" }).catch(() => {});
44038
+ this.agentCache.delete(layer);
44039
+ const embeddingModel = await this.detectEmbeddingModel();
43960
44040
  const agentName = this.getAgentName(layer);
43961
44041
  const response2 = await this.request("/v1/agents", {
43962
44042
  method: "POST",
43963
44043
  body: JSON.stringify({
43964
44044
  name: agentName,
43965
44045
  model: this.config.llmModel ?? DEFAULT_LLM_MODEL,
43966
- embedding: this.config.embeddingModel ?? DEFAULT_EMBEDDING_MODEL,
44046
+ embedding: embeddingModel,
43967
44047
  memory_blocks: [
43968
44048
  { label: "persona", value: `OpenCode memory agent for ${layer} layer` },
43969
44049
  { label: "human", value: this.getUserId(layer) }
@@ -44010,7 +44090,8 @@ class LettaAdapter {
44010
44090
  const response2 = await fetch(`${this.endpoint}${path7}`, {
44011
44091
  method: options.method,
44012
44092
  headers,
44013
- body: options.body
44093
+ body: options.body,
44094
+ redirect: "follow"
44014
44095
  });
44015
44096
  if (!response2.ok) {
44016
44097
  const text = await response2.text().catch(() => "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode-kikokikok",
3
- "version": "2.15.1",
3
+ "version": "2.15.3",
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",