@principles/pd-cli 1.164.0 → 1.166.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.
- package/dist/commands/health-mcp.d.ts +19 -0
- package/dist/commands/health-mcp.d.ts.map +1 -1
- package/dist/commands/health-mcp.js +226 -0
- package/dist/commands/health-mcp.js.map +1 -1
- package/dist/commands/health.d.ts.map +1 -1
- package/dist/commands/health.js +18 -1
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/mcp-logs-export.d.ts +7 -0
- package/dist/commands/mcp-logs-export.d.ts.map +1 -0
- package/dist/commands/mcp-logs-export.js +267 -0
- package/dist/commands/mcp-logs-export.js.map +1 -0
- package/dist/commands/runtime-activation.d.ts +18 -0
- package/dist/commands/runtime-activation.d.ts.map +1 -1
- package/dist/commands/runtime-activation.js +73 -1
- package/dist/commands/runtime-activation.js.map +1 -1
- package/dist/commands/workbuddy-worker.d.ts.map +1 -1
- package/dist/commands/workbuddy-worker.js +2 -1
- package/dist/commands/workbuddy-worker.js.map +1 -1
- package/dist/index.js +38 -1
- package/dist/index.js.map +1 -1
- package/dist/services/zip-writer.d.ts +6 -0
- package/dist/services/zip-writer.d.ts.map +1 -0
- package/dist/services/zip-writer.js +97 -0
- package/dist/services/zip-writer.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pd mcp logs export` — bundle the durable PD MCP logs for offline analysis.
|
|
3
|
+
*
|
|
4
|
+
* The Owner runs one command on the machine where PD is installed; the
|
|
5
|
+
* resulting zip can be sent to an agent as-is. Contents:
|
|
6
|
+
* README.md field/event meanings + privacy contract
|
|
7
|
+
* manifest.json generation window, file list, sizes (no absolute paths)
|
|
8
|
+
* *.jsonl the raw sanitized log lines, unmodified
|
|
9
|
+
*
|
|
10
|
+
* The archive is bounded (≤20 MiB) and includes only the last N days (default
|
|
11
|
+
* 7) of `mcp-*.jsonl` from the PD-owned log directory. Nothing here reads or
|
|
12
|
+
* rewrites a log file.
|
|
13
|
+
*/
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as os from 'node:os';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import { buildZip } from '../services/zip-writer.js';
|
|
18
|
+
const MAX_ZIP_BYTES = 20 * 1024 * 1024;
|
|
19
|
+
const MAX_UNCOMPRESSED_BYTES = 18 * 1024 * 1024;
|
|
20
|
+
const DEFAULT_DAYS = 7;
|
|
21
|
+
const LOG_FILE_PATTERN = /^mcp-.*\.jsonl$/;
|
|
22
|
+
function logDirPath() {
|
|
23
|
+
const override = process.env.PD_MCP_LOG_DIR;
|
|
24
|
+
if (typeof override === 'string' && override.trim().length > 0) {
|
|
25
|
+
return { dir: path.resolve(override), source: 'PD_MCP_LOG_DIR (custom)' };
|
|
26
|
+
}
|
|
27
|
+
return { dir: path.join(os.homedir(), '.pd', 'logs', 'mcp'), source: '~/.pd/logs/mcp' };
|
|
28
|
+
}
|
|
29
|
+
function localTimestamp(date) {
|
|
30
|
+
const offset = -date.getTimezoneOffset();
|
|
31
|
+
const sign = offset >= 0 ? '+' : '-';
|
|
32
|
+
const abs = Math.abs(offset);
|
|
33
|
+
const pad = (value, width = 2) => String(value).padStart(width, '0');
|
|
34
|
+
return {
|
|
35
|
+
ts: `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}` +
|
|
36
|
+
`T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}` +
|
|
37
|
+
`${sign}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`,
|
|
38
|
+
tzOffsetMinutes: offset,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function countLines(text) {
|
|
42
|
+
if (text.length === 0)
|
|
43
|
+
return 0;
|
|
44
|
+
let lines = 0;
|
|
45
|
+
for (const char of text)
|
|
46
|
+
if (char === '\n')
|
|
47
|
+
lines += 1;
|
|
48
|
+
return text.endsWith('\n') ? lines : lines + 1;
|
|
49
|
+
}
|
|
50
|
+
const README = `# PD MCP logs bundle
|
|
51
|
+
|
|
52
|
+
This archive was produced by \`pd mcp logs export\`. It contains the sanitized
|
|
53
|
+
JSON Lines log files written by the PD MCP server and its launcher.
|
|
54
|
+
|
|
55
|
+
## Privacy
|
|
56
|
+
|
|
57
|
+
- No pain text, principle text, tool input, token, secret or workspace path is
|
|
58
|
+
recorded. Workspaces are represented by a short fingerprint.
|
|
59
|
+
- Paths never appear in events. Hosts and environment variables appear only
|
|
60
|
+
as booleans or enum values.
|
|
61
|
+
- Each line has the same fields the server already writes to stderr.
|
|
62
|
+
|
|
63
|
+
## Common fields
|
|
64
|
+
|
|
65
|
+
| field | meaning |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| ts | event time, RFC3339 with the machine's local offset |
|
|
68
|
+
| tzOffsetMinutes | local UTC offset in minutes |
|
|
69
|
+
| runId | 8-hex id shared by the launcher and server of ONE process |
|
|
70
|
+
| seq | per-file sequence starting at 1; gaps mean dropped lines |
|
|
71
|
+
| server | pd-mcp-launcher or pd-mcp-server |
|
|
72
|
+
| version | emitting component version |
|
|
73
|
+
| level | info / warn / error |
|
|
74
|
+
| event | event name (see below) |
|
|
75
|
+
| host | codex / openclaw / workbuddy / unspecified |
|
|
76
|
+
| pid | process id |
|
|
77
|
+
|
|
78
|
+
## Events
|
|
79
|
+
|
|
80
|
+
### launcher_start
|
|
81
|
+
Emitted once after binding validation, before importing the server.
|
|
82
|
+
|
|
83
|
+
| field | meaning |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| launcherVersion | launcher contract stamp |
|
|
86
|
+
| mcpServerVersion | installed server package version |
|
|
87
|
+
| bindingPathExists | mcp-binding.json exists (boolean, never the path) |
|
|
88
|
+
| workspaceResolution | ok / not_checked / declaration failure category |
|
|
89
|
+
| envPresence | booleans for PD_MCP_WORKSPACE_DIR, PD_MCP_HOST, PD_WORKSPACE_DIR, OPENCLAW_WORKSPACE |
|
|
90
|
+
|
|
91
|
+
### startup
|
|
92
|
+
Server resolved a usable binding.
|
|
93
|
+
|
|
94
|
+
| field | meaning |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| host | host marker |
|
|
97
|
+
| workspaceFingerprint | sha256(path) prefix 16; same workspace = same value |
|
|
98
|
+
| nodeVersion | Node runtime version |
|
|
99
|
+
| platform | process.platform |
|
|
100
|
+
|
|
101
|
+
### initialize
|
|
102
|
+
Two lines per MCP handshake: phase=request (client asked) and phase=response
|
|
103
|
+
(the server answered). If only the request line exists, the handshake never
|
|
104
|
+
completed.
|
|
105
|
+
|
|
106
|
+
| field | meaning |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| phase | request / response |
|
|
109
|
+
| requestId | bounded JSON-RPC id |
|
|
110
|
+
| clientName / clientVersion / protocolVersion | bounded labels (request) |
|
|
111
|
+
| capabilityKeysCount | number of client capability keys (request) |
|
|
112
|
+
| ok | response succeeded (response) |
|
|
113
|
+
| errorCode | bounded error code when ok=false |
|
|
114
|
+
| durationMs | request → response time |
|
|
115
|
+
| responseBytes | response JSON size |
|
|
116
|
+
|
|
117
|
+
### tools_list
|
|
118
|
+
Same two-phase shape as initialize; response adds toolCount.
|
|
119
|
+
|
|
120
|
+
### tool_call
|
|
121
|
+
One line per call, including refused/deadline/exception paths.
|
|
122
|
+
|
|
123
|
+
| field | meaning |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| toolName | MCP tool name |
|
|
126
|
+
| durationMs | call duration |
|
|
127
|
+
| status | ok / partial / unavailable / invalid_input ... |
|
|
128
|
+
| errorCode | bounded code; see below |
|
|
129
|
+
| responseBytes | bytes returned to the client |
|
|
130
|
+
| truncated | true only if the response was truncated (never: over-budget responses are withheld) |
|
|
131
|
+
|
|
132
|
+
Diagnostic errorCode values: shutting_down, saturated, deadline_exceeded,
|
|
133
|
+
tool_execution_failed, response_budget_exceeded, failure_envelope_over_budget.
|
|
134
|
+
|
|
135
|
+
### shutdown
|
|
136
|
+
| field | meaning |
|
|
137
|
+
| --- | --- |
|
|
138
|
+
| reason | stdin_closed |
|
|
139
|
+
| orphans | timed-out calls still settling |
|
|
140
|
+
| active | calls executing at close |
|
|
141
|
+
| uptimeMs | process uptime |
|
|
142
|
+
|
|
143
|
+
### startup_failure
|
|
144
|
+
A process exited before the MCP handshake completed. This is the ONLY PD-side
|
|
145
|
+
evidence available for that failure class.
|
|
146
|
+
|
|
147
|
+
| field | meaning |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| stage | server / launcher |
|
|
150
|
+
| reasonCategory | invalid_binding (server) |
|
|
151
|
+
| reasonCode | workspace_env_missing, workspace_not_absolute, workspace_unreadable, workspace_not_directory, host_invalid |
|
|
152
|
+
| reason | bounded launcher failure code (launcher stage) |
|
|
153
|
+
| bindingPathExists | boolean |
|
|
154
|
+
| workspaceResolution | ok / not_checked / declaration category |
|
|
155
|
+
| envPresence | environment-variable presence booleans |
|
|
156
|
+
| envVar | env var named by an invalid binding |
|
|
157
|
+
| nextAction | remediation hint (no paths or values) |
|
|
158
|
+
|
|
159
|
+
## How to read it
|
|
160
|
+
|
|
161
|
+
- No launcher_start and no startup_failure: the host never started PD.
|
|
162
|
+
- launcher_start without startup: the server failed between validation and
|
|
163
|
+
startup, or was killed.
|
|
164
|
+
- initialize request without initialize response: handshake failed.
|
|
165
|
+
- initialize response without tool_call: the model never called the tool.
|
|
166
|
+
- tool_call status=partial: the capability returned partial data (one or more
|
|
167
|
+
sources unavailable); status=unavailable: inspect errorCode.
|
|
168
|
+
`;
|
|
169
|
+
function resolveOutputPath(out, now) {
|
|
170
|
+
const stamp = now.toISOString().replace(/[-:]/g, '').replace(/\..+$/, 'Z');
|
|
171
|
+
const defaultName = `pd-mcp-logs-${stamp}.zip`;
|
|
172
|
+
if (typeof out !== 'string' || out.trim().length === 0) {
|
|
173
|
+
return path.resolve(process.cwd(), defaultName);
|
|
174
|
+
}
|
|
175
|
+
const resolved = path.resolve(out.trim());
|
|
176
|
+
return resolved.toLowerCase().endsWith('.zip') ? resolved : path.join(resolved, defaultName);
|
|
177
|
+
}
|
|
178
|
+
export async function handleMcpLogsExport(opts = {}) {
|
|
179
|
+
const days = Number.isInteger(opts.days) && opts.days > 0 ? opts.days : DEFAULT_DAYS;
|
|
180
|
+
if (days > 365)
|
|
181
|
+
throw new Error('--days must be between 1 and 365');
|
|
182
|
+
const now = new Date();
|
|
183
|
+
const cutoff = now.getTime() - days * 24 * 60 * 60 * 1000;
|
|
184
|
+
const { dir, source } = logDirPath();
|
|
185
|
+
const skipped = [];
|
|
186
|
+
const collected = [];
|
|
187
|
+
if (fs.existsSync(dir)) {
|
|
188
|
+
const files = fs.readdirSync(dir, { withFileTypes: true })
|
|
189
|
+
.filter((entry) => entry.isFile() && LOG_FILE_PATTERN.test(entry.name))
|
|
190
|
+
.map((entry) => {
|
|
191
|
+
const fullPath = path.join(dir, entry.name);
|
|
192
|
+
const stat = fs.statSync(fullPath);
|
|
193
|
+
return { name: entry.name, fullPath, size: stat.size, mtimeMs: stat.mtimeMs };
|
|
194
|
+
})
|
|
195
|
+
.filter((file) => file.mtimeMs >= cutoff)
|
|
196
|
+
.sort((left, right) => right.mtimeMs - left.mtimeMs);
|
|
197
|
+
let budget = MAX_UNCOMPRESSED_BYTES;
|
|
198
|
+
for (const file of files) {
|
|
199
|
+
if (file.size > budget) {
|
|
200
|
+
skipped.push(file.name);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const data = fs.readFileSync(file.fullPath);
|
|
204
|
+
budget -= data.length;
|
|
205
|
+
collected.push({ ...file, data });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Oldest first in the archive keeps a natural reading order.
|
|
209
|
+
collected.sort((left, right) => left.mtimeMs - right.mtimeMs);
|
|
210
|
+
const outPath = resolveOutputPath(opts.out, now);
|
|
211
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
212
|
+
let archive;
|
|
213
|
+
let base = localTimestamp(now);
|
|
214
|
+
while (true) {
|
|
215
|
+
const included = collected;
|
|
216
|
+
const manifest = {
|
|
217
|
+
generatedAt: base.ts,
|
|
218
|
+
tzOffsetMinutes: base.tzOffsetMinutes,
|
|
219
|
+
days,
|
|
220
|
+
source,
|
|
221
|
+
files: included.map((file) => ({
|
|
222
|
+
name: file.name,
|
|
223
|
+
bytes: file.data.length,
|
|
224
|
+
lines: countLines(file.data.toString('utf8')),
|
|
225
|
+
modifiedAt: localTimestamp(new Date(file.mtimeMs)).ts,
|
|
226
|
+
})),
|
|
227
|
+
skippedForSize: skipped,
|
|
228
|
+
totalBytes: included.reduce((sum, file) => sum + file.data.length, 0),
|
|
229
|
+
note: included.length === 0 ? 'No MCP log files matched the requested window.' : '',
|
|
230
|
+
};
|
|
231
|
+
const entries = [
|
|
232
|
+
{ name: 'README.md', data: Buffer.from(README, 'utf8') },
|
|
233
|
+
{ name: 'manifest.json', data: Buffer.from(JSON.stringify(manifest, null, 2), 'utf8') },
|
|
234
|
+
...included.map((file) => ({ name: file.name, data: file.data })),
|
|
235
|
+
];
|
|
236
|
+
archive = buildZip(entries, now);
|
|
237
|
+
if (archive.length <= MAX_ZIP_BYTES)
|
|
238
|
+
break;
|
|
239
|
+
// Size is enforced on the compressed result: drop the oldest file and retry.
|
|
240
|
+
const dropped = collected.shift();
|
|
241
|
+
if (dropped === undefined)
|
|
242
|
+
throw new Error('Bundle exceeds 20 MiB even without log files');
|
|
243
|
+
skipped.push(dropped.name);
|
|
244
|
+
base = localTimestamp(new Date());
|
|
245
|
+
}
|
|
246
|
+
fs.writeFileSync(outPath, archive);
|
|
247
|
+
const manifestForOutput = {
|
|
248
|
+
output: outPath,
|
|
249
|
+
bytes: archive.length,
|
|
250
|
+
files: collected.map((file) => file.name),
|
|
251
|
+
days,
|
|
252
|
+
skippedForSize: skipped,
|
|
253
|
+
};
|
|
254
|
+
if (opts.json) {
|
|
255
|
+
console.log(JSON.stringify(manifestForOutput, null, 2));
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
console.log(`PD MCP log bundle: ${outPath}`);
|
|
259
|
+
console.log(`Window: last ${days} day(s) | files: ${collected.length} | size: ${archive.length} bytes`);
|
|
260
|
+
for (const file of collected) {
|
|
261
|
+
console.log(` ${file.name} (${file.data.length} bytes, ${countLines(file.data.toString('utf8'))} lines)`);
|
|
262
|
+
}
|
|
263
|
+
if (skipped.length > 0) {
|
|
264
|
+
console.log(` skipped for size/window: ${skipped.join(', ')}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=mcp-logs-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-logs-export.js","sourceRoot":"","sources":["../../src/commands/mcp-logs-export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AAQpE,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACvC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAqB3C,SAAS,UAAU;IACjB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC5C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;IAC5E,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,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8B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -150,5 +150,23 @@ export declare function registerRuntimeActivationDeactivateCommand(parent: Comma
|
|
|
150
150
|
export declare function registerRuntimeActivationListCommand(parent: Command): Command;
|
|
151
151
|
export declare function registerRuntimeActivationDispatchCommand(parent: Command): Command;
|
|
152
152
|
export declare function registerRuntimeActivationApproveCommand(parent: Command): Command;
|
|
153
|
+
export interface RuntimeActivationJournalOptions {
|
|
154
|
+
workspace?: string;
|
|
155
|
+
since?: string;
|
|
156
|
+
until?: string;
|
|
157
|
+
host?: string;
|
|
158
|
+
maxInvocations?: string;
|
|
159
|
+
maxDateFiles?: string;
|
|
160
|
+
maxFileBytes?: string;
|
|
161
|
+
maxTerminalVariants?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* PRI-1109: thin CLI wrapper over the read-only reconciler in
|
|
165
|
+
* @principles/host-runtime. All semantic decisions live in the library; this
|
|
166
|
+
* handler only parses options, prints the library's single JSON document to
|
|
167
|
+
* stdout, routes diagnostics to stderr, and sets the exit code.
|
|
168
|
+
*/
|
|
169
|
+
export declare function handleRuntimeActivationJournal(opts: RuntimeActivationJournalOptions): Promise<void>;
|
|
170
|
+
export declare function registerRuntimeActivationJournalCommand(parent: Command): Command;
|
|
153
171
|
export {};
|
|
154
172
|
//# sourceMappingURL=runtime-activation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-activation.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-activation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-activation.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-activation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0EzC,OAAO,KAAK,EA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node:crypto';
|
|
4
4
|
import { RuntimeStateManager, ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, createProductionGateDeps, SqliteActivationStateStore, SqliteApprovalQueueStore, SqlitePIArtifactStore, PrincipleTreeLedgerAdapter, ApprovalQueue, ApprovalCompletionService, isArtifactRevisionOf, extractEvidenceRefs, extractPrincipleId, isFeatureEnabled, RuleCodeOwnerDecisionService, PromotionReadinessReader, SqliteActivationSafetyStore, collectOpenClawPromotionChecks, summarizeRuleCodeShadowEvents, buildPromotionEvidenceSnapshot, detectPromptReplacementTarget, } from '@principles/core/runtime-v2';
|
|
5
|
-
import { checkPromptArtifactDeliverabilityById, RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS } from '@principles/host-runtime';
|
|
5
|
+
import { checkPromptArtifactDeliverabilityById, RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS, reconcileAdaptiveJournal, } from '@principles/host-runtime';
|
|
6
6
|
/**
|
|
7
7
|
* I3 upgrade (Owner review of PR #1856, P1): ledger-aware identity deps for
|
|
8
8
|
* the dispatcher. Membership is verified against the ledger SSOT at
|
|
@@ -1686,4 +1686,76 @@ export function registerRuntimeActivationApproveCommand(parent) {
|
|
|
1686
1686
|
});
|
|
1687
1687
|
});
|
|
1688
1688
|
}
|
|
1689
|
+
/**
|
|
1690
|
+
* PRI-1109: thin CLI wrapper over the read-only reconciler in
|
|
1691
|
+
* @principles/host-runtime. All semantic decisions live in the library; this
|
|
1692
|
+
* handler only parses options, prints the library's single JSON document to
|
|
1693
|
+
* stdout, routes diagnostics to stderr, and sets the exit code.
|
|
1694
|
+
*/
|
|
1695
|
+
export async function handleRuntimeActivationJournal(opts) {
|
|
1696
|
+
const workspaceDir = opts.workspace ? path.resolve(opts.workspace) : resolveWorkspaceDir();
|
|
1697
|
+
const limits = {};
|
|
1698
|
+
if (opts.maxInvocations !== undefined)
|
|
1699
|
+
limits.maxInvocations = Number(opts.maxInvocations);
|
|
1700
|
+
if (opts.maxDateFiles !== undefined)
|
|
1701
|
+
limits.maxDateFilesPerDir = Number(opts.maxDateFiles);
|
|
1702
|
+
if (opts.maxFileBytes !== undefined)
|
|
1703
|
+
limits.maxFileBytes = Number(opts.maxFileBytes);
|
|
1704
|
+
if (opts.maxTerminalVariants !== undefined)
|
|
1705
|
+
limits.maxTerminalVariantsPerInvocation = Number(opts.maxTerminalVariants);
|
|
1706
|
+
const result = reconcileAdaptiveJournal({
|
|
1707
|
+
workspaceDir,
|
|
1708
|
+
...(opts.since !== undefined ? { since: opts.since } : {}),
|
|
1709
|
+
...(opts.until !== undefined ? { until: opts.until } : {}),
|
|
1710
|
+
...(opts.host !== undefined ? { host: opts.host } : {}),
|
|
1711
|
+
limits,
|
|
1712
|
+
});
|
|
1713
|
+
if (!result.ok) {
|
|
1714
|
+
// cli-1-strict-json: stdout carries exactly one machine-readable document.
|
|
1715
|
+
console.log(JSON.stringify(result, null, 2));
|
|
1716
|
+
console.error(`[activation journal] ${result.error.code}: ${result.error.message}`);
|
|
1717
|
+
console.error(`[activation journal] nextAction: ${result.error.nextAction}`);
|
|
1718
|
+
process.exitCode = 2;
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
const { report } = result;
|
|
1722
|
+
console.log(JSON.stringify(report, null, 2));
|
|
1723
|
+
console.error(`[activation journal] effective window: ${report.request.window.start} ~ ${report.request.window.end}`
|
|
1724
|
+
+ ` (endIsNow=${report.request.window.endIsNow}, clampedByRetention=${report.request.window.clampedByRetention})`);
|
|
1725
|
+
console.error(`[activation journal] coverage=${report.coverage.status} filesRead=${report.coverage.filesRead}`
|
|
1726
|
+
+ ` invocations=${report.totals.uniqueInvocations ?? 'unknown'}`);
|
|
1727
|
+
if (report.coverage.status === 'unavailable') {
|
|
1728
|
+
console.error('[activation journal] no readable log directory: result is unknown, not zero invocations');
|
|
1729
|
+
process.exitCode = 3;
|
|
1730
|
+
return;
|
|
1731
|
+
}
|
|
1732
|
+
if (report.outputTruncated) {
|
|
1733
|
+
console.error('[activation journal] output truncated: reported counts are lower bounds');
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
export function registerRuntimeActivationJournalCommand(parent) {
|
|
1737
|
+
return parent
|
|
1738
|
+
.command('journal')
|
|
1739
|
+
.description('Read-only reconciliation of adaptive_delivery journal records (never writes, never runs a model)')
|
|
1740
|
+
.option('-w, --workspace <path>', 'Workspace directory')
|
|
1741
|
+
.option('--since <iso>', 'Explicit window start (ISO timestamp; default: 7 days before the window end)')
|
|
1742
|
+
.option('--until <iso>', 'Explicit window end (ISO timestamp; default: now)')
|
|
1743
|
+
.option('--host <host>', 'Host identity to reconcile', 'openclaw')
|
|
1744
|
+
.option('--max-invocations <n>', 'Maximum invocations emitted (default: 1000)')
|
|
1745
|
+
.option('--max-date-files <n>', 'Maximum date files read per log directory (default: 8)')
|
|
1746
|
+
.option('--max-file-bytes <n>', 'Maximum bytes read per file (default: 4194304)')
|
|
1747
|
+
.option('--max-terminal-variants <n>', 'Maximum terminal variants per invocation (default: 5)')
|
|
1748
|
+
.action(async (opts) => {
|
|
1749
|
+
await handleRuntimeActivationJournal({
|
|
1750
|
+
workspace: opts.workspace,
|
|
1751
|
+
since: opts.since,
|
|
1752
|
+
until: opts.until,
|
|
1753
|
+
host: opts.host,
|
|
1754
|
+
maxInvocations: opts.maxInvocations,
|
|
1755
|
+
maxDateFiles: opts.maxDateFiles,
|
|
1756
|
+
maxFileBytes: opts.maxFileBytes,
|
|
1757
|
+
maxTerminalVariants: opts.maxTerminalVariants,
|
|
1758
|
+
});
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1689
1761
|
//# sourceMappingURL=runtime-activation.js.map
|