principles-disciple 1.154.0 → 1.156.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/core/control-ui-db.d.ts +11 -0
- package/dist/core/control-ui-db.js +40 -16
- package/dist/core/trajectory.d.ts +16 -0
- package/dist/core/trajectory.js +343 -254
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/service/subagent-workflow/workflow-store.d.ts +14 -0
- package/dist/service/subagent-workflow/workflow-store.js +91 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +7 -3
- package/dist/core/schema/db-types.d.ts +0 -11
- package/dist/core/schema/db-types.js +0 -5
- package/dist/core/schema/index.d.ts +0 -17
- package/dist/core/schema/index.js +0 -15
- package/dist/core/schema/migration-runner.d.ts +0 -53
- package/dist/core/schema/migration-runner.js +0 -170
- package/dist/core/schema/migrations/001-init-trajectory.d.ts +0 -6
- package/dist/core/schema/migrations/001-init-trajectory.js +0 -190
- package/dist/core/schema/migrations/002-init-central.d.ts +0 -5
- package/dist/core/schema/migrations/002-init-central.js +0 -108
- package/dist/core/schema/migrations/003-init-workflow.d.ts +0 -5
- package/dist/core/schema/migrations/003-init-workflow.js +0 -50
- package/dist/core/schema/migrations/004-add-thinking-and-gfi.d.ts +0 -8
- package/dist/core/schema/migrations/004-add-thinking-and-gfi.js +0 -66
- package/dist/core/schema/migrations/index.d.ts +0 -16
- package/dist/core/schema/migrations/index.js +0 -27
- package/dist/core/schema/schema-definitions.d.ts +0 -46
- package/dist/core/schema/schema-definitions.js +0 -599
- package/scripts/db-migrate.mjs +0 -170
|
@@ -102,5 +102,16 @@ export declare class ControlUiDatabase {
|
|
|
102
102
|
run(sql: string, ...params: unknown[]): void;
|
|
103
103
|
restoreRawText(inlineText?: string | null, blobRef?: string | null): string;
|
|
104
104
|
private initSchema;
|
|
105
|
+
/**
|
|
106
|
+
* Create or replace a view, tolerating missing dependency tables.
|
|
107
|
+
*
|
|
108
|
+
* Views in ControlUiDatabase depend on tables created by TrajectoryDatabase
|
|
109
|
+
* (assistant_turns, tool_calls, pain_events, user_turns, correction_samples).
|
|
110
|
+
* If ControlUiDatabase is constructed before TrajectoryDatabase has created
|
|
111
|
+
* those tables, CREATE VIEW would throw. We DROP+CREATE with try/catch so
|
|
112
|
+
* missing-dependency views are skipped with a warning (rc-9: surfaced via
|
|
113
|
+
* console.info) rather than aborting schema initialization.
|
|
114
|
+
*/
|
|
115
|
+
private createViewSafely;
|
|
105
116
|
private withWrite;
|
|
106
117
|
}
|
|
@@ -180,9 +180,15 @@ export class ControlUiDatabase {
|
|
|
180
180
|
ON thinking_model_events(assistant_turn_id);
|
|
181
181
|
CREATE INDEX IF NOT EXISTS idx_thinking_model_events_run_id
|
|
182
182
|
ON thinking_model_events(run_id);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
`);
|
|
184
|
+
// Views depend on tables owned by TrajectoryDatabase (assistant_turns, tool_calls,
|
|
185
|
+
// pain_events, user_turns, correction_samples). If ControlUiDatabase is constructed
|
|
186
|
+
// before TrajectoryDatabase has run initSchema (e.g. llm_output is the first hook
|
|
187
|
+
// triggered on a fresh workspace), CREATE VIEW would throw and break the hook.
|
|
188
|
+
// Wrap each view creation in try/catch so missing-dependency views are skipped with
|
|
189
|
+
// a warning rather than aborting schema initialization (rc-9: no silent fallback —
|
|
190
|
+
// failures are surfaced via console.info).
|
|
191
|
+
this.createViewSafely('v_thinking_model_usage', `
|
|
186
192
|
WITH totals AS (
|
|
187
193
|
SELECT COUNT(*) AS assistant_turns FROM assistant_turns
|
|
188
194
|
),
|
|
@@ -205,10 +211,9 @@ export class ControlUiDatabase {
|
|
|
205
211
|
ELSE ROUND(CAST(usage_rows.distinct_turns AS REAL) / CAST(totals.assistant_turns AS REAL), 4)
|
|
206
212
|
END AS coverage_rate
|
|
207
213
|
FROM usage_rows, totals
|
|
208
|
-
ORDER BY usage_rows.hits DESC, usage_rows.model_id ASC
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
CREATE VIEW v_thinking_model_effectiveness AS
|
|
214
|
+
ORDER BY usage_rows.hits DESC, usage_rows.model_id ASC
|
|
215
|
+
`);
|
|
216
|
+
this.createViewSafely('v_thinking_model_effectiveness', `
|
|
212
217
|
WITH event_windows AS (
|
|
213
218
|
SELECT
|
|
214
219
|
e.id,
|
|
@@ -274,10 +279,9 @@ export class ControlUiDatabase {
|
|
|
274
279
|
) THEN 1 ELSE 0 END) AS correction_sample_windows
|
|
275
280
|
FROM bounded_windows b
|
|
276
281
|
GROUP BY b.model_id
|
|
277
|
-
ORDER BY events DESC, model_id ASC
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
CREATE VIEW v_thinking_model_scenarios AS
|
|
282
|
+
ORDER BY events DESC, model_id ASC
|
|
283
|
+
`);
|
|
284
|
+
this.createViewSafely('v_thinking_model_scenarios', `
|
|
281
285
|
SELECT
|
|
282
286
|
e.model_id AS model_id,
|
|
283
287
|
CAST(j.value AS TEXT) AS scenario,
|
|
@@ -290,19 +294,39 @@ export class ControlUiDatabase {
|
|
|
290
294
|
END
|
|
291
295
|
) AS j
|
|
292
296
|
GROUP BY e.model_id, CAST(j.value AS TEXT)
|
|
293
|
-
ORDER BY hits DESC, scenario ASC
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
CREATE VIEW v_thinking_model_daily_trend AS
|
|
297
|
+
ORDER BY hits DESC, scenario ASC
|
|
298
|
+
`);
|
|
299
|
+
this.createViewSafely('v_thinking_model_daily_trend', `
|
|
297
300
|
SELECT
|
|
298
301
|
substr(created_at, 1, 10) AS day,
|
|
299
302
|
model_id,
|
|
300
303
|
COUNT(*) AS hits
|
|
301
304
|
FROM thinking_model_events
|
|
302
305
|
GROUP BY substr(created_at, 1, 10), model_id
|
|
303
|
-
ORDER BY day ASC, model_id ASC
|
|
306
|
+
ORDER BY day ASC, model_id ASC
|
|
304
307
|
`);
|
|
305
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Create or replace a view, tolerating missing dependency tables.
|
|
311
|
+
*
|
|
312
|
+
* Views in ControlUiDatabase depend on tables created by TrajectoryDatabase
|
|
313
|
+
* (assistant_turns, tool_calls, pain_events, user_turns, correction_samples).
|
|
314
|
+
* If ControlUiDatabase is constructed before TrajectoryDatabase has created
|
|
315
|
+
* those tables, CREATE VIEW would throw. We DROP+CREATE with try/catch so
|
|
316
|
+
* missing-dependency views are skipped with a warning (rc-9: surfaced via
|
|
317
|
+
* console.info) rather than aborting schema initialization.
|
|
318
|
+
*/
|
|
319
|
+
createViewSafely(viewName, viewBody) {
|
|
320
|
+
try {
|
|
321
|
+
this.db.exec(`DROP VIEW IF EXISTS ${viewName};`);
|
|
322
|
+
this.db.exec(`CREATE VIEW ${viewName} AS ${viewBody};`);
|
|
323
|
+
}
|
|
324
|
+
catch (err) {
|
|
325
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
326
|
+
// rc-9: surface the failure — do not silently swallow
|
|
327
|
+
console.info(`[PD:ControlUiDatabase] view ${viewName} creation skipped: ${message}. It will be created on next TrajectoryDatabase initSchema().`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
306
330
|
withWrite(fn) {
|
|
307
331
|
return withLock(this.dbPath, fn, { lockSuffix: '.trajectory.lock', lockStaleMs: 30000 });
|
|
308
332
|
}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import type { CorrectionSampleReviewStatus, CorrectionExportMode, TrajectoryDataStats, TrajectoryAssistantTurnInput, TrajectoryUserTurnInput, TrajectoryToolCallInput, TrajectoryPainEventInput, TrajectoryGateBlockInput, TrajectoryTrustChangeInput, TrajectoryPrincipleEventInput, TrajectoryTaskOutcomeInput, TrajectorySessionInput, EvolutionTaskInput, EvolutionEventInput, EvolutionTaskRecord, EvolutionEventRecord, EvolutionTaskFilters, AssistantTurnRecord, CorrectionSampleRecord, TrajectoryExportResult, TrajectoryDatabaseOptions } from './trajectory-types.js';
|
|
2
2
|
export type { CorrectionSampleReviewStatus, CorrectionExportMode, TrajectoryDataStats, TrajectoryAssistantTurnInput, TrajectoryUserTurnInput, TrajectoryToolCallInput, TrajectoryPainEventInput, TrajectoryGateBlockInput, DailyMetricRow, TrajectoryTrustChangeInput, TrajectoryPrincipleEventInput, TrajectoryTaskOutcomeInput, TrajectorySessionInput, TaskKind, TaskPriority, EvolutionTaskInput, EvolutionEventInput, EvolutionTaskRecord, EvolutionEventRecord, EvolutionTaskFilters, AssistantTurnRecord, CorrectionSampleRecord, TrajectoryExportResult, TrajectoryDatabaseOptions, } from './trajectory-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Initialize trajectory.db schema at the given workspace directory.
|
|
5
|
+
*
|
|
6
|
+
* Opens trajectory.db in write mode, applies the full schema (tables + indexes + views +
|
|
7
|
+
* migrations), then closes the DB. Does NOT run importLegacyArtifacts() or
|
|
8
|
+
* pruneUnreferencedBlobs() — those are runtime side-effects of TrajectoryDatabase
|
|
9
|
+
* construction and are not needed for pure initialization.
|
|
10
|
+
*
|
|
11
|
+
* Idempotent: safe to call on an existing DB; all CREATE statements use IF NOT EXISTS.
|
|
12
|
+
*
|
|
13
|
+
* @returns list of created/verified table names and any warnings
|
|
14
|
+
*/
|
|
15
|
+
export declare function initTrajectorySchema(workspaceDir: string): {
|
|
16
|
+
tables: string[];
|
|
17
|
+
warnings: string[];
|
|
18
|
+
};
|
|
3
19
|
export declare class TrajectoryDatabase {
|
|
4
20
|
private readonly workspaceDir;
|
|
5
21
|
private readonly stateDir;
|