@lore-co/core 0.2.26 → 0.2.28

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 (119) hide show
  1. package/dist/approaches.d.ts +7 -0
  2. package/dist/approaches.d.ts.map +1 -1
  3. package/dist/approaches.js +6 -0
  4. package/dist/approaches.js.map +1 -1
  5. package/dist/auth-schemas.d.ts.map +1 -1
  6. package/dist/auth-schemas.js +3 -2
  7. package/dist/auth-schemas.js.map +1 -1
  8. package/dist/capture-policy.d.ts +18 -0
  9. package/dist/capture-policy.d.ts.map +1 -1
  10. package/dist/capture-policy.js +20 -0
  11. package/dist/capture-policy.js.map +1 -1
  12. package/dist/control-characters.d.ts +11 -0
  13. package/dist/control-characters.d.ts.map +1 -0
  14. package/dist/control-characters.js +30 -0
  15. package/dist/control-characters.js.map +1 -0
  16. package/dist/draft-learnings.d.ts +288 -0
  17. package/dist/draft-learnings.d.ts.map +1 -0
  18. package/dist/draft-learnings.js +67 -0
  19. package/dist/draft-learnings.js.map +1 -0
  20. package/dist/engine.d.ts +7 -2
  21. package/dist/engine.d.ts.map +1 -1
  22. package/dist/engine.js +39 -19
  23. package/dist/engine.js.map +1 -1
  24. package/dist/guard-policy-change.d.ts +17 -0
  25. package/dist/guard-policy-change.d.ts.map +1 -0
  26. package/dist/guard-policy-change.js +30 -0
  27. package/dist/guard-policy-change.js.map +1 -0
  28. package/dist/guard-schemas.d.ts +22 -4
  29. package/dist/guard-schemas.d.ts.map +1 -1
  30. package/dist/guard-schemas.js +19 -17
  31. package/dist/guard-schemas.js.map +1 -1
  32. package/dist/in-memory-repository.d.ts.map +1 -1
  33. package/dist/in-memory-repository.js +1 -0
  34. package/dist/in-memory-repository.js.map +1 -1
  35. package/dist/index.d.ts +5 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +5 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/injected-context.d.ts +2 -2
  40. package/dist/injected-context.d.ts.map +1 -1
  41. package/dist/injected-context.js +3 -3
  42. package/dist/injected-context.js.map +1 -1
  43. package/dist/learning-governance.d.ts +24 -1
  44. package/dist/learning-governance.d.ts.map +1 -1
  45. package/dist/learning-governance.js +71 -1
  46. package/dist/learning-governance.js.map +1 -1
  47. package/dist/learning-line.d.ts +29 -0
  48. package/dist/learning-line.d.ts.map +1 -0
  49. package/dist/learning-line.js +37 -0
  50. package/dist/learning-line.js.map +1 -0
  51. package/dist/{learning-drafts.d.ts → learning-sources.d.ts} +1 -1
  52. package/dist/learning-sources.d.ts.map +1 -0
  53. package/dist/{learning-drafts.js → learning-sources.js} +1 -1
  54. package/dist/learning-sources.js.map +1 -0
  55. package/dist/learning-titles.d.ts +16 -5
  56. package/dist/learning-titles.d.ts.map +1 -1
  57. package/dist/learning-titles.js +8 -3
  58. package/dist/learning-titles.js.map +1 -1
  59. package/dist/local-scope.d.ts +1 -1
  60. package/dist/local-scope.d.ts.map +1 -1
  61. package/dist/local-scope.js +5 -3
  62. package/dist/local-scope.js.map +1 -1
  63. package/dist/no-follow.d.ts +12 -0
  64. package/dist/no-follow.d.ts.map +1 -0
  65. package/dist/no-follow.js +41 -0
  66. package/dist/no-follow.js.map +1 -0
  67. package/dist/pilot-schemas.d.ts +17 -0
  68. package/dist/pilot-schemas.d.ts.map +1 -1
  69. package/dist/pilot-schemas.js +16 -0
  70. package/dist/pilot-schemas.js.map +1 -1
  71. package/dist/prepared-context.d.ts +2 -0
  72. package/dist/prepared-context.d.ts.map +1 -1
  73. package/dist/prepared-context.js +30 -9
  74. package/dist/prepared-context.js.map +1 -1
  75. package/dist/product-usage.d.ts +2 -2
  76. package/dist/reliability-schemas.d.ts +18 -2
  77. package/dist/reliability-schemas.d.ts.map +1 -1
  78. package/dist/reliability-schemas.js +21 -0
  79. package/dist/reliability-schemas.js.map +1 -1
  80. package/dist/repository-location.d.ts.map +1 -1
  81. package/dist/repository-location.js +10 -1
  82. package/dist/repository-location.js.map +1 -1
  83. package/dist/schemas.d.ts +26 -0
  84. package/dist/schemas.d.ts.map +1 -1
  85. package/dist/schemas.js +25 -3
  86. package/dist/schemas.js.map +1 -1
  87. package/dist/session-schemas.d.ts +12 -0
  88. package/dist/session-schemas.d.ts.map +1 -1
  89. package/dist/skill-context.d.ts +11 -1
  90. package/dist/skill-context.d.ts.map +1 -1
  91. package/dist/skill-context.js +41 -3
  92. package/dist/skill-context.js.map +1 -1
  93. package/dist/skill-folder.d.ts +16 -0
  94. package/dist/skill-folder.d.ts.map +1 -0
  95. package/dist/skill-folder.js +83 -0
  96. package/dist/skill-folder.js.map +1 -0
  97. package/dist/skills.d.ts +92 -0
  98. package/dist/skills.d.ts.map +1 -1
  99. package/dist/skills.js +139 -0
  100. package/dist/skills.js.map +1 -1
  101. package/dist/slack-schemas.d.ts +5 -5
  102. package/dist/slack-schemas.d.ts.map +1 -1
  103. package/dist/slack-schemas.js +4 -6
  104. package/dist/slack-schemas.js.map +1 -1
  105. package/dist/snapshot-schemas.d.ts +20 -0
  106. package/dist/snapshot-schemas.d.ts.map +1 -1
  107. package/dist/snapshot-schemas.js +50 -1
  108. package/dist/snapshot-schemas.js.map +1 -1
  109. package/dist/system-command.d.ts +26 -0
  110. package/dist/system-command.d.ts.map +1 -0
  111. package/dist/system-command.js +65 -0
  112. package/dist/system-command.js.map +1 -0
  113. package/dist/user-message.d.ts +9 -0
  114. package/dist/user-message.d.ts.map +1 -1
  115. package/dist/user-message.js +14 -1
  116. package/dist/user-message.js.map +1 -1
  117. package/package.json +31 -3
  118. package/dist/learning-drafts.d.ts.map +0 -1
  119. package/dist/learning-drafts.js.map +0 -1
@@ -0,0 +1,288 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * A draft learning belongs to one member. Nobody else, owners and admins
4
+ * included, can list, read, review or receive it. Drafts live outside the
5
+ * shared knowledge base: sharing one creates an ordinary learning through the
6
+ * same path as `remember`, so workspace review rules apply at that moment.
7
+ *
8
+ * A draft may leave its repository open. The author chooses where it applies
9
+ * when sharing.
10
+ */
11
+ export declare const DraftLearningScopeSchema: z.ZodObject<{
12
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
13
+ repo: z.ZodOptional<z.ZodString>;
14
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
15
+ project: z.ZodOptional<z.ZodString>;
16
+ component: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strict>;
18
+ export type DraftLearningScope = z.infer<typeof DraftLearningScopeSchema>;
19
+ /** Where the draft came from. The owner is the viewer, so no user is exposed. */
20
+ export declare const DraftLearningSourceSchema: z.ZodObject<{
21
+ sessionId: z.ZodOptional<z.ZodString>;
22
+ agent: z.ZodString;
23
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ eventId: z.ZodOptional<z.ZodUUID>;
26
+ }, z.core.$strict>;
27
+ export type DraftLearningSource = z.infer<typeof DraftLearningSourceSchema>;
28
+ export declare const DRAFT_LEARNING_MAX_CHARACTERS = 5000;
29
+ export declare const DraftLearningSchema: z.ZodObject<{
30
+ id: z.ZodUUID;
31
+ content: z.ZodString;
32
+ category: z.ZodEnum<{
33
+ architecture: "architecture";
34
+ convention: "convention";
35
+ correction: "correction";
36
+ gotcha: "gotcha";
37
+ known_gotcha: "known_gotcha";
38
+ deprecated: "deprecated";
39
+ behavior: "behavior";
40
+ review_feedback: "review_feedback";
41
+ other: "other";
42
+ }>;
43
+ scope: z.ZodObject<{
44
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
45
+ repo: z.ZodOptional<z.ZodString>;
46
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
47
+ project: z.ZodOptional<z.ZodString>;
48
+ component: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strict>;
50
+ source: z.ZodObject<{
51
+ sessionId: z.ZodOptional<z.ZodString>;
52
+ agent: z.ZodString;
53
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
+ eventId: z.ZodOptional<z.ZodUUID>;
56
+ }, z.core.$strict>;
57
+ createdAt: z.ZodISODateTime;
58
+ updatedAt: z.ZodISODateTime;
59
+ }, z.core.$strict>;
60
+ export type DraftLearning = z.infer<typeof DraftLearningSchema>;
61
+ export declare const CreateDraftLearningSchema: z.ZodObject<{
62
+ content: z.ZodPipe<z.ZodString, z.ZodString>;
63
+ category: z.ZodOptional<z.ZodEnum<{
64
+ architecture: "architecture";
65
+ convention: "convention";
66
+ correction: "correction";
67
+ gotcha: "gotcha";
68
+ known_gotcha: "known_gotcha";
69
+ deprecated: "deprecated";
70
+ behavior: "behavior";
71
+ review_feedback: "review_feedback";
72
+ other: "other";
73
+ }>>;
74
+ scope: z.ZodOptional<z.ZodObject<{
75
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
76
+ repo: z.ZodOptional<z.ZodString>;
77
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
78
+ project: z.ZodOptional<z.ZodString>;
79
+ component: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strict>>;
81
+ source: z.ZodObject<{
82
+ sessionId: z.ZodOptional<z.ZodString>;
83
+ agent: z.ZodString;
84
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
85
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
+ eventId: z.ZodOptional<z.ZodUUID>;
87
+ }, z.core.$strict>;
88
+ }, z.core.$strict>;
89
+ export type CreateDraftLearningInput = z.infer<typeof CreateDraftLearningSchema>;
90
+ /** A scope replaces the stored one; `{}` leaves the repository open again. */
91
+ export declare const UpdateDraftLearningSchema: z.ZodObject<{
92
+ content: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
93
+ category: z.ZodOptional<z.ZodEnum<{
94
+ architecture: "architecture";
95
+ convention: "convention";
96
+ correction: "correction";
97
+ gotcha: "gotcha";
98
+ known_gotcha: "known_gotcha";
99
+ deprecated: "deprecated";
100
+ behavior: "behavior";
101
+ review_feedback: "review_feedback";
102
+ other: "other";
103
+ }>>;
104
+ scope: z.ZodOptional<z.ZodObject<{
105
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
106
+ repo: z.ZodOptional<z.ZodString>;
107
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
108
+ project: z.ZodOptional<z.ZodString>;
109
+ component: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strict>>;
111
+ }, z.core.$strict>;
112
+ export type UpdateDraftLearningInput = z.infer<typeof UpdateDraftLearningSchema>;
113
+ /**
114
+ * Without a scope, the draft's own scope is used. Sharing to every repository
115
+ * must be asked for with `workspaceWide`, so an open draft is never shared
116
+ * workspace-wide by omission.
117
+ */
118
+ export declare const ShareDraftLearningSchema: z.ZodObject<{
119
+ scope: z.ZodOptional<z.ZodObject<{
120
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
121
+ repo: z.ZodOptional<z.ZodString>;
122
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
123
+ project: z.ZodOptional<z.ZodString>;
124
+ component: z.ZodOptional<z.ZodString>;
125
+ }, z.core.$strict>>;
126
+ workspaceWide: z.ZodOptional<z.ZodBoolean>;
127
+ }, z.core.$strict>;
128
+ export type ShareDraftLearningInput = z.infer<typeof ShareDraftLearningSchema>;
129
+ /** The shared learning: active when it published, proposed when it waits for review. */
130
+ export declare const ShareDraftLearningResponseSchema: z.ZodObject<{
131
+ memory: z.ZodObject<{
132
+ id: z.ZodUUID;
133
+ workspaceId: z.ZodOptional<z.ZodUUID>;
134
+ content: z.ZodString;
135
+ scope: z.ZodObject<{
136
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
137
+ organization: z.ZodOptional<z.ZodString>;
138
+ project: z.ZodOptional<z.ZodString>;
139
+ repo: z.ZodOptional<z.ZodString>;
140
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
141
+ component: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strict>;
143
+ category: z.ZodEnum<{
144
+ architecture: "architecture";
145
+ convention: "convention";
146
+ correction: "correction";
147
+ gotcha: "gotcha";
148
+ known_gotcha: "known_gotcha";
149
+ deprecated: "deprecated";
150
+ behavior: "behavior";
151
+ review_feedback: "review_feedback";
152
+ other: "other";
153
+ }>;
154
+ status: z.ZodEnum<{
155
+ active: "active";
156
+ proposed: "proposed";
157
+ suppressed: "suppressed";
158
+ superseded: "superseded";
159
+ deleted: "deleted";
160
+ }>;
161
+ source: z.ZodObject<{
162
+ agent: z.ZodString;
163
+ sessionId: z.ZodOptional<z.ZodString>;
164
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
165
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
166
+ workspaceId: z.ZodOptional<z.ZodUUID>;
167
+ eventId: z.ZodOptional<z.ZodUUID>;
168
+ userId: z.ZodOptional<z.ZodUUID>;
169
+ redacted: z.ZodOptional<z.ZodBoolean>;
170
+ }, z.core.$strict>;
171
+ confidence: z.ZodOptional<z.ZodNumber>;
172
+ confirmation: z.ZodOptional<z.ZodEnum<{
173
+ unconfirmed: "unconfirmed";
174
+ implicit: "implicit";
175
+ explicit: "explicit";
176
+ }>>;
177
+ enforcement: z.ZodOptional<z.ZodEnum<{
178
+ required: "required";
179
+ advisory: "advisory";
180
+ }>>;
181
+ guardRule: z.ZodOptional<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
182
+ version: z.ZodLiteral<1>;
183
+ action: z.ZodLiteral<"push">;
184
+ branches: z.ZodOptional<z.ZodArray<z.ZodString>>;
185
+ }, z.core.$strict>, z.ZodObject<{
186
+ version: z.ZodLiteral<1>;
187
+ action: z.ZodLiteral<"edit">;
188
+ path: z.ZodString;
189
+ }, z.core.$strict>, z.ZodObject<{
190
+ version: z.ZodLiteral<1>;
191
+ action: z.ZodEnum<{
192
+ shell: "shell";
193
+ deploy: "deploy";
194
+ commit: "commit";
195
+ }>;
196
+ }, z.core.$strict>], "action">>>;
197
+ reconciliationKey: z.ZodOptional<z.ZodString>;
198
+ fingerprint: z.ZodString;
199
+ supersedesMemoryId: z.ZodNullable<z.ZodUUID>;
200
+ createdAt: z.ZodISODateTime;
201
+ updatedAt: z.ZodISODateTime;
202
+ suppressedAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
203
+ deletedAt: z.ZodNullable<z.ZodISODateTime>;
204
+ }, z.core.$strict>;
205
+ inserted: z.ZodBoolean;
206
+ }, z.core.$strict>;
207
+ export type ShareDraftLearningResponse = z.infer<typeof ShareDraftLearningResponseSchema>;
208
+ export declare const ListDraftLearningsQuerySchema: z.ZodObject<{
209
+ repo: z.ZodOptional<z.ZodString>;
210
+ query: z.ZodOptional<z.ZodString>;
211
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
212
+ offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
213
+ }, z.core.$strict>;
214
+ export type ListDraftLearningsQuery = z.infer<typeof ListDraftLearningsQuerySchema>;
215
+ export declare const ListDraftLearningsResponseSchema: z.ZodObject<{
216
+ drafts: z.ZodArray<z.ZodObject<{
217
+ id: z.ZodUUID;
218
+ content: z.ZodString;
219
+ category: z.ZodEnum<{
220
+ architecture: "architecture";
221
+ convention: "convention";
222
+ correction: "correction";
223
+ gotcha: "gotcha";
224
+ known_gotcha: "known_gotcha";
225
+ deprecated: "deprecated";
226
+ behavior: "behavior";
227
+ review_feedback: "review_feedback";
228
+ other: "other";
229
+ }>;
230
+ scope: z.ZodObject<{
231
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
232
+ repo: z.ZodOptional<z.ZodString>;
233
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
234
+ project: z.ZodOptional<z.ZodString>;
235
+ component: z.ZodOptional<z.ZodString>;
236
+ }, z.core.$strict>;
237
+ source: z.ZodObject<{
238
+ sessionId: z.ZodOptional<z.ZodString>;
239
+ agent: z.ZodString;
240
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
241
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
242
+ eventId: z.ZodOptional<z.ZodUUID>;
243
+ }, z.core.$strict>;
244
+ createdAt: z.ZodISODateTime;
245
+ updatedAt: z.ZodISODateTime;
246
+ }, z.core.$strict>>;
247
+ total: z.ZodNumber;
248
+ }, z.core.$strict>;
249
+ export type ListDraftLearningsResponse = z.infer<typeof ListDraftLearningsResponseSchema>;
250
+ export declare const DraftLearningResponseSchema: z.ZodObject<{
251
+ draft: z.ZodObject<{
252
+ id: z.ZodUUID;
253
+ content: z.ZodString;
254
+ category: z.ZodEnum<{
255
+ architecture: "architecture";
256
+ convention: "convention";
257
+ correction: "correction";
258
+ gotcha: "gotcha";
259
+ known_gotcha: "known_gotcha";
260
+ deprecated: "deprecated";
261
+ behavior: "behavior";
262
+ review_feedback: "review_feedback";
263
+ other: "other";
264
+ }>;
265
+ scope: z.ZodObject<{
266
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
267
+ repo: z.ZodOptional<z.ZodString>;
268
+ agent: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
269
+ project: z.ZodOptional<z.ZodString>;
270
+ component: z.ZodOptional<z.ZodString>;
271
+ }, z.core.$strict>;
272
+ source: z.ZodObject<{
273
+ sessionId: z.ZodOptional<z.ZodString>;
274
+ agent: z.ZodString;
275
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
277
+ eventId: z.ZodOptional<z.ZodUUID>;
278
+ }, z.core.$strict>;
279
+ createdAt: z.ZodISODateTime;
280
+ updatedAt: z.ZodISODateTime;
281
+ }, z.core.$strict>;
282
+ }, z.core.$strict>;
283
+ export type DraftLearningResponse = z.infer<typeof DraftLearningResponseSchema>;
284
+ export declare const DeleteDraftLearningResponseSchema: z.ZodObject<{
285
+ deleted: z.ZodLiteral<true>;
286
+ }, z.core.$strict>;
287
+ export type DeleteDraftLearningResponse = z.infer<typeof DeleteDraftLearningResponseSchema>;
288
+ //# sourceMappingURL=draft-learnings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-learnings.d.ts","sourceRoot":"","sources":["../src/draft-learnings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB;;;;;;kBAAiD,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,iFAAiF;AACjF,eAAO,MAAM,yBAAyB;;;;;;kBAMpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,6BAA6B,OAAQ,CAAC;AAGnD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAQrB,CAAC;AACZ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAK3B,CAAC;AACZ,MAAM,MAAM,wBAAwB,G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ryResultSchema, LearningContentSchema, MemoryCategorySchema, MemoryScopeSchema, MemorySourceSchema, } from "./schemas.js";
3
+ /**
4
+ * A draft learning belongs to one member. Nobody else, owners and admins
5
+ * included, can list, read, review or receive it. Drafts live outside the
6
+ * shared knowledge base: sharing one creates an ordinary learning through the
7
+ * same path as `remember`, so workspace review rules apply at that moment.
8
+ *
9
+ * A draft may leave its repository open. The author chooses where it applies
10
+ * when sharing.
11
+ */
12
+ export const DraftLearningScopeSchema = MemoryScopeSchema.omit({ organization: true });
13
+ /** Where the draft came from. The owner is the viewer, so no user is exposed. */
14
+ export const DraftLearningSourceSchema = MemorySourceSchema.pick({
15
+ agent: true,
16
+ sessionId: true,
17
+ messageId: true,
18
+ rawText: true,
19
+ eventId: true,
20
+ });
21
+ export const DRAFT_LEARNING_MAX_CHARACTERS = 5_000;
22
+ const DraftContentSchema = LearningContentSchema.pipe(z.string().max(DRAFT_LEARNING_MAX_CHARACTERS));
23
+ export const DraftLearningSchema = z.object({
24
+ id: z.uuid(),
25
+ content: z.string().min(1),
26
+ category: MemoryCategorySchema,
27
+ scope: DraftLearningScopeSchema,
28
+ source: DraftLearningSourceSchema,
29
+ createdAt: z.iso.datetime({ offset: true }),
30
+ updatedAt: z.iso.datetime({ offset: true }),
31
+ }).strict();
32
+ export const CreateDraftLearningSchema = z.object({
33
+ content: DraftContentSchema,
34
+ category: MemoryCategorySchema.optional(),
35
+ scope: DraftLearningScopeSchema.optional(),
36
+ source: DraftLearningSourceSchema,
37
+ }).strict();
38
+ /** A scope replaces the stored one; `{}` leaves the repository open again. */
39
+ export const UpdateDraftLearningSchema = z.object({
40
+ content: DraftContentSchema.optional(),
41
+ category: MemoryCategorySchema.optional(),
42
+ scope: DraftLearningScopeSchema.optional(),
43
+ }).strict().refine(input => input.content !== undefined || input.category !== undefined || input.scope !== undefined, { message: "Change the content, category or scope." });
44
+ /**
45
+ * Without a scope, the draft's own scope is used. Sharing to every repository
46
+ * must be asked for with `workspaceWide`, so an open draft is never shared
47
+ * workspace-wide by omission.
48
+ */
49
+ export const ShareDraftLearningSchema = z.object({
50
+ scope: DraftLearningScopeSchema.optional(),
51
+ workspaceWide: z.boolean().optional(),
52
+ }).strict().refine(input => !(input.workspaceWide && input.scope?.repo), { message: "Choose a repository or the entire workspace, not both.", path: ["workspaceWide"] });
53
+ /** The shared learning: active when it published, proposed when it waits for review. */
54
+ export const ShareDraftLearningResponseSchema = InsertMemoryResultSchema;
55
+ export const ListDraftLearningsQuerySchema = z.object({
56
+ repo: z.string().trim().min(1).max(1000).optional(),
57
+ query: z.string().trim().min(1).max(500).optional(),
58
+ limit: z.coerce.number().int().positive().max(100).optional(),
59
+ offset: z.coerce.number().int().nonnegative().optional(),
60
+ }).strict();
61
+ export const ListDraftLearningsResponseSchema = z.object({
62
+ drafts: z.array(DraftLearningSchema),
63
+ total: z.number().int().nonnegative(),
64
+ }).strict();
65
+ export const DraftLearningResponseSchema = z.object({ draft: DraftLearningSchema }).strict();
66
+ export const DeleteDraftLearningResponseSchema = z.object({ deleted: z.literal(true) }).strict();
67
+ //# sourceMappingURL=draft-learnings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-learnings.js","sourceRoot":"","sources":["../src/draft-learnings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;AAGvF,iFAAiF;AACjF,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAC/D,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IA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,EAAE;CACzD,CAAC,CAAC,MAAM,EAAE,CAAC;AAGZ,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;CACtC,CAAC,CAAC,MAAM,EAAE,CAAC;AAGZ,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAG7F,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC"}
package/dist/engine.d.ts CHANGED
@@ -6,8 +6,6 @@ export interface SharedMemoryEngineDependencies {
6
6
  retriever: MemoryRetriever;
7
7
  conflictDetector?: MemoryConflictDetector;
8
8
  minimumConfidence?: number;
9
- /** Hosted workspaces require administrator review of all agent captures. */
10
- requireCaptureReview?: boolean;
11
9
  }
12
10
  export interface MemoryObservationOptions extends MemoryExtractionOptions {
13
11
  mutationFence?: MemoryMutationFence;
@@ -64,8 +62,15 @@ export declare class SharedMemoryEngine {
64
62
  getProposal(proposalMemoryId: string, context: WorkspaceRepositoryContext): Promise<ProposalRecord | null>;
65
63
  recordProposalConflict(inputValue: RecordProposalConflictDto, context: WorkspaceRepositoryContext): Promise<MemoryConflict>;
66
64
  reviewProposal(inputValue: ReviewProposalDto, context: WorkspaceRepositoryContext): Promise<ReviewProposalResponse>;
65
+ /**
66
+ * `reviewIfOverlapping` checks the learning against existing knowledge and
67
+ * records plausible overlaps as conflicts, so the proposal carries them to
68
+ * its reviewer. A learning that would otherwise publish directly waits for
69
+ * review when it overlaps.
70
+ */
67
71
  remember(input: CreateMemoryDto, options?: {
68
72
  requireReview?: boolean;
73
+ reviewIfOverlapping?: boolean;
69
74
  }): Promise<RememberResponse>;
70
75
  correct(input: CorrectMemoryDto, context?: RepositoryContext): Promise<CorrectMemoryResponse>;
71
76
  forget(input: ForgetMemoryDto | string, context?: RepositoryContext): Promise<ForgetMemoryResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAEA,OAAO,EAqBL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EAEpB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC7B,MAAM,cAAc,CAAC;AAQtB,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAChC,MAAM,YAAY,CAAC;AAMpB,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,eAAe,CAAC;IAC3B,gBAAgB,CAAC,EAAE,sBAAsB,CA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AE,iBAAiB,EAC7B,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,sBAAsB,CAAC;IAQlC;;;;;OAKG;IACG,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAC;QAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqErI,OAAO,CACX,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC;IAqD3B,MAAM,CACV,KAAK,EAAE,eAAe,GAAG,MAAM,EAC/B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAe1B,YAAY,CAChB,KAAK,GAAE,eAAoB,EAC3B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IAa1B,SAAS,CACb,KAAK,EAAE,YAAY,GAAG,MAAM,EAC5B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,iBAAiB,CAAC;CAU9B;AAED,OAAO,EAAE,kBAAkB,IAAI,UAAU,EAAE,CAAC"}
package/dist/engine.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
2
  import { REVIEW_REQUIRED_CONNECTOR_REASON } from "./connector-review.js";
3
- import { AgentInteractionSchema, AgentTaskSchema, CandidateMemorySchema, CorrectMemoryDtoSchema, CreateMemoryDtoSchema, ForgetMemoryDtoSchema, GetMemoryDtoSchema, ListMemoriesDtoSchema, MemoryConflictSchema, MemorySchema, normalizeInteractionScope, normalizeScopeAgent, ProposalMetadataSchema, ProposalRecordSchema, RecordProposalConflictDtoSchema, ReviewProposalDtoSchema, ReviewProposalResponseSchema, UpdateWorkspaceLearningPolicySchema, WorkspaceLearningPolicySchema, withRetrievalExplanation, } from "./schemas.js";
3
+ import { AgentInteractionSchema, AgentTaskSchema, CandidateMemorySchema, CorrectMemoryDtoSchema, CreateMemoryDtoSchema, ForgetMemoryDtoSchema, GetMemoryDtoSchema, isWorkspaceWideScope, ListMemoriesDtoSchema, MemoryConflictSchema, MemorySchema, normalizeInteractionScope, normalizeScopeAgent, ProposalMetadataSchema, ProposalRecordSchema, RecordProposalConflictDtoSchema, ReviewProposalDtoSchema, ReviewProposalResponseSchema, UpdateWorkspaceLearningPolicySchema, WorkspaceLearningPolicySchema, withRetrievalExplanation, } from "./schemas.js";
4
4
  import { redactMemoryForDelivery, redactRetrievalHitForDelivery, redactSensitiveText, redactUnknown, } from "./redaction.js";
5
5
  import { MAX_EXTRACTED_MEMORY_CANDIDATES, ProviderError, } from "./ports.js";
6
6
  import { ScopedMemoryConflictDetector } from "./conflict-detector.js";
7
7
  import { contradictoryObligations, isTemporaryTeaching, isTaskOnlyText } from "./knowledge-quality.js";
8
- import { isQuestionReplyMessage } from "./user-message.js";
8
+ import { hasPersonRequest, isQuestionReplyMessage } from "./user-message.js";
9
9
  import { createCanonicalJsonSha256 } from "./canonical-json.js";
10
10
  /** Resolve references only after earlier writes reveal their persisted IDs. */
11
11
  export function remapMemoryMutationPlanEntry(entry, persistedIds) {
@@ -112,6 +112,12 @@ function isExplicitOrganizationCandidate(candidate) {
112
112
  return (normalizedComparison(rawText).includes(normalizedComparison(evidence)) &&
113
113
  ORGANIZATION_SCOPE_SIGNAL.test(evidence));
114
114
  }
115
+ function isPlausibleConflict(conflict) {
116
+ return conflict.detector === "deterministic" || conflict.detector === "semantic" ||
117
+ (conflict.detector === "llm" && conflict.evidence.details?.classification === "conflict") ||
118
+ (conflict.detector === "lexical" && Array.isArray(conflict.evidence.details?.matchedTerms) &&
119
+ conflict.evidence.details.matchedTerms.length >= 2);
120
+ }
115
121
  function resolveCandidateScope(taskScope, candidate, reconciliationTarget) {
116
122
  if (isExplicitOrganizationCandidate(candidate) &&
117
123
  taskScope.organization !== undefined) {
@@ -307,7 +313,6 @@ export class SharedMemoryEngine {
307
313
  #retriever;
308
314
  #conflictDetector;
309
315
  #minimumConfidence;
310
- #requireCaptureReview;
311
316
  constructor(dependenciesOrRepository, extractor, retriever) {
312
317
  if ("repository" in dependenciesOrRepository &&
313
318
  "extractor" in dependenciesOrRepository &&
@@ -315,7 +320,6 @@ export class SharedMemoryEngine {
315
320
  this.#repository = dependenciesOrRepository.repository;
316
321
  this.#extractor = dependenciesOrRepository.extractor;
317
322
  this.#retriever = dependenciesOrRepository.retriever;
318
- this.#requireCaptureReview = dependenciesOrRepository.requireCaptureReview ?? false;
319
323
  this.#conflictDetector =
320
324
  dependenciesOrRepository.conflictDetector ??
321
325
  new ScopedMemoryConflictDetector(dependenciesOrRepository.retriever);
@@ -330,7 +334,6 @@ export class SharedMemoryEngine {
330
334
  this.#retriever = retriever;
331
335
  this.#conflictDetector = new ScopedMemoryConflictDetector(retriever);
332
336
  this.#minimumConfidence = 0.8;
333
- this.#requireCaptureReview = false;
334
337
  }
335
338
  async assertRepositoryAllowed(workspaceId, repo) {
336
339
  if (workspaceId === undefined)
@@ -476,10 +479,13 @@ export class SharedMemoryEngine {
476
479
  // Harvested text (for example a merged pull request) never publishes
477
480
  // directly, even when the extractor marks the teaching explicit.
478
481
  const reviewRequired = interaction.reviewRequired === true;
482
+ // Knowledge for the entire workspace reaches every repository, so only
483
+ // an owner or admin publishes it, even when review is otherwise off.
484
+ const workspaceWide = isWorkspaceWideScope(candidateScope);
479
485
  let shouldPropose = interaction.workspaceId !== undefined &&
480
486
  (reviewRequired ||
481
- this.#requireCaptureReview ||
482
487
  learningMode === "proposal_only" ||
488
+ workspaceWide ||
483
489
  supersedesMemoryId !== undefined ||
484
490
  candidate.confirmation !== "explicit");
485
491
  let memory = createMemory({
@@ -522,10 +528,7 @@ export class SharedMemoryEngine {
522
528
  ];
523
529
  // Explicit teaching is evidence of intent, not evidence that it is
524
530
  // compatible with existing knowledge. Review plausible overlaps too.
525
- const possibleConflict = detected.some((conflict) => conflict.detector === "deterministic" || conflict.detector === "semantic" ||
526
- (conflict.detector === "llm" && conflict.evidence.details?.classification === "conflict") ||
527
- (conflict.detector === "lexical" && Array.isArray(conflict.evidence.details?.matchedTerms) &&
528
- conflict.evidence.details.matchedTerms.length >= 2));
531
+ const possibleConflict = detected.some(isPlausibleConflict);
529
532
  if (!shouldPropose && possibleConflict) {
530
533
  shouldPropose = true;
531
534
  memory = { ...memory, status: "proposed" };
@@ -541,10 +544,10 @@ export class SharedMemoryEngine {
541
544
  policyMode: learningMode,
542
545
  reason: reviewRequired
543
546
  ? REVIEW_REQUIRED_CONNECTOR_REASON
544
- : this.#requireCaptureReview
545
- ? "Automatic captures require owner or admin review."
546
- : learningMode === "proposal_only"
547
- ? "Workspace policy requires review for automatic captures."
547
+ : learningMode === "proposal_only"
548
+ ? "Workspace policy requires review for automatic captures."
549
+ : workspaceWide
550
+ ? "Automatic captures for the entire workspace need owner or admin review."
548
551
  : supersedesMemoryId === undefined
549
552
  ? possibleConflict
550
553
  ? "This teaching overlaps existing knowledge and requires conflict review."
@@ -672,6 +675,9 @@ export class SharedMemoryEngine {
672
675
  }
673
676
  async getContextWithDiagnostics(taskInput, context) {
674
677
  const task = AgentTaskSchema.parse(taskInput);
678
+ if (!hasPersonRequest(task.task)) {
679
+ return { memories: [], hits: [], retrievalMode: "lexical_only" };
680
+ }
675
681
  // Searching every repository must not reach one the workspace turned off.
676
682
  const retrievalContext = context?.allRepositories && context.workspaceId !== undefined && context.repositoryPolicy === undefined
677
683
  ? { ...context, repositoryPolicy: await this.#repository.getRepositoryPolicy(context.workspaceId) }
@@ -730,6 +736,12 @@ export class SharedMemoryEngine {
730
736
  const result = await this.#repository.reviewProposal(input, context);
731
737
  return ReviewProposalResponseSchema.parse(redactUnknown(result).value);
732
738
  }
739
+ /**
740
+ * `reviewIfOverlapping` checks the learning against existing knowledge and
741
+ * records plausible overlaps as conflicts, so the proposal carries them to
742
+ * its reviewer. A learning that would otherwise publish directly waits for
743
+ * review when it overlaps.
744
+ */
733
745
  async remember(input, options = {}) {
734
746
  const redaction = redactUnknown(CreateMemoryDtoSchema.parse(input));
735
747
  const value = CreateMemoryDtoSchema.parse(redaction.value);
@@ -746,7 +758,7 @@ export class SharedMemoryEngine {
746
758
  if (value.import?.targetMemoryId && (!target || target.status !== "active")) {
747
759
  throw new Error("Import replacement target must be an active memory in this workspace.");
748
760
  }
749
- const memory = createMemory({
761
+ let memory = createMemory({
750
762
  ...(source.workspaceId === undefined
751
763
  ? {}
752
764
  : { workspaceId: source.workspaceId }),
@@ -760,22 +772,30 @@ export class SharedMemoryEngine {
760
772
  confirmation: "explicit",
761
773
  ...(requireReview ? { status: "proposed" } : {}),
762
774
  });
763
- const detected = value.import && memory.workspaceId ? await this.#conflictDetector.detect({
775
+ const checkOverlap = options.reviewIfOverlapping === true;
776
+ const detected = (value.import || checkOverlap) && memory.workspaceId ? await this.#conflictDetector.detect({
764
777
  proposal: memory,
765
778
  ...(target ? { deterministicTarget: target } : {}),
766
779
  policy: { ...await this.#repository.getWorkspaceLearningPolicy(memory.workspaceId), llmConflictAnalysisEnabled: false },
767
780
  }, { workspaceId: memory.workspaceId }) : [];
768
- const conflicts = detected.map(conflict => MemoryConflictSchema.parse({
781
+ const overlapping = checkOverlap && detected.some(isPlausibleConflict);
782
+ if (overlapping)
783
+ memory = { ...memory, status: "proposed" };
784
+ // An import keeps every detected conflict; a person's save keeps plausible ones.
785
+ const conflicts = (value.import ? detected : detected.filter(isPlausibleConflict)).map(conflict => MemoryConflictSchema.parse({
769
786
  ...conflict, id: randomUUID(), workspaceId: memory.workspaceId,
770
787
  proposalMemoryId: memory.id, createdAt: memory.createdAt,
771
788
  resolution: null, resolvedAt: null,
772
789
  }));
773
- const result = requireReview
790
+ const result = requireReview || overlapping
774
791
  ? await this.#repository.propose(memory, {
775
792
  memoryId: memory.id,
776
793
  workspaceId: memory.workspaceId,
777
794
  policyMode: "proposal_only",
778
- reason: value.import ? "Imported knowledge needs owner or admin review before agents can use it." : "An owner or admin must approve this learning before agents can use it.",
795
+ // Why it waits; who may approve depends on the workspace review rules.
796
+ reason: value.import ? "Imported from local agent knowledge."
797
+ : overlapping ? "This learning overlaps existing knowledge."
798
+ : "Saved by a member.",
779
799
  provenance: memory.source,
780
800
  proposedAt: memory.createdAt,
781
801
  decision: null,