@jmanuelcorral/openteam 0.1.37 → 0.1.40

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 (84) hide show
  1. package/.opencode/command/openteam.md +5 -5
  2. package/AGENTS.md +27 -27
  3. package/README.es.md +759 -0
  4. package/README.md +213 -480
  5. package/dist/capabilities/types.d.ts +1 -1
  6. package/dist/cli/consoleServe.d.ts.map +1 -1
  7. package/dist/cli/setupAdapters.d.ts.map +1 -1
  8. package/dist/cli.js +1122 -250
  9. package/dist/commands/frontierCatalog.d.ts +27 -0
  10. package/dist/commands/frontierCatalog.d.ts.map +1 -0
  11. package/dist/commands/orchestratorAgent.d.ts +2 -1
  12. package/dist/commands/orchestratorAgent.d.ts.map +1 -1
  13. package/dist/commands/setup.d.ts +16 -18
  14. package/dist/commands/setup.d.ts.map +1 -1
  15. package/dist/config/schema.d.ts +196 -0
  16. package/dist/config/schema.d.ts.map +1 -1
  17. package/dist/console/assets.d.ts +9 -0
  18. package/dist/console/assets.d.ts.map +1 -0
  19. package/dist/console/render.d.ts.map +1 -1
  20. package/dist/contract/opencode.d.ts +1 -1
  21. package/dist/contract/opencode.d.ts.map +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +835 -87
  24. package/dist/local/embeddings.d.ts +29 -0
  25. package/dist/local/embeddings.d.ts.map +1 -0
  26. package/dist/local/extractClient.d.ts +31 -0
  27. package/dist/local/extractClient.d.ts.map +1 -0
  28. package/dist/local/openai-compatible.d.ts +1 -0
  29. package/dist/local/openai-compatible.d.ts.map +1 -1
  30. package/dist/mcp/semanticRecall.d.ts +25 -0
  31. package/dist/mcp/semanticRecall.d.ts.map +1 -0
  32. package/dist/mcp/server.d.ts +22 -0
  33. package/dist/mcp/server.d.ts.map +1 -1
  34. package/dist/memory/consolidate.d.ts +21 -0
  35. package/dist/memory/consolidate.d.ts.map +1 -0
  36. package/dist/memory/extract.d.ts +68 -0
  37. package/dist/memory/extract.d.ts.map +1 -0
  38. package/dist/memory/fold.d.ts +24 -0
  39. package/dist/memory/fold.d.ts.map +1 -0
  40. package/dist/memory/index.d.ts +18 -0
  41. package/dist/memory/index.d.ts.map +1 -0
  42. package/dist/memory/inject.d.ts +29 -0
  43. package/dist/memory/inject.d.ts.map +1 -0
  44. package/dist/memory/log.d.ts +16 -0
  45. package/dist/memory/log.d.ts.map +1 -0
  46. package/dist/memory/merge.d.ts +38 -0
  47. package/dist/memory/merge.d.ts.map +1 -0
  48. package/dist/memory/rank.d.ts +32 -0
  49. package/dist/memory/rank.d.ts.map +1 -0
  50. package/dist/memory/recall.d.ts +30 -0
  51. package/dist/memory/recall.d.ts.map +1 -0
  52. package/dist/memory/temporal.d.ts +39 -0
  53. package/dist/memory/temporal.d.ts.map +1 -0
  54. package/dist/memory/types.d.ts +159 -0
  55. package/dist/memory/types.d.ts.map +1 -0
  56. package/dist/memory/vector.d.ts +18 -0
  57. package/dist/memory/vector.d.ts.map +1 -0
  58. package/dist/orchestrator/roles.d.ts +1 -1
  59. package/dist/orchestrator/roles.d.ts.map +1 -1
  60. package/dist/plugin/hooks.d.ts +13 -0
  61. package/dist/plugin/hooks.d.ts.map +1 -1
  62. package/dist/plugin/memoryInject.d.ts +25 -0
  63. package/dist/plugin/memoryInject.d.ts.map +1 -0
  64. package/dist/router/chooseModel.d.ts.map +1 -1
  65. package/dist/router/cost.d.ts +4 -0
  66. package/dist/router/cost.d.ts.map +1 -0
  67. package/dist/router/frontierBaseline.d.ts +13 -0
  68. package/dist/router/frontierBaseline.d.ts.map +1 -0
  69. package/dist/router/modelSelection.d.ts +18 -0
  70. package/dist/router/modelSelection.d.ts.map +1 -0
  71. package/dist/storage/index/memoryConsolidate.d.ts +24 -0
  72. package/dist/storage/index/memoryConsolidate.d.ts.map +1 -0
  73. package/dist/storage/index/memoryIndex.d.ts +52 -0
  74. package/dist/storage/index/memoryIndex.d.ts.map +1 -0
  75. package/dist/storage/index/memoryRecall.d.ts +23 -0
  76. package/dist/storage/index/memoryRecall.d.ts.map +1 -0
  77. package/dist/storage/index/memoryRuntime.d.ts +41 -0
  78. package/dist/storage/index/memoryRuntime.d.ts.map +1 -0
  79. package/dist/telemetry/events.d.ts +3 -1
  80. package/dist/telemetry/events.d.ts.map +1 -1
  81. package/dist/telemetry/hash.d.ts.map +1 -1
  82. package/dist/web/server.d.ts +4 -0
  83. package/dist/web/server.d.ts.map +1 -1
  84. package/package.json +14 -6
