@openclawbrain/openclaw 0.1.1 → 0.1.3

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.
@@ -1,5 +1,10 @@
1
- import { type ActivationPointerRecordV1, type FeedbackEventKind, type NormalizedEventExportV1, type RouteMode, type RuntimeCompileResponseV1 } from "@openclawbrain/contracts";
2
- import { type ActivationSlotInspection } from "@openclawbrain/pack-format";
1
+ import { CONTRACT_IDS, type ArtifactManifestV1, type ActivationPointerRecordV1, type ActivationPointerSlot, type RuntimeTurnBrainAttachmentPolicyV1, type ContextCompactionMode, type ContextContributionEvidenceStateV1, type CurrentProfileBrainStatusAnswerV1, type FeedbackEventKind, type FeedbackEventV1, type KernelSurfaceValidationResultV1, type LearningBootProfile, type InteractionEventV1, type NormalizedEventExportV1, type RouteMode, type RuntimeCompileResponseV1, type RuntimeCompileTargetV1, type RuntimeGraphPlasticityStateV1, type RuntimePlasticitySourceV1, type SparseFeedbackPolicyV1, type TeacherSupervisionArtifactV1, type WorkspaceInjectionSurfaceV1 } from "@openclawbrain/contracts";
2
+ import { type AdvanceAlwaysOnLearningRuntimeInput, type AlwaysOnLearningCadenceV1, type AlwaysOnLearningMaterializationJobV1, type AlwaysOnLearningRuntimePlanV1, type AlwaysOnLearningRuntimeStateV1 } from "@openclawbrain/learner";
3
+ import { type ActivationInspection, type ActivationObservabilityReport, type ActivationSlotInspection, type InitHandoffState } from "@openclawbrain/pack-format";
4
+ export declare const DEFAULT_ASYNC_TEACHER_QUEUE_CAPACITY = 8;
5
+ declare const RECORDED_SESSION_TRACE_CONTRACT: "recorded_session_trace.v1";
6
+ declare const RECORDED_SESSION_FIXTURE_CONTRACT: "recorded_session_replay_fixture.v1";
7
+ declare const RECORDED_SESSION_BUNDLE_CONTRACT: "recorded_session_replay_bundle.v1";
3
8
  declare const RUNTIME_EVENT_EXPORT_BUNDLE_CONTRACT: "normalized_event_export_bundle.v1";
4
9
  export declare const RUNTIME_EVENT_EXPORT_BUNDLE_LAYOUT: {
5
10
  readonly manifest: "manifest.json";
@@ -35,7 +40,9 @@ export interface CompileRuntimeContextInput {
35
40
  message: string;
36
41
  agentId?: string;
37
42
  maxContextBlocks?: number;
43
+ maxContextChars?: number;
38
44
  mode?: RouteMode;
45
+ compactionMode?: ContextCompactionMode;
39
46
  runtimeHints?: readonly string[];
40
47
  }
41
48
  export interface ActiveCompileTarget {
@@ -46,20 +53,161 @@ export interface ActiveCompileTarget {
46
53
  export interface RuntimeCompileSuccess {
47
54
  ok: true;
48
55
  fallbackToStaticContext: false;
56
+ hardRequirementViolated: false;
49
57
  activationRoot: string;
50
58
  activePackId: string;
51
59
  packRootDir: string;
52
60
  compileResponse: RuntimeCompileResponseV1;
53
61
  brainContext: string;
54
62
  }
55
- export interface RuntimeCompileFailure {
63
+ export interface RuntimeCompileFailOpenFailure {
56
64
  ok: false;
57
65
  fallbackToStaticContext: true;
66
+ hardRequirementViolated: false;
58
67
  activationRoot: string;
59
68
  error: string;
60
69
  brainContext: string;
61
70
  }
71
+ export interface RuntimeCompileHardFailure {
72
+ ok: false;
73
+ fallbackToStaticContext: false;
74
+ hardRequirementViolated: true;
75
+ activationRoot: string;
76
+ error: string;
77
+ brainContext: string;
78
+ }
79
+ export type RuntimeCompileFailure = RuntimeCompileFailOpenFailure | RuntimeCompileHardFailure;
62
80
  export type RuntimeCompileResult = RuntimeCompileSuccess | RuntimeCompileFailure;
81
+ export interface AttachStatusInput {
82
+ activationRoot: string;
83
+ compile?: false | Omit<CompileRuntimeContextInput, "activationRoot">;
84
+ }
85
+ export type ContextContributionEvidenceState = ContextContributionEvidenceStateV1;
86
+ export interface ContextAttributionSummaryV1 {
87
+ selectedContextCount: number;
88
+ stableKernelBlockCount: number;
89
+ brainCompiledBlockCount: number;
90
+ stableKernelSources: string[];
91
+ brainCompiledSources: string[];
92
+ selectionTiers: string | null;
93
+ evidence: ContextContributionEvidenceState;
94
+ detail: string;
95
+ }
96
+ export interface AttachCompileStatusV1 {
97
+ ok: boolean;
98
+ fallbackToStaticContext: boolean;
99
+ hardRequirementViolated: boolean;
100
+ activePackId: string | null;
101
+ usedLearnedRouteFn: boolean | null;
102
+ routerIdentity: string | null;
103
+ initMode: string | null;
104
+ handoffState: string | null;
105
+ seedSources: string[];
106
+ contextAttribution: ContextAttributionSummaryV1;
107
+ notes: string[];
108
+ error: string | null;
109
+ }
110
+ export interface OpenClawCompileBoundaryV1 {
111
+ contract: typeof CONTRACT_IDS.runtimeCompile;
112
+ activationSlot: "active";
113
+ entrypoint: "compileRuntimeContext";
114
+ servedFromCandidateBeforePromotion: false;
115
+ learnedRouteEvidenceRequiredWhenManifestRequiresIt: true;
116
+ }
117
+ export interface OpenClawEventExportBoundaryV1 {
118
+ emittedContracts: readonly [typeof CONTRACT_IDS.interactionEvents, typeof CONTRACT_IDS.feedbackEvents];
119
+ entrypoint: "runRuntimeTurn";
120
+ bundleWriteOptional: true;
121
+ writeFailuresEraseSuccessfulCompile: false;
122
+ learningHandoffStaysOffHotPath: true;
123
+ }
124
+ export interface OpenClawActivePackBoundaryV1 {
125
+ servingSlot: "active";
126
+ inspectableSlots: readonly ActivationPointerSlot[];
127
+ candidateServedBeforePromotion: false;
128
+ previousSlotUsedForRollback: true;
129
+ }
130
+ export interface OpenClawPromotionBoundaryV1 {
131
+ candidateSlot: "candidate";
132
+ activeSlot: "active";
133
+ previousSlot: "previous";
134
+ requiresActivationReadyCandidate: true;
135
+ compileSeesCandidateOnlyAfterPromotion: true;
136
+ promotionHappensOffHotPath: true;
137
+ }
138
+ export interface OpenClawFailOpenSemanticsV1 {
139
+ missingActivePackFallsBackToStaticContext: true;
140
+ learnedRequiredRouteArtifactDriftHardFails: true;
141
+ hardFailuresDisableStaticFallback: true;
142
+ eventExportWriteFailurePreservesCompile: true;
143
+ }
144
+ export interface OpenClawLandingBoundariesV1 {
145
+ compileBoundary: OpenClawCompileBoundaryV1;
146
+ eventExportBoundary: OpenClawEventExportBoundaryV1;
147
+ activePackBoundary: OpenClawActivePackBoundaryV1;
148
+ promotionBoundary: OpenClawPromotionBoundaryV1;
149
+ failOpenSemantics: OpenClawFailOpenSemanticsV1;
150
+ runtimeResponsibilities: string[];
151
+ brainResponsibilities: string[];
152
+ }
153
+ export interface AttachStatusSnapshotV1 {
154
+ runtimeOwner: "openclaw";
155
+ activationRoot: string;
156
+ inspection: ActivationInspection;
157
+ activeObservability: ActivationObservabilityReport | null;
158
+ compile: AttachCompileStatusV1 | null;
159
+ landingBoundaries: OpenClawLandingBoundariesV1;
160
+ successSignals: string[];
161
+ }
162
+ export interface RollbackRuntimeAttachInput {
163
+ activationRoot: string;
164
+ updatedAt?: string;
165
+ dryRun?: boolean;
166
+ }
167
+ export interface RollbackRuntimeAttachResult {
168
+ runtimeOwner: "openclaw";
169
+ activationRoot: string;
170
+ updatedAt: string;
171
+ dryRun: boolean;
172
+ allowed: boolean;
173
+ findings: string[];
174
+ before: {
175
+ activePackId: string | null;
176
+ candidatePackId: string | null;
177
+ previousPackId: string | null;
178
+ };
179
+ after: {
180
+ activePackId: string | null;
181
+ candidatePackId: string | null;
182
+ previousPackId: string | null;
183
+ } | null;
184
+ restoredPackId: string | null;
185
+ parkedCandidatePackId: string | null;
186
+ }
187
+ export interface BootstrapRuntimeAttachInput {
188
+ activationRoot: string;
189
+ packRoot: string;
190
+ packLabel: string;
191
+ workspace: AdvanceAlwaysOnLearningRuntimeInput["workspace"];
192
+ normalizedEventExport?: NormalizedEventExportV1;
193
+ interactionEvents?: readonly InteractionEventV1[];
194
+ feedbackEvents?: readonly FeedbackEventV1[];
195
+ learnedRouting?: boolean;
196
+ builtAt?: string;
197
+ activatedAt?: string;
198
+ offlineArtifacts?: string[];
199
+ structuralOps?: Partial<ArtifactManifestV1["graphDynamics"]["structuralOps"]>;
200
+ sparseFeedback?: Partial<SparseFeedbackPolicyV1>;
201
+ compile?: false | Omit<CompileRuntimeContextInput, "activationRoot">;
202
+ }
203
+ export interface BootstrapRuntimeAttachResult {
204
+ runtimeOwner: "openclaw";
205
+ activationRoot: string;
206
+ packRoot: string;
207
+ packId: string;
208
+ normalizedEventExport: NormalizedEventExportV1;
209
+ status: AttachStatusSnapshotV1;
210
+ }
63
211
  export interface RuntimeTurnCompileInput {
64
212
  createdAt?: string | null;
65
213
  sequence?: number | null;
@@ -97,6 +245,7 @@ export interface OpenClawRuntimeTurnInput {
97
245
  maxContextBlocks?: number;
98
246
  mode?: RouteMode;
99
247
  runtimeHints?: readonly string[];
248
+ brainAttachmentPolicy?: RuntimeTurnBrainAttachmentPolicyV1 | null;
100
249
  compile?: RuntimeTurnCompileInput | null;
101
250
  delivery?: boolean | RuntimeTurnDeliveryInput | null;
102
251
  feedback?: readonly (RuntimeTurnFeedbackInput | null)[] | null;
@@ -130,6 +279,183 @@ export type RuntimeTurnResult = RuntimeCompileResult & {
130
279
  eventExport: RuntimeEventExportResult;
131
280
  warnings: string[];
132
281
  };
282
+ export type TeacherLoopNoOpReason = "none" | "duplicate_export" | "queue_full" | "no_teacher_artifacts";
283
+ export interface AsyncTeacherLiveLoopInput extends Pick<AdvanceAlwaysOnLearningRuntimeInput, "packLabel" | "workspace" | "learnedRouting" | "builtAt" | "offlineArtifacts" | "structuralOps" | "sparseFeedback" | "liveSliceSize" | "backfillSliceSize" | "cadence"> {
284
+ maxQueuedExports?: number;
285
+ staleAfterMs?: number;
286
+ }
287
+ export interface AsyncTeacherQueuedExportJobV1 {
288
+ jobId: string;
289
+ exportDigest: string;
290
+ observedAt: string;
291
+ normalizedEventExport: NormalizedEventExportV1;
292
+ }
293
+ export interface AsyncTeacherLiveLoopDiagnosticsV1 {
294
+ acceptedExportCount: number;
295
+ processedExportCount: number;
296
+ duplicateExportCount: number;
297
+ droppedExportCount: number;
298
+ emittedArtifactCount: number;
299
+ dedupedArtifactCount: number;
300
+ lastProcessedAt: string | null;
301
+ latestFreshness: TeacherSupervisionArtifactV1["freshness"]["status"] | "none";
302
+ lastNoOpReason: TeacherLoopNoOpReason;
303
+ notes: string[];
304
+ }
305
+ export interface AsyncTeacherLiveLoopSnapshotV1 {
306
+ runtimeOwner: "openclaw";
307
+ queue: {
308
+ capacity: number;
309
+ depth: number;
310
+ running: boolean;
311
+ };
312
+ teacher: {
313
+ artifactCount: number;
314
+ artifacts: TeacherSupervisionArtifactV1[];
315
+ latestFreshness: TeacherSupervisionArtifactV1["freshness"]["status"] | "none";
316
+ };
317
+ learner: {
318
+ state: AlwaysOnLearningRuntimeStateV1;
319
+ lastMaterialization: AlwaysOnLearningMaterializationJobV1 | null;
320
+ };
321
+ diagnostics: AsyncTeacherLiveLoopDiagnosticsV1;
322
+ }
323
+ export interface AsyncTeacherEnqueueResultV1 {
324
+ accepted: boolean;
325
+ exportDigest: string;
326
+ queueDepth: number;
327
+ notes: string[];
328
+ reason: Exclude<TeacherLoopNoOpReason, "none"> | null;
329
+ }
330
+ export interface CanonicalSupervisionFeedbackRecordV1 {
331
+ eventId: string;
332
+ kind: FeedbackEventKind;
333
+ sequence: number;
334
+ createdAt: string;
335
+ content: string;
336
+ relatedInteractionId: string | null;
337
+ }
338
+ export interface CanonicalSupervisionV1 {
339
+ runtimeOwner: "openclaw";
340
+ exportDigest: string;
341
+ supervisionDigest: string;
342
+ sessionId: string | null;
343
+ channel: string | null;
344
+ eventRange: Pick<NormalizedEventExportV1["range"], "start" | "end" | "count">;
345
+ sourceStreams: string[];
346
+ humanLabelCount: number;
347
+ selfLabelCount: number;
348
+ feedbackCounts: {
349
+ corrections: number;
350
+ teachings: number;
351
+ approvals: number;
352
+ suppressions: number;
353
+ };
354
+ compilePackIds: string[];
355
+ relatedInteractionIds: string[];
356
+ feedback: CanonicalSupervisionFeedbackRecordV1[];
357
+ }
358
+ export interface ContinuousProductLoopPackVersionV1 {
359
+ version: number;
360
+ packId: string;
361
+ routePolicy: RuntimeCompileTargetV1["routePolicy"];
362
+ routerIdentity: string | null;
363
+ workspaceSnapshot: string;
364
+ workspaceRevision: string | null;
365
+ eventRange: RuntimeCompileTargetV1["eventRange"];
366
+ eventExportDigest: string | null;
367
+ builtAt: string;
368
+ }
369
+ export interface ContinuousProductLoopStateV1 {
370
+ runtimeOwner: "openclaw";
371
+ activationRoot: string;
372
+ loopRoot: string;
373
+ interactionEvents: InteractionEventV1[];
374
+ feedbackEvents: FeedbackEventV1[];
375
+ learner: AlwaysOnLearningRuntimeStateV1;
376
+ runtimePlasticity: RuntimeGraphPlasticityStateV1 | null;
377
+ activePackVersion: number;
378
+ currentActivePack: ContinuousProductLoopPackVersionV1 | null;
379
+ candidatePack: ContinuousProductLoopPackVersionV1 | null;
380
+ packLineage: ContinuousProductLoopPackVersionV1[];
381
+ nextPackVersion: number;
382
+ promotionCount: number;
383
+ lastSupervision: CanonicalSupervisionV1 | null;
384
+ }
385
+ export interface ContinuousProductLoopLearningUpdateV1 {
386
+ warnings: string[];
387
+ supervisionDigest: string | null;
388
+ bridgeDigest: string | null;
389
+ selectedSliceIds: string[];
390
+ materializationJobId: string | null;
391
+ materializationReason: AlwaysOnLearningMaterializationJobV1["reason"] | null;
392
+ materializationLane: AlwaysOnLearningMaterializationJobV1["lane"] | null;
393
+ candidateRootDir: string | null;
394
+ candidatePack: ContinuousProductLoopPackVersionV1 | null;
395
+ runtimePlasticity: RuntimeGraphPlasticityStateV1 | null;
396
+ promotionAllowed: boolean;
397
+ promotionFindings: string[];
398
+ promoted: boolean;
399
+ }
400
+ export interface RunContinuousProductLoopTurnInput {
401
+ activationRoot: string;
402
+ loopRoot: string;
403
+ packLabel: string;
404
+ workspace: AdvanceAlwaysOnLearningRuntimeInput["workspace"];
405
+ turn: OpenClawRuntimeTurnInput;
406
+ state?: ContinuousProductLoopStateV1;
407
+ learnedRouting?: boolean;
408
+ failOpen?: boolean;
409
+ autoPromote?: boolean;
410
+ candidateBuiltAt?: string | null;
411
+ stageUpdatedAt?: string | null;
412
+ promoteUpdatedAt?: string | null;
413
+ offlineArtifacts?: string[];
414
+ structuralOps?: Partial<ArtifactManifestV1["graphDynamics"]["structuralOps"]>;
415
+ sparseFeedback?: Partial<SparseFeedbackPolicyV1>;
416
+ liveSliceSize?: number;
417
+ backfillSliceSize?: number;
418
+ cadence?: Partial<AlwaysOnLearningCadenceV1>;
419
+ }
420
+ export interface ContinuousProductLoopTurnResultV1 {
421
+ runtimeOwner: "openclaw";
422
+ compileActiveVersion: number;
423
+ compileActivePackId: string | null;
424
+ turn: RuntimeTurnResult;
425
+ supervision: CanonicalSupervisionV1 | null;
426
+ learning: ContinuousProductLoopLearningUpdateV1;
427
+ state: ContinuousProductLoopStateV1;
428
+ }
429
+ export declare function buildCanonicalSupervision(normalizedEventExport: NormalizedEventExportV1): CanonicalSupervisionV1;
430
+ export declare function createContinuousProductLoopState(input: {
431
+ activationRoot: string;
432
+ loopRoot: string;
433
+ }): ContinuousProductLoopStateV1;
434
+ export declare class AsyncTeacherLiveLoop {
435
+ private readonly input;
436
+ private readonly queueCapacity;
437
+ private readonly staleAfterMs;
438
+ private readonly queuedExportDigests;
439
+ private readonly seenExportDigests;
440
+ private queue;
441
+ private drainPromise;
442
+ private interactionEvents;
443
+ private feedbackEvents;
444
+ private teacherArtifacts;
445
+ private learnerState;
446
+ private lastMaterialization;
447
+ private diagnostics;
448
+ constructor(input: AsyncTeacherLiveLoopInput);
449
+ enqueueNormalizedEventExport(normalizedEventExport: NormalizedEventExportV1, options?: {
450
+ observedAt?: string;
451
+ }): AsyncTeacherEnqueueResultV1;
452
+ flush(): Promise<AsyncTeacherLiveLoopSnapshotV1>;
453
+ snapshot(): AsyncTeacherLiveLoopSnapshotV1;
454
+ private ensureDrain;
455
+ private drain;
456
+ private refreshNotes;
457
+ }
458
+ export declare function createAsyncTeacherLiveLoop(input: AsyncTeacherLiveLoopInput): AsyncTeacherLiveLoop;
133
459
  export declare function buildRuntimeEventExportBundleManifest(input: {
134
460
  exportName: string;
135
461
  exportedAt: string;
@@ -142,7 +468,426 @@ export declare function classifyFeedbackKind(content: string): FeedbackEventKind
142
468
  export declare function formatPromptContext(compileResponse: RuntimeCompileResponseV1): string;
143
469
  export declare function resolveActivePackForCompile(activationRoot: string): ActiveCompileTarget;
144
470
  export declare function compileRuntimeContext(input: CompileRuntimeContextInput): RuntimeCompileResult;
471
+ export declare function describeAttachStatus(input: AttachStatusInput): AttachStatusSnapshotV1;
472
+ export declare function rollbackRuntimeAttach(input: RollbackRuntimeAttachInput): RollbackRuntimeAttachResult;
473
+ export declare function bootstrapRuntimeAttach(input: BootstrapRuntimeAttachInput): BootstrapRuntimeAttachResult;
145
474
  export declare function buildNormalizedRuntimeEventExport(turn: OpenClawRuntimeTurnInput, compileResult: RuntimeCompileResult): NormalizedEventExportV1;
146
475
  export declare function writeRuntimeEventExportBundle(turn: OpenClawRuntimeTurnInput, normalizedEventExport: NormalizedEventExportV1): RuntimeEventExportNoWrite | RuntimeEventExportWriteSuccess;
147
476
  export declare function runRuntimeTurn(turn: OpenClawRuntimeTurnInput, options?: RunRuntimeTurnOptions): RuntimeTurnResult;
148
- export {};
477
+ export declare function runContinuousProductLoopTurn(input: RunContinuousProductLoopTurnInput): ContinuousProductLoopTurnResultV1;
478
+ export type RecordedSessionReplayMode = "no_brain" | "seed_pack" | "learned_replay";
479
+ export interface RecordedSessionReplayWorkspaceV1 {
480
+ workspaceId: string;
481
+ snapshotId: string;
482
+ capturedAt: string;
483
+ rootDir: string;
484
+ branch?: string;
485
+ revision: string;
486
+ labels?: string[];
487
+ }
488
+ export interface RecordedSessionSeedCueV1 {
489
+ cueId: string;
490
+ createdAt: string;
491
+ content: string;
492
+ kind?: FeedbackEventKind;
493
+ }
494
+ export interface RecordedSessionTraceFeedbackV1 {
495
+ createdAt: string;
496
+ content: string;
497
+ kind?: FeedbackEventKind | null;
498
+ }
499
+ export interface RecordedSessionTraceTurnV1 {
500
+ turnId?: string;
501
+ createdAt: string;
502
+ deliveredAt?: string | null;
503
+ userMessage: string;
504
+ runtimeHints?: readonly string[];
505
+ feedback?: readonly RecordedSessionTraceFeedbackV1[];
506
+ expectedContextPhrases: readonly string[];
507
+ minimumPhraseHits?: number;
508
+ }
509
+ export interface RecordedSessionTraceV1 {
510
+ contract: typeof RECORDED_SESSION_TRACE_CONTRACT;
511
+ traceId: string;
512
+ source: "sanitized_recorded_session";
513
+ recordedAt: string;
514
+ bundleBuiltAt: string;
515
+ agentId?: string | null;
516
+ sessionId: string;
517
+ channel: string;
518
+ sourceStream: string;
519
+ privacy: {
520
+ sanitized: true;
521
+ notes: string[];
522
+ };
523
+ workspace: RecordedSessionReplayWorkspaceV1;
524
+ seedBuiltAt: string;
525
+ seedActivatedAt: string;
526
+ seedCues: readonly RecordedSessionSeedCueV1[];
527
+ turns: readonly RecordedSessionTraceTurnV1[];
528
+ }
529
+ export interface RecordedSessionReplayTurnFixtureV1 {
530
+ turnId: string;
531
+ turn: OpenClawRuntimeTurnInput;
532
+ expectedContextPhrases: string[];
533
+ minimumPhraseHits: number;
534
+ }
535
+ export interface RecordedSessionReplayFixtureV1 {
536
+ contract: typeof RECORDED_SESSION_FIXTURE_CONTRACT;
537
+ traceId: string;
538
+ source: RecordedSessionTraceV1["source"];
539
+ recordedAt: string;
540
+ bundleBuiltAt: string;
541
+ traceHash: string;
542
+ fixtureHash: string;
543
+ privacy: RecordedSessionTraceV1["privacy"];
544
+ workspace: RecordedSessionReplayWorkspaceV1;
545
+ seedBuiltAt: string;
546
+ seedActivatedAt: string;
547
+ seedExport: NormalizedEventExportV1;
548
+ turns: RecordedSessionReplayTurnFixtureV1[];
549
+ }
550
+ export interface RecordedSessionReplayTurnReportV1 {
551
+ turnId: string;
552
+ compileOk: boolean;
553
+ fallbackToStaticContext: boolean;
554
+ hardRequirementViolated: boolean;
555
+ activePackId: string | null;
556
+ usedLearnedRouteFn: boolean;
557
+ routerIdentity: string | null;
558
+ selectionDigest: string | null;
559
+ selectedContextIds: string[];
560
+ selectedContextTexts: string[];
561
+ eventExportDigest: string | null;
562
+ expectedContextPhrases: string[];
563
+ minimumPhraseHits: number;
564
+ phraseHits: string[];
565
+ missedPhrases: string[];
566
+ qualityScore: number;
567
+ compileActiveVersion: number | null;
568
+ promoted: boolean;
569
+ warnings: string[];
570
+ }
571
+ export interface RecordedSessionReplayModeSummaryV1 {
572
+ mode: RecordedSessionReplayMode;
573
+ qualityScore: number;
574
+ compileOkCount: number;
575
+ phraseHitCount: number;
576
+ phraseCount: number;
577
+ usedLearnedRouteTurnCount: number;
578
+ promotionCount: number;
579
+ packIds: string[];
580
+ scoreHash: string;
581
+ }
582
+ export interface RecordedSessionReplayModeReportV1 {
583
+ mode: RecordedSessionReplayMode;
584
+ summary: RecordedSessionReplayModeSummaryV1;
585
+ turns: RecordedSessionReplayTurnReportV1[];
586
+ }
587
+ export interface RecordedSessionReplayBundleV1 {
588
+ contract: typeof RECORDED_SESSION_BUNDLE_CONTRACT;
589
+ traceId: string;
590
+ source: RecordedSessionReplayFixtureV1["source"];
591
+ recordedAt: string;
592
+ generatedAt: string;
593
+ traceHash: string;
594
+ fixtureHash: string;
595
+ scoreHash: string;
596
+ bundleHash: string;
597
+ privacy: RecordedSessionReplayFixtureV1["privacy"];
598
+ modes: RecordedSessionReplayModeReportV1[];
599
+ summary: {
600
+ winnerMode: RecordedSessionReplayMode | null;
601
+ ranking: Array<{
602
+ mode: RecordedSessionReplayMode;
603
+ qualityScore: number;
604
+ }>;
605
+ };
606
+ }
607
+ export interface RecordedSessionReplayRescoreReportV1 {
608
+ scoreHash: string;
609
+ modes: Array<{
610
+ mode: RecordedSessionReplayMode;
611
+ qualityScore: number;
612
+ scoreHash: string;
613
+ }>;
614
+ }
615
+ export interface RecordedSessionReplayBundleHashVerificationV1 {
616
+ bundleHashMatches: boolean;
617
+ scoreHashMatches: boolean;
618
+ }
619
+ export declare function buildRecordedSessionReplayFixture(trace: RecordedSessionTraceV1): RecordedSessionReplayFixtureV1;
620
+ export declare function runRecordedSessionReplay(rootDir: string, fixture: RecordedSessionReplayFixtureV1): RecordedSessionReplayBundleV1;
621
+ export declare function rescoreRecordedSessionReplayBundle(bundle: RecordedSessionReplayBundleV1): RecordedSessionReplayRescoreReportV1;
622
+ export declare function verifyRecordedSessionReplayBundleHashes(bundle: RecordedSessionReplayBundleV1): RecordedSessionReplayBundleHashVerificationV1;
623
+ export type OperatorSurfaceStatus = "ok" | "warn" | "fail";
624
+ export type OperatorFindingSeverity = "pass" | "warn" | "fail";
625
+ export type OperatorLastPromotionConfidence = "proven_from_previous_pointer" | "unknown_from_local_pointers" | "no_active_pack";
626
+ export declare const OPERATOR_API_CONTRACT_ID: "openclaw_operator_api.v1";
627
+ export declare const SUPPORTED_OPERATOR_API_FAMILIES: readonly ["bootstrap_attach", "status", "export", "refresh", "promote", "rollback", "proof_observability"];
628
+ export type SupportedOperatorApiFamily = (typeof SUPPORTED_OPERATOR_API_FAMILIES)[number];
629
+ export type OperatorApiRouteScope = "cli" | "programmatic" | "proof_lane";
630
+ export interface OperatorApiRouteDescriptor {
631
+ family: SupportedOperatorApiFamily;
632
+ scope: OperatorApiRouteScope;
633
+ packageName: string;
634
+ entrypoints: readonly string[];
635
+ summary: string;
636
+ notes: readonly string[];
637
+ }
638
+ export interface OperatorApiContractV1 {
639
+ contract: typeof OPERATOR_API_CONTRACT_ID;
640
+ runtimeOwner: "openclaw";
641
+ scope: "narrow_supported_operator_surface";
642
+ families: readonly SupportedOperatorApiFamily[];
643
+ routes: readonly OperatorApiRouteDescriptor[];
644
+ quarantinedSurface: readonly string[];
645
+ }
646
+ export declare const OPERATOR_API_CONTRACT_V1: {
647
+ readonly contract: "openclaw_operator_api.v1";
648
+ readonly runtimeOwner: "openclaw";
649
+ readonly scope: "narrow_supported_operator_surface";
650
+ readonly families: readonly ["bootstrap_attach", "status", "export", "refresh", "promote", "rollback", "proof_observability"];
651
+ readonly routes: readonly [{
652
+ readonly family: "bootstrap_attach";
653
+ readonly scope: "programmatic";
654
+ readonly packageName: "@openclawbrain/openclaw";
655
+ readonly entrypoints: readonly ["bootstrapRuntimeAttach", "describeAttachStatus"];
656
+ readonly summary: "Bootstrap the first attach pack and prove the initial handoff state without pretending live learning has already run.";
657
+ readonly notes: readonly ["Zero-event bootstrap is supported and stays explicit through awaiting_first_export.", "Attach serves only from activation's active slot after bootstrap completes."];
658
+ }, {
659
+ readonly family: "status";
660
+ readonly scope: "cli";
661
+ readonly packageName: "@openclawbrain/openclaw";
662
+ readonly entrypoints: readonly ["openclawbrain-ops status", "describeCurrentProfileBrainStatus"];
663
+ readonly summary: "Read the canonical current-profile brain-status object for the active Host/Profile/Brain/Attachment boundary.";
664
+ readonly notes: readonly ["Status is the first operator read path.", "describeCurrentProfileBrainStatus() freezes the supported Host/Profile/Brain/Attachment answer shape for the current profile.", "Use activation and export observability proof helpers when you need candidate/previous or export-freshness detail."];
665
+ }, {
666
+ readonly family: "export";
667
+ readonly scope: "programmatic";
668
+ readonly packageName: "@openclawbrain/openclaw";
669
+ readonly entrypoints: readonly ["buildNormalizedRuntimeEventExport", "writeRuntimeEventExportBundle", "loadRuntimeEventExportBundle"];
670
+ readonly summary: "Emit the deterministic learner handoff artifact explicitly instead of folding export into a larger implicit runtime loop.";
671
+ readonly notes: readonly ["Export is an off-hot-path operator handoff artifact, not proof of immediate active-pack mutation.", "Bundle roots and normalized payloads are both accepted downstream by observability surfaces."];
672
+ }, {
673
+ readonly family: "refresh";
674
+ readonly scope: "programmatic";
675
+ readonly packageName: "@openclawbrain/learner";
676
+ readonly entrypoints: readonly ["createAlwaysOnLearningRuntimeState", "advanceAlwaysOnLearningRuntime", "materializeAlwaysOnLearningCandidatePack"];
677
+ readonly summary: "Refresh candidate learning state explicitly through the learner boundary before any activation-pointer move happens.";
678
+ readonly notes: readonly ["Refresh is PG-only candidate-pack materialization in this repo.", "Refresh does not mutate the currently served active pack in place."];
679
+ }, {
680
+ readonly family: "promote";
681
+ readonly scope: "programmatic";
682
+ readonly packageName: "@openclawbrain/pack-format";
683
+ readonly entrypoints: readonly ["stageCandidatePack", "promoteCandidatePack"];
684
+ readonly summary: "Stage and promote activation-ready candidate packs through explicit pointer changes.";
685
+ readonly notes: readonly ["Promotion is the only path that changes which pack is served.", "Candidate and previous remain inspectable around the pointer move."];
686
+ }, {
687
+ readonly family: "rollback";
688
+ readonly scope: "cli";
689
+ readonly packageName: "@openclawbrain/openclaw";
690
+ readonly entrypoints: readonly ["openclawbrain-ops rollback", "rollbackRuntimeAttach", "formatOperatorRollbackReport"];
691
+ readonly summary: "Preview and apply the explicit active<-previous / active->candidate rollback move.";
692
+ readonly notes: readonly ["Rollback is blocked when the previous pointer is unavailable.", "Dry-run is the required first read path for safe operator rollback."];
693
+ }, {
694
+ readonly family: "proof_observability";
695
+ readonly scope: "programmatic";
696
+ readonly packageName: "@openclawbrain/openclaw";
697
+ readonly entrypoints: readonly ["describeAttachStatus", "describeKernelBrainBoundary"];
698
+ readonly summary: "Prove the local attach and kernel-vs-brain boundary from the shipped bridge surface.";
699
+ readonly notes: readonly ["Use these for repo-local or installed-package operator proof reads.", "These surfaces report the promoted artifact boundary, not full live runtime plasticity."];
700
+ }, {
701
+ readonly family: "proof_observability";
702
+ readonly scope: "programmatic";
703
+ readonly packageName: "@openclawbrain/pack-format";
704
+ readonly entrypoints: readonly ["describeActivationObservability"];
705
+ readonly summary: "Inspect activation health, freshness, route artifacts, rollback lineage, and slot readiness.";
706
+ readonly notes: readonly ["Activation observability is the ground truth for active/candidate/previous slot inspection."];
707
+ }, {
708
+ readonly family: "proof_observability";
709
+ readonly scope: "programmatic";
710
+ readonly packageName: "@openclawbrain/event-export";
711
+ readonly entrypoints: readonly ["describeNormalizedEventExportObservability"];
712
+ readonly summary: "Inspect supervision freshness and teacher freshness from the exported learner handoff artifact.";
713
+ readonly notes: readonly ["Export observability is local-to-export proof only."];
714
+ }, {
715
+ readonly family: "proof_observability";
716
+ readonly scope: "proof_lane";
717
+ readonly packageName: "workspace";
718
+ readonly entrypoints: readonly ["pnpm current-profile-lifecycle:smoke", "pnpm observability:smoke"];
719
+ readonly summary: "Run the repo-local proof lanes that derive operator truth from the canonical current-profile status object plus activation observability.";
720
+ readonly notes: readonly ["These lanes are proof machinery, not a second semver-stable API."];
721
+ }];
722
+ readonly quarantinedSurface: readonly ["openclawbrain-ops doctor was deleted; use the canonical current-profile status object plus proof helpers instead of a parallel troubleshooting surface.", "buildOperatorSurfaceReport / formatOperatorStatusReport / formatOperatorDoctorReport were historical parallel status surfaces and are not the supported operator API.", "runContinuousProductLoopTurn collapses export/refresh/promote into one proof helper and is not the supported operator API.", "runRecordedSessionReplay and recorded-session fixtures are proof helpers, not operator API.", "release scripts, root smoke plumbing, and workspace layout are proof-and-build machinery, not operator API.", "runRuntimeTurn is a runtime convenience wrapper and not the narrow operator export contract.", "createAsyncTeacherLiveLoop is supporting internals for refresh/teacher snapshots, not the narrow operator contract."];
723
+ };
724
+ export declare const OPENCLAW_OPERATOR_NOUNS_V1: readonly ["Host", "Profile", "Brain", "Attachment"];
725
+ export declare const CURRENT_PROFILE_BRAIN_STATUS_CONTRACT: "current_profile_brain_status.v1";
726
+ export declare const BRAIN_ATTACHMENT_POLICY_SEMANTICS_V1: {
727
+ readonly undeclared: "The Host has not declared whether the current Profile's Brain attachment policy is shared or dedicated; do not infer profile exclusivity from activation state alone.";
728
+ readonly dedicated: "The Host declares a dedicated Brain attachment policy: one Profile is intentionally attached to one Brain activation root, and operators may treat the served Brain state as profile-specific until the attachment changes.";
729
+ readonly shared: "The Host declares a shared Brain attachment policy: multiple Profiles may intentionally attach to the same Brain activation root, attribution must stay current-profile explicit, and operators must not treat later served context as profile-exclusive.";
730
+ };
731
+ export type OperatorBrainState = InitHandoffState | "no_active_pack";
732
+ export type OperatorServePathState = "serving_active_pack" | "fail_open_static_context" | "hard_fail" | "unprobed";
733
+ export interface OperatorSurfaceInput {
734
+ activationRoot: string;
735
+ updatedAt?: string | null;
736
+ eventExportPath?: string | null;
737
+ teacherSnapshotPath?: string | null;
738
+ }
739
+ export interface OperatorSurfaceSlotSummary {
740
+ slot: ActivationPointerSlot;
741
+ packId: string;
742
+ activationReady: boolean;
743
+ routePolicy: RuntimeCompileTargetV1["routePolicy"];
744
+ routerIdentity: string | null;
745
+ workspaceSnapshot: string;
746
+ workspaceRevision: string | null;
747
+ eventRange: RuntimeCompileTargetV1["eventRange"];
748
+ eventExportDigest: string | null;
749
+ builtAt: string;
750
+ updatedAt: string | null;
751
+ findings: string[];
752
+ }
753
+ export interface OperatorLastPromotionSummary {
754
+ known: boolean;
755
+ at: string | null;
756
+ confidence: OperatorLastPromotionConfidence;
757
+ note: string;
758
+ }
759
+ export interface OperatorBrainStateSummary {
760
+ state: OperatorBrainState;
761
+ initMode: LearningBootProfile | null;
762
+ runtimePlasticitySource: RuntimePlasticitySourceV1 | null;
763
+ seedStateVisible: boolean;
764
+ seedBlockCount: number;
765
+ activePackId: string | null;
766
+ activeWorkspaceSnapshot: string | null;
767
+ activeEventExportDigest: string | null;
768
+ detail: string;
769
+ }
770
+ export interface OperatorServePathSummary {
771
+ state: OperatorServePathState;
772
+ fallbackToStaticContext: boolean;
773
+ hardRequirementViolated: boolean;
774
+ activePackId: string | null;
775
+ usedLearnedRouteFn: boolean | null;
776
+ routerIdentity: string | null;
777
+ selectionMode: string | null;
778
+ refreshStatus: string | null;
779
+ freshnessChecksum: string | null;
780
+ contextAttribution: ContextAttributionSummaryV1;
781
+ error: string | null;
782
+ }
783
+ export interface OperatorDoctorFinding {
784
+ severity: OperatorFindingSeverity;
785
+ code: string;
786
+ summary: string;
787
+ detail: string;
788
+ }
789
+ export interface OperatorSupervisionSummary {
790
+ available: boolean;
791
+ sourcePath: string | null;
792
+ sourceKind: "bundle_root" | "payload" | "missing";
793
+ exportDigest: string | null;
794
+ exportedAt: string | null;
795
+ flowing: boolean | null;
796
+ sourceCount: number;
797
+ freshestSourceStream: string | null;
798
+ freshestCreatedAt: string | null;
799
+ freshestKind: string | null;
800
+ humanLabelCount: number | null;
801
+ sources: string[];
802
+ detail: string;
803
+ }
804
+ export interface OperatorTeacherLoopSummary {
805
+ available: boolean;
806
+ sourcePath: string | null;
807
+ lastNoOpReason: TeacherLoopNoOpReason | "unavailable";
808
+ latestFreshness: AsyncTeacherLiveLoopDiagnosticsV1["latestFreshness"] | "unavailable";
809
+ lastProcessedAt: string | null;
810
+ queueDepth: number | null;
811
+ queueCapacity: number | null;
812
+ running: boolean | null;
813
+ lastMaterializedPackId: string | null;
814
+ notes: string[];
815
+ detail: string;
816
+ }
817
+ export interface OperatorLearningSummary {
818
+ available: boolean;
819
+ sourcePath: string | null;
820
+ bootstrapped: boolean | null;
821
+ mode: AlwaysOnLearningRuntimePlanV1["mode"] | "unavailable";
822
+ nextPriorityLane: AlwaysOnLearningRuntimePlanV1["nextPriorityLane"] | "unavailable";
823
+ pendingLive: number | null;
824
+ pendingBackfill: number | null;
825
+ pendingTotal: number | null;
826
+ freshLivePriority: boolean | null;
827
+ learnedRange: RuntimeCompileTargetV1["eventRange"] | null;
828
+ materializationCount: number | null;
829
+ lastMaterializedAt: string | null;
830
+ lastMaterializationReason: AlwaysOnLearningMaterializationJobV1["reason"] | null;
831
+ lastMaterializationLane: AlwaysOnLearningMaterializationJobV1["lane"] | null;
832
+ lastMaterializationPriority: AlwaysOnLearningMaterializationJobV1["priority"] | null;
833
+ lastMaterializedPackId: string | null;
834
+ detail: string;
835
+ }
836
+ export interface CurrentProfileBrainStatusInput extends OperatorSurfaceInput {
837
+ brainAttachmentPolicy?: RuntimeTurnBrainAttachmentPolicyV1 | null;
838
+ }
839
+ export type CurrentProfileBrainStatusV1 = CurrentProfileBrainStatusAnswerV1;
840
+ export declare function describeCurrentProfileBrainStatus(input: CurrentProfileBrainStatusInput): CurrentProfileBrainStatusV1;
841
+ export declare function formatOperatorRollbackReport(result: RollbackRuntimeAttachResult): string;
842
+ /**
843
+ * A per-turn summary of what was kernel-injected vs brain-compiled in a given
844
+ * compile response. Useful for operator observability and debugging.
845
+ *
846
+ * "Kernel" content is whatever the operator injected directly in the system
847
+ * prompt — this function cannot observe it, only describe the brain side.
848
+ * The `kernelSurface` field is present only when the caller supplies a surface
849
+ * descriptor (from `WorkspaceInjectionSurfaceV1`) alongside the compile
850
+ * response; otherwise it is null.
851
+ */
852
+ export interface KernelBrainBoundaryDescriptionV1 {
853
+ /**
854
+ * Summary of what the brain compiler contributed to this turn.
855
+ */
856
+ brain: {
857
+ packId: string;
858
+ mode: "learned" | "heuristic";
859
+ selectedBlockCount: number;
860
+ /** Roles of the selected blocks, deduplicated. */
861
+ selectedRoles: string[];
862
+ /** Whether the learned route_fn ran (true means learned routing was used). */
863
+ usedLearnedRouteFn: boolean;
864
+ /** Whether context was compacted due to char budget pressure. */
865
+ compactionApplied: boolean;
866
+ };
867
+ /**
868
+ * Validation result for the operator-supplied kernel surface descriptor.
869
+ * Null when no surface descriptor was supplied.
870
+ */
871
+ kernelValidation: KernelSurfaceValidationResultV1 | null;
872
+ /**
873
+ * Advisory: based on the compile diagnostics, is the brain context likely
874
+ * covering the query well, or should the operator investigate pack freshness?
875
+ *
876
+ * - `"likely_covered"` — learned routing ran and found token-matched blocks.
877
+ * - `"partial"` — some token matches, but mode was heuristic or routing gap.
878
+ * - `"likely_gap"` — no token matches or heuristic-only; pack may need refresh.
879
+ */
880
+ brainCoverageAdvisory: "likely_covered" | "partial" | "likely_gap";
881
+ }
882
+ /**
883
+ * Describes the kernel/brain boundary for a single compile response.
884
+ *
885
+ * Combines:
886
+ * - Brain context summary (from the compile response diagnostics)
887
+ * - Kernel surface validation (if a surface descriptor is supplied)
888
+ * - A coverage advisory based on routing signals
889
+ *
890
+ * See `docs/kernel-brain-boundary.md` for the full decision framework.
891
+ */
892
+ export declare function describeKernelBrainBoundary(compileResponse: RuntimeCompileResponseV1, surface?: WorkspaceInjectionSurfaceV1): KernelBrainBoundaryDescriptionV1;
893
+ export type { BrainEligibleContentKind, KernelContentKind, KernelSurfaceValidationResultV1, WorkspaceInjectionSurfaceV1 } from "@openclawbrain/contracts";