@openclawbrain/cli 0.4.11 → 0.4.13
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/README.md +3 -2
- package/dist/src/cli.js +45 -8
- package/dist/src/daemon.d.ts +6 -1
- package/dist/src/daemon.js +229 -41
- package/dist/src/local-learner.d.ts +1 -0
- package/dist/src/local-learner.js +8 -8
- package/dist/src/proof-command.js +654 -0
- package/extension/runtime-guard.ts +45 -0
- package/package.json +3 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface ExtensionCompileInput {
|
|
2
2
|
activationRoot: string;
|
|
3
3
|
message: string;
|
|
4
|
+
maxContextChars?: number;
|
|
4
5
|
sessionId?: string;
|
|
5
6
|
channel?: string;
|
|
6
7
|
_serveRouteBreadcrumbs?: {
|
|
@@ -38,6 +39,7 @@ export interface ExtensionRegistrationApi {
|
|
|
38
39
|
|
|
39
40
|
export interface NormalizedPromptBuildEvent {
|
|
40
41
|
message: string;
|
|
42
|
+
maxContextChars?: number;
|
|
41
43
|
sessionId?: string;
|
|
42
44
|
channel?: string;
|
|
43
45
|
warnings: ExtensionDiagnostic[];
|
|
@@ -94,6 +96,7 @@ export function normalizePromptBuildEvent(event: unknown): { ok: true; event: No
|
|
|
94
96
|
const warnings: ExtensionDiagnostic[] = [];
|
|
95
97
|
const sessionId = normalizeOptionalScalarField(event.sessionId, "sessionId", warnings);
|
|
96
98
|
const channel = normalizeOptionalScalarField(event.channel, "channel", warnings);
|
|
99
|
+
const maxContextChars = normalizeOptionalNonNegativeIntegerField(event.maxContextChars, "maxContextChars", warnings);
|
|
97
100
|
const promptFallback = extractTextContent(event.prompt);
|
|
98
101
|
let extractedMessage = promptFallback ?? "";
|
|
99
102
|
|
|
@@ -125,6 +128,7 @@ export function normalizePromptBuildEvent(event: unknown): { ok: true; event: No
|
|
|
125
128
|
ok: true,
|
|
126
129
|
event: {
|
|
127
130
|
message: extractedMessage,
|
|
131
|
+
...(maxContextChars !== undefined ? { maxContextChars } : {}),
|
|
128
132
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
129
133
|
...(channel !== undefined ? { channel } : {}),
|
|
130
134
|
warnings
|
|
@@ -170,6 +174,7 @@ export function createBeforePromptBuildHandler(input: {
|
|
|
170
174
|
const result = input.compileRuntimeContext({
|
|
171
175
|
activationRoot: input.activationRoot,
|
|
172
176
|
message: normalized.event.message,
|
|
177
|
+
...(normalized.event.maxContextChars !== undefined ? { maxContextChars: normalized.event.maxContextChars } : {}),
|
|
173
178
|
...(normalized.event.sessionId !== undefined ? { sessionId: normalized.event.sessionId } : {}),
|
|
174
179
|
...(normalized.event.channel !== undefined ? { channel: normalized.event.channel } : {}),
|
|
175
180
|
...(input.extensionEntryPath === undefined
|
|
@@ -249,6 +254,46 @@ function normalizeOptionalScalarField(
|
|
|
249
254
|
return undefined;
|
|
250
255
|
}
|
|
251
256
|
|
|
257
|
+
function normalizeOptionalNonNegativeIntegerField(
|
|
258
|
+
value: unknown,
|
|
259
|
+
fieldName: "maxContextChars",
|
|
260
|
+
warnings: ExtensionDiagnostic[]
|
|
261
|
+
): number | undefined {
|
|
262
|
+
if (value === undefined || value === null) {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) {
|
|
267
|
+
return value;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (typeof value === "bigint" && value >= 0n && value <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
271
|
+
return Number(value);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (typeof value === "string") {
|
|
275
|
+
const trimmed = value.trim();
|
|
276
|
+
if (trimmed.length === 0) {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
if (/^\d+$/.test(trimmed)) {
|
|
280
|
+
const parsed = Number(trimmed);
|
|
281
|
+
if (Number.isSafeInteger(parsed)) {
|
|
282
|
+
return parsed;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
warnings.push({
|
|
288
|
+
key: `runtime-${fieldName}-ignored`,
|
|
289
|
+
message:
|
|
290
|
+
`[openclawbrain] fail-open: ignored unsupported before_prompt_build ${fieldName} ` +
|
|
291
|
+
`(${fieldName}=${describeValue(value)})`
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
|
|
252
297
|
function extractPromptMessage(message: unknown): string | undefined {
|
|
253
298
|
if (typeof message === "string") {
|
|
254
299
|
return normalizeText(message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclawbrain/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"description": "OpenClawBrain operator CLI package with install/status helpers, daemon controls, and import/export tooling.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@openclawbrain/compiler": "
|
|
48
|
+
"@openclawbrain/compiler": "0.3.5",
|
|
49
49
|
"@openclawbrain/contracts": "^0.3.5",
|
|
50
50
|
"@openclawbrain/events": "^0.3.4",
|
|
51
51
|
"@openclawbrain/learner": "^0.3.4",
|
|
@@ -62,3 +62,4 @@
|
|
|
62
62
|
"test": "node --test dist/test/*.test.js"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
|