@@ -0,0 +1,159 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Modelo de memoria semántica de openteam (capa **long-term**). Tipos puros
4
+ * validados con Zod. Módulo puro: **sin I/O, red, reloj, random ni env vars** —
5
+ * los timestamps (epoch ms) los inyecta el productor, igual que en
6
+ * `telemetry/events.ts`.
7
+ *
8
+ * Privacidad: por defecto la memoria guarda estructura redactada + `sourceHash`
9
+ * (provenance), **nunca** el prompt crudo. El contenido literal (`object`,
10
+ * `preference`, `canonicalName`) solo se persiste si el proyecto activa
11
+ * `memory.semantic.storeContent`.
12
+ *
13
+ * Modelo **bitemporal** (inspirado en agent-memory-dotnet, simplificado):
14
+ * - valid-time (`validFrom`/`validUntil`): cuándo es cierto en el mundo modelado.
15
+ * - transaction-time (`createdAt`/`invalidatedAt`): cuándo lo creyó el sistema.
16
+ * La supersesión es **no destructiva**: el perdedor se marca `invalidatedAt` y
17
+ * apunta al ganador con `supersededBy`.
18
+ */
19
+ export declare const MEMORY_SCHEMA_VERSION: 1;
20
+ /**
21
+ * Clave de propietario (scope de proyecto o usuario). El sentinela
22
+ * `SHARED_OWNER_KEY` representa memoria compartida/global (visible por cualquier
23
+ * owner cuando el recall pide `includeShared`).
24
+ */
25
+ export declare const SHARED_OWNER_KEY: "*";
26
+ export declare const OwnerKeySchema: z.ZodString;
27
+ export declare const MemoryKindSchema: z.ZodEnum<{
28
+ fact: "fact";
29
+ preference: "preference";
30
+ entity: "entity";
31
+ }>;
32
+ /** Hecho estructurado como triple sujeto-predicado-objeto (dueño-scoped). */
33
+ export declare const FactSchema: z.ZodObject<{
34
+ id: z.ZodString;
35
+ ownerKey: z.ZodString;
36
+ confidence: z.ZodNumber;
37
+ validFrom: z.ZodNumber;
38
+ validUntil: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
39
+ createdAt: z.ZodNumber;
40
+ invalidatedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
41
+ sourceHash: z.ZodString;
42
+ supersededBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
43
+ kind: z.ZodLiteral<"fact">;
44
+ subject: z.ZodString;
45
+ predicate: z.ZodString;
46
+ object: z.ZodString;
47
+ category: z.ZodDefault<z.ZodNullable<z.ZodString>>;
48
+ }, z.core.$strip>;
49
+ /** Preferencia del usuario/proyecto en una categoría. */
50
+ export declare const PreferenceSchema: z.ZodObject<{
51
+ id: z.ZodString;
52
+ ownerKey: z.ZodString;
53
+ confidence: z.ZodNumber;
54
+ validFrom: z.ZodNumber;
55
+ validUntil: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
56
+ createdAt: z.ZodNumber;
57
+ invalidatedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
58
+ sourceHash: z.ZodString;
59
+ supersededBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
60
+ kind: z.ZodLiteral<"preference">;
61
+ category: z.ZodString;
62
+ preference: z.ZodString;
63
+ context: z.ZodDefault<z.ZodNullable<z.ZodString>>;
64
+ lastAccessedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
65
+ accessCount: z.ZodDefault<z.ZodNumber>;
66
+ }, z.core.$strip>;
67
+ /** Entidad canónica (persona/objeto/lugar/evento/organización). */
68
+ export declare const EntitySchema: z.ZodObject<{
69
+ id: z.ZodString;
70
+ ownerKey: z.ZodString;
71
+ confidence: z.ZodNumber;
72
+ validFrom: z.ZodNumber;
73
+ validUntil: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
74
+ createdAt: z.ZodNumber;
75
+ invalidatedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
76
+ sourceHash: z.ZodString;
77
+ supersededBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
78
+ kind: z.ZodLiteral<"entity">;
79
+ canonicalName: z.ZodString;
80
+ type: z.ZodString;
81
+ aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
82
+ }, z.core.$strip>;
83
+ export declare const MemoryRecordSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
84
+ id: z.ZodString;
85
+ ownerKey: z.ZodString;
86
+ confidence: z.ZodNumber;
87
+ validFrom: z.ZodNumber;
88
+ validUntil: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
89
+ createdAt: z.ZodNumber;
90
+ invalidatedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
91
+ sourceHash: z.ZodString;
92
+ supersededBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
93
+ kind: z.ZodLiteral<"fact">;
94
+ subject: z.ZodString;
95
+ predicate: z.ZodString;
96
+ object: z.ZodString;
97
+ category: z.ZodDefault<z.ZodNullable<z.ZodString>>;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ id: z.ZodString;
100
+ ownerKey: z.ZodString;
101
+ confidence: z.ZodNumber;
102
+ validFrom: z.ZodNumber;
103
+ validUntil: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
104
+ createdAt: z.ZodNumber;
105
+ invalidatedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
106
+ sourceHash: z.ZodString;
107
+ supersededBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
108
+ kind: z.ZodLiteral<"preference">;
109
+ category: z.ZodString;
110
+ preference: z.ZodString;
111
+ context: z.ZodDefault<z.ZodNullable<z.ZodString>>;
112
+ lastAccessedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
113
+ accessCount: z.ZodDefault<z.ZodNumber>;
114
+ }, z.core.$strip>, z.ZodObject<{
115
+ id: z.ZodString;
116
+ ownerKey: z.ZodString;
117
+ confidence: z.ZodNumber;
118
+ validFrom: z.ZodNumber;
119
+ validUntil: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
120
+ createdAt: z.ZodNumber;
121
+ invalidatedAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
122
+ sourceHash: z.ZodString;
123
+ supersededBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
124
+ kind: z.ZodLiteral<"entity">;
125
+ canonicalName: z.ZodString;
126
+ type: z.ZodString;
127
+ aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
128
+ }, z.core.$strip>], "kind">;
129
+ /** Consulta de recall (dueño-scoped, temporal y semántica). */
130
+ export declare const RecallQuerySchema: z.ZodObject<{
131
+ ownerKey: z.ZodString;
132
+ kinds: z.ZodDefault<z.ZodArray<z.ZodEnum<{
133
+ fact: "fact";
134
+ preference: "preference";
135
+ entity: "entity";
136
+ }>>>;
137
+ asOf: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
138
+ limit: z.ZodDefault<z.ZodNumber>;
139
+ minSimilarity: z.ZodDefault<z.ZodNumber>;
140
+ includeShared: z.ZodDefault<z.ZodBoolean>;
141
+ }, z.core.$strip>;
142
+ export type MemoryKind = z.infer<typeof MemoryKindSchema>;
143
+ export type Fact = z.infer<typeof FactSchema>;
144
+ export type Preference = z.infer<typeof PreferenceSchema>;
145
+ export type Entity = z.infer<typeof EntitySchema>;
146
+ export type MemoryRecord = z.infer<typeof MemoryRecordSchema>;
147
+ export type RecallQuery = z.infer<typeof RecallQuerySchema>;
148
+ /** Vector de embedding (dimensiones configurables). */
149
+ export type Embedding = readonly number[];
150
+ /** Candidato de recall con su similitud ya calculada. */
151
+ export type RecallCandidate = {
152
+ record: MemoryRecord;
153
+ similarity: number;
154
+ };
155
+ /** Resultado de recall rankeado (similitud + score combinado). */
156
+ export type RecallResult = RecallCandidate & {
157
+ score: number;
158
+ };
159
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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G,SAAS,MAAM,EAAE,CAAC;AAE1C,yDAAyD;AACzD,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Embedding } from "./types";
2
+ /**
3
+ * Álgebra vectorial **pura y determinista** para el recall semántico. Sin I/O ni
4
+ * dependencias nativas: implementa el motor por defecto de `VectorIndex`
5
+ * (ADR-3). Un adapter `sqlite-vec` podrá sustituirlo detrás de la misma interfaz
6
+ * para volúmenes altos, pero la semántica de similitud vive aquí.
7
+ */
8
+ /** Producto escalar. Lanza si las dimensiones no coinciden (invariante de datos). */
9
+ export declare function dot(a: Embedding, b: Embedding): number;
10
+ /** Norma euclídea (L2). */
11
+ export declare function norm(a: Embedding): number;
12
+ /**
13
+ * Similitud coseno en `[-1, 1]`. Devuelve `0` si algún vector es nulo (norma 0),
14
+ * evitando divisiones por cero. El recall filtra por `minSimilarity`, así que los
15
+ * valores negativos (disimilares) quedan naturalmente excluidos.
16
+ */
17
+ export declare function cosineSimilarity(a: Embedding, b: Embedding): number;
18
+ //# sourceMappingURL=vector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../src/memory/vector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AAEH,qFAAqF;AACrF,wBAAgB,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAStD;AAED,2BAA2B;AAC3B,wBAAgB,IAAI,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAOzC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAMnE"}
@@ -34,7 +34,7 @@ export declare const AgentRoleProfileSchema: z.ZodObject<{
34
34
  }, z.core.$strip>, z.ZodLiteral<"auto">]>>;
35
35
  localFirst: z.ZodBoolean;
36
36
  }, z.core.$strip>;
37
- export declare const SQUAD_ROLES: Record<string, AgentRoleProfile>;
37
+ export declare const TEAM_ROLES: Record<string, AgentRoleProfile>;
38
38
  export declare function getRoleProfile(roleID: string): AgentRoleProfile | undefined;
39
39
  export declare function roleToRequirement(role: AgentRoleProfile, task: TaskSignals, tier?: ComplexityTier): CapabilityRequirement;
40
40
  //# sourceMappingURL=roles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/orchestrator/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,cAAc,CAAC;IAC5B,gBAAgB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,kBAAkB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,yBAAyB,EAAE,OAAO,CAAC;IACnC,oBAAoB,EAAE,cAAc,EAAE,CAAC;IACvC,uBAAuB,EAAE,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,CAAC;IACxD,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAeF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;iBAYjC,CAAC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E;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,WAAW,EACjB,IAAI,CAAC,EAAE,cAAc,GACpB,qBAAqB,CAevB"}
@@ -7,8 +7,21 @@ export type ChatMessageHook = NonNullable<Hooks["chat.message"]>;
7
7
  export type ChatMessageHookOptions = {
8
8
  sink?: EventSink;
9
9
  now?: () => number;
10
+ /**
11
+ * Inyección de memoria M6 (opt-in). Dado el texto del prompt, devuelve un bloque
12
+ * de contexto a **prepender** al primer part de texto, o `null` para no inyectar.
13
+ * Se invoca **después** de elegir modelo y emitir telemetría, de modo que no
14
+ * altera el determinismo del router ni el hash del prompt.
15
+ */
16
+ injectMemory?: (queryText: string) => Promise<string | null>;
10
17
  };
11
18
  export declare function deriveTaskSignals(input: Parameters<ChatMessageHook>[0], output: Parameters<ChatMessageHook>[1]): TaskSignals;
19
+ /**
20
+ * Prepend el bloque de memoria al primer part de texto del mensaje. Devuelve
21
+ * `true` si inyectó. No añade parts nuevos (superficie de contrato acotada:
22
+ * mutar `text` de un part existente), y es un no-op si no hay part de texto.
23
+ */
24
+ export declare function injectMemoryBlock(output: Parameters<ChatMessageHook>[1], block: string): boolean;
12
25
  export declare function createChatMessageHook(config: OpenTeamConfig, getAvailable: AvailabilityProvider, options?: ChatMessageHookOptions): ChatMessageHook;
13
26
  export declare function createHooks(config: OpenTeamConfig, getAvailable: AvailabilityProvider, options?: ChatMessageHookOptions): Hooks;
14
27
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/plugin/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAGL,KAAK,SAAS,E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MAAM,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9D,CAAC;AA8CF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EACrC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GACrC,WAAW,CAqBb;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EACtC,KAAK,EAAE,MAAM,GACZ,OAAO,CAQT;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,oBAAoB,EAClC,OAAO,GAAE,sBAA2B,GACnC,eAAe,CA+CjB;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,oBAAoB,EAClC,OAAO,GAAE,sBAA2B,GACnC,KAAK,CAIP"}
@@ -0,0 +1,25 @@
1
+ import type { Embedder } from "../local/embeddings";
2
+ import { type MemoryInjectionParams } from "../memory/inject";
3
+ import type { MemoryIndex } from "../storage/index/memoryIndex";
4
+ /**
5
+ * Compone el callback `injectMemory` de M6 (push a `chat.message`) a partir del
6
+ * índice de memoria, un `Embedder` local y la política de recall/inyección.
7
+ * Aísla el wiring para que `index.ts` sea un caller fino y esto quede cubierto
8
+ * por tests. El único I/O es el embedding de la query (dentro de `recallMemory`);
9
+ * el formateo del bloque es puro (`buildMemoryBlock`).
10
+ */
11
+ export type MemoryInjectorDeps = {
12
+ index: MemoryIndex;
13
+ embedder: Embedder;
14
+ /** Reloj inyectado (epoch ms) para el `asOf` "ahora". */
15
+ now: () => number;
16
+ };
17
+ export type MemoryInjectorPolicy = {
18
+ ownerKey: string;
19
+ minSimilarity: number;
20
+ maxResults: number;
21
+ includeShared: boolean;
22
+ injection: MemoryInjectionParams;
23
+ };
24
+ export declare function buildMemoryInjector(deps: MemoryInjectorDeps, policy: MemoryInjectorPolicy): (queryText: string) => Promise<string | null>;
25
+ //# sourceMappingURL=memoryInject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryInject.d.ts","sourceRoot":"","sources":["../../src/plugin/memoryInject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGhE;;;;;;GAMG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,yDAAyD;IACzD,GAAG,EAAE,MAAM,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,qBAAqB,CAAC;CAClC,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,oBAAoB,GAC3B,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAe/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"chooseModel.d.ts","sourceRoot":"","sources":["../../src/router/chooseModel.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAIV,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAoXjB,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CA8HhE"}
1
+ {"version":3,"file":"chooseModel.d.ts","sourceRoot":"","sources":["../../src/router/chooseModel.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIV,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAsMjB,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CA8HhE"}
@@ -0,0 +1,4 @@
1
+ import type { ModelSelection, RoutingInput } from "./types";
2
+ export declare function estimatedCostUSD(input: RoutingInput, model: ModelSelection): number;
3
+ export declare function roundUSD(value: number): number;
4
+ //# sourceMappingURL=cost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/router/cost.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAW5D,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,cAAc,GACpB,MAAM,CAcR;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C"}
@@ -0,0 +1,13 @@
1
+ import type { ComplexityTier } from "../capabilities/types";
2
+ import type { ModelSelection, RoutingInput } from "./types";
3
+ /**
4
+ * Resolución pura del baseline frontier (cheapest-capable o pinned). Vive
5
+ * separada del resto del router para aislar la dependencia del catálogo de
6
+ * capacidades. Sin I/O ni estado.
7
+ */
8
+ export type FrontierResolution = {
9
+ model: ModelSelection;
10
+ rationale: string[];
11
+ };
12
+ export declare function resolveFrontierBaseline(input: RoutingInput, tier: ComplexityTier): FrontierResolution;
13
+ //# sourceMappingURL=frontierBaseline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontierBaseline.d.ts","sourceRoot":"","sources":["../../src/router/frontierBaseline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;GAIG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,cAAc,GACnB,kBAAkB,CA4BpB"}
@@ -0,0 +1,18 @@
1
+ import type { ModelRef, OpenTeamConfig } from "../config/schema";
2
+ import type { AvailableModel, ModelSelection, RoutingInput } from "./types";
3
+ /**
4
+ * Utilidades puras de selección de modelos para el router: identidad,
5
+ * comparación, deduplicación y resolución de los modelos disponibles.
6
+ * Sin I/O, sin reloj, sin aleatoriedad — igual que el resto de `router/`.
7
+ */
8
+ export declare function modelKey(model: ModelSelection): string;
9
+ export declare function sameModel(left: ModelRef, right: ModelSelection): boolean;
10
+ export declare function compareModels(left: ModelSelection, right: ModelSelection): number;
11
+ export declare function uniqueModelSelections(models: ModelSelection[]): ModelSelection[];
12
+ export declare function localDefault(config: OpenTeamConfig): ModelSelection;
13
+ export declare function resolveConfiguredFrontierBaseline(config: OpenTeamConfig): ModelSelection;
14
+ export declare function availableModels(input: RoutingInput): AvailableModel[];
15
+ export declare function listedModel(input: RoutingInput, model: ModelSelection): AvailableModel | undefined;
16
+ export declare function frontierAvailable(input: RoutingInput, model: ModelSelection): boolean;
17
+ export declare function availableLocalFallbacks(input: RoutingInput, selected: ModelSelection): ModelSelection[];
18
+ //# sourceMappingURL=modelSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelSelection.d.ts","sourceRoot":"","sources":["../../src/router/modelSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;GAIG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAEtD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAExE;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,cAAc,GACpB,MAAM,CAER;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EAAE,GACvB,cAAc,EAAE,CAQlB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAKnE;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,cAAc,GACrB,cAAc,CAShB;AAwBD,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,cAAc,EAAE,CAIrE;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,cAAc,GACpB,cAAc,GAAG,SAAS,CAI5B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,cAAc,GACpB,OAAO,CAET;AAaD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACvB,cAAc,EAAE,CAUlB"}
@@ -0,0 +1,24 @@
1
+ import { type DecayParams } from "../../memory";
2
+ import type { StorageProvider } from "../provider";
3
+ /**
4
+ * Orquestación **I/O** de la consolidación (M5): lee el log de memoria, repliega
5
+ * el estado vigente, computa los tombstones por decay (núcleo puro `consolidate`)
6
+ * y los **anexa** al log append-only. El índice SQLite se reconstruye después
7
+ * (derivado); aquí solo se toca el log, la fuente de verdad.
8
+ *
9
+ * Idempotente: una segunda pasada sin cambios de reloj no produce tombstones
10
+ * nuevos (los ya invalidados se ignoran). Todo el determinismo vive en el core;
11
+ * el único I/O es leer/anexar el log vía el `StorageProvider` inyectado.
12
+ */
13
+ export type ConsolidateMemoryDeps = {
14
+ storage: StorageProvider;
15
+ /** Instante de consolidación (epoch ms). */
16
+ now: number;
17
+ params?: DecayParams;
18
+ };
19
+ export type ConsolidationResult = {
20
+ /** Records olvidados (soft-invalidated) en esta pasada. */
21
+ forgotten: number;
22
+ };
23
+ export declare function runConsolidation(logPath: string, deps: ConsolidateMemoryDeps): Promise<ConsolidationResult>;
24
+ //# sourceMappingURL=memoryConsolidate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryConsolidate.d.ts","sourceRoot":"","sources":["../../../src/storage/index/memoryConsolidate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,WAAW,EAIjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;GASG;AAEH,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,eAAe,CAAC;IACzB,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAW9B"}
@@ -0,0 +1,52 @@
1
+ import { type MemoryState } from "../../memory/fold";
2
+ import { type Embedding, type MemoryRecord } from "../../memory/types";
3
+ import type { StorageProvider } from "../provider";
4
+ import type { SqliteDatabase } from "./sqliteIndex";
5
+ /**
6
+ * Índice SQLite **derivado** del log de memoria (`records.jsonl`). No es fuente de
7
+ * verdad: `rebuild` repliega las aserciones (vía `foldAssertions`) y materializa
8
+ * el estado vigente + histórico. Si el fichero se corrompe o se borra, se
9
+ * reconstruye desde el log sin pérdida.
10
+ *
11
+ * Los **embeddings** (M3) se persisten en una tabla aparte, keyed por `record.id`.
12
+ * A diferencia de los records, no son reconstruibles desde el log (el texto fuente
13
+ * no se persiste por privacidad): son un store derivado que requiere re-embedding.
14
+ *
15
+ * El driver SQLite se inyecta como `SqliteDatabase` (compatible con `bun:sqlite`),
16
+ * igual que `sqliteIndex.ts`, para no acoplar este módulo a un runtime concreto.
17
+ */
18
+ /** Embedding asociado a un record (por `recordId`). */
19
+ export type EmbeddingEntry = {
20
+ recordId: string;
21
+ vector: Embedding;
22
+ };
23
+ export type MemoryIndex = {
24
+ /** Vacía y repuebla el índice replegando `assertions` (derivado). */
25
+ rebuild: (assertions: readonly MemoryRecord[]) => void;
26
+ /** Todos los records materializados (vigentes + invalidados), orden estable. */
27
+ allRecords: () => MemoryRecord[];
28
+ /** Estado particionado por kind. */
29
+ state: () => MemoryState;
30
+ /** Records recuperables (bitemporalmente activos) en `asOf`. */
31
+ activeAt: (asOf: number) => MemoryRecord[];
32
+ /** Persiste (upsert) embeddings por `recordId`. */
33
+ putEmbeddings: (entries: readonly EmbeddingEntry[]) => void;
34
+ /** Mapa `recordId -> vector` para alimentar el recall puro. */
35
+ embeddingMap: () => Map<string, Embedding>;
36
+ /** Elimina embeddings huérfanos (sin record). Devuelve cuántos borró. */
37
+ pruneEmbeddings: () => number;
38
+ /** Cierra la conexión subyacente. */
39
+ close: () => void;
40
+ };
41
+ /** Crea el índice sobre una base de datos ya abierta y asegura el esquema. */
42
+ export declare function createMemoryIndex(db: SqliteDatabase): MemoryIndex;
43
+ export type RebuildMemoryDeps = {
44
+ storage: StorageProvider;
45
+ };
46
+ /**
47
+ * Reconstruye el índice desde el log de memoria leído por el `StorageProvider`.
48
+ * Devuelve el número de aserciones replegadas. Es la operación de "regenerar"
49
+ * tras un borrado del índice.
50
+ */
51
+ export declare function rebuildMemoryIndexFromStorage(index: MemoryIndex, logPath: string, deps: RebuildMemoryDeps): Promise<number>;
52
+ //# sourceMappingURL=memoryIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryIndex.d.ts","sourceRoot":"","sources":["../../../src/storage/index/memoryIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW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AAC,MAAM,CAAC,CAKjB"}
@@ -0,0 +1,23 @@
1
+ import type { Embedder } from "../../local/embeddings";
2
+ import type { RankSignals } from "../../memory/rank";
3
+ import type { RecallQuery, RecallResult } from "../../memory/types";
4
+ import type { MemoryIndex } from "./memoryIndex";
5
+ /**
6
+ * Orquestación de recall semántico: embebe el texto de consulta con el
7
+ * `Embedder` local inyectado y delega el ranking al `recall` **puro** sobre los
8
+ * records + embeddings materializados en el índice. El core determinista no toca
9
+ * red; el único I/O es el embedding de la query.
10
+ */
11
+ export type RecallMemoryDeps = {
12
+ index: MemoryIndex;
13
+ embedder: Embedder;
14
+ /** Instante de recall (epoch ms) cuando `query.asOf` es `null`. */
15
+ now: number;
16
+ signals?: Omit<RankSignals, "now">;
17
+ };
18
+ /**
19
+ * Recupera los records más relevantes para `queryText`. Devuelve `[]` si el
20
+ * embedder no produce vector para la consulta.
21
+ */
22
+ export declare function recallMemory(deps: RecallMemoryDeps, queryText: string, query: RecallQuery): Promise<RecallResult[]>;
23
+ //# sourceMappingURL=memoryRecall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryRecall.d.ts","sourceRoot":"","sources":["../../../src/storage/index/memoryRecall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,gBAAgB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC,CAYzB"}
@@ -0,0 +1,41 @@
1
+ import type { MemorySemanticConfig, OpenTeamConfig } from "../../config/schema";
2
+ import { createLocalEmbedder, type Embedder } from "../../local/embeddings";
3
+ import type { StorageProvider } from "../provider";
4
+ import { createBunSqliteDatabase } from "./bunSqlite";
5
+ import { type MemoryIndex } from "./memoryIndex";
6
+ /**
7
+ * Runtime de memoria semántica ya materializado: índice SQLite reconstruido +
8
+ * embedder local + reloj. Es la base común que consumen tanto el recall del MCP
9
+ * (`buildSemanticRecall`) como la inyección M6 (`buildMemoryInjector`), evitando
10
+ * duplicar el wiring de I/O en `cli.ts` e `index.ts`.
11
+ */
12
+ export type MemoryRuntime = {
13
+ index: MemoryIndex;
14
+ embedder: Embedder;
15
+ now: () => number;
16
+ ownerKey: "user" | "project";
17
+ semantic: MemorySemanticConfig;
18
+ };
19
+ export type BuildMemoryRuntimeDeps = {
20
+ storage: StorageProvider;
21
+ fetch?: typeof globalThis.fetch;
22
+ now?: () => number;
23
+ /** Inyectable en tests; por defecto abre `bun:sqlite`. */
24
+ openDatabase?: typeof createBunSqliteDatabase;
25
+ /** Inyectable en tests; por defecto crea el embedder local. */
26
+ createEmbedder?: typeof createLocalEmbedder;
27
+ };
28
+ export type BuildMemoryRuntimeOptions = {
29
+ /** Si `true`, además exige `injection.enabled` (uso de la inyección M6). */
30
+ requireInjectionEnabled?: boolean;
31
+ };
32
+ /**
33
+ * Construye (opt-in) el runtime de memoria semántica a partir de la config. Todo
34
+ * el I/O (SQLite + embeddings) queda aislado aquí. Devuelve `undefined` —
35
+ * degradación segura, sin lanzar— si la memoria semántica está desactivada, si
36
+ * no hay proveedor de embeddings local, si (con `requireInjectionEnabled`) la
37
+ * inyección está desactivada, si no hay runtime local con `baseURL`, o si el
38
+ * índice SQLite no puede abrirse (p. ej. sin `bun:sqlite`).
39
+ */
40
+ export declare function buildMemoryRuntimeFromConfig(config: OpenTeamConfig, deps: BuildMemoryRuntimeDeps, options?: BuildMemoryRuntimeOptions): Promise<MemoryRuntime | undefined>;
41
+ //# sourceMappingURL=memoryRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryRuntime.d.ts","sourceRoot":"","sources":["../../../src/storage/index/memoryRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,OAAO,uBAAuB,CAAC;IAC9C,+DAA+D;IAC/D,cAAc,CAAC,EAAE,OAAO,mBAAmB,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,4EAA4E;IAC5E,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,sBAAsB,EAC5B,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAyCpC"}
@@ -4,7 +4,9 @@ import { z } from "zod";
4
4
  * de estos eventos (JSONL) que el console agrega. Discriminados por `type`.
5
5
  *
6
6
  * Privacidad: **nunca** contienen texto de prompt, argumentos de tool ni salida
7
- * en claro; solo `promptHash`, contadores y resúmenes ya redactados.
7
+ * en claro; solo `promptHash`, contadores y resúmenes ya redactados. La garantía
8
+ * es el **no-almacenamiento** del prompt crudo; `promptHash` es solo un id de
9
+ * correlación no-criptográfico (ver `telemetry/hash.ts`), no una ofuscación.
8
10
  *
9
11
  * Módulo puro: sin I/O, red, reloj, random ni env vars.
10
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/telemetry/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAG,CAAU,CAAC;AAW/C,yEAAyE;AACzE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqB3B,CAAC;AAEH,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;iBAc7B,CAAC;AAEH,sEAAsE;AACtE,eAAO,MAAM,mBAAmB;;;;;;;;;;;iBAS9B,CAAC;AAEH,iEAAiE;AACjE,eAAO,MAAM,kBAAkB;;;;;;;;;iBAM7B,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,mBAAmB;;;;;;;;iBAK9B,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;iBAK9B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B;;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M,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/telemetry/hash.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CASjD"}
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/telemetry/hash.ts"],"names":[],"mappings":"AAmBA,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CASjD"}
@@ -39,6 +39,10 @@ export type ConsoleServer = {
39
39
  * loopback. Sirve `/` (HTML), `/api/state` (JSON), `/events` (SSE) y `/healthz`.
40
40
  * Solo lectura: cualquier método ≠ GET → 405; ruta desconocida → 404. Con
41
41
  * `autoPortFallback` prueba puertos sucesivos si el preferido está ocupado.
42
+ *
43
+ * Cuando se inyecta `storageApi` (exposición remota opt-in), las rutas de lectura
44
+ * (`/`, `/api/state`, `/events`) además exigen token (bearer o `?token=`); sin él
45
+ * → 401. En modo loopback puro (sin `storageApi`) esas rutas quedan abiertas.
42
46
  */
43
47
  export declare function createConsoleServer(deps: ConsoleServerDeps): Promise<ConsoleServer>;
44
48
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/web/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,gBAAgB,EAIjC,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAW3E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iEAAiE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AE,MAAM,kBAAkB,CAAC;AAItD,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAW3E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iEAAiE;IACjE,YAAY,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,EAAE,aAAa,CAAC;IACtB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,gBAAgB,CAAC;IACvC,sCAAsC;IACtC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,8EAA8E;IAC9E,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,OAAO,CAAC;QACzB,+DAA+D;QAC/D,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,aAAa,CAAC;QAClD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,SAAS,CAAC;KACnD,CAAC;IACF;;;OAGG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAmFF;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,aAAa,CAAC,CA2JxB"}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@jmanuelcorral/openteam",
3
- "version": "0.1.37",
4
- "description": "Plugin opencode de routing coste-consciente local-first con orquestación Squad.",
3
+ "version": "0.1.40",
4
+ "packageManager": "bun@1.3.14",
5
+ "description": "Cost-aware, local-first routing plugin for opencode with cheapest-capable frontier fallback and multi-agent orchestration.",
5
6
  "license": "MIT",
6
7
  "author": "Jose Manuel Corral",
7
8
  "repository": {
@@ -22,11 +23,11 @@
22
23
  "lm-studio",
23
24
  "foundry-local",
24
25
  "cost-optimization",
25
- "squad"
26
+ "multi-agent"
26
27
  ],
27
28
  "engines": {
28
29
  "bun": ">=1.3",
29
- "node": ">=20"
30
+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
30
31
  },
31
32
  "type": "module",
32
33
  "main": "./dist/index.js",
@@ -51,8 +52,10 @@
51
52
  ".opencode/command/openteam.md"
52
53
  ],
53
54
  "publishConfig": {
54
- "access": "public"
55
+ "access": "public",
56
+ "registry": "https://registry.npmjs.org/"
55
57
  },
58
+ "trustedDependencies": [],
56
59
  "sideEffects": false,
57
60
  "scripts": {
58
61
  "prebuild": "bun run clean",
@@ -63,12 +66,17 @@
63
66
  "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
64
67
  "test": "bun test",
65
68
  "test:cov": "bun test --coverage",
69
+ "coverage:check": "node scripts/check-coverage.mjs",
66
70
  "typecheck": "tsc --noEmit",
67
71
  "lint": "biome check .",
68
72
  "format:check": "biome format .",
73
+ "docs:install": "cd docs && bun install --frozen-lockfile --ignore-scripts",
74
+ "docs:dev": "cd docs && bun run docs:dev",
75
+ "docs:build": "cd docs && bun run docs:build",
76
+ "docs:preview": "cd docs && bun run docs:preview",
69
77
  "prepublishOnly": "bun run build",
70
78
  "link:local": "bun run build && npm link",
71
- "prepare": "node -e \"try{require('node:child_process').execSync('git config core.hooksPath .githooks',{stdio:'ignore'})}catch{}\""
79
+ "hooks:install": "git config core.hooksPath .githooks"
72
80
  },
73
81
  "dependencies": {
74
82
  "@clack/prompts": "1.7.0",