@haaaiawd/second-nature 0.2.9 → 0.2.12
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/index.js +6 -0
- package/openclaw.plugin.json +2 -5
- package/package.json +1 -1
- package/runtime/cli/host-capability/probe-host-capability.js +1 -1
- package/runtime/cli/host-capability/types.d.ts +2 -7
- package/runtime/cli/host-capability/types.js +0 -5
- package/runtime/cli/ops/heartbeat-surface.d.ts +2 -0
- package/runtime/cli/ops/heartbeat-surface.js +32 -3
- package/runtime/cli/ops/ops-router.js +3 -3
- package/runtime/cli/ops/workspace-heartbeat-runner.js +2 -5
- package/runtime/connectors/manifest/manifest-schema.d.ts +2 -2
- package/runtime/connectors/registry/dynamic-connector-registry.js +16 -1
- package/runtime/connectors/services/connector-executor-adapter.js +54 -35
- package/runtime/core/second-nature/action/action-closure-recorder.d.ts +2 -0
- package/runtime/core/second-nature/action/action-closure-recorder.js +2 -4
- package/runtime/core/second-nature/action/action-proposal-builder.js +5 -32
- package/runtime/core/second-nature/action/policy-bound-dispatch.js +4 -3
- package/runtime/core/second-nature/control-plane/accepted-projection-loader.js +1 -11
- package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.d.ts +1 -0
- package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.js +10 -6
- package/runtime/core/second-nature/control-plane/real-runtime-spine.d.ts +2 -0
- package/runtime/core/second-nature/control-plane/real-runtime-spine.js +1 -0
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +4 -3
- package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +3 -2
- package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +3 -2
- package/runtime/core/second-nature/orchestrator/intent-planner.js +4 -2
- package/runtime/core/second-nature/orchestrator/narrative-update.js +1 -2
- package/runtime/core/second-nature/orchestrator/platform-capability-router.d.ts +2 -2
- package/runtime/core/second-nature/orchestrator/platform-capability-router.js +1 -1
- package/runtime/core/second-nature/outreach/build-outreach-draft-request.js +2 -3
- package/runtime/core/second-nature/outreach/dispatch-user-outreach.d.ts +2 -2
- package/runtime/core/second-nature/outreach/dispatch-user-outreach.js +6 -1
- package/runtime/core/second-nature/outreach/judge-input-from-snapshot.js +3 -14
- package/runtime/core/second-nature/outreach/judge-outreach.d.ts +6 -5
- package/runtime/core/second-nature/perception/judgment-engine.js +2 -12
- package/runtime/core/second-nature/perception/perception-builder.js +1 -9
- package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +13 -15
- package/runtime/core/second-nature/quiet-dream/daily-rhythm-scheduler.js +10 -13
- package/runtime/core/second-nature/quiet-dream/dream-scheduler.js +0 -2
- package/runtime/core/second-nature/quiet-dream/memory-projection-lifecycle.js +0 -12
- package/runtime/core/second-nature/quiet-dream/quiet-daily-review-builder.js +1 -11
- package/runtime/core/second-nature/types.d.ts +2 -9
- package/runtime/dream/dream-engine.js +11 -4
- package/runtime/guidance/outreach-draft-schema.d.ts +12 -12
- package/runtime/guidance/persona-selection.js +5 -0
- package/runtime/guidance/template-registry.js +6 -1
- package/runtime/guidance/types.d.ts +2 -2
- package/runtime/observability/living-loop-health-gate.js +2 -8
- package/runtime/observability/loop-stage-event-sink.js +0 -1
- package/runtime/observability/services/lived-experience-audit.d.ts +7 -7
- package/runtime/shared/serialization.d.ts +17 -0
- package/runtime/shared/serialization.js +27 -0
- package/runtime/shared/source-ref-compat.d.ts +26 -0
- package/runtime/shared/source-ref-compat.js +61 -0
- package/runtime/shared/types/goal.d.ts +4 -4
- package/runtime/shared/types/goal.js +1 -1
- package/runtime/shared/types/index.d.ts +1 -0
- package/runtime/shared/types/index.js +1 -3
- package/runtime/shared/types/source-ref.d.ts +2 -2
- package/runtime/shared/types/v7-entities.d.ts +5 -5
- package/runtime/shared/types/v7-entities.js +1 -1
- package/runtime/shared/types/v8-contracts.d.ts +1 -1
- package/runtime/storage/db/index.js +31 -26
- package/runtime/storage/db/migrations/index.js +4 -0
- package/runtime/storage/db/migrations/v8-004-schema-closure.d.ts +19 -0
- package/runtime/storage/db/migrations/v8-004-schema-closure.js +74 -0
- package/runtime/storage/db/migrations/v8-005-single-status-schema.d.ts +11 -0
- package/runtime/storage/db/migrations/v8-005-single-status-schema.js +16 -0
- package/runtime/storage/db/schema/v8-entities.d.ts +0 -95
- package/runtime/storage/db/schema/v8-entities.js +4 -7
- package/runtime/storage/delivery/types.d.ts +2 -2
- package/runtime/storage/fallback/load-operator-fallback.d.ts +2 -2
- package/runtime/storage/fallback/operator-fallback-types.d.ts +2 -2
- package/runtime/storage/fallback/operator-fallback-view.d.ts +2 -2
- package/runtime/storage/index.d.ts +1 -1
- package/runtime/storage/life-evidence/types.d.ts +5 -5
- package/runtime/storage/quiet/quiet-artifact-types.d.ts +4 -4
- package/runtime/storage/quiet/quiet-artifact-writer.d.ts +2 -2
- package/runtime/storage/services/write-validation-gate.d.ts +1 -1
- package/runtime/storage/services/write-validation-gate.js +16 -4
- package/runtime/storage/snapshots/types.d.ts +8 -8
- package/runtime/storage/user-interest/types.d.ts +3 -3
- package/runtime/storage/v8-state-stores.d.ts +8 -1
- package/runtime/storage/v8-state-stores.js +23 -20
|
@@ -21,27 +21,12 @@
|
|
|
21
21
|
*
|
|
22
22
|
* Test coverage: tests/unit/storage/v8-state-stores.test.ts
|
|
23
23
|
*/
|
|
24
|
-
import { eq, and, desc, like, isNull } from "drizzle-orm";
|
|
24
|
+
import { eq, and, desc, like, isNull, inArray } from "drizzle-orm";
|
|
25
25
|
import { evidenceItem, perceptionCard, judgmentVerdict, actionClosureRecord, quietDailyReview, dreamConsolidationRun, longTermMemoryProjection, heartbeatCycleTrace, loopStageEvent, impulseContextArtifact, dailyRhythmState, connectorCooldownState, } from "./db/schema/v8-entities.js";
|
|
26
|
+
import { serializeSourceRefs, parseSourceRefs, } from "../shared/serialization.js";
|
|
26
27
|
// ───────────────────────────────────────────────────────────────
|
|
27
28
|
// Shared helpers
|
|
28
29
|
// ───────────────────────────────────────────────────────────────
|
|
29
|
-
function serializeSourceRefs(refs) {
|
|
30
|
-
return JSON.stringify(refs);
|
|
31
|
-
}
|
|
32
|
-
function parseSourceRefs(json) {
|
|
33
|
-
if (!json)
|
|
34
|
-
return [];
|
|
35
|
-
try {
|
|
36
|
-
const parsed = JSON.parse(json);
|
|
37
|
-
if (Array.isArray(parsed))
|
|
38
|
-
return parsed;
|
|
39
|
-
return [];
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
30
|
function makeDegraded(reason, ownerStage, operatorNextAction, sourceRefs = []) {
|
|
46
31
|
return {
|
|
47
32
|
status: "degraded",
|
|
@@ -444,8 +429,6 @@ export async function updateDreamConsolidationRunStatus(db, id, status, options)
|
|
|
444
429
|
const updateData = { status };
|
|
445
430
|
if (options?.reason !== undefined)
|
|
446
431
|
updateData.reason = options.reason;
|
|
447
|
-
if (options?.lifecycleStatus !== undefined)
|
|
448
|
-
updateData.lifecycleStatus = options.lifecycleStatus;
|
|
449
432
|
if (options?.payloadJson !== undefined)
|
|
450
433
|
updateData.payloadJson = options.payloadJson;
|
|
451
434
|
await db.db.update(dreamConsolidationRun).set(updateData).where(eq(dreamConsolidationRun.id, id));
|
|
@@ -486,6 +469,26 @@ export async function readDreamConsolidationRunsByQuietId(db, quietReviewId) {
|
|
|
486
469
|
};
|
|
487
470
|
}
|
|
488
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Read the most recent DreamConsolidationRun globally, filtered by status.
|
|
474
|
+
* Used to enforce the 7-day Dream interval across Quiet review IDs.
|
|
475
|
+
*/
|
|
476
|
+
export async function readLatestDreamConsolidationRunByStatus(db, statuses) {
|
|
477
|
+
try {
|
|
478
|
+
const rows = await db.db
|
|
479
|
+
.select()
|
|
480
|
+
.from(dreamConsolidationRun)
|
|
481
|
+
.where(inArray(dreamConsolidationRun.status, statuses))
|
|
482
|
+
.orderBy(desc(dreamConsolidationRun.createdAt))
|
|
483
|
+
.limit(1);
|
|
484
|
+
return { row: rows[0] };
|
|
485
|
+
}
|
|
486
|
+
catch {
|
|
487
|
+
return {
|
|
488
|
+
degraded: makeDegraded("state_unreadable", "dream", "Check state database connectivity"),
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
}
|
|
489
492
|
// ───────────────────────────────────────────────────────────────
|
|
490
493
|
// LongTermMemoryProjection store
|
|
491
494
|
// ───────────────────────────────────────────────────────────────
|
|
@@ -511,7 +514,7 @@ export async function writeLongTermMemoryProjection(db, row) {
|
|
|
511
514
|
*/
|
|
512
515
|
export async function updateLongTermMemoryProjectionStatus(db, id, status, payloadJson) {
|
|
513
516
|
try {
|
|
514
|
-
const updateData = { status
|
|
517
|
+
const updateData = { status };
|
|
515
518
|
if (payloadJson !== undefined) {
|
|
516
519
|
updateData.payloadJson = payloadJson;
|
|
517
520
|
}
|