@myclaw163/clawclaw-cli 0.8.20 → 0.8.21
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/docs/configuration.md +57 -2
- package/package.json +1 -1
- package/skills/clawclaw/SKILL.md +3 -1
- package/skills/clawclaw/references/COMMANDS.md +2 -0
- package/src/commands/behavior.ts +1 -0
- package/src/commands/capability.ts +1 -0
- package/src/commands/data.ts +1 -0
- package/src/commands/load.ts +31 -2
- package/src/lib/agent-workspace-client.ts +1 -0
- package/src/lib/agent-workspace-runtime.ts +6 -0
- package/src/lib/agent-workspace-sync.ts +117 -6
- package/src/lib/capability-cloud-refresh.ts +7 -0
- package/src/lib/capability-cloud-sync.ts +11 -3
- package/src/lib/capability-workspace.ts +3 -0
- package/src/lib/diagnostics-config.ts +26 -1
- package/src/lib/hub-client.ts +6 -0
- package/src/lib/persona.ts +2 -0
- package/src/runtime/clawclaw/owner.ts +1 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +21 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +8 -1
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +19 -1
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +36 -0
- package/src/runtime/clawclaw/plugins/perception/perception-reducer-thread-pool.ts +13 -0
- package/src/runtime/clawclaw/runtime-data-export.ts +9 -0
- package/src/runtime/framework/runtime.ts +12 -0
- package/src/runtime/observability/detail-capture.ts +123 -0
- package/src/runtime/observability/factory.ts +13 -0
- package/src/runtime/observability/recorder.ts +34 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'crypto';
|
|
2
2
|
import { ObservabilityRedactor } from './redaction.js';
|
|
3
3
|
import { NoopObservabilityReporter } from './reporter.js';
|
|
4
|
+
import { captureSnapshot, detailCategory, type DetailCaptureConfig } from './detail-capture.js';
|
|
4
5
|
import {
|
|
5
6
|
OBSERVABILITY_SCHEMA,
|
|
6
7
|
type ObservabilityCorrelation,
|
|
@@ -22,6 +23,8 @@ export interface TelemetryRecorderOptions {
|
|
|
22
23
|
idFactory?: () => string;
|
|
23
24
|
scopeProvider?: () => ObservabilityScope | undefined;
|
|
24
25
|
sampler?: (input: Readonly<RecordTelemetryInput>) => boolean;
|
|
26
|
+
capture?: DetailCaptureConfig;
|
|
27
|
+
detailReporter?: ObservabilityReporter;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
function defaultSeverity(kind: RecordTelemetryInput['kind']): ObservabilitySeverity {
|
|
@@ -73,6 +76,9 @@ export class TelemetryRecorder {
|
|
|
73
76
|
private readonly idFactory: () => string;
|
|
74
77
|
private readonly scopeProvider?: () => ObservabilityScope | undefined;
|
|
75
78
|
private readonly sampler: (input: Readonly<RecordTelemetryInput>) => boolean;
|
|
79
|
+
private readonly capture?: DetailCaptureConfig;
|
|
80
|
+
private readonly detailReporter?: ObservabilityReporter;
|
|
81
|
+
private lastDetailScope?: ObservabilityScope;
|
|
76
82
|
|
|
77
83
|
constructor(options: TelemetryRecorderOptions) {
|
|
78
84
|
this.process = { ...options.process };
|
|
@@ -83,15 +89,22 @@ export class TelemetryRecorder {
|
|
|
83
89
|
this.idFactory = options.idFactory ?? (() => `obs_${randomUUID()}`);
|
|
84
90
|
this.scopeProvider = options.scopeProvider;
|
|
85
91
|
this.sampler = options.sampler ?? (() => true);
|
|
92
|
+
this.capture = options.capture;
|
|
93
|
+
this.detailReporter = options.detailReporter;
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
record(input: RecordTelemetryInput): string | null {
|
|
89
97
|
if (!this.enabled) return null;
|
|
90
98
|
try {
|
|
91
|
-
|
|
99
|
+
const category = detailCategory(input.name);
|
|
100
|
+
if (category ? !this.capture?.[category] : !this.sampler(input)) return null;
|
|
92
101
|
const recordId = this.idFactory();
|
|
93
102
|
const scope = normalizedScope(input.scope ?? this.scopeProvider?.());
|
|
94
|
-
|
|
103
|
+
if (category && scope) this.lastDetailScope = scope;
|
|
104
|
+
const captured = category ? captureSnapshot(input.attributes ?? {}, this.capture!.max_record_bytes - 2048) : undefined;
|
|
105
|
+
const attributes = captured
|
|
106
|
+
? { ...(captured.value as Record<string, unknown>), capture_truncated: captured.truncated }
|
|
107
|
+
: this.redactor.redactRecord(input.attributes ?? {});
|
|
95
108
|
const correlation = input.correlation
|
|
96
109
|
? this.redactor.redactRecord(input.correlation as Record<string, unknown>) as ObservabilityCorrelation
|
|
97
110
|
: undefined;
|
|
@@ -117,7 +130,7 @@ export class TelemetryRecorder {
|
|
|
117
130
|
...(metric ? { metric } : {}),
|
|
118
131
|
...(redactedError ? { error: redactedError } : {}),
|
|
119
132
|
};
|
|
120
|
-
return this.reporter.enqueue(record) ? recordId : null;
|
|
133
|
+
return (category ? this.detailReporter ?? this.reporter : this.reporter).enqueue(record) ? recordId : null;
|
|
121
134
|
} catch {
|
|
122
135
|
return null;
|
|
123
136
|
}
|
|
@@ -162,8 +175,20 @@ export class TelemetryRecorder {
|
|
|
162
175
|
return new StructuredLogger(this, component, base);
|
|
163
176
|
}
|
|
164
177
|
|
|
165
|
-
|
|
166
|
-
|
|
178
|
+
private captureSummary(): void {
|
|
179
|
+
if (!this.detailReporter) return;
|
|
180
|
+
const category = (['actions', 'behavior_io', 'perception_io'] as const).find(key => this.capture?.[key]);
|
|
181
|
+
if (category) this.log('debug', `runtime.detail.${category}.summary`, { reporter: this.detailReporter.stats() },
|
|
182
|
+
{ component: 'runtime.capture', scope: this.lastDetailScope });
|
|
183
|
+
}
|
|
184
|
+
async flush(): Promise<void> {
|
|
185
|
+
await Promise.all([this.reporter.flush(), this.detailReporter?.flush()]);
|
|
186
|
+
this.captureSummary();
|
|
187
|
+
await this.detailReporter?.flush();
|
|
188
|
+
}
|
|
189
|
+
async close(): Promise<void> {
|
|
190
|
+
try { await this.flush(); } finally { await Promise.all([this.reporter.close(), this.detailReporter?.close()]); }
|
|
191
|
+
}
|
|
167
192
|
flushWithin(timeoutMs: number): Promise<boolean> {
|
|
168
193
|
return settleWithin(this.flush(), timeoutMs);
|
|
169
194
|
}
|
|
@@ -171,6 +196,10 @@ export class TelemetryRecorder {
|
|
|
171
196
|
return settleWithin(this.close(), timeoutMs);
|
|
172
197
|
}
|
|
173
198
|
stats() { return this.reporter.stats(); }
|
|
199
|
+
detailStats() { return this.detailReporter?.stats(); }
|
|
200
|
+
captureEnabled(category: keyof Pick<DetailCaptureConfig, 'actions' | 'behavior_io' | 'perception_io'>): boolean {
|
|
201
|
+
return this.enabled && this.capture?.[category] === true;
|
|
202
|
+
}
|
|
174
203
|
}
|
|
175
204
|
|
|
176
205
|
/** Stop awaiting diagnostics after a bounded window; gameplay owns hard exit/cancellation. */
|