@jmanuelcorral/openteam 0.1.38 → 0.1.41
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/.opencode/command/openteam.md +5 -5
- package/AGENTS.md +50 -35
- package/README.es.md +759 -0
- package/README.md +213 -480
- package/dist/capabilities/types.d.ts +1 -1
- package/dist/cli/consoleServe.d.ts.map +1 -1
- package/dist/cli.js +1123 -232
- package/dist/commands/frontierCatalog.d.ts +27 -0
- package/dist/commands/frontierCatalog.d.ts.map +1 -0
- package/dist/commands/graph.d.ts +65 -0
- package/dist/commands/graph.d.ts.map +1 -0
- package/dist/commands/orchestratorAgent.d.ts +2 -1
- package/dist/commands/orchestratorAgent.d.ts.map +1 -1
- package/dist/commands/setup.d.ts +3 -18
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/migrations.d.ts +27 -0
- package/dist/config/migrations.d.ts.map +1 -0
- package/dist/config/resolve.d.ts +34 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/schema.d.ts +235 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/console/assets.d.ts +9 -0
- package/dist/console/assets.d.ts.map +1 -0
- package/dist/console/render.d.ts.map +1 -1
- package/dist/context/redaction.d.ts +48 -0
- package/dist/context/redaction.d.ts.map +1 -0
- package/dist/context/schema.d.ts +115 -0
- package/dist/context/schema.d.ts.map +1 -0
- package/dist/context/types.d.ts +8 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/contract/opencode.d.ts +1 -1
- package/dist/contract/opencode.d.ts.map +1 -1
- package/dist/graph/events.d.ts +25 -0
- package/dist/graph/events.d.ts.map +1 -0
- package/dist/graph/ids.d.ts +5 -0
- package/dist/graph/ids.d.ts.map +1 -0
- package/dist/graph/planner.d.ts +15 -0
- package/dist/graph/planner.d.ts.map +1 -0
- package/dist/graph/policies.d.ts +34 -0
- package/dist/graph/policies.d.ts.map +1 -0
- package/dist/graph/privacyPolicy.d.ts +29 -0
- package/dist/graph/privacyPolicy.d.ts.map +1 -0
- package/dist/graph/reducer.d.ts +27 -0
- package/dist/graph/reducer.d.ts.map +1 -0
- package/dist/graph/replay.d.ts +20 -0
- package/dist/graph/replay.d.ts.map +1 -0
- package/dist/graph/reviewerPolicy.d.ts +27 -0
- package/dist/graph/reviewerPolicy.d.ts.map +1 -0
- package/dist/graph/schema.d.ts +220 -0
- package/dist/graph/schema.d.ts.map +1 -0
- package/dist/graph/types.d.ts +40 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/validate.d.ts +19 -0
- package/dist/graph/validate.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +873 -88
- package/dist/local/embeddings.d.ts +29 -0
- package/dist/local/embeddings.d.ts.map +1 -0
- package/dist/local/extractClient.d.ts +31 -0
- package/dist/local/extractClient.d.ts.map +1 -0
- package/dist/local/openai-compatible.d.ts +1 -0
- package/dist/local/openai-compatible.d.ts.map +1 -1
- package/dist/mcp/semanticRecall.d.ts +25 -0
- package/dist/mcp/semanticRecall.d.ts.map +1 -0
- package/dist/mcp/server.d.ts +22 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/memory/consolidate.d.ts +21 -0
- package/dist/memory/consolidate.d.ts.map +1 -0
- package/dist/memory/extract.d.ts +68 -0
- package/dist/memory/extract.d.ts.map +1 -0
- package/dist/memory/fold.d.ts +24 -0
- package/dist/memory/fold.d.ts.map +1 -0
- package/dist/memory/index.d.ts +18 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/inject.d.ts +29 -0
- package/dist/memory/inject.d.ts.map +1 -0
- package/dist/memory/log.d.ts +16 -0
- package/dist/memory/log.d.ts.map +1 -0
- package/dist/memory/merge.d.ts +38 -0
- package/dist/memory/merge.d.ts.map +1 -0
- package/dist/memory/rank.d.ts +32 -0
- package/dist/memory/rank.d.ts.map +1 -0
- package/dist/memory/recall.d.ts +30 -0
- package/dist/memory/recall.d.ts.map +1 -0
- package/dist/memory/temporal.d.ts +39 -0
- package/dist/memory/temporal.d.ts.map +1 -0
- package/dist/memory/types.d.ts +159 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/vector.d.ts +18 -0
- package/dist/memory/vector.d.ts.map +1 -0
- package/dist/orchestrator/graphCancellation.d.ts +84 -0
- package/dist/orchestrator/graphCancellation.d.ts.map +1 -0
- package/dist/orchestrator/graphEffects.d.ts +63 -0
- package/dist/orchestrator/graphEffects.d.ts.map +1 -0
- package/dist/orchestrator/graphReview.d.ts +84 -0
- package/dist/orchestrator/graphReview.d.ts.map +1 -0
- package/dist/orchestrator/graphRuntime.d.ts +69 -0
- package/dist/orchestrator/graphRuntime.d.ts.map +1 -0
- package/dist/orchestrator/opencodeSessionAdapter.d.ts +117 -0
- package/dist/orchestrator/opencodeSessionAdapter.d.ts.map +1 -0
- package/dist/orchestrator/roles.d.ts +1 -1
- package/dist/orchestrator/roles.d.ts.map +1 -1
- package/dist/orchestrator/sdd.d.ts +38 -2
- package/dist/orchestrator/sdd.d.ts.map +1 -1
- package/dist/orchestrator/sddCompiler.d.ts +44 -0
- package/dist/orchestrator/sddCompiler.d.ts.map +1 -0
- package/dist/orchestrator/sessionReconciler.d.ts +74 -0
- package/dist/orchestrator/sessionReconciler.d.ts.map +1 -0
- package/dist/orchestrator/shadowComparator.d.ts +62 -0
- package/dist/orchestrator/shadowComparator.d.ts.map +1 -0
- package/dist/plugin/hooks.d.ts +13 -0
- package/dist/plugin/hooks.d.ts.map +1 -1
- package/dist/plugin/memoryInject.d.ts +25 -0
- package/dist/plugin/memoryInject.d.ts.map +1 -0
- package/dist/router/chooseModel.d.ts.map +1 -1
- package/dist/router/cost.d.ts +4 -0
- package/dist/router/cost.d.ts.map +1 -0
- package/dist/router/frontierBaseline.d.ts +13 -0
- package/dist/router/frontierBaseline.d.ts.map +1 -0
- package/dist/router/modelSelection.d.ts +18 -0
- package/dist/router/modelSelection.d.ts.map +1 -0
- package/dist/storage/graph/codec.d.ts +52 -0
- package/dist/storage/graph/codec.d.ts.map +1 -0
- package/dist/storage/graph/fsGraphJournal.d.ts +3 -0
- package/dist/storage/graph/fsGraphJournal.d.ts.map +1 -0
- package/dist/storage/graph/importLegacy.d.ts +62 -0
- package/dist/storage/graph/importLegacy.d.ts.map +1 -0
- package/dist/storage/graph/memoryGraphJournal.d.ts +11 -0
- package/dist/storage/graph/memoryGraphJournal.d.ts.map +1 -0
- package/dist/storage/graph/migrateLegacyBriefs.d.ts +32 -0
- package/dist/storage/graph/migrateLegacyBriefs.d.ts.map +1 -0
- package/dist/storage/graph/projections.d.ts +31 -0
- package/dist/storage/graph/projections.d.ts.map +1 -0
- package/dist/storage/graph/provider.d.ts +52 -0
- package/dist/storage/graph/provider.d.ts.map +1 -0
- package/dist/storage/graph/recovery.d.ts +38 -0
- package/dist/storage/graph/recovery.d.ts.map +1 -0
- package/dist/storage/graph/runRegistry.d.ts +17 -0
- package/dist/storage/graph/runRegistry.d.ts.map +1 -0
- package/dist/storage/graph/snapshot.d.ts +44 -0
- package/dist/storage/graph/snapshot.d.ts.map +1 -0
- package/dist/storage/graph/workspaceLease.d.ts +36 -0
- package/dist/storage/graph/workspaceLease.d.ts.map +1 -0
- package/dist/storage/graph/writer.d.ts +20 -0
- package/dist/storage/graph/writer.d.ts.map +1 -0
- package/dist/storage/index/memoryConsolidate.d.ts +24 -0
- package/dist/storage/index/memoryConsolidate.d.ts.map +1 -0
- package/dist/storage/index/memoryIndex.d.ts +52 -0
- package/dist/storage/index/memoryIndex.d.ts.map +1 -0
- package/dist/storage/index/memoryRecall.d.ts +23 -0
- package/dist/storage/index/memoryRecall.d.ts.map +1 -0
- package/dist/storage/index/memoryRuntime.d.ts +41 -0
- package/dist/storage/index/memoryRuntime.d.ts.map +1 -0
- package/dist/telemetry/events.d.ts +3 -1
- package/dist/telemetry/events.d.ts.map +1 -1
- package/dist/telemetry/graphProjection.d.ts +36 -0
- package/dist/telemetry/graphProjection.d.ts.map +1 -0
- package/dist/telemetry/hash.d.ts.map +1 -1
- package/dist/web/server.d.ts +4 -0
- package/dist/web/server.d.ts.map +1 -1
- package/package.json +14 -6
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { GraphEventV1, GraphSpecV1 } from "../../graph/schema";
|
|
2
|
+
import type { GraphState } from "../../graph/types";
|
|
3
|
+
/**
|
|
4
|
+
* `GraphJournal` — boundary de persistencia append-only del run de Graph.
|
|
5
|
+
*
|
|
6
|
+
* Modela un log de eventos por `runID` con dos garantías de integridad:
|
|
7
|
+
* - **Secuencia contigua**: los eventos se anexan con `seq` estrictamente
|
|
8
|
+
* creciente desde 0 (concurrencia optimista sobre la cabeza del log).
|
|
9
|
+
* - **Escritor único (fencing)**: cada journal tiene un `writerToken` vigente;
|
|
10
|
+
* un `takeOver` emite uno nuevo e invalida el anterior. Anexar con un token
|
|
11
|
+
* caduco cierra en falso con `writer-conflict`.
|
|
12
|
+
*
|
|
13
|
+
* `load` reconstruye el estado reducido reproduciendo el journal; si el log
|
|
14
|
+
* almacenado es ilegible o produce transiciones ilegales, surface `corrupt`.
|
|
15
|
+
*
|
|
16
|
+
* Este módulo **no** contiene I/O: solo tipos. `router/` nunca lo importa. Los
|
|
17
|
+
* adapters concretos (`memoryGraphJournal`, futuros durables FS/SQLite) lo
|
|
18
|
+
* implementan y comparten `tests/storage/graph/contract.ts`.
|
|
19
|
+
*/
|
|
20
|
+
/** Taxonomía cerrada de errores del journal. */
|
|
21
|
+
export type JournalErrorCode = "already-exists" | "not-found" | "writer-conflict" | "sequence-mismatch" | "duplicate-event" | "corrupt";
|
|
22
|
+
/** Error tipado de una operación inválida sobre el journal. */
|
|
23
|
+
export declare class JournalError extends Error {
|
|
24
|
+
readonly code: JournalErrorCode;
|
|
25
|
+
readonly detail: string;
|
|
26
|
+
constructor(code: JournalErrorCode, detail: string);
|
|
27
|
+
}
|
|
28
|
+
/** Referencia a un journal abierto por un escritor concreto. */
|
|
29
|
+
export type GraphJournalHandle = {
|
|
30
|
+
readonly runID: string;
|
|
31
|
+
readonly writerToken: string;
|
|
32
|
+
};
|
|
33
|
+
/** Resultado de `load`: spec, eventos y estado reducido reproducido. */
|
|
34
|
+
export type LoadedJournal = {
|
|
35
|
+
spec: GraphSpecV1;
|
|
36
|
+
events: GraphEventV1[];
|
|
37
|
+
state: GraphState;
|
|
38
|
+
};
|
|
39
|
+
/** Contrato del journal de eventos de un run de Graph. */
|
|
40
|
+
export interface GraphJournal {
|
|
41
|
+
/** Crea un journal vacío para el run del spec; `already-exists` si ya existe. */
|
|
42
|
+
create(spec: GraphSpecV1): Promise<GraphJournalHandle>;
|
|
43
|
+
/** Toma el relevo como escritor único, emitiendo un token nuevo; `not-found` si falta. */
|
|
44
|
+
takeOver(runID: string): Promise<GraphJournalHandle>;
|
|
45
|
+
/** Anexa un evento en la posición `expectedSeq` (cabeza del log). */
|
|
46
|
+
append(handle: GraphJournalHandle, event: GraphEventV1, expectedSeq: number): Promise<void>;
|
|
47
|
+
/** Carga el journal y reproduce su estado; `not-found`/`corrupt` si procede. */
|
|
48
|
+
load(runID: string): Promise<LoadedJournal>;
|
|
49
|
+
/** `true` si existe un journal para el run. */
|
|
50
|
+
exists(runID: string): Promise<boolean>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/storage/graph/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AAEH,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,WAAW,GACX,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,SAAS,CAAC;AAEd,+DAA+D;AAC/D,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM;CAMnD;AAED,gEAAgE;AAChE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvD,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrD,qEAAqE;IACrE,MAAM,CACJ,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,gFAAgF;IAChF,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5C,+CAA+C;IAC/C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { GraphEventV1, GraphSpecV1 } from "../../graph/schema";
|
|
2
|
+
import type { GraphState } from "../../graph/types";
|
|
3
|
+
/**
|
|
4
|
+
* Recuperación determinista de un journal tras un fallo en un boundary de commit.
|
|
5
|
+
*
|
|
6
|
+
* Reproduce el prefijo autoritativo con una política de cola explícita:
|
|
7
|
+
* - una **cola parcial reconocida** (escritura truncada, sin `\n`) se descarta y
|
|
8
|
+
* se recupera el prefijo confirmado (`tail: "recovered"`), de modo que el
|
|
9
|
+
* intento truncado se puede reintentar sin duplicar autoridad;
|
|
10
|
+
* - un log limpio recupera todo commit confirmado (`tail: "clean"`).
|
|
11
|
+
*
|
|
12
|
+
* Cierra en falso sin adivinar ante una **corrupción intermedia** (frame ilegible
|
|
13
|
+
* en medio, cadena rota o checksum falseado) o una **ambigüedad de secuencia**
|
|
14
|
+
* (`seq` no contiguo), y también si el prefijo confirmado reproduce ilegalmente.
|
|
15
|
+
*
|
|
16
|
+
* Puro y determinista: sin I/O, reloj ni random. Opera sobre los bytes del
|
|
17
|
+
* journal para que la matriz de inyección de fallos sea byte a byte reproducible.
|
|
18
|
+
*/
|
|
19
|
+
/** Estado de la cola tras recuperar. */
|
|
20
|
+
export type RecoveryTail = "clean" | "recovered";
|
|
21
|
+
/** Resultado de recuperar un journal: prefijo autoritativo y estado reducido. */
|
|
22
|
+
export type RecoveredJournal = {
|
|
23
|
+
events: GraphEventV1[];
|
|
24
|
+
state: GraphState;
|
|
25
|
+
digest: string;
|
|
26
|
+
tail: RecoveryTail;
|
|
27
|
+
};
|
|
28
|
+
/** Taxonomía cerrada de fallos irrecuperables (paran en vez de adivinar). */
|
|
29
|
+
export type RecoveryErrorCode = "corrupt" | "sequence-ambiguity";
|
|
30
|
+
/** Error tipado de un journal que no puede recuperarse de forma segura. */
|
|
31
|
+
export declare class RecoveryError extends Error {
|
|
32
|
+
readonly code: RecoveryErrorCode;
|
|
33
|
+
readonly detail: string;
|
|
34
|
+
constructor(code: RecoveryErrorCode, detail: string);
|
|
35
|
+
}
|
|
36
|
+
/** Recupera el prefijo autoritativo y su estado desde los bytes del journal. */
|
|
37
|
+
export declare function recoverJournal(spec: GraphSpecV1, text: string): RecoveredJournal;
|
|
38
|
+
//# sourceMappingURL=recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../../src/storage/graph/recovery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;;;;;;;;;;;;;GAeG;AAEH,wCAAwC;AACxC,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,WAAW,CAAC;AAEjD,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,oBAAoB,CAAC;AAEjE,2EAA2E;AAC3E,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM;CAMpD;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,GACX,gBAAgB,CAwBlB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Error tipado de un registro de runs ilegible. */
|
|
2
|
+
export declare class RunRegistryError extends Error {
|
|
3
|
+
readonly code = "corrupt";
|
|
4
|
+
readonly detail: string;
|
|
5
|
+
constructor(detail: string);
|
|
6
|
+
}
|
|
7
|
+
/** Contrato del registro de runs activos del workspace. */
|
|
8
|
+
export interface RunRegistry {
|
|
9
|
+
/** Marca `runID` como activo (idempotente). */
|
|
10
|
+
markActive(runID: string): Promise<void>;
|
|
11
|
+
/** Marca `runID` como inactivo (idempotente). */
|
|
12
|
+
markInactive(runID: string): Promise<void>;
|
|
13
|
+
/** Lista los runs activos, ordenados. */
|
|
14
|
+
list(): Promise<string[]>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createRunRegistry(root: string): RunRegistry;
|
|
17
|
+
//# sourceMappingURL=runRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runRegistry.d.ts","sourceRoot":"","sources":["../../../src/storage/graph/runRegistry.ts"],"names":[],"mappings":"AAqBA,oDAAoD;AACpD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAK3B;AAED,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,iDAAiD;IACjD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,yCAAyC;IACzC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CA8C3D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { GraphEventV1, GraphSpecV1 } from "../../graph/schema";
|
|
2
|
+
import type { GraphState } from "../../graph/types";
|
|
3
|
+
/**
|
|
4
|
+
* Snapshots versionados del estado reducido con equivalencia al replay total.
|
|
5
|
+
*
|
|
6
|
+
* Un snapshot captura el `GraphState` tras aplicar los primeros `count` eventos
|
|
7
|
+
* junto al digest de cadena de ese prefijo (`prefixDigest`). Cargar puede así
|
|
8
|
+
* arrancar desde el snapshot y reproducir sólo la cola, obteniendo exactamente
|
|
9
|
+
* el mismo estado que reproducir el journal completo desde génesis.
|
|
10
|
+
*
|
|
11
|
+
* El journal sigue siendo la autoridad: el snapshot es un acelerador desechable.
|
|
12
|
+
* - Borrarlo no pierde autoridad: se recae al replay total del journal.
|
|
13
|
+
* - Un snapshot corrupto o de versión desconocida no se confía: se recae **sólo**
|
|
14
|
+
* al replay estricto del journal (nunca a un estado a medio validar).
|
|
15
|
+
*
|
|
16
|
+
* La integridad se ancla con un checksum sobre el sobre y el hash del estado, y
|
|
17
|
+
* el `prefixDigest` ata el snapshot a un prefijo concreto del journal.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SNAPSHOT_VERSION = 1;
|
|
20
|
+
/** Snapshot del estado reducido en un punto del journal. */
|
|
21
|
+
export type GraphSnapshot = {
|
|
22
|
+
version: number;
|
|
23
|
+
runID: string;
|
|
24
|
+
count: number;
|
|
25
|
+
prefixDigest: string;
|
|
26
|
+
state: GraphState;
|
|
27
|
+
};
|
|
28
|
+
/** Construye un snapshot puro tras los primeros `count` eventos del journal. */
|
|
29
|
+
export declare function snapshotAt(spec: GraphSpecV1, events: readonly GraphEventV1[], count: number): GraphSnapshot;
|
|
30
|
+
/** Persiste el snapshot de forma durable en `<root>/<runID>/snapshot.json`. */
|
|
31
|
+
export declare function writeSnapshot(root: string, snapshot: GraphSnapshot): void;
|
|
32
|
+
/**
|
|
33
|
+
* Lee el snapshot si es íntegro y de versión conocida; devuelve `undefined`
|
|
34
|
+
* (para recaer al replay) si falta, es ilegible, tiene versión desconocida o su
|
|
35
|
+
* checksum no cuadra.
|
|
36
|
+
*/
|
|
37
|
+
export declare function readSnapshot(root: string, runID: string): GraphSnapshot | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Resuelve el estado del run: si el snapshot ata al prefijo del journal, arranca
|
|
40
|
+
* desde él y reproduce la cola; en cualquier otro caso recae al replay estricto
|
|
41
|
+
* y total del journal, que es la autoridad.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveState(spec: GraphSpecV1, events: readonly GraphEventV1[], snapshot: GraphSnapshot | undefined): GraphState;
|
|
44
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/storage/graph/snapshot.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAIlC,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAkDF,gFAAgF;AAChF,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,KAAK,EAAE,MAAM,GACZ,aAAa,CASf;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAIzE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,aAAa,GAAG,SAAS,CA8B3B;AA4BD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,QAAQ,EAAE,aAAa,GAAG,SAAS,GAClC,UAAU,CAKZ"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type RunRegistry } from "./runRegistry";
|
|
3
|
+
declare const leaseRecordSchema: z.ZodObject<{
|
|
4
|
+
runID: z.ZodString;
|
|
5
|
+
holder: z.ZodString;
|
|
6
|
+
token: z.ZodString;
|
|
7
|
+
released: z.ZodBoolean;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
/** Registro persistido de un lease del workspace. */
|
|
10
|
+
export type LeaseRecord = z.infer<typeof leaseRecordSchema>;
|
|
11
|
+
/** Taxonomía cerrada de errores del lease. */
|
|
12
|
+
export type LeaseErrorCode = "held" | "not-holder" | "not-found" | "corrupt";
|
|
13
|
+
/** Error tipado de una operación inválida sobre el lease. */
|
|
14
|
+
export declare class LeaseError extends Error {
|
|
15
|
+
readonly code: LeaseErrorCode;
|
|
16
|
+
readonly detail: string;
|
|
17
|
+
constructor(code: LeaseErrorCode, detail: string);
|
|
18
|
+
}
|
|
19
|
+
/** Concesión de un lease a un holder concreto. */
|
|
20
|
+
export type LeaseHandle = {
|
|
21
|
+
readonly runID: string;
|
|
22
|
+
readonly holder: string;
|
|
23
|
+
readonly token: string;
|
|
24
|
+
};
|
|
25
|
+
/** Contrato del lease exclusivo del workspace. */
|
|
26
|
+
export interface WorkspaceLease {
|
|
27
|
+
/** Adquiere el run para `holder`; readquisición del mismo holder es idempotente. */
|
|
28
|
+
acquire(runID: string, holder: string): Promise<LeaseHandle>;
|
|
29
|
+
/** Libera el run de forma durable; el registro deja de listarlo. */
|
|
30
|
+
release(handle: LeaseHandle): Promise<void>;
|
|
31
|
+
/** Devuelve el registro persistido del lease, o `undefined` si no existe. */
|
|
32
|
+
inspect(runID: string): Promise<LeaseRecord | undefined>;
|
|
33
|
+
}
|
|
34
|
+
export declare function createWorkspaceLease(root: string, registry?: RunRegistry): WorkspaceLease;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=workspaceLease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaceLease.d.ts","sourceRoot":"","sources":["../../../src/storage/graph/workspaceLease.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;A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ptor, de modo que el boundary de confirmación coincide con
|
|
4
|
+
* la persistencia real (no con el buffer del SO). Es la única razón por la que
|
|
5
|
+
* el journal no se apoya en `StorageProvider.append`, que no fuerza `fsync`.
|
|
6
|
+
*
|
|
7
|
+
* Aísla `node:fs` para que el resto del adapter permanezca declarativo. No
|
|
8
|
+
* interpreta contenido: sólo bytes, directorios y el boundary de flush.
|
|
9
|
+
*/
|
|
10
|
+
/** Crea el directorio (recursivo, idempotente). */
|
|
11
|
+
export declare function ensureDir(dir: string): void;
|
|
12
|
+
/** Escribe (trunca) un fichero y fuerza `fsync` antes de retornar. */
|
|
13
|
+
export declare function writeDurable(file: string, content: string): void;
|
|
14
|
+
/** Anexa al final de un fichero y fuerza `fsync` antes de retornar. */
|
|
15
|
+
export declare function appendDurable(file: string, content: string): void;
|
|
16
|
+
/** Lee el contenido UTF-8 de un fichero; `undefined` si no existe. */
|
|
17
|
+
export declare function readText(file: string): string | undefined;
|
|
18
|
+
/** `true` si la ruta existe (fichero o directorio). */
|
|
19
|
+
export declare function pathExists(path: string): boolean;
|
|
20
|
+
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/storage/graph/writer.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AAEH,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQhE;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQjE;AAED,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKzD;AAED,uDAAuD;AACvD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD"}
|
|
@@ -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,EACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EAElB,MAAM,oBA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
|
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
|
|
1
|
+
{"version":3,"file":"events.d.ts","s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,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ErrorClass, GraphEventType, GraphEventV1 } from "../graph/schema";
|
|
2
|
+
/**
|
|
3
|
+
* Proyección de telemetría **reference-only** de eventos de Graph (GE-037).
|
|
4
|
+
*
|
|
5
|
+
* `projectGraphEvent` mapea un evento validado a un registro de telemetría con
|
|
6
|
+
* un conjunto de campos **allow-listed y acotados**: envoltura (`v`, `seq`,
|
|
7
|
+
* `runID`, `type`) más identificadores/digests concretos según el tipo. Nunca
|
|
8
|
+
* copia el evento entero ni transporta contenido crudo; el artefacto se reduce
|
|
9
|
+
* a su referencia (`uri`, `sha256`, `bytes`). Un guard final rechaza cualquier
|
|
10
|
+
* campo de contenido crudo. Puro y determinista: sin I/O, reloj ni random.
|
|
11
|
+
*/
|
|
12
|
+
/** Registro de telemetría de un evento Graph: solo campos allow-listed. */
|
|
13
|
+
export type GraphTelemetryRecord = {
|
|
14
|
+
readonly v: number;
|
|
15
|
+
readonly seq: number;
|
|
16
|
+
readonly runID: string;
|
|
17
|
+
readonly type: GraphEventType;
|
|
18
|
+
readonly nodeID?: string;
|
|
19
|
+
readonly operationID?: string;
|
|
20
|
+
readonly attemptID?: string;
|
|
21
|
+
readonly errorClass?: ErrorClass;
|
|
22
|
+
readonly specDigest?: string;
|
|
23
|
+
readonly artifact?: {
|
|
24
|
+
readonly uri: string;
|
|
25
|
+
readonly sha256: string;
|
|
26
|
+
readonly bytes: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Proyecta un evento Graph a un registro de telemetría reference-only. Solo
|
|
31
|
+
* emite los campos allow-listed presentes en el evento y reduce el artefacto a
|
|
32
|
+
* su referencia; el guard reference-only asegura que ningún derivado futuro
|
|
33
|
+
* introduzca contenido crudo.
|
|
34
|
+
*/
|
|
35
|
+
export declare function projectGraphEvent(event: GraphEventV1): GraphTelemetryRecord;
|
|
36
|
+
//# sourceMappingURL=graphProjection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphProjection.d.ts","sourceRoot":"","sources":["../../src/telemetry/graphProjection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEhF;;;;;;;;;GASG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,oBAAoB,CAe3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/telemetry/hash.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/web/server.d.ts
CHANGED
|
@@ -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
|
package/dist/web/server.d.ts.map
CHANGED
|
@@ -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,kBA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B,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.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.41",
|
|
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
|
-
"
|
|
26
|
+
"multi-agent"
|
|
26
27
|
],
|
|
27
28
|
"engines": {
|
|
28
29
|
"bun": ">=1.3",
|
|
29
|
-
"node": ">=
|
|
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
|
-
"
|
|
79
|
+
"hooks:install": "git config core.hooksPath .githooks"
|
|
72
80
|
},
|
|
73
81
|
"dependencies": {
|
|
74
82
|
"@clack/prompts": "1.7.0",
|