@openclawbrain/cli 0.4.0

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 (64) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +18 -0
  3. package/dist/extension/index.d.ts +1 -0
  4. package/dist/extension/index.js +98 -0
  5. package/dist/extension/index.js.map +1 -0
  6. package/dist/extension/runtime-guard.d.ts +61 -0
  7. package/dist/extension/runtime-guard.js +238 -0
  8. package/dist/extension/runtime-guard.js.map +1 -0
  9. package/dist/src/attachment-truth.d.ts +34 -0
  10. package/dist/src/attachment-truth.js +220 -0
  11. package/dist/src/attachment-truth.js.map +1 -0
  12. package/dist/src/cli.d.ts +170 -0
  13. package/dist/src/cli.js +5583 -0
  14. package/dist/src/cli.js.map +1 -0
  15. package/dist/src/daemon.d.ts +70 -0
  16. package/dist/src/daemon.js +955 -0
  17. package/dist/src/daemon.js.map +1 -0
  18. package/dist/src/import-export.d.ts +36 -0
  19. package/dist/src/import-export.js +171 -0
  20. package/dist/src/import-export.js.map +1 -0
  21. package/dist/src/index.d.ts +1730 -0
  22. package/dist/src/index.js +6882 -0
  23. package/dist/src/index.js.map +1 -0
  24. package/dist/src/learning-spine.d.ts +50 -0
  25. package/dist/src/learning-spine.js +461 -0
  26. package/dist/src/learning-spine.js.map +1 -0
  27. package/dist/src/local-session-passive-learning.d.ts +61 -0
  28. package/dist/src/local-session-passive-learning.js +454 -0
  29. package/dist/src/local-session-passive-learning.js.map +1 -0
  30. package/dist/src/ollama-client.d.ts +46 -0
  31. package/dist/src/ollama-client.js +231 -0
  32. package/dist/src/ollama-client.js.map +1 -0
  33. package/dist/src/openclaw-home-layout.d.ts +17 -0
  34. package/dist/src/openclaw-home-layout.js +182 -0
  35. package/dist/src/openclaw-home-layout.js.map +1 -0
  36. package/dist/src/openclaw-hook-truth.d.ts +33 -0
  37. package/dist/src/openclaw-hook-truth.js +260 -0
  38. package/dist/src/openclaw-hook-truth.js.map +1 -0
  39. package/dist/src/openclaw-plugin-install.d.ts +40 -0
  40. package/dist/src/openclaw-plugin-install.js +282 -0
  41. package/dist/src/provider-config.d.ts +64 -0
  42. package/dist/src/provider-config.js +306 -0
  43. package/dist/src/provider-config.js.map +1 -0
  44. package/dist/src/resolve-activation-root.d.ts +27 -0
  45. package/dist/src/resolve-activation-root.js +190 -0
  46. package/dist/src/resolve-activation-root.js.map +1 -0
  47. package/dist/src/semantic-metadata.d.ts +5 -0
  48. package/dist/src/semantic-metadata.js +70 -0
  49. package/dist/src/semantic-metadata.js.map +1 -0
  50. package/dist/src/session-store.d.ts +168 -0
  51. package/dist/src/session-store.js +250 -0
  52. package/dist/src/session-store.js.map +1 -0
  53. package/dist/src/session-tail.d.ts +73 -0
  54. package/dist/src/session-tail.js +602 -0
  55. package/dist/src/session-tail.js.map +1 -0
  56. package/dist/src/shadow-extension-proof.d.ts +43 -0
  57. package/dist/src/shadow-extension-proof.js +218 -0
  58. package/dist/src/shadow-extension-proof.js.map +1 -0
  59. package/dist/src/teacher-labeler.d.ts +50 -0
  60. package/dist/src/teacher-labeler.js +424 -0
  61. package/dist/src/teacher-labeler.js.map +1 -0
  62. package/extension/index.ts +125 -0
  63. package/extension/runtime-guard.ts +362 -0
  64. package/package.json +64 -0
@@ -0,0 +1,34 @@
1
+ import { type OpenClawHomeInspection } from "./openclaw-home-layout.js";
2
+ declare const ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT: "openclaw_profile_runtime_load_proofs.v1";
3
+ export interface OpenClawProfileRuntimeLoadProofRecordV1 {
4
+ openclawHome: string;
5
+ profileId: string | null;
6
+ profileSource: OpenClawHomeInspection["profileSource"];
7
+ loadedAt: string;
8
+ extensionEntryPath: string;
9
+ }
10
+ export interface OpenClawProfileRuntimeLoadProofsV1 {
11
+ contract: typeof ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT;
12
+ runtimeOwner: "openclaw";
13
+ activationRoot: string;
14
+ updatedAt: string;
15
+ profiles: OpenClawProfileRuntimeLoadProofRecordV1[];
16
+ }
17
+ export interface OpenClawProfileRuntimeLoadProofSetV1 {
18
+ path: string;
19
+ proofs: OpenClawProfileRuntimeLoadProofsV1 | null;
20
+ error: string | null;
21
+ }
22
+ export declare function resolveAttachmentRuntimeLoadProofsPath(activationRoot: string): string;
23
+ export declare function listOpenClawProfileRuntimeLoadProofs(activationRoot: string): OpenClawProfileRuntimeLoadProofSetV1;
24
+ export declare function recordOpenClawProfileRuntimeLoadProof(input: {
25
+ activationRoot: string;
26
+ extensionEntryPath: string;
27
+ loadedAt?: string | null;
28
+ }): OpenClawProfileRuntimeLoadProofRecordV1;
29
+ export declare function clearOpenClawProfileRuntimeLoadProof(input: {
30
+ activationRoot: string;
31
+ openclawHome: string;
32
+ clearedAt?: string | null;
33
+ }): boolean;
34
+ export {};
@@ -0,0 +1,220 @@
1
+ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { inspectOpenClawHome } from "./openclaw-home-layout.js";
4
+ import { resolveOpenClawHomeFromExtensionEntryPath } from "./openclaw-plugin-install.js";
5
+ const ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT = "openclaw_profile_runtime_load_proofs.v1";
6
+ const ATTACHMENT_TRUTH_DIRNAME = "attachment-truth";
7
+ const ATTACHMENT_RUNTIME_LOAD_PROOFS_BASENAME = "runtime-load-proofs.json";
8
+ function toErrorMessage(error) {
9
+ return error instanceof Error ? error.message : String(error);
10
+ }
11
+ function canonicalizeFilesystemPath(filePath) {
12
+ const resolvedPath = path.resolve(filePath);
13
+ try {
14
+ return realpathSync(resolvedPath);
15
+ }
16
+ catch {
17
+ return resolvedPath;
18
+ }
19
+ }
20
+ function normalizeIsoTimestamp(value, fieldName, fallbackValue) {
21
+ const candidate = value ?? fallbackValue;
22
+ if (candidate === undefined || candidate === null || candidate.trim().length === 0) {
23
+ throw new Error(`${fieldName} is required`);
24
+ }
25
+ if (Number.isNaN(Date.parse(candidate))) {
26
+ throw new Error(`${fieldName} must be an ISO timestamp`);
27
+ }
28
+ return new Date(candidate).toISOString();
29
+ }
30
+ function readRecord(value) {
31
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
32
+ return null;
33
+ }
34
+ return value;
35
+ }
36
+ function validateRuntimeLoadProofRecord(value, index) {
37
+ const record = readRecord(value);
38
+ if (record === null) {
39
+ throw new Error(`profiles[${index}] must be an object`);
40
+ }
41
+ const openclawHome = typeof record.openclawHome === "string" && record.openclawHome.trim().length > 0
42
+ ? canonicalizeFilesystemPath(record.openclawHome)
43
+ : null;
44
+ const profileId = record.profileId === null ? null : typeof record.profileId === "string" && record.profileId.trim().length > 0
45
+ ? record.profileId.trim()
46
+ : undefined;
47
+ const profileSource = record.profileSource === "openclaw_json_profile" ||
48
+ record.profileSource === "openclaw_json_single_profile_key" ||
49
+ record.profileSource === "directory_name" ||
50
+ record.profileSource === "none"
51
+ ? record.profileSource
52
+ : null;
53
+ const extensionEntryPath = typeof record.extensionEntryPath === "string" && record.extensionEntryPath.trim().length > 0
54
+ ? canonicalizeFilesystemPath(record.extensionEntryPath)
55
+ : null;
56
+ const loadedAt = typeof record.loadedAt === "string" && record.loadedAt.trim().length > 0
57
+ ? normalizeIsoTimestamp(record.loadedAt, `profiles[${index}].loadedAt`)
58
+ : null;
59
+ if (openclawHome === null) {
60
+ throw new Error(`profiles[${index}].openclawHome must be a non-empty string`);
61
+ }
62
+ if (profileId === undefined) {
63
+ throw new Error(`profiles[${index}].profileId must be null or a non-empty string`);
64
+ }
65
+ if (profileSource === null) {
66
+ throw new Error(`profiles[${index}].profileSource must be a supported OpenClaw profile source`);
67
+ }
68
+ if (extensionEntryPath === null) {
69
+ throw new Error(`profiles[${index}].extensionEntryPath must be a non-empty string`);
70
+ }
71
+ if (loadedAt === null) {
72
+ throw new Error(`profiles[${index}].loadedAt must be a non-empty ISO timestamp`);
73
+ }
74
+ return {
75
+ openclawHome,
76
+ profileId,
77
+ profileSource,
78
+ extensionEntryPath,
79
+ loadedAt
80
+ };
81
+ }
82
+ function validateRuntimeLoadProofs(activationRoot, value) {
83
+ const record = readRecord(value);
84
+ if (record === null) {
85
+ throw new Error("runtime load proof file must contain an object");
86
+ }
87
+ if (record.contract !== ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT) {
88
+ throw new Error(`runtime load proof contract must be ${ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT}`);
89
+ }
90
+ if (record.runtimeOwner !== "openclaw") {
91
+ throw new Error("runtime load proof runtimeOwner must be openclaw");
92
+ }
93
+ if (typeof record.activationRoot !== "string" || record.activationRoot.trim().length === 0) {
94
+ throw new Error("runtime load proof activationRoot must be a non-empty string");
95
+ }
96
+ const resolvedActivationRoot = path.resolve(record.activationRoot);
97
+ if (resolvedActivationRoot !== activationRoot) {
98
+ throw new Error(`runtime load proof activationRoot mismatch: expected ${activationRoot}, received ${resolvedActivationRoot}`);
99
+ }
100
+ const updatedAt = typeof record.updatedAt === "string" && record.updatedAt.trim().length > 0
101
+ ? normalizeIsoTimestamp(record.updatedAt, "updatedAt")
102
+ : null;
103
+ if (updatedAt === null) {
104
+ throw new Error("runtime load proof updatedAt must be a non-empty ISO timestamp");
105
+ }
106
+ if (!Array.isArray(record.profiles)) {
107
+ throw new Error("runtime load proof profiles must be an array");
108
+ }
109
+ const profiles = record.profiles.map((entry, index) => validateRuntimeLoadProofRecord(entry, index));
110
+ return {
111
+ contract: ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT,
112
+ runtimeOwner: "openclaw",
113
+ activationRoot,
114
+ updatedAt,
115
+ profiles
116
+ };
117
+ }
118
+ function buildEmptyRuntimeLoadProofs(activationRoot, updatedAt) {
119
+ return {
120
+ contract: ATTACHMENT_RUNTIME_LOAD_PROOFS_CONTRACT,
121
+ runtimeOwner: "openclaw",
122
+ activationRoot,
123
+ updatedAt,
124
+ profiles: []
125
+ };
126
+ }
127
+ function writeRuntimeLoadProofs(proofPath, proofs) {
128
+ mkdirSync(path.dirname(proofPath), { recursive: true });
129
+ writeFileSync(proofPath, `${JSON.stringify(proofs, null, 2)}\n`, "utf8");
130
+ }
131
+ function deriveOpenClawHomeFromExtensionEntryPath(extensionEntryPath) {
132
+ const openclawHome = resolveOpenClawHomeFromExtensionEntryPath(extensionEntryPath);
133
+ if (openclawHome === null) {
134
+ throw new Error(`extension entry path ${extensionEntryPath} is not nested under an OpenClaw extensions dir`);
135
+ }
136
+ return canonicalizeFilesystemPath(openclawHome);
137
+ }
138
+ export function resolveAttachmentRuntimeLoadProofsPath(activationRoot) {
139
+ return path.join(path.resolve(activationRoot), ATTACHMENT_TRUTH_DIRNAME, ATTACHMENT_RUNTIME_LOAD_PROOFS_BASENAME);
140
+ }
141
+ export function listOpenClawProfileRuntimeLoadProofs(activationRoot) {
142
+ const resolvedActivationRoot = path.resolve(activationRoot);
143
+ const proofPath = resolveAttachmentRuntimeLoadProofsPath(resolvedActivationRoot);
144
+ if (!existsSync(proofPath)) {
145
+ return {
146
+ path: proofPath,
147
+ proofs: null,
148
+ error: null
149
+ };
150
+ }
151
+ try {
152
+ const parsed = JSON.parse(readFileSync(proofPath, "utf8"));
153
+ return {
154
+ path: proofPath,
155
+ proofs: validateRuntimeLoadProofs(resolvedActivationRoot, parsed),
156
+ error: null
157
+ };
158
+ }
159
+ catch (error) {
160
+ return {
161
+ path: proofPath,
162
+ proofs: null,
163
+ error: toErrorMessage(error)
164
+ };
165
+ }
166
+ }
167
+ export function recordOpenClawProfileRuntimeLoadProof(input) {
168
+ const activationRoot = path.resolve(input.activationRoot);
169
+ const loadedAt = normalizeIsoTimestamp(input.loadedAt, "loadedAt", new Date().toISOString());
170
+ const extensionEntryPath = canonicalizeFilesystemPath(input.extensionEntryPath);
171
+ const openclawHome = deriveOpenClawHomeFromExtensionEntryPath(extensionEntryPath);
172
+ const inspection = inspectOpenClawHome(openclawHome);
173
+ const loadedProofs = listOpenClawProfileRuntimeLoadProofs(activationRoot);
174
+ if (loadedProofs.error !== null) {
175
+ throw new Error(`runtime load proof file ${loadedProofs.path} is unreadable: ${loadedProofs.error}`);
176
+ }
177
+ const nextRecord = {
178
+ openclawHome: canonicalizeFilesystemPath(openclawHome),
179
+ profileId: inspection.profileId,
180
+ profileSource: inspection.profileSource,
181
+ loadedAt,
182
+ extensionEntryPath
183
+ };
184
+ const nextProofs = loadedProofs.proofs === null
185
+ ? buildEmptyRuntimeLoadProofs(activationRoot, loadedAt)
186
+ : {
187
+ ...loadedProofs.proofs,
188
+ updatedAt: loadedAt,
189
+ profiles: [...loadedProofs.proofs.profiles]
190
+ };
191
+ nextProofs.profiles = nextProofs.profiles
192
+ .filter((record) => canonicalizeFilesystemPath(record.openclawHome) !== nextRecord.openclawHome)
193
+ .concat(nextRecord)
194
+ .sort((left, right) => left.openclawHome.localeCompare(right.openclawHome));
195
+ writeRuntimeLoadProofs(loadedProofs.path, nextProofs);
196
+ return nextRecord;
197
+ }
198
+ export function clearOpenClawProfileRuntimeLoadProof(input) {
199
+ const activationRoot = path.resolve(input.activationRoot);
200
+ const clearedAt = normalizeIsoTimestamp(input.clearedAt, "clearedAt", new Date().toISOString());
201
+ const openclawHome = canonicalizeFilesystemPath(input.openclawHome);
202
+ const loadedProofs = listOpenClawProfileRuntimeLoadProofs(activationRoot);
203
+ if (loadedProofs.error !== null) {
204
+ throw new Error(`runtime load proof file ${loadedProofs.path} is unreadable: ${loadedProofs.error}`);
205
+ }
206
+ if (loadedProofs.proofs === null) {
207
+ return false;
208
+ }
209
+ const filteredProfiles = loadedProofs.proofs.profiles.filter((record) => canonicalizeFilesystemPath(record.openclawHome) !== openclawHome);
210
+ if (filteredProfiles.length === loadedProofs.proofs.profiles.length) {
211
+ return false;
212
+ }
213
+ writeRuntimeLoadProofs(loadedProofs.path, {
214
+ ...loadedProofs.proofs,
215
+ updatedAt: clearedAt,
216
+ profiles: filteredProfiles
217
+ });
218
+ return true;
219
+ }
220
+ //# sourceMappingURL=attachment-truth.js.map
@@ -0,0 +1 @@
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0B,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,oCAAoC,CAAC,cAAc,CAAC,CAAC;IAE1E,IAAI,YAAY,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,2BAA2B,YAAY,CAAC,IAAI,mBAAmB,YAAY,CAAC,KAAK,EAAE,CACpF,CAAC;IACJ,CAAC;IAED,IAAI,YAAY,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,gBAAgB,GAAG,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAC1D,CAAC,MAAM,EAAE,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,YAAY,CAC7E,CAAC;IACF,IAAI,gBAAgB,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,sBAAsB,CAAC,YAAY,CAAC,IAAI,EAAE;QACxC,GAAG,YAAY,CAAC,MAAM;QACtB,SAAS,EAAE,SAAS;QACpB,QAAQ,EAAE,gBAAgB;KAC3B,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+ import { type TextEmbedder } from "@openclawbrain/compiler";
3
+ import { type DaemonCliArgs } from "./daemon.js";
4
+ import { createAsyncTeacherLiveLoop, createOpenClawLocalSessionTail, createRuntimeEventExportScanner, type AsyncTeacherLabelerConfigV1, type CurrentProfileBrainStatusInput, type WatchEmbedInstrumentationTraceV1 } from "./index.js";
5
+ interface ParsedStatusRollbackCliArgs {
6
+ command: "status" | "rollback";
7
+ input: CurrentProfileBrainStatusInput;
8
+ openclawHome: string | null;
9
+ json: boolean;
10
+ help: boolean;
11
+ dryRun: boolean;
12
+ detailed: boolean;
13
+ }
14
+ interface ParsedAttachCliArgs {
15
+ command: "attach";
16
+ openclawHome: string;
17
+ openclawHomeSource: "explicit";
18
+ activationRoot: string;
19
+ activationRootSource: ParsedInstallCliArgs["activationRootSource"];
20
+ shared: boolean;
21
+ workspaceId: string;
22
+ workspaceIdSource: ParsedInstallCliArgs["workspaceIdSource"];
23
+ skipEmbedderProvision: boolean;
24
+ skipEmbedderProvisionSource: ParsedInstallCliArgs["skipEmbedderProvisionSource"];
25
+ json: boolean;
26
+ help: boolean;
27
+ }
28
+ interface ParsedInstallCliArgs {
29
+ command: "install";
30
+ openclawHome: string;
31
+ openclawHomeSource: "explicit" | "env" | "discovered_single_home";
32
+ activationRoot: string;
33
+ activationRootSource: "explicit" | "default_from_openclaw_home";
34
+ shared: boolean;
35
+ workspaceId: string;
36
+ workspaceIdSource: "explicit" | "openclaw_json_profile" | "openclaw_json_single_profile_key" | "current_profile_boundary" | "openclaw_home_dir" | "fallback";
37
+ skipEmbedderProvision: boolean;
38
+ skipEmbedderProvisionSource: "flag" | "env" | null;
39
+ json: boolean;
40
+ help: boolean;
41
+ }
42
+ type RestartMode = "never" | "safe" | "external";
43
+ interface ParsedDetachCliArgs {
44
+ command: "detach";
45
+ openclawHome: string;
46
+ activationRoot: string | null;
47
+ restart: RestartMode;
48
+ json: boolean;
49
+ help: boolean;
50
+ }
51
+ interface ParsedUninstallCliArgs {
52
+ command: "uninstall";
53
+ openclawHome: string;
54
+ activationRoot: string | null;
55
+ dataMode: "keep" | "purge";
56
+ restart: RestartMode;
57
+ json: boolean;
58
+ help: boolean;
59
+ }
60
+ interface ParsedScanCliArgs {
61
+ command: "scan";
62
+ json: boolean;
63
+ help: boolean;
64
+ sessionPath: string | null;
65
+ livePath: string | null;
66
+ rootDir: string | null;
67
+ workspacePath: string | null;
68
+ packLabel: string | null;
69
+ observedAt: string | null;
70
+ snapshotOutPath: string | null;
71
+ }
72
+ interface ParsedContextCliArgs {
73
+ command: "context";
74
+ message: string;
75
+ activationRoot: string;
76
+ json: boolean;
77
+ help: boolean;
78
+ }
79
+ interface ParsedHistoryCliArgs {
80
+ command: "history";
81
+ activationRoot: string;
82
+ limit: number;
83
+ json: boolean;
84
+ help: boolean;
85
+ }
86
+ interface ParsedLearnCliArgs {
87
+ command: "learn";
88
+ activationRoot: string;
89
+ json: boolean;
90
+ help: boolean;
91
+ }
92
+ interface ParsedWatchCliArgs {
93
+ command: "watch";
94
+ activationRoot: string;
95
+ scanRoot: string | null;
96
+ interval: number;
97
+ json: boolean;
98
+ help: boolean;
99
+ }
100
+ interface ParsedExportCliArgs {
101
+ command: "export";
102
+ activationRoot: string;
103
+ outputPath: string;
104
+ json: boolean;
105
+ help: boolean;
106
+ }
107
+ interface ParsedImportCliArgs {
108
+ command: "import";
109
+ archivePath: string;
110
+ activationRoot: string;
111
+ force: boolean;
112
+ json: boolean;
113
+ help: boolean;
114
+ }
115
+ interface ParsedResetCliArgs {
116
+ command: "reset";
117
+ activationRoot: string;
118
+ yes: boolean;
119
+ json: boolean;
120
+ help: boolean;
121
+ }
122
+ type ParsedOperatorCliArgs = ParsedStatusRollbackCliArgs | ParsedAttachCliArgs | ParsedScanCliArgs | ParsedInstallCliArgs | ParsedDetachCliArgs | ParsedUninstallCliArgs | ParsedContextCliArgs | ParsedHistoryCliArgs | ParsedLearnCliArgs | ParsedWatchCliArgs | DaemonCliArgs | ParsedExportCliArgs | ParsedImportCliArgs | ParsedResetCliArgs;
123
+ export declare function parseOperatorCliArgs(argv: readonly string[]): ParsedOperatorCliArgs;
124
+ export interface WatchCommandRuntimeV1 {
125
+ activationRoot: string;
126
+ scanRoot: string;
127
+ pollIntervalSeconds: number;
128
+ sessionTailCursorPath: string;
129
+ teacherSnapshotPath: string;
130
+ startupWarnings: string[];
131
+ lastTeacherError: string | null;
132
+ replayState: {
133
+ replayedBundleCount: number;
134
+ replayedEventCount: number;
135
+ };
136
+ lastHandledMaterializationPackId: string | null;
137
+ lastEmbedInstrumentation: WatchEmbedInstrumentationTraceV1 | null;
138
+ scanner: ReturnType<typeof createRuntimeEventExportScanner>;
139
+ teacherLoop: ReturnType<typeof createAsyncTeacherLiveLoop>;
140
+ localSessionTail: ReturnType<typeof createOpenClawLocalSessionTail>;
141
+ embedder: TextEmbedder | null;
142
+ }
143
+ export interface CreateWatchCommandRuntimeInputV1 {
144
+ activationRoot: string;
145
+ scanRoot?: string | null;
146
+ pollIntervalSeconds?: number;
147
+ profileRoots?: readonly string[];
148
+ log?: (message: string) => void;
149
+ teacherLabeler?: AsyncTeacherLabelerConfigV1 | null;
150
+ embedder?: TextEmbedder | null;
151
+ }
152
+ export interface WatchCommandPassResultV1 {
153
+ localPoll: ReturnType<WatchCommandRuntimeV1["localSessionTail"]["pollOnce"]>;
154
+ exported: {
155
+ exportedBundleCount: number;
156
+ exportedEventCount: number;
157
+ warnings: string[];
158
+ };
159
+ scanResult: ReturnType<WatchCommandRuntimeV1["scanner"]["scanOnce"]>;
160
+ snapshot: ReturnType<WatchCommandRuntimeV1["teacherLoop"]["snapshot"]>;
161
+ materializedPackId: string | null;
162
+ }
163
+ export declare function createWatchCommandRuntime(input: CreateWatchCommandRuntimeInputV1): Promise<WatchCommandRuntimeV1>;
164
+ export declare function runWatchCommandPass(runtime: WatchCommandRuntimeV1, options?: {
165
+ observedAt?: string;
166
+ json?: boolean;
167
+ log?: (message: string) => void;
168
+ }): Promise<WatchCommandPassResultV1>;
169
+ export declare function runOperatorCli(argv?: readonly string[]): number;
170
+ export {};