@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.
Files changed (162) hide show
  1. package/.opencode/command/openteam.md +5 -5
  2. package/AGENTS.md +50 -35
  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.js +1123 -232
  8. package/dist/commands/frontierCatalog.d.ts +27 -0
  9. package/dist/commands/frontierCatalog.d.ts.map +1 -0
  10. package/dist/commands/graph.d.ts +65 -0
  11. package/dist/commands/graph.d.ts.map +1 -0
  12. package/dist/commands/orchestratorAgent.d.ts +2 -1
  13. package/dist/commands/orchestratorAgent.d.ts.map +1 -1
  14. package/dist/commands/setup.d.ts +3 -18
  15. package/dist/commands/setup.d.ts.map +1 -1
  16. package/dist/config/load.d.ts.map +1 -1
  17. package/dist/config/migrations.d.ts +27 -0
  18. package/dist/config/migrations.d.ts.map +1 -0
  19. package/dist/config/resolve.d.ts +34 -0
  20. package/dist/config/resolve.d.ts.map +1 -0
  21. package/dist/config/schema.d.ts +235 -0
  22. package/dist/config/schema.d.ts.map +1 -1
  23. package/dist/console/assets.d.ts +9 -0
  24. package/dist/console/assets.d.ts.map +1 -0
  25. package/dist/console/render.d.ts.map +1 -1
  26. package/dist/context/redaction.d.ts +48 -0
  27. package/dist/context/redaction.d.ts.map +1 -0
  28. package/dist/context/schema.d.ts +115 -0
  29. package/dist/context/schema.d.ts.map +1 -0
  30. package/dist/context/types.d.ts +8 -0
  31. package/dist/context/types.d.ts.map +1 -0
  32. package/dist/contract/opencode.d.ts +1 -1
  33. package/dist/contract/opencode.d.ts.map +1 -1
  34. package/dist/graph/events.d.ts +25 -0
  35. package/dist/graph/events.d.ts.map +1 -0
  36. package/dist/graph/ids.d.ts +5 -0
  37. package/dist/graph/ids.d.ts.map +1 -0
  38. package/dist/graph/planner.d.ts +15 -0
  39. package/dist/graph/planner.d.ts.map +1 -0
  40. package/dist/graph/policies.d.ts +34 -0
  41. package/dist/graph/policies.d.ts.map +1 -0
  42. package/dist/graph/privacyPolicy.d.ts +29 -0
  43. package/dist/graph/privacyPolicy.d.ts.map +1 -0
  44. package/dist/graph/reducer.d.ts +27 -0
  45. package/dist/graph/reducer.d.ts.map +1 -0
  46. package/dist/graph/replay.d.ts +20 -0
  47. package/dist/graph/replay.d.ts.map +1 -0
  48. package/dist/graph/reviewerPolicy.d.ts +27 -0
  49. package/dist/graph/reviewerPolicy.d.ts.map +1 -0
  50. package/dist/graph/schema.d.ts +220 -0
  51. package/dist/graph/schema.d.ts.map +1 -0
  52. package/dist/graph/types.d.ts +40 -0
  53. package/dist/graph/types.d.ts.map +1 -0
  54. package/dist/graph/validate.d.ts +19 -0
  55. package/dist/graph/validate.d.ts.map +1 -0
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +873 -88
  58. package/dist/local/embeddings.d.ts +29 -0
  59. package/dist/local/embeddings.d.ts.map +1 -0
  60. package/dist/local/extractClient.d.ts +31 -0
  61. package/dist/local/extractClient.d.ts.map +1 -0
  62. package/dist/local/openai-compatible.d.ts +1 -0
  63. package/dist/local/openai-compatible.d.ts.map +1 -1
  64. package/dist/mcp/semanticRecall.d.ts +25 -0
  65. package/dist/mcp/semanticRecall.d.ts.map +1 -0
  66. package/dist/mcp/server.d.ts +22 -0
  67. package/dist/mcp/server.d.ts.map +1 -1
  68. package/dist/memory/consolidate.d.ts +21 -0
  69. package/dist/memory/consolidate.d.ts.map +1 -0
  70. package/dist/memory/extract.d.ts +68 -0
  71. package/dist/memory/extract.d.ts.map +1 -0
  72. package/dist/memory/fold.d.ts +24 -0
  73. package/dist/memory/fold.d.ts.map +1 -0
  74. package/dist/memory/index.d.ts +18 -0
  75. package/dist/memory/index.d.ts.map +1 -0
  76. package/dist/memory/inject.d.ts +29 -0
  77. package/dist/memory/inject.d.ts.map +1 -0
  78. package/dist/memory/log.d.ts +16 -0
  79. package/dist/memory/log.d.ts.map +1 -0
  80. package/dist/memory/merge.d.ts +38 -0
  81. package/dist/memory/merge.d.ts.map +1 -0
  82. package/dist/memory/rank.d.ts +32 -0
  83. package/dist/memory/rank.d.ts.map +1 -0
  84. package/dist/memory/recall.d.ts +30 -0
  85. package/dist/memory/recall.d.ts.map +1 -0
  86. package/dist/memory/temporal.d.ts +39 -0
  87. package/dist/memory/temporal.d.ts.map +1 -0
  88. package/dist/memory/types.d.ts +159 -0
  89. package/dist/memory/types.d.ts.map +1 -0
  90. package/dist/memory/vector.d.ts +18 -0
  91. package/dist/memory/vector.d.ts.map +1 -0
  92. package/dist/orchestrator/graphCancellation.d.ts +84 -0
  93. package/dist/orchestrator/graphCancellation.d.ts.map +1 -0
  94. package/dist/orchestrator/graphEffects.d.ts +63 -0
  95. package/dist/orchestrator/graphEffects.d.ts.map +1 -0
  96. package/dist/orchestrator/graphReview.d.ts +84 -0
  97. package/dist/orchestrator/graphReview.d.ts.map +1 -0
  98. package/dist/orchestrator/graphRuntime.d.ts +69 -0
  99. package/dist/orchestrator/graphRuntime.d.ts.map +1 -0
  100. package/dist/orchestrator/opencodeSessionAdapter.d.ts +117 -0
  101. package/dist/orchestrator/opencodeSessionAdapter.d.ts.map +1 -0
  102. package/dist/orchestrator/roles.d.ts +1 -1
  103. package/dist/orchestrator/roles.d.ts.map +1 -1
  104. package/dist/orchestrator/sdd.d.ts +38 -2
  105. package/dist/orchestrator/sdd.d.ts.map +1 -1
  106. package/dist/orchestrator/sddCompiler.d.ts +44 -0
  107. package/dist/orchestrator/sddCompiler.d.ts.map +1 -0
  108. package/dist/orchestrator/sessionReconciler.d.ts +74 -0
  109. package/dist/orchestrator/sessionReconciler.d.ts.map +1 -0
  110. package/dist/orchestrator/shadowComparator.d.ts +62 -0
  111. package/dist/orchestrator/shadowComparator.d.ts.map +1 -0
  112. package/dist/plugin/hooks.d.ts +13 -0
  113. package/dist/plugin/hooks.d.ts.map +1 -1
  114. package/dist/plugin/memoryInject.d.ts +25 -0
  115. package/dist/plugin/memoryInject.d.ts.map +1 -0
  116. package/dist/router/chooseModel.d.ts.map +1 -1
  117. package/dist/router/cost.d.ts +4 -0
  118. package/dist/router/cost.d.ts.map +1 -0
  119. package/dist/router/frontierBaseline.d.ts +13 -0
  120. package/dist/router/frontierBaseline.d.ts.map +1 -0
  121. package/dist/router/modelSelection.d.ts +18 -0
  122. package/dist/router/modelSelection.d.ts.map +1 -0
  123. package/dist/storage/graph/codec.d.ts +52 -0
  124. package/dist/storage/graph/codec.d.ts.map +1 -0
  125. package/dist/storage/graph/fsGraphJournal.d.ts +3 -0
  126. package/dist/storage/graph/fsGraphJournal.d.ts.map +1 -0
  127. package/dist/storage/graph/importLegacy.d.ts +62 -0
  128. package/dist/storage/graph/importLegacy.d.ts.map +1 -0
  129. package/dist/storage/graph/memoryGraphJournal.d.ts +11 -0
  130. package/dist/storage/graph/memoryGraphJournal.d.ts.map +1 -0
  131. package/dist/storage/graph/migrateLegacyBriefs.d.ts +32 -0
  132. package/dist/storage/graph/migrateLegacyBriefs.d.ts.map +1 -0
  133. package/dist/storage/graph/projections.d.ts +31 -0
  134. package/dist/storage/graph/projections.d.ts.map +1 -0
  135. package/dist/storage/graph/provider.d.ts +52 -0
  136. package/dist/storage/graph/provider.d.ts.map +1 -0
  137. package/dist/storage/graph/recovery.d.ts +38 -0
  138. package/dist/storage/graph/recovery.d.ts.map +1 -0
  139. package/dist/storage/graph/runRegistry.d.ts +17 -0
  140. package/dist/storage/graph/runRegistry.d.ts.map +1 -0
  141. package/dist/storage/graph/snapshot.d.ts +44 -0
  142. package/dist/storage/graph/snapshot.d.ts.map +1 -0
  143. package/dist/storage/graph/workspaceLease.d.ts +36 -0
  144. package/dist/storage/graph/workspaceLease.d.ts.map +1 -0
  145. package/dist/storage/graph/writer.d.ts +20 -0
  146. package/dist/storage/graph/writer.d.ts.map +1 -0
  147. package/dist/storage/index/memoryConsolidate.d.ts +24 -0
  148. package/dist/storage/index/memoryConsolidate.d.ts.map +1 -0
  149. package/dist/storage/index/memoryIndex.d.ts +52 -0
  150. package/dist/storage/index/memoryIndex.d.ts.map +1 -0
  151. package/dist/storage/index/memoryRecall.d.ts +23 -0
  152. package/dist/storage/index/memoryRecall.d.ts.map +1 -0
  153. package/dist/storage/index/memoryRuntime.d.ts +41 -0
  154. package/dist/storage/index/memoryRuntime.d.ts.map +1 -0
  155. package/dist/telemetry/events.d.ts +3 -1
  156. package/dist/telemetry/events.d.ts.map +1 -1
  157. package/dist/telemetry/graphProjection.d.ts +36 -0
  158. package/dist/telemetry/graphProjection.d.ts.map +1 -0
  159. package/dist/telemetry/hash.d.ts.map +1 -1
  160. package/dist/web/server.d.ts +4 -0
  161. package/dist/web/server.d.ts.map +1 -1
  162. 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":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAG,GAAY,CAAC;AAE7C,eAAO,MAAM,cAAc,aAAoB,CAAC;AAEhD,eAAO,MAAM,gBAAgB;;;;EAA2C,CAAC;AAiBzE,6EAA6E;AAC7E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;iBAMrB,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;iBAO3B,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;iBAKvB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAI7B,CAAC;AAEH,+DAA+D;AAC/D,eAAO,MAAM,iBAAiB;;;;;;;;;;;iBAQ5B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAC9C,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAClD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,uDAAuD;AACvD,MAAM,MAAM,SAAS,GAAG,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"}
@@ -0,0 +1,84 @@
1
+ import type { GraphState, NodeStatus, RunStatus } from "../graph/types";
2
+ /**
3
+ * Políticas puras de cancelación, timeout y compleción tardía (GE-034).
4
+ *
5
+ * Deciden, sin I/O ni reloj, qué hacer ante tres situaciones del runtime de
6
+ * Graph. El runtime les inyecta la evidencia ya observada (estado del nodo, si
7
+ * ya se pidió el abort, si expiró la ventana de gracia) y aplica el resultado:
8
+ *
9
+ * - `timeoutAction`: en un timeout se pide **primero** el abort y solo se
10
+ * reconcilia tras agotar una ventana de gracia acotada; un nodo no `running`
11
+ * no tiene nada que expirar.
12
+ * - `planCancellation`: cancelar un run en curso cancela sus nodos `pending` y
13
+ * `running` (así los `pending` no llegan a despacharse) y pide abort de los
14
+ * `running`; cancelar un run ya terminal es un no-op idempotente.
15
+ * - `classifyLateCompletion`: un resultado que llega tarde se **audita** pero no
16
+ * puede revivir un intento cancelado, superado (otro `attemptID`/`operationID`)
17
+ * ni de un run ya terminal.
18
+ *
19
+ * Todo es determinista: la misma evidencia produce la misma decisión, de modo
20
+ * que se reproduce igual tras un reinicio.
21
+ */
22
+ /** Acción de timeout sobre el nodo en vuelo. */
23
+ export type TimeoutAction = "noop" | "request-abort" | "awaiting-grace" | "reconcile";
24
+ /** Evidencia inyectada para decidir el timeout de un nodo. */
25
+ export type TimeoutInput = {
26
+ readonly nodeStatus: NodeStatus;
27
+ /** `true` si el runtime ya solicitó el abort de este intento. */
28
+ readonly abortRequested: boolean;
29
+ /** `true` si la ventana de gracia acotada ya expiró. */
30
+ readonly graceExceeded: boolean;
31
+ };
32
+ /**
33
+ * Decide la acción de timeout. Solo un nodo `running` puede expirar: si aún no
34
+ * se pidió el abort, se pide; si ya se pidió, se espera hasta agotar la gracia y
35
+ * entonces se reconcilia. Un nodo no `running` es un no-op.
36
+ */
37
+ export declare function timeoutAction(input: TimeoutInput): TimeoutAction;
38
+ /** Plan determinista de cancelación de un run. */
39
+ export type CancellationPlan = {
40
+ /** `true` si el run sigue en curso y debe marcarse `cancelled`. */
41
+ readonly cancelRun: boolean;
42
+ /** Nodos a marcar `cancelled` (los `pending` y `running`), en orden estable. */
43
+ readonly cancelNodeIDs: readonly string[];
44
+ /** Nodos `running` cuyo efecto debe abortarse, en orden estable. */
45
+ readonly abortNodeIDs: readonly string[];
46
+ };
47
+ /**
48
+ * Planifica la cancelación del run. Cancela los nodos `pending` (para que no
49
+ * lleguen a despacharse) y `running`, y pide abort de los `running`. Un run ya
50
+ * terminal no vuelve a cancelarse y no deja nodos por cancelar (idempotente).
51
+ */
52
+ export declare function planCancellation(state: GraphState): CancellationPlan;
53
+ /** Motivo por el que una compleción tardía se descarta. */
54
+ export type LateCompletionReason = "run-terminal" | "unknown-node" | "not-running" | "superseded";
55
+ /** Veredicto sobre un recibo que llega tarde. */
56
+ export type LateCompletionVerdict = {
57
+ readonly kind: "apply";
58
+ } | {
59
+ readonly kind: "stale";
60
+ readonly reason: LateCompletionReason;
61
+ };
62
+ /** Estado mínimo del nodo destino del recibo tardío. */
63
+ export type LateCompletionNode = {
64
+ readonly status: NodeStatus;
65
+ readonly operationID?: string;
66
+ readonly attemptID?: string;
67
+ };
68
+ /** Entrada para clasificar una compleción tardía. */
69
+ export type LateCompletionInput = {
70
+ readonly runStatus: RunStatus;
71
+ readonly node: LateCompletionNode | undefined;
72
+ readonly receipt: {
73
+ readonly operationID: string;
74
+ readonly attemptID: string;
75
+ };
76
+ };
77
+ /**
78
+ * Clasifica un recibo tardío. Solo se aplica al intento `running` vigente con
79
+ * `operationID`/`attemptID` coincidentes; en cualquier otro caso (run terminal,
80
+ * nodo desconocido, nodo no `running`, intento superado) se marca `stale` para
81
+ * auditarlo sin mutar el estado.
82
+ */
83
+ export declare function classifyLateCompletion(input: LateCompletionInput): LateCompletionVerdict;
84
+ //# sourceMappingURL=graphCancellation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphCancellation.d.ts","sourceRoot":"","sources":["../../src/orchestrator/graphCancellation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gDAAgD;AAChD,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,eAAe,GACf,gBAAgB,GAChB,WAAW,CAAC;AAEhB,8DAA8D;AAC9D,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,iEAAiE;IACjE,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,wDAAwD;IACxD,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,CAQhE;AAED,kDAAkD;AAClD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,oEAAoE;IACpE,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,gBAAgB,CAiBpE;AAED,2DAA2D;AAC3D,MAAM,MAAM,oBAAoB,GAC5B,cAAc,GACd,cAAc,GACd,aAAa,GACb,YAAY,CAAC;AAEjB,iDAAiD;AACjD,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAEtE,wDAAwD;AACxD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,qDAAqD;AACrD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,mBAAmB,GACzB,qBAAqB,CAkBvB"}
@@ -0,0 +1,63 @@
1
+ import type { ContextRef, PrivacyClass } from "../context/schema";
2
+ import { type PrivacyMode, type RouteKind } from "../graph/privacyPolicy";
3
+ import type { ErrorClass, GraphNode } from "../graph/schema";
4
+ /**
5
+ * `GraphEffectExecutor` — puerto del único efecto que el runtime de Graph
6
+ * (GE-031) ejecuta por nodo. El runtime commitea la intención (`node.dispatched`)
7
+ * en el journal **antes** de invocar `execute`, y el recibo (`node.succeeded` o
8
+ * `node.failed`) **después**; el executor solo produce el resultado del efecto.
9
+ *
10
+ * Este módulo es solo tipos: sin I/O, SDK, storage ni estado global. El runtime
11
+ * recibe un executor inyectado; en producción lo implementará el adaptador de
12
+ * sesión de opencode (GE-030), y en tests un doble determinista. Mantener el
13
+ * seam como puerto permite probar el runtime sin red ni SDK reales.
14
+ */
15
+ /** Solicitud de ejecución de un efecto para un nodo e intento concretos. */
16
+ export type EffectRequest = {
17
+ readonly runID: string;
18
+ readonly node: GraphNode;
19
+ readonly operationID: string;
20
+ readonly attemptID: string;
21
+ };
22
+ /** Recibo de un efecto: éxito con artefacto referenciado, o fallo clasificado. */
23
+ export type EffectReceipt = {
24
+ readonly outcome: "succeeded";
25
+ readonly artifact: ContextRef;
26
+ } | {
27
+ readonly outcome: "failed";
28
+ readonly errorClass: ErrorClass;
29
+ };
30
+ /** Ejecutor inyectable del efecto de un nodo. Determinista dado el request. */
31
+ export interface GraphEffectExecutor {
32
+ execute(request: EffectRequest): Promise<EffectReceipt>;
33
+ }
34
+ /**
35
+ * Contexto de privacidad de un despacho: clase de privacidad del nodo, modo
36
+ * efectivo de la config y ruta preferida por el router. Deja al seam de efectos
37
+ * la decisión reference-only/frontier antes y después de invocar al executor.
38
+ */
39
+ export type EffectDispatchContext = {
40
+ readonly privacyClass: PrivacyClass;
41
+ readonly mode: PrivacyMode;
42
+ readonly routeKind: RouteKind;
43
+ };
44
+ /**
45
+ * Resuelve la ruta **efectiva** de un despacho (GE-037). Si la política prohíbe
46
+ * frontier para la clase de privacidad bajo el modo activo, degrada a `local`
47
+ * en vez de lanzar: un nodo `sensitive` con `forceLocalOnSensitive` produce
48
+ * **cero** despachos a frontier. Puro y determinista.
49
+ */
50
+ export declare function resolveDispatchRoute(privacyClass: PrivacyClass, mode: PrivacyMode, preferred: RouteKind): RouteKind;
51
+ /**
52
+ * Gate de privacidad **antes** de invocar al executor: lanza
53
+ * `PrivacyPolicyError` si un nodo `sensitive` bajo `forceLocalOnSensitive`
54
+ * intenta una ruta frontier.
55
+ */
56
+ export declare function assertDispatchAllowed(ctx: EffectDispatchContext): void;
57
+ /**
58
+ * Gate reference-only **después** del executor: el recibo solo puede llevar una
59
+ * `ContextRef` (éxito) o una clase de error (fallo); lanza `RedactionError` si
60
+ * alguna estructura transporta un campo de contenido crudo.
61
+ */
62
+ export declare function assertReceiptReferenceOnly(receipt: EffectReceipt): void;
63
+ //# sourceMappingURL=graphEffects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphEffects.d.ts","sourceRoot":"","sources":["../../src/orchestrator/graphEffects.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;GAUG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,kFAAkF;AAClF,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC;AAEpE,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACzD;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS,GACnB,SAAS,CAIX;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAEvE"}
@@ -0,0 +1,84 @@
1
+ import { type Sha256, type TaskAnchor } from "../context/schema";
2
+ import type { Capability } from "../graph/types";
3
+ /** Veredicto normalizado de una revisión. */
4
+ export type ReviewVerdict = {
5
+ readonly decision: "approved";
6
+ } | {
7
+ readonly decision: "rejected";
8
+ readonly reason: string;
9
+ } | {
10
+ readonly decision: "inconclusive";
11
+ readonly reason: string;
12
+ };
13
+ /** Lo que el runtime despachó y a lo que debe anclarse la aprobación. */
14
+ export type ReviewExpectation = {
15
+ readonly anchor: TaskAnchor;
16
+ readonly artifactSha256: Sha256;
17
+ };
18
+ /**
19
+ * Parsea el veredicto de forma conservadora. Entrada no estructurada o inválida
20
+ * es `inconclusive`; un rechazo se honra con su motivo; una aprobación exige un
21
+ * ancla y un digest de artefacto que coincidan con lo despachado, y en cualquier
22
+ * discrepancia degrada a `inconclusive` (fail-closed).
23
+ */
24
+ export declare function parseReviewVerdict(raw: unknown, expected: ReviewExpectation): ReviewVerdict;
25
+ /** Decisión de lockout del efecto de un reviewer antes del despacho. */
26
+ export type ReviewerEffectDecision = {
27
+ readonly kind: "allow";
28
+ } | {
29
+ readonly kind: "reject";
30
+ readonly capability: Capability;
31
+ };
32
+ /**
33
+ * Bloquea el efecto de un reviewer a solo lectura. Devuelve `reject` con la
34
+ * primera capacidad mutante planificada (orden de entrada, determinista); si
35
+ * todas las capacidades son de solo lectura, `allow`.
36
+ */
37
+ export declare function reviewerEffectDecision(capabilities: readonly Capability[]): ReviewerEffectDecision;
38
+ /** Plan de linaje tras un rechazo: nueva revisión enlazada o agotamiento. */
39
+ export type RevisionPlan = {
40
+ readonly kind: "revise";
41
+ readonly nodeID: string;
42
+ /** Índice de la nueva revisión (0 la implementación inicial). */
43
+ readonly revision: number;
44
+ /** Operación de la nueva revisión, distinta de la anterior. */
45
+ readonly operationID: string;
46
+ /** Operación de la que procede (enlace append-only). */
47
+ readonly previousOperationID: string;
48
+ } | {
49
+ readonly kind: "exhausted";
50
+ readonly revision: number;
51
+ };
52
+ /**
53
+ * Planifica la revisión que enlaza un rechazo. Si aún queda margen bajo el
54
+ * límite, produce una nueva revisión con una `operationID` distinta que apunta
55
+ * a la anterior (`previousOperationID`), preservando la historia append-only;
56
+ * si se agotó el margen, `exhausted`.
57
+ */
58
+ export declare function planRevision(input: {
59
+ readonly runID: string;
60
+ readonly nodeID: string;
61
+ readonly currentRevision: number;
62
+ readonly currentOperationID: string;
63
+ readonly limit?: number;
64
+ }): RevisionPlan;
65
+ /** Resultado de reasignar el reviewer tras un fallo técnico. */
66
+ export type ReviewerReassignment = {
67
+ readonly kind: "reassign";
68
+ readonly reviewerID: string;
69
+ /** Un fallo técnico del reviewer no re-ejecuta la implementación. */
70
+ readonly rerunImplementation: false;
71
+ } | {
72
+ readonly kind: "no-reviewer";
73
+ };
74
+ /**
75
+ * Reasigna la revisión al primer candidato elegible (orden de entrada), nunca
76
+ * el autor ni un reviewer que ya falló. La implementación no se re-ejecuta: su
77
+ * artefacto se conserva. Sin candidatos elegibles, `no-reviewer`.
78
+ */
79
+ export declare function reassignReviewer(input: {
80
+ readonly authorID: string;
81
+ readonly failedReviewers: readonly string[];
82
+ readonly candidates: readonly string[];
83
+ }): ReviewerReassignment;
84
+ //# sourceMappingURL=graphReview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphReview.d.ts","sourceRoot":"","sources":["../../src/orchestrator/graphReview.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,MAAM,EAEX,KAAK,UAAU,EAEhB,MA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B,EAAE,MAAM,CAAC;CACtC,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,YAAY,CAaf;AAED,gEAAgE;AAChE,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC;CACrC,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAErC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC,GAAG,oBAAoB,CAevB"}
@@ -0,0 +1,69 @@
1
+ import type { GraphSpecV1 } from "../graph/schema";
2
+ import type { RunStatus } from "../graph/types";
3
+ import type { GraphJournal } from "../storage/graph/provider";
4
+ import type { WorkspaceLease } from "../storage/graph/workspaceLease";
5
+ import type { GraphEffectExecutor } from "./graphEffects";
6
+ /**
7
+ * Runtime single-writer de Graph (GE-031, GE-033).
8
+ *
9
+ * Un `step` adquiere (idempotentemente) el lease del workspace, garantiza el
10
+ * evento `run.started`, y avanza **como mucho un efecto**: commitea la intención
11
+ * (`node.dispatched`) en el journal antes de invocar el executor y el recibo
12
+ * (`node.succeeded`/`node.failed`) después. Reanuda tras un reinicio tomando el
13
+ * relevo del journal (`takeOver`) y no re-despacha un efecto en vuelo: un nodo
14
+ * `running` sin recibo se deja a la reconciliación (GE-032) devolviendo
15
+ * `blocked`. El fencing del lease impide un segundo orquestador simultáneo.
16
+ *
17
+ * Reintentos (GE-033): un nodo `failed` con una clase de error reintentable
18
+ * (`transient`/`timeout`) y dentro del límite se vuelve a despachar con el mismo
19
+ * `operationID` y un `attemptID` nuevo derivado del journal, de modo que la
20
+ * decisión y el ID reaparecen igual tras un reinicio. El retardo de backoff es
21
+ * una función pura del índice de intento que el runtime expone en el resultado
22
+ * del paso; no duerme ni consulta reloj.
23
+ *
24
+ * El runtime aísla toda la lógica de orquestación; el I/O real vive en los
25
+ * puertos inyectados (`WorkspaceLease`, `GraphJournal`, `GraphEffectExecutor`),
26
+ * de modo que se prueba con dobles deterministas sin red ni SDK.
27
+ */
28
+ /** Resultado de un `step` del runtime. */
29
+ export type RuntimeStepOutcome = {
30
+ readonly kind: "dispatched";
31
+ readonly nodeID: string;
32
+ readonly operationID: string;
33
+ readonly attemptID: string;
34
+ /** Índice de intento (0 el primero); crece en cada reintento. */
35
+ readonly attempt: number;
36
+ /** Retardo determinista sugerido antes de este intento, en ms. */
37
+ readonly backoffMs: number;
38
+ } | {
39
+ readonly kind: "completed";
40
+ } | {
41
+ readonly kind: "failed";
42
+ } | {
43
+ readonly kind: "blocked";
44
+ readonly reason: "in-flight-effect";
45
+ } | {
46
+ readonly kind: "terminal";
47
+ readonly status: RunStatus;
48
+ };
49
+ /** Dependencias inyectadas del runtime; ninguna hace I/O dentro de este módulo. */
50
+ export type GraphRuntimeDeps = {
51
+ readonly spec: GraphSpecV1;
52
+ readonly journal: GraphJournal;
53
+ readonly lease: WorkspaceLease;
54
+ readonly effects: GraphEffectExecutor;
55
+ readonly holder: string;
56
+ /** Límite de intentos por nodo reintentable; por defecto `DEFAULT_RETRY_LIMIT`. */
57
+ readonly retryLimit?: number;
58
+ };
59
+ /** Runtime que avanza un run de Graph paso a paso. */
60
+ export interface GraphRuntime {
61
+ /** Adquiere el lease y garantiza `run.started`; idempotente. */
62
+ start(): Promise<void>;
63
+ /** Avanza como mucho un efecto y devuelve el resultado del paso. */
64
+ step(): Promise<RuntimeStepOutcome>;
65
+ /** Repite `step` hasta un estado no despachador (terminal, completado, etc.). */
66
+ runToCompletion(): Promise<RuntimeStepOutcome>;
67
+ }
68
+ export declare function createGraphRuntime(deps: GraphRuntimeDeps): GraphRuntime;
69
+ //# sourceMappingURL=graphRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphRuntime.d.ts","sourceRoot":"","sources":["../../src/orchestrator/graphRuntime.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,0CAA0C;AAC1C,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAC9B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,GACjE;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAE9D,mFAAmF;AACnF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,oEAAoE;IACpE,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpC,iFAAiF;IACjF,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChD;AAkDD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,YAAY,CA2JvE"}
@@ -0,0 +1,117 @@
1
+ import type { ModelSelection } from "../router/types";
2
+ /**
3
+ * Adaptador tipado de sesión de opencode (GE-030).
4
+ *
5
+ * Estrecha la superficie de sesión de opencode a las seis operaciones de ciclo
6
+ * de vida verificadas por el contrato (create, dispatch/prompt, children,
7
+ * status/get, messages, abort) y normaliza cada fallo del cliente a un error
8
+ * tipado {@link SessionAdapterError}. Deliberadamente **no** expone acciones
9
+ * destructivas ni de resumen (delete, summarize, share/unshare, fork, command):
10
+ * la autoridad del grafo nunca borra ni resume una sesión de forma automática.
11
+ *
12
+ * El adaptador no realiza I/O propio: envuelve un cliente inyectado
13
+ * ({@link GraphSessionClient}) cuya forma es asignable desde el cliente real de
14
+ * `@opencode-ai/sdk`. Un contract test fija esa correspondencia.
15
+ */
16
+ /** Resultado del SDK: dato tipado o error opaco, nunca ambos. */
17
+ type ClientResult<T> = {
18
+ data?: T;
19
+ error?: unknown;
20
+ };
21
+ /** Referencia mínima a una sesión (subconjunto verificado de `Session`). */
22
+ export type SessionInfo = {
23
+ readonly id: string;
24
+ };
25
+ /**
26
+ * Puerto del cliente de sesión de opencode acotado a las operaciones que usa el
27
+ * adaptador. Estructuralmente compatible con `client.session` del SDK real.
28
+ */
29
+ export type GraphSessionClient = {
30
+ session: {
31
+ create(args: {
32
+ body?: {
33
+ parentID?: string;
34
+ title?: string;
35
+ };
36
+ query?: {
37
+ directory?: string;
38
+ };
39
+ }): Promise<ClientResult<{
40
+ id: string;
41
+ }>>;
42
+ prompt(args: {
43
+ path: {
44
+ id: string;
45
+ };
46
+ body: {
47
+ model?: ModelSelection;
48
+ agent?: string;
49
+ system?: string;
50
+ parts: Array<{
51
+ type: "text";
52
+ text: string;
53
+ }>;
54
+ };
55
+ }): Promise<ClientResult<unknown>>;
56
+ children(args: {
57
+ path: {
58
+ id: string;
59
+ };
60
+ }): Promise<ClientResult<ReadonlyArray<SessionInfo>>>;
61
+ get(args: {
62
+ path: {
63
+ id: string;
64
+ };
65
+ }): Promise<ClientResult<SessionInfo>>;
66
+ messages(args: {
67
+ path: {
68
+ id: string;
69
+ };
70
+ }): Promise<ClientResult<ReadonlyArray<unknown>>>;
71
+ abort(args: {
72
+ path: {
73
+ id: string;
74
+ };
75
+ }): Promise<ClientResult<boolean>>;
76
+ };
77
+ };
78
+ /** Taxonomía cerrada de errores del adaptador de sesión. */
79
+ export type SessionAdapterErrorCode = "create-failed" | "missing-session-id" | "dispatch-failed" | "children-failed" | "status-failed" | "messages-failed" | "abort-failed";
80
+ /** Error tipado de una operación de sesión que falló o devolvió datos inválidos. */
81
+ export declare class SessionAdapterError extends Error {
82
+ readonly code: SessionAdapterErrorCode;
83
+ readonly detail: string;
84
+ constructor(code: SessionAdapterErrorCode, detail: string);
85
+ }
86
+ /** Datos para crear una sub-sesión hija. */
87
+ export type CreateChildInput = {
88
+ readonly parentSessionID?: string;
89
+ readonly title?: string;
90
+ readonly directory?: string;
91
+ };
92
+ /** Datos para despachar un prompt (el efecto) a una sesión existente. */
93
+ export type DispatchInput = {
94
+ readonly sessionID: string;
95
+ readonly prompt: string;
96
+ readonly model?: ModelSelection;
97
+ readonly agent?: string;
98
+ readonly system?: string;
99
+ };
100
+ /** Superficie verificada del adaptador de sesión de opencode. */
101
+ export interface OpencodeSessionAdapter {
102
+ /** Crea una sub-sesión hija y devuelve su id; falla cerrado si no hay id. */
103
+ createChild(input: CreateChildInput): Promise<string>;
104
+ /** Despacha un prompt a la sesión y devuelve la respuesta cruda del efecto. */
105
+ dispatch(input: DispatchInput): Promise<unknown>;
106
+ /** Lista los ids de las sesiones hijas. */
107
+ listChildren(sessionID: string): Promise<readonly string[]>;
108
+ /** Devuelve el estado de la sesión (get por id). */
109
+ getStatus(sessionID: string): Promise<SessionInfo>;
110
+ /** Lista los mensajes de la sesión. */
111
+ listMessages(sessionID: string): Promise<readonly unknown[]>;
112
+ /** Solicita abortar la sesión; devuelve si el runtime lo aceptó. */
113
+ abort(sessionID: string): Promise<boolean>;
114
+ }
115
+ export declare function createOpencodeSessionAdapter(client: GraphSessionClient): OpencodeSessionAdapter;
116
+ export {};
117
+ //# sourceMappingURL=opencodeSessionAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencodeSessionAdapter.d.ts","sourceRoot":"","sources":["../../src/orchestrator/opencodeSessionAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;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AAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,iEAAiE;AACjE,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,2CAA2C;IAC3C,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5D,oDAAoD;IACpD,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,uCAAuC;IACvC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IAC7D,oEAAoE;IACpE,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5C;AAiBD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,kBAAkB,GACzB,sBAAsB,CA4GxB"}
@@ -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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