@popmelt.com/core 0.8.13 → 0.8.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.d.mts CHANGED
@@ -33,7 +33,13 @@ type ImprintConcrete = {
33
33
  createdAt: string;
34
34
  updatedAt: string;
35
35
  };
36
- type ImprintRelationType = 'operationalizes' | 'refines' | 'supports' | 'contradicts' | 'excepts' | 'instantiates' | 'supersedes';
36
+ type ImprintTopologyRelationType = 'expresses' | 'excepts';
37
+ /**
38
+ * Historical relation names remain readable so append-only Imprint journals can
39
+ * be replayed. New writers must use ImprintTopologyRelationType.
40
+ */
41
+ type LegacyImprintRelationType = 'operationalizes' | 'refines' | 'supports' | 'contradicts' | 'instantiates' | 'supersedes';
42
+ type ImprintRelationType = ImprintTopologyRelationType | LegacyImprintRelationType;
37
43
  type ImprintRelation = {
38
44
  id: string;
39
45
  type: ImprintRelationType;
@@ -95,7 +101,7 @@ type ImprintTransaction = {
95
101
  previousHash: string | null;
96
102
  hash: string;
97
103
  source: {
98
- kind: 'automatic' | 'grounding' | 'correction' | 'undo';
104
+ kind: 'automatic' | 'grounding' | 'correction' | 'migration' | 'undo';
99
105
  threadId: string;
100
106
  jobId: string;
101
107
  };
@@ -125,13 +131,14 @@ type ImprintThreadSummary = {
125
131
  };
126
132
  resolvedAction?: ImprintGroundingAction;
127
133
  };
128
- type ImprintGroundingAction = 'confirm' | 'reason_wrong' | 'narrow' | 'exception' | 'edit' | 'dont_learn' | 'undo';
134
+ type ImprintGroundingAction = 'yes' | 'this_time' | 'no';
129
135
  type ImprintContext = {
130
136
  explanations: Array<Pick<ImprintExplanation, 'id' | 'kind' | 'statement' | 'rationale' | 'scope' | 'state'> & {
131
137
  concrete: Array<Pick<ImprintConcrete, 'id' | 'modelPath' | 'value'>>;
132
138
  }>;
133
139
  truncated: boolean;
134
140
  pendingGroundingExplanationIds?: string[];
141
+ correctionExplanationIds?: string[];
135
142
  relations?: Array<Pick<ImprintRelation, 'id' | 'type' | 'fromId' | 'toId' | 'rationale'>>;
136
143
  };
137
144
 
@@ -174,7 +181,12 @@ declare class ImprintStore {
174
181
  private writeChain;
175
182
  constructor(projectRoot: string, projectId: string);
176
183
  private readManifest;
184
+ private loadRaw;
177
185
  load(): Promise<ImprintLoadResult>;
186
+ migrateTopology(): Promise<{
187
+ migrated: boolean;
188
+ relationMutations: number;
189
+ }>;
178
190
  commit(input: {
179
191
  transactionId: string;
180
192
  committedAt: string;
@@ -215,7 +227,7 @@ type ProposedMutation = {
215
227
  summary: string;
216
228
  } | {
217
229
  op: 'relation';
218
- type: ImprintRelationType;
230
+ type: ImprintTopologyRelationType;
219
231
  fromId: string;
220
232
  toId: string;
221
233
  rationale: string;
@@ -249,9 +261,36 @@ type ImprintMutationDraft = {
249
261
  question: string;
250
262
  };
251
263
  };
252
- type ImprintDraft = ImprintMutationDraft | {
264
+ type ImprintApplicationDraft = {
265
+ decision: 'apply';
266
+ summary: {
267
+ title: string;
268
+ detail: string;
269
+ };
270
+ appliedExplanationIds: string[];
271
+ grounding?: {
272
+ explanationId: string;
273
+ question: string;
274
+ };
275
+ };
276
+ type ImprintRecognitionDraft = {
277
+ decision: 'recognize';
278
+ explanationId: string;
279
+ summary: {
280
+ title: string;
281
+ detail: string;
282
+ };
283
+ };
284
+ type ImprintDraft = ImprintMutationDraft | ImprintApplicationDraft | ImprintRecognitionDraft | {
253
285
  decision: 'none';
254
286
  reason: ImprintNoopReason;
287
+ duplicateOfExplanationId?: string;
288
+ scopeComparison?: 'equivalent' | 'existing_broader';
289
+ };
290
+ type ImprintParseContext = {
291
+ context?: ImprintContext;
292
+ requestText?: string;
293
+ applicationOccurred?: boolean;
255
294
  };
256
295
  type ImprintCaptureInput = {
257
296
  threadId: string;
@@ -259,36 +298,42 @@ type ImprintCaptureInput = {
259
298
  occurredAt?: string;
260
299
  concreteModel?: Record<string, unknown> | null;
261
300
  pendingGroundingExplanationIds?: string[];
301
+ applicationOccurred?: boolean;
262
302
  };
263
- declare function parseImprintDraft(responseText: string): {
303
+ declare function parseImprintDraft(responseText: string, parseContext?: ImprintParseContext): {
264
304
  draft?: ImprintDraft;
265
305
  visibleText: string;
266
306
  error?: string;
267
307
  };
268
- declare function formatImprintPrompt(context: ImprintContext | undefined): string;
308
+ declare function formatImprintPrompt(context: ImprintContext | undefined, options?: {
309
+ requestText?: string;
310
+ }): string;
269
311
  declare class ImprintService {
270
312
  readonly store: ImprintStore;
271
313
  private readonly noopCounts;
314
+ private readonly assessmentFailures;
272
315
  constructor(projectRoot: string, projectId: string);
273
316
  recordNoop(reason: ImprintNoopReason): void;
317
+ recordAssessmentFailure(state: 'missing' | 'invalid'): void;
274
318
  diagnostics(): {
275
319
  noopDecisions: Partial<Record<ImprintNoopReason, number>>;
320
+ assessmentFailures: Partial<Record<'missing' | 'invalid', number>>;
276
321
  };
277
322
  contextualize(input: {
278
323
  text?: string;
279
324
  subjectHints?: string[];
280
325
  maxExplanations?: number;
281
326
  pendingGroundingExplanationIds?: string[];
327
+ correctionExplanationIds?: string[];
282
328
  }): Promise<ImprintContext | undefined>;
283
- capture(draft: ImprintMutationDraft, input: ImprintCaptureInput): Promise<ImprintThreadSummary | undefined>;
329
+ capture(draft: ImprintMutationDraft | ImprintApplicationDraft, input: ImprintCaptureInput): Promise<ImprintThreadSummary | undefined>;
284
330
  applyGroundingAction(input: {
285
331
  summary: ImprintThreadSummary;
286
332
  action: ImprintGroundingAction;
287
- value?: string;
288
333
  threadId: string;
289
334
  jobId: string;
290
335
  occurredAt?: string;
291
- }): Promise<void>;
336
+ }): Promise<'applied' | 'pending_correction'>;
292
337
  }
293
338
 
294
339
  type StartPopmeltOptions = PopmeltOptions & {