@principles/pd-cli 1.73.2 → 1.74.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.
@@ -0,0 +1,142 @@
1
+ /**
2
+ * PD Config Doctor — discovers and explains PD / OpenClaw configuration state.
3
+ *
4
+ * PRI-299 MVP UX: provides a single, read-only view of:
5
+ * - PD workspace config paths (with existence checks)
6
+ * - OpenClaw config paths (with existence checks)
7
+ * - Effective feature flags
8
+ * - Provider/model/auth status (classified)
9
+ *
10
+ * Constraints:
11
+ * - NEVER reads or returns API key values, env var values, or raw config bytes.
12
+ * - All file reads are bounded; YAML/JSON is treated as `unknown` and validated.
13
+ * - Missing/malformed config produces a structured warning, never a crash.
14
+ * - Failures include `reason` and `nextAction` for operator guidance.
15
+ */
16
+ export type DoctorClassification = 'healthy' | 'config_missing' | 'auth_missing' | 'rate_limit' | 'unavailable' | 'parse_failure' | 'unknown';
17
+ export type DoctorStatus = 'ok' | 'degraded' | 'failed';
18
+ export interface ConfigPathEntry {
19
+ path: string;
20
+ exists: boolean;
21
+ /** Optional structural check (file is parseable JSON/YAML, etc.) */
22
+ parseable?: boolean;
23
+ }
24
+ export interface ProviderHealthEntry {
25
+ provider: string | null;
26
+ model: string | null;
27
+ apiKeyEnv: string | null;
28
+ /** True if the env var name is non-empty and the env var is set. */
29
+ apiKeyPresent: boolean;
30
+ classification: DoctorClassification;
31
+ reason: string;
32
+ nextAction: string;
33
+ /** Source of the discovered config (e.g., 'workflows.yaml', 'cli_flag', 'default'). */
34
+ source: string;
35
+ }
36
+ export interface FeatureFlagSummary {
37
+ source: string;
38
+ configPath: string;
39
+ enabledMvpChannels: string[];
40
+ disabledFlags: string[];
41
+ warnings: string[];
42
+ }
43
+ export interface DoctorOutput {
44
+ status: DoctorStatus;
45
+ workspaceDir: string;
46
+ pdConfigPaths: {
47
+ workspaceDir: ConfigPathEntry;
48
+ pdDir: ConfigPathEntry;
49
+ featureFlags: ConfigPathEntry;
50
+ workflowsYaml: ConfigPathEntry;
51
+ stateDb: ConfigPathEntry;
52
+ };
53
+ openclawConfigPaths: {
54
+ openclawHome: ConfigPathEntry;
55
+ openclawConfig: ConfigPathEntry;
56
+ };
57
+ featureFlags: FeatureFlagSummary;
58
+ providerHealth: ProviderHealthEntry[];
59
+ internalAgents: {
60
+ correctionObserver: {
61
+ enabled: boolean;
62
+ flagSource: string;
63
+ status: 'disabled' | 'configured' | 'auth_missing' | 'config_missing' | 'unavailable';
64
+ configSource: 'workflows.yaml' | 'env' | 'missing' | 'unavailable';
65
+ provider: string | null;
66
+ model: string | null;
67
+ apiKeyEnv: string | null;
68
+ apiKeyPresent: boolean;
69
+ reason: string;
70
+ nextAction: string;
71
+ };
72
+ };
73
+ warnings: string[];
74
+ reason?: string;
75
+ nextActions: string[];
76
+ }
77
+ /**
78
+ * Resolve the OpenClaw home directory used to look up `openclaw.json` and
79
+ * extension state. PD does not own this path — it only reports its existence.
80
+ */
81
+ export declare function getOpenClawHome(): string;
82
+ export declare function getOpenClawConfigPath(): string;
83
+ export interface InspectStateDbOptions {
84
+ /** Max rows to scan from tasks table. */
85
+ maxRows?: number;
86
+ /** Max age in ms — only signals within this window are considered "recent". */
87
+ maxAgeMs?: number;
88
+ }
89
+ export interface RecentProviderSignal {
90
+ classification: DoctorClassification;
91
+ reason: string;
92
+ observedAt: string | null;
93
+ }
94
+ export interface StateDbSignalResult {
95
+ signal: RecentProviderSignal | null;
96
+ /** True if the DB was found and could be opened in readonly mode. */
97
+ dbReachable: boolean;
98
+ /** Optional warning when the DB exists but couldn't be read. */
99
+ warning?: string;
100
+ }
101
+ /**
102
+ * Read the state.db recent provider error signal (best-effort, structural only).
103
+ *
104
+ * We inspect recent task/run rows in `<workspaceDir>/.pd/state.db` to detect
105
+ * `rate_limit` / `auth_missing` / `unavailable` signals from the live pipeline.
106
+ * This is a bounded best-effort probe — if the DB is missing or unreadable we
107
+ * return `null` and let the doctor fall back to config-only classification.
108
+ */
109
+ export declare function inspectStateDbForProviderSignal(stateDbPath: string, nowMs?: number, opts?: InspectStateDbOptions): Promise<StateDbSignalResult>;
110
+ /**
111
+ * Resolve the provider/model/apiKeyEnv from the workspace's `workflows.yaml`
112
+ * funnel policy. Returns `null` for each field when not configured.
113
+ *
114
+ * NEVER leaks api key values or env var values.
115
+ */
116
+ export interface ProviderConfigFromWorkflows {
117
+ provider: string | null;
118
+ model: string | null;
119
+ apiKeyEnv: string | null;
120
+ baseUrl: string | null;
121
+ source: 'workflows.yaml' | 'cli_flag' | 'default' | 'missing';
122
+ /** True if the workflows.yaml file was found and parseable. */
123
+ workflowsFound: boolean;
124
+ /** Parse warning, if any. */
125
+ parseWarning?: string;
126
+ }
127
+ export declare function resolveProviderConfigFromWorkflows(stateDir: string, opts?: {
128
+ cliProvider?: string;
129
+ cliModel?: string;
130
+ cliApiKeyEnv?: string;
131
+ cliBaseUrl?: string;
132
+ }): Promise<ProviderConfigFromWorkflows>;
133
+ export interface BuildDoctorInput {
134
+ workspaceDir: string;
135
+ /** Optional CLI overrides for provider/model/apiKeyEnv. */
136
+ cliProvider?: string;
137
+ cliModel?: string;
138
+ cliApiKeyEnv?: string;
139
+ cliBaseUrl?: string;
140
+ }
141
+ export declare function buildDoctorOutput(input: BuildDoctorInput): Promise<DoctorOutput>;
142
+ //# sourceMappingURL=config-doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-doctor.d.ts","sourceRoot":"","sources":["../../src/services/config-doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,MAAM,MAAM,oBAAoB,GAC5B,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,YAAY,GACZ,aAAa,GACb,eAAe,GACf,SAAS,CAAC;AAEd,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,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