@lore-co/core 0.1.13 → 0.1.14

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.
@@ -0,0 +1,406 @@
1
+ import { z } from "zod";
2
+ import { ConnectorEventTypeSchema } from "./pilot-schemas.js";
3
+ export declare const WorkSessionSchema: z.ZodObject<{
4
+ id: z.ZodUUID;
5
+ workspaceId: z.ZodUUID;
6
+ connector: z.ZodString;
7
+ externalSessionId: z.ZodString;
8
+ agent: z.ZodString;
9
+ project: z.ZodNullable<z.ZodString>;
10
+ repo: z.ZodNullable<z.ZodString>;
11
+ title: z.ZodNullable<z.ZodString>;
12
+ parentSessionId: z.ZodNullable<z.ZodUUID>;
13
+ startedAt: z.ZodISODateTime;
14
+ lastActivityAt: z.ZodISODateTime;
15
+ endedAt: z.ZodNullable<z.ZodISODateTime>;
16
+ eventCount: z.ZodNumber;
17
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
18
+ }, z.core.$strict>;
19
+ export type WorkSession = z.infer<typeof WorkSessionSchema>;
20
+ export declare const ListWorkSessionsQuerySchema: z.ZodObject<{
21
+ repo: z.ZodOptional<z.ZodString>;
22
+ project: z.ZodOptional<z.ZodString>;
23
+ agent: z.ZodOptional<z.ZodString>;
24
+ connector: z.ZodOptional<z.ZodString>;
25
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
26
+ offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
27
+ }, z.core.$strict>;
28
+ export type ListWorkSessionsQuery = z.infer<typeof ListWorkSessionsQuerySchema>;
29
+ export declare const ListWorkSessionsResponseSchema: z.ZodObject<{
30
+ sessions: z.ZodArray<z.ZodObject<{
31
+ id: z.ZodUUID;
32
+ workspaceId: z.ZodUUID;
33
+ connector: z.ZodString;
34
+ externalSessionId: z.ZodString;
35
+ agent: z.ZodString;
36
+ project: z.ZodNullable<z.ZodString>;
37
+ repo: z.ZodNullable<z.ZodString>;
38
+ title: z.ZodNullable<z.ZodString>;
39
+ parentSessionId: z.ZodNullable<z.ZodUUID>;
40
+ startedAt: z.ZodISODateTime;
41
+ lastActivityAt: z.ZodISODateTime;
42
+ endedAt: z.ZodNullable<z.ZodISODateTime>;
43
+ eventCount: z.ZodNumber;
44
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
45
+ }, z.core.$strict>>;
46
+ total: z.ZodNumber;
47
+ limit: z.ZodNumber;
48
+ offset: z.ZodNumber;
49
+ }, z.core.$strict>;
50
+ export type ListWorkSessionsResponse = z.infer<typeof ListWorkSessionsResponseSchema>;
51
+ export declare const SessionEventDigestSchema: z.ZodObject<{
52
+ eventId: z.ZodUUID;
53
+ type: z.ZodEnum<{
54
+ observation: "observation";
55
+ paired_turn: "paired_turn";
56
+ context_delivery: "context_delivery";
57
+ }>;
58
+ occurredAt: z.ZodISODateTime;
59
+ task: z.ZodNullable<z.ZodString>;
60
+ userText: z.ZodNullable<z.ZodString>;
61
+ assistantText: z.ZodNullable<z.ZodString>;
62
+ }, z.core.$strict>;
63
+ export type SessionEventDigest = z.infer<typeof SessionEventDigestSchema>;
64
+ export declare const SessionMemorySummarySchema: z.ZodObject<{
65
+ id: z.ZodUUID;
66
+ content: z.ZodString;
67
+ category: z.ZodEnum<{
68
+ architecture: "architecture";
69
+ convention: "convention";
70
+ correction: "correction";
71
+ gotcha: "gotcha";
72
+ known_gotcha: "known_gotcha";
73
+ deprecated: "deprecated";
74
+ behavior: "behavior";
75
+ review_feedback: "review_feedback";
76
+ other: "other";
77
+ }>;
78
+ status: z.ZodEnum<{
79
+ active: "active";
80
+ proposed: "proposed";
81
+ suppressed: "suppressed";
82
+ superseded: "superseded";
83
+ deleted: "deleted";
84
+ }>;
85
+ }, z.core.$strict>;
86
+ export type SessionMemorySummary = z.infer<typeof SessionMemorySummarySchema>;
87
+ export declare const WorkSessionDetailResponseSchema: z.ZodObject<{
88
+ session: z.ZodObject<{
89
+ id: z.ZodUUID;
90
+ workspaceId: z.ZodUUID;
91
+ connector: z.ZodString;
92
+ externalSessionId: z.ZodString;
93
+ agent: z.ZodString;
94
+ project: z.ZodNullable<z.ZodString>;
95
+ repo: z.ZodNullable<z.ZodString>;
96
+ title: z.ZodNullable<z.ZodString>;
97
+ parentSessionId: z.ZodNullable<z.ZodUUID>;
98
+ startedAt: z.ZodISODateTime;
99
+ lastActivityAt: z.ZodISODateTime;
100
+ endedAt: z.ZodNullable<z.ZodISODateTime>;
101
+ eventCount: z.ZodNumber;
102
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
103
+ }, z.core.$strict>;
104
+ events: z.ZodArray<z.ZodObject<{
105
+ eventId: z.ZodUUID;
106
+ type: z.ZodEnum<{
107
+ observation: "observation";
108
+ paired_turn: "paired_turn";
109
+ context_delivery: "context_delivery";
110
+ }>;
111
+ occurredAt: z.ZodISODateTime;
112
+ task: z.ZodNullable<z.ZodString>;
113
+ userText: z.ZodNullable<z.ZodString>;
114
+ assistantText: z.ZodNullable<z.ZodString>;
115
+ }, z.core.$strict>>;
116
+ learnings: z.ZodArray<z.ZodObject<{
117
+ id: z.ZodUUID;
118
+ content: z.ZodString;
119
+ category: z.ZodEnum<{
120
+ architecture: "architecture";
121
+ convention: "convention";
122
+ correction: "correction";
123
+ gotcha: "gotcha";
124
+ known_gotcha: "known_gotcha";
125
+ deprecated: "deprecated";
126
+ behavior: "behavior";
127
+ review_feedback: "review_feedback";
128
+ other: "other";
129
+ }>;
130
+ status: z.ZodEnum<{
131
+ active: "active";
132
+ proposed: "proposed";
133
+ suppressed: "suppressed";
134
+ superseded: "superseded";
135
+ deleted: "deleted";
136
+ }>;
137
+ }, z.core.$strict>>;
138
+ deliveredMemories: z.ZodArray<z.ZodObject<{
139
+ id: z.ZodUUID;
140
+ content: z.ZodString;
141
+ category: z.ZodEnum<{
142
+ architecture: "architecture";
143
+ convention: "convention";
144
+ correction: "correction";
145
+ gotcha: "gotcha";
146
+ known_gotcha: "known_gotcha";
147
+ deprecated: "deprecated";
148
+ behavior: "behavior";
149
+ review_feedback: "review_feedback";
150
+ other: "other";
151
+ }>;
152
+ status: z.ZodEnum<{
153
+ active: "active";
154
+ proposed: "proposed";
155
+ suppressed: "suppressed";
156
+ superseded: "superseded";
157
+ deleted: "deleted";
158
+ }>;
159
+ }, z.core.$strict>>;
160
+ }, z.core.$strict>;
161
+ export type WorkSessionDetailResponse = z.infer<typeof WorkSessionDetailResponseSchema>;
162
+ export declare const AskRequestSchema: z.ZodObject<{
163
+ question: z.ZodString;
164
+ agent: z.ZodOptional<z.ZodString>;
165
+ project: z.ZodOptional<z.ZodString>;
166
+ repo: z.ZodOptional<z.ZodString>;
167
+ limit: z.ZodOptional<z.ZodNumber>;
168
+ includeSessions: z.ZodOptional<z.ZodBoolean>;
169
+ sessionLimit: z.ZodOptional<z.ZodNumber>;
170
+ }, z.core.$strict>;
171
+ export type AskRequest = z.infer<typeof AskRequestSchema>;
172
+ export declare const AskSessionExcerptSchema: z.ZodObject<{
173
+ eventId: z.ZodUUID;
174
+ type: z.ZodEnum<{
175
+ observation: "observation";
176
+ paired_turn: "paired_turn";
177
+ context_delivery: "context_delivery";
178
+ }>;
179
+ occurredAt: z.ZodISODateTime;
180
+ text: z.ZodString;
181
+ }, z.core.$strict>;
182
+ export type AskSessionExcerpt = z.infer<typeof AskSessionExcerptSchema>;
183
+ export declare const AskSessionMatchSchema: z.ZodObject<{
184
+ session: z.ZodObject<{
185
+ id: z.ZodUUID;
186
+ workspaceId: z.ZodUUID;
187
+ connector: z.ZodString;
188
+ externalSessionId: z.ZodString;
189
+ agent: z.ZodString;
190
+ project: z.ZodNullable<z.ZodString>;
191
+ repo: z.ZodNullable<z.ZodString>;
192
+ title: z.ZodNullable<z.ZodString>;
193
+ parentSessionId: z.ZodNullable<z.ZodUUID>;
194
+ startedAt: z.ZodISODateTime;
195
+ lastActivityAt: z.ZodISODateTime;
196
+ endedAt: z.ZodNullable<z.ZodISODateTime>;
197
+ eventCount: z.ZodNumber;
198
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
199
+ }, z.core.$strict>;
200
+ excerpts: z.ZodArray<z.ZodObject<{
201
+ eventId: z.ZodUUID;
202
+ type: z.ZodEnum<{
203
+ observation: "observation";
204
+ paired_turn: "paired_turn";
205
+ context_delivery: "context_delivery";
206
+ }>;
207
+ occurredAt: z.ZodISODateTime;
208
+ text: z.ZodString;
209
+ }, z.core.$strict>>;
210
+ }, z.core.$strict>;
211
+ export type AskSessionMatch = z.infer<typeof AskSessionMatchSchema>;
212
+ export declare const AskResponseSchema: z.ZodObject<{
213
+ question: z.ZodString;
214
+ knowledge: z.ZodArray<z.ZodObject<{
215
+ memory: z.ZodObject<{
216
+ id: z.ZodUUID;
217
+ workspaceId: z.ZodOptional<z.ZodUUID>;
218
+ content: z.ZodString;
219
+ scope: z.ZodObject<{
220
+ organization: z.ZodOptional<z.ZodString>;
221
+ project: z.ZodOptional<z.ZodString>;
222
+ repo: z.ZodOptional<z.ZodString>;
223
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
224
+ component: z.ZodOptional<z.ZodString>;
225
+ }, z.core.$strict>;
226
+ category: z.ZodEnum<{
227
+ architecture: "architecture";
228
+ convention: "convention";
229
+ correction: "correction";
230
+ gotcha: "gotcha";
231
+ known_gotcha: "known_gotcha";
232
+ deprecated: "deprecated";
233
+ behavior: "behavior";
234
+ review_feedback: "review_feedback";
235
+ other: "other";
236
+ }>;
237
+ status: z.ZodEnum<{
238
+ active: "active";
239
+ proposed: "proposed";
240
+ suppressed: "suppressed";
241
+ superseded: "superseded";
242
+ deleted: "deleted";
243
+ }>;
244
+ source: z.ZodObject<{
245
+ agent: z.ZodString;
246
+ sessionId: z.ZodOptional<z.ZodString>;
247
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
248
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
249
+ workspaceId: z.ZodOptional<z.ZodUUID>;
250
+ eventId: z.ZodOptional<z.ZodUUID>;
251
+ userId: z.ZodOptional<z.ZodUUID>;
252
+ redacted: z.ZodOptional<z.ZodBoolean>;
253
+ }, z.core.$strict>;
254
+ confidence: z.ZodOptional<z.ZodNumber>;
255
+ confirmation: z.ZodOptional<z.ZodEnum<{
256
+ unconfirmed: "unconfirmed";
257
+ implicit: "implicit";
258
+ explicit: "explicit";
259
+ }>>;
260
+ reconciliationKey: z.ZodOptional<z.ZodString>;
261
+ fingerprint: z.ZodString;
262
+ supersedesMemoryId: z.ZodNullable<z.ZodUUID>;
263
+ createdAt: z.ZodISODateTime;
264
+ updatedAt: z.ZodISODateTime;
265
+ suppressedAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
266
+ deletedAt: z.ZodNullable<z.ZodISODateTime>;
267
+ }, z.core.$strict>;
268
+ score: z.ZodNumber;
269
+ reasons: z.ZodArray<z.ZodEnum<{
270
+ symbol: "symbol";
271
+ path: "path";
272
+ lexical: "lexical";
273
+ semantic: "semantic";
274
+ component: "component";
275
+ repository: "repository";
276
+ }>>;
277
+ matchedTerms: z.ZodDefault<z.ZodArray<z.ZodString>>;
278
+ lexicalRank: z.ZodNullable<z.ZodNumber>;
279
+ semanticRank: z.ZodNullable<z.ZodNumber>;
280
+ }, z.core.$strict>>;
281
+ memories: z.ZodArray<z.ZodObject<{
282
+ id: z.ZodUUID;
283
+ workspaceId: z.ZodOptional<z.ZodUUID>;
284
+ content: z.ZodString;
285
+ scope: z.ZodObject<{
286
+ organization: z.ZodOptional<z.ZodString>;
287
+ project: z.ZodOptional<z.ZodString>;
288
+ repo: z.ZodOptional<z.ZodString>;
289
+ path: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
290
+ component: z.ZodOptional<z.ZodString>;
291
+ }, z.core.$strict>;
292
+ category: z.ZodEnum<{
293
+ architecture: "architecture";
294
+ convention: "convention";
295
+ correction: "correction";
296
+ gotcha: "gotcha";
297
+ known_gotcha: "known_gotcha";
298
+ deprecated: "deprecated";
299
+ behavior: "behavior";
300
+ review_feedback: "review_feedback";
301
+ other: "other";
302
+ }>;
303
+ status: z.ZodEnum<{
304
+ active: "active";
305
+ proposed: "proposed";
306
+ suppressed: "suppressed";
307
+ superseded: "superseded";
308
+ deleted: "deleted";
309
+ }>;
310
+ source: z.ZodObject<{
311
+ agent: z.ZodString;
312
+ sessionId: z.ZodOptional<z.ZodString>;
313
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
314
+ rawText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
315
+ workspaceId: z.ZodOptional<z.ZodUUID>;
316
+ eventId: z.ZodOptional<z.ZodUUID>;
317
+ userId: z.ZodOptional<z.ZodUUID>;
318
+ redacted: z.ZodOptional<z.ZodBoolean>;
319
+ }, z.core.$strict>;
320
+ confidence: z.ZodOptional<z.ZodNumber>;
321
+ confirmation: z.ZodOptional<z.ZodEnum<{
322
+ unconfirmed: "unconfirmed";
323
+ implicit: "implicit";
324
+ explicit: "explicit";
325
+ }>>;
326
+ reconciliationKey: z.ZodOptional<z.ZodString>;
327
+ fingerprint: z.ZodString;
328
+ supersedesMemoryId: z.ZodNullable<z.ZodUUID>;
329
+ createdAt: z.ZodISODateTime;
330
+ updatedAt: z.ZodISODateTime;
331
+ suppressedAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
332
+ deletedAt: z.ZodNullable<z.ZodISODateTime>;
333
+ }, z.core.$strict>>;
334
+ sessions: z.ZodArray<z.ZodObject<{
335
+ session: z.ZodObject<{
336
+ id: z.ZodUUID;
337
+ workspaceId: z.ZodUUID;
338
+ connector: z.ZodString;
339
+ externalSessionId: z.ZodString;
340
+ agent: z.ZodString;
341
+ project: z.ZodNullable<z.ZodString>;
342
+ repo: z.ZodNullable<z.ZodString>;
343
+ title: z.ZodNullable<z.ZodString>;
344
+ parentSessionId: z.ZodNullable<z.ZodUUID>;
345
+ startedAt: z.ZodISODateTime;
346
+ lastActivityAt: z.ZodISODateTime;
347
+ endedAt: z.ZodNullable<z.ZodISODateTime>;
348
+ eventCount: z.ZodNumber;
349
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
350
+ }, z.core.$strict>;
351
+ excerpts: z.ZodArray<z.ZodObject<{
352
+ eventId: z.ZodUUID;
353
+ type: z.ZodEnum<{
354
+ observation: "observation";
355
+ paired_turn: "paired_turn";
356
+ context_delivery: "context_delivery";
357
+ }>;
358
+ occurredAt: z.ZodISODateTime;
359
+ text: z.ZodString;
360
+ }, z.core.$strict>>;
361
+ }, z.core.$strict>>;
362
+ context: z.ZodString;
363
+ packing: z.ZodOptional<z.ZodObject<{
364
+ policyVersion: z.ZodLiteral<"context-pack-v1">;
365
+ estimator: z.ZodLiteral<"utf8-bytes-div-3-v1">;
366
+ limits: z.ZodObject<{
367
+ requestedItems: z.ZodNullable<z.ZodNumber>;
368
+ effectiveItems: z.ZodNumber;
369
+ maxCharacters: z.ZodNumber;
370
+ maxEstimatedTokens: z.ZodNumber;
371
+ }, z.core.$strict>;
372
+ usage: z.ZodObject<{
373
+ retrievedItems: z.ZodNumber;
374
+ includedItems: z.ZodNumber;
375
+ omittedItems: z.ZodNumber;
376
+ characters: z.ZodNumber;
377
+ utf8Bytes: z.ZodNumber;
378
+ estimatedTokens: z.ZodNumber;
379
+ }, z.core.$strict>;
380
+ includedMemoryIds: z.ZodArray<z.ZodUUID>;
381
+ omitted: z.ZodArray<z.ZodObject<{
382
+ memoryId: z.ZodUUID;
383
+ reason: z.ZodEnum<{
384
+ characters: "characters";
385
+ items: "items";
386
+ estimated_tokens: "estimated_tokens";
387
+ }>;
388
+ }, z.core.$strict>>;
389
+ contextSha256: z.ZodString;
390
+ }, z.core.$strict>>;
391
+ }, z.core.$strict>;
392
+ export type AskResponse = z.infer<typeof AskResponseSchema>;
393
+ export interface SessionEventLike {
394
+ id: string;
395
+ type: z.infer<typeof ConnectorEventTypeSchema>;
396
+ payload: Record<string, unknown>;
397
+ occurredAt: string;
398
+ }
399
+ /**
400
+ * Extracts the human-meaningful text from a connector event payload without
401
+ * assuming a single payload shape. Observations store the raw request,
402
+ * paired turns store the turn request, and context deliveries store a
403
+ * request/response envelope.
404
+ */
405
+ export declare function digestSessionEvent(event: SessionEventLike): SessionEventDigest;
406
+ //# sourceMappingURL=session-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-schemas.d.ts","sourceRoot":"","sources":["../src/session-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,wBAAwB,EAEzB,MAAM,oBAAoB,CAAC;AAS5B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;kBAiBnB,CAAC;AACZ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,2BAA2B;;;;;;;kBAS7B,CAAC;AACZ,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CACzC,OAAO,2BAA2B,CACnC,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;kBAOhC,CAAC;AACZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;kBAS1B,CAAC;AACZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;kBAO5B,CAAC;AACZ,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAOjC,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from "./pilot-schemas.js";
3
+ import { ContextPackingSchema, MemoryCategorySchema, MemorySchema, MemoryStatusSchema, RetrievalHitSchema, } from "./schemas.js";
4
+ export const WorkSessionSchema = z
5
+ .object({
6
+ id: z.uuid(),
7
+ workspaceId: z.uuid(),
8
+ connector: z.string().trim().min(1).max(100),
9
+ externalSessionId: z.string().trim().min(1).max(500),
10
+ agent: z.string().trim().min(1).max(100),
11
+ project: z.string().nullable(),
12
+ repo: z.string().nullable(),
13
+ title: z.string().nullable(),
14
+ parentSessionId: z.uuid().nullable(),
15
+ startedAt: z.iso.datetime({ offset: true }),
16
+ lastActivityAt: z.iso.datetime({ offset: true }),
17
+ endedAt: z.iso.datetime({ offset: true }).nullable(),
18
+ eventCount: z.number().int().nonnegative(),
19
+ metadata: z.record(z.string(), z.unknown()),
20
+ })
21
+ .strict();
22
+ export const ListWorkSessionsQuerySchema = z
23
+ .object({
24
+ repo: z.string().trim().min(1).max(1_000).optional(),
25
+ project: z.string().trim().min(1).max(500).optional(),
26
+ agent: z.string().trim().min(1).max(100).optional(),
27
+ connector: ConnectorNameSchema.optional(),
28
+ limit: z.coerce.number().int().positive().max(100).optional(),
29
+ offset: z.coerce.number().int().nonnegative().optional(),
30
+ })
31
+ .strict();
32
+ export const ListWorkSessionsResponseSchema = z
33
+ .object({
34
+ sessions: z.array(WorkSessionSchema),
35
+ total: z.number().int().nonnegative(),
36
+ limit: z.number().int().positive(),
37
+ offset: z.number().int().nonnegative(),
38
+ })
39
+ .strict();
40
+ export const SessionEventDigestSchema = z
41
+ .object({
42
+ eventId: z.uuid(),
43
+ type: ConnectorEventTypeSchema,
44
+ occurredAt: z.iso.datetime({ offset: true }),
45
+ task: z.string().nullable(),
46
+ userText: z.string().nullable(),
47
+ assistantText: z.string().nullable(),
48
+ })
49
+ .strict();
50
+ export const SessionMemorySummarySchema = z
51
+ .object({
52
+ id: z.uuid(),
53
+ content: z.string(),
54
+ category: MemoryCategorySchema,
55
+ status: MemoryStatusSchema,
56
+ })
57
+ .strict();
58
+ export const WorkSessionDetailResponseSchema = z
59
+ .object({
60
+ session: WorkSessionSchema,
61
+ events: z.array(SessionEventDigestSchema),
62
+ learnings: z.array(SessionMemorySummarySchema),
63
+ deliveredMemories: z.array(SessionMemorySummarySchema),
64
+ })
65
+ .strict();
66
+ export const AskRequestSchema = z
67
+ .object({
68
+ question: z.string().trim().min(1).max(10_000),
69
+ agent: z.string().trim().min(1).max(100).optional(),
70
+ project: z.string().trim().min(1).max(500).optional(),
71
+ repo: z.string().trim().min(1).max(1_000).optional(),
72
+ limit: z.number().int().positive().max(20).optional(),
73
+ includeSessions: z.boolean().optional(),
74
+ sessionLimit: z.number().int().positive().max(10).optional(),
75
+ })
76
+ .strict();
77
+ export const AskSessionExcerptSchema = z
78
+ .object({
79
+ eventId: z.uuid(),
80
+ type: ConnectorEventTypeSchema,
81
+ occurredAt: z.iso.datetime({ offset: true }),
82
+ text: z.string().max(2_000),
83
+ })
84
+ .strict();
85
+ export const AskSessionMatchSchema = z
86
+ .object({
87
+ session: WorkSessionSchema,
88
+ excerpts: z.array(AskSessionExcerptSchema),
89
+ })
90
+ .strict();
91
+ export const AskResponseSchema = z
92
+ .object({
93
+ question: z.string(),
94
+ knowledge: z.array(RetrievalHitSchema),
95
+ memories: z.array(MemorySchema),
96
+ sessions: z.array(AskSessionMatchSchema),
97
+ context: z.string(),
98
+ packing: ContextPackingSchema.optional(),
99
+ })
100
+ .strict();
101
+ const TEXT_FIELD_LIMIT = 2_000;
102
+ function truncate(value) {
103
+ return value.length > TEXT_FIELD_LIMIT
104
+ ? `${value.slice(0, TEXT_FIELD_LIMIT - 1)}…`
105
+ : value;
106
+ }
107
+ function stringAt(value, path) {
108
+ let current = value;
109
+ for (const key of path) {
110
+ if (typeof current !== "object" || current === null) {
111
+ return null;
112
+ }
113
+ current = current[key];
114
+ }
115
+ return typeof current === "string" && current.trim().length > 0
116
+ ? truncate(current)
117
+ : null;
118
+ }
119
+ /**
120
+ * Extracts the human-meaningful text from a connector event payload without
121
+ * assuming a single payload shape. Observations store the raw request,
122
+ * paired turns store the turn request, and context deliveries store a
123
+ * request/response envelope.
124
+ */
125
+ export function digestSessionEvent(event) {
126
+ const payload = event.payload;
127
+ const task = stringAt(payload, ["task"]) ??
128
+ stringAt(payload, ["request", "task"]) ??
129
+ stringAt(payload, ["request", "task", "task"]);
130
+ let userText = stringAt(payload, ["currentUser", "content"]) ??
131
+ stringAt(payload, ["currentUserPrompt"]) ??
132
+ stringAt(payload, ["request", "currentUser", "content"]) ??
133
+ stringAt(payload, ["request", "currentUserPrompt"]);
134
+ const assistantText = stringAt(payload, ["previousAssistant", "content"]) ??
135
+ stringAt(payload, ["request", "previousAssistant", "content"]);
136
+ if (userText === null) {
137
+ const request = payload.request;
138
+ const messages = Array.isArray(payload.messages)
139
+ ? payload.messages
140
+ : typeof request === "object" &&
141
+ request !== null &&
142
+ Array.isArray(request.messages)
143
+ ? request.messages
144
+ : [];
145
+ const lastUser = [...messages]
146
+ .reverse()
147
+ .find((message) => typeof message === "object" &&
148
+ message !== null &&
149
+ message.role === "user" &&
150
+ typeof message.content === "string");
151
+ userText = lastUser === undefined ? null : truncate(lastUser.content);
152
+ }
153
+ return SessionEventDigestSchema.parse({
154
+ eventId: event.id,
155
+ type: event.type,
156
+ occurredAt: event.occurredAt,
157
+ task,
158
+ userText,
159
+ assistantText,
160
+ });
161
+ }
162
+ //# sourceMappingURL=session-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-schemas.js","sourceRoot":"","sources":["../src/session-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,iBAAi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AC3B,OAAO,KAAK,IAAI;YACf,OAAmC,CAAC,IAAI,KAAK,MAAM;YACpD,OAAQ,OAAmC,CAAC,OAAO,KAAK,QAAQ,CACnE,CAAC;QACJ,QAAQ,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,wBAAwB,CAAC,KAAK,CAAC;QACpC,OAAO,EAAE,KAAK,CAAC,EAAE;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,IAAI;QACJ,QAAQ;QACR,aAAa;KACd,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lore-co/core",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Schemas and primitives for auditable Lore engineering memory",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,6 +22,10 @@
22
22
  "types": "./dist/auth-schemas.d.ts",
23
23
  "import": "./dist/auth-schemas.js"
24
24
  },
25
+ "./session-schemas": {
26
+ "types": "./dist/session-schemas.d.ts",
27
+ "import": "./dist/session-schemas.js"
28
+ },
25
29
  "./redaction": {
26
30
  "types": "./dist/redaction.d.ts",
27
31
  "import": "./dist/redaction.js"