@haaaiawd/second-nature 0.1.43 → 0.1.51
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/openclaw.plugin.json +29 -29
- package/package.json +55 -55
- package/runtime/cli/commands/index.js +325 -325
- package/runtime/cli/ops/heartbeat-surface.d.ts +84 -75
- package/runtime/cli/ops/heartbeat-surface.js +100 -97
- package/runtime/cli/ops/ops-router.js +1482 -1454
- package/runtime/cli/ops/workspace-heartbeat-runner.d.ts +85 -76
- package/runtime/cli/ops/workspace-heartbeat-runner.js +242 -236
- package/runtime/connectors/base/contract.d.ts +111 -111
- package/runtime/connectors/base/failure-taxonomy.d.ts +13 -13
- package/runtime/connectors/base/failure-taxonomy.js +186 -186
- package/runtime/connectors/base/map-life-evidence.js +137 -137
- package/runtime/connectors/base/policy-layer.js +202 -202
- package/runtime/connectors/manifest/manifest-schema.d.ts +152 -152
- package/runtime/connectors/manifest/manifest-schema.js +54 -54
- package/runtime/connectors/services/connector-executor-adapter.d.ts +20 -20
- package/runtime/connectors/services/connector-executor-adapter.js +645 -645
- package/runtime/core/second-nature/heartbeat/goal-lifecycle-policy.d.ts +24 -37
- package/runtime/core/second-nature/heartbeat/goal-lifecycle-policy.js +61 -61
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +97 -88
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +397 -329
- package/runtime/core/second-nature/orchestrator/platform-capability-router.js +149 -131
|
@@ -1,76 +1,85 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wires CLI read models into control-plane `runHeartbeatCycle` for `heartbeat_check` (US-001 / CH-09-02 / T1.2.3).
|
|
3
|
-
*
|
|
4
|
-
* Snapshot inputs are derived from aggregated status; delivery defaults to none until host capability is modeled here.
|
|
5
|
-
*
|
|
6
|
-
* T1.2.3: when a `RuntimeDecisionRecorder` is provided, persist a `sn-runtime-*` ledger row +
|
|
7
|
-
* `second-nature-runtime` execution attempt after each cycle so `loadStatus` exits its `unknown`
|
|
8
|
-
* baseline once the runtime has actually executed at least one full-runtime turn.
|
|
9
|
-
*
|
|
10
|
-
* T2.2.2: when `state` + `workspaceRoot` are supplied, call `loadLifeEvidenceSnapshot` to fill
|
|
11
|
-
* `lifeEvidenceRefs`, `platformEventCount`, `workEventCount`, and `lifeEvidenceEmptyReason` on
|
|
12
|
-
* `SnapshotInputs` so planner/guard paths that require source refs see real DB truth.
|
|
13
|
-
* Falls back gracefully to `lifeEvidenceEmptyReason: "state_unavailable"` when state is absent.
|
|
14
|
-
*/
|
|
15
|
-
import type { HeartbeatSignal, HeartbeatCycleResult } from "../../core/second-nature/heartbeat/signal.js";
|
|
16
|
-
import type { SnapshotInputs } from "../../core/second-nature/heartbeat/snapshot-builder.js";
|
|
17
|
-
import type { CliReadModels } from "../read-models/index.js";
|
|
18
|
-
import type { RuntimeDecisionRecorder } from "../../observability/services/runtime-decision-recorder.js";
|
|
19
|
-
import type { StateDatabase } from "../../storage/db/index.js";
|
|
20
|
-
import type { ConnectorExecutor } from "../../core/second-nature/orchestrator/effect-dispatcher.js";
|
|
21
|
-
import type { CapabilityContractRegistry } from "../../connectors/base/manifest.js";
|
|
22
|
-
import type { AffordanceMap } from "../../shared/types/v7-entities.js";
|
|
23
|
-
import type { ExperienceWriter } from "../../core/second-nature/body/tool-experience/experience-writer.js";
|
|
24
|
-
import type { QuietDreamSchedulePort } from "../../core/second-nature/quiet/run-source-backed-quiet.js";
|
|
25
|
-
import { type HeartbeatDigestAssemblerDeps } from "../../observability/services/heartbeat-digest-assembler.js";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Wires CLI read models into control-plane `runHeartbeatCycle` for `heartbeat_check` (US-001 / CH-09-02 / T1.2.3).
|
|
3
|
+
*
|
|
4
|
+
* Snapshot inputs are derived from aggregated status; delivery defaults to none until host capability is modeled here.
|
|
5
|
+
*
|
|
6
|
+
* T1.2.3: when a `RuntimeDecisionRecorder` is provided, persist a `sn-runtime-*` ledger row +
|
|
7
|
+
* `second-nature-runtime` execution attempt after each cycle so `loadStatus` exits its `unknown`
|
|
8
|
+
* baseline once the runtime has actually executed at least one full-runtime turn.
|
|
9
|
+
*
|
|
10
|
+
* T2.2.2: when `state` + `workspaceRoot` are supplied, call `loadLifeEvidenceSnapshot` to fill
|
|
11
|
+
* `lifeEvidenceRefs`, `platformEventCount`, `workEventCount`, and `lifeEvidenceEmptyReason` on
|
|
12
|
+
* `SnapshotInputs` so planner/guard paths that require source refs see real DB truth.
|
|
13
|
+
* Falls back gracefully to `lifeEvidenceEmptyReason: "state_unavailable"` when state is absent.
|
|
14
|
+
*/
|
|
15
|
+
import type { HeartbeatSignal, HeartbeatCycleResult } from "../../core/second-nature/heartbeat/signal.js";
|
|
16
|
+
import type { SnapshotInputs } from "../../core/second-nature/heartbeat/snapshot-builder.js";
|
|
17
|
+
import type { CliReadModels } from "../read-models/index.js";
|
|
18
|
+
import type { RuntimeDecisionRecorder } from "../../observability/services/runtime-decision-recorder.js";
|
|
19
|
+
import type { StateDatabase } from "../../storage/db/index.js";
|
|
20
|
+
import type { ConnectorExecutor } from "../../core/second-nature/orchestrator/effect-dispatcher.js";
|
|
21
|
+
import type { CapabilityContractRegistry } from "../../connectors/base/manifest.js";
|
|
22
|
+
import type { AffordanceMap } from "../../shared/types/v7-entities.js";
|
|
23
|
+
import type { ExperienceWriter } from "../../core/second-nature/body/tool-experience/experience-writer.js";
|
|
24
|
+
import type { QuietDreamSchedulePort } from "../../core/second-nature/quiet/run-source-backed-quiet.js";
|
|
25
|
+
import { type HeartbeatDigestAssemblerDeps } from "../../observability/services/heartbeat-digest-assembler.js";
|
|
26
|
+
import type { GoalLifecyclePolicy } from "../../core/second-nature/heartbeat/goal-lifecycle-policy.js";
|
|
27
|
+
import type { IdleCuriosityPolicy } from "../../core/second-nature/heartbeat/idle-curiosity-policy.js";
|
|
28
|
+
import type { CircuitBreakerManager } from "../../core/second-nature/body/circuit-breaker/circuit-breaker-manager.js";
|
|
29
|
+
export interface WorkspaceHeartbeatRunnerOptions {
|
|
30
|
+
/** When supplied, the runner persists the cycle so `loadStatus` can read it (T1.2.3). */
|
|
31
|
+
runtimeRecorder?: RuntimeDecisionRecorder;
|
|
32
|
+
/**
|
|
33
|
+
* T2.2.2: when state + workspaceRoot are provided, life evidence is loaded from DB and merged
|
|
34
|
+
* into SnapshotInputs so planner/guard paths have real source-ref truth.
|
|
35
|
+
*/
|
|
36
|
+
state?: StateDatabase;
|
|
37
|
+
workspaceRoot?: string;
|
|
38
|
+
/**
|
|
39
|
+
* T1.2.4: when true (and workspaceRoot is set), inject a `quietWorkflow` dep into the heartbeat
|
|
40
|
+
* cycle so quiet/reflection intents can call `runSourceBackedQuiet` and write artifacts to disk.
|
|
41
|
+
* Defaults to true when workspaceRoot is provided, since this is the host-safe workspace path.
|
|
42
|
+
*/
|
|
43
|
+
enableQuietWorkflow?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* When present, guard-allowed connector_action intents are dispatched through the
|
|
46
|
+
* connector-system instead of returning connector_dispatch_unwired.
|
|
47
|
+
*/
|
|
48
|
+
connectorExecutor?: ConnectorExecutor;
|
|
49
|
+
/**
|
|
50
|
+
* T2.4.1: when present, planner resolves platform-specific intents from accepted goals
|
|
51
|
+
* and connector evidence.
|
|
52
|
+
*/
|
|
53
|
+
connectorRegistry?: CapabilityContractRegistry;
|
|
54
|
+
/** v7 T-V7C.C.2: affordance map for breaker-aware guard evaluation. */
|
|
55
|
+
affordanceMap?: AffordanceMap;
|
|
56
|
+
/** v7 T-V7C.C.2: experience writer for heartbeat connector attempts. */
|
|
57
|
+
experienceWriter?: ExperienceWriter;
|
|
58
|
+
/** v7 T-V7C.C.3: when present, a successful Quiet write auto-triggers Dream scheduling. */
|
|
59
|
+
dreamSchedulePort?: QuietDreamSchedulePort;
|
|
60
|
+
/** v7 T-CP.C.3: goal lifecycle policy for evaluating goal transitions before planning. */
|
|
61
|
+
goalLifecyclePolicy?: GoalLifecyclePolicy;
|
|
62
|
+
/** v7 T-CP.C.3: idle curiosity policy for read-only sensing when no active goals exist. */
|
|
63
|
+
idleCuriosityPolicy?: IdleCuriosityPolicy;
|
|
64
|
+
/** v7 T-BTS.C.5: circuit breaker manager for tracking connector execution health. */
|
|
65
|
+
circuitBreakerManager?: CircuitBreakerManager;
|
|
66
|
+
/**
|
|
67
|
+
* v7 T-V7C.C.3: when present, generates a HeartbeatDigest after each cycle
|
|
68
|
+
* (inside the digest window hour, if specified) and attempts delivery.
|
|
69
|
+
* Digest delivery failure is recorded as fallbackReason — never blocks the cycle.
|
|
70
|
+
*/
|
|
71
|
+
digestOpts?: {
|
|
72
|
+
assemblerDeps: HeartbeatDigestAssemblerDeps;
|
|
73
|
+
/**
|
|
74
|
+
* UTC hour (0–23) at which to attempt digest generation.
|
|
75
|
+
* If unset, digest is generated on every cycle (for testing / always-on mode).
|
|
76
|
+
*/
|
|
77
|
+
digestWindowHour?: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export declare function loadSnapshotInputsForWorkspaceHeartbeat(readModels: CliReadModels, options?: {
|
|
81
|
+
state?: StateDatabase;
|
|
82
|
+
workspaceRoot?: string;
|
|
83
|
+
affordanceMap?: AffordanceMap;
|
|
84
|
+
}): Promise<SnapshotInputs>;
|
|
85
|
+
export declare function createWorkspaceHeartbeatRunner(readModels: CliReadModels, options?: WorkspaceHeartbeatRunnerOptions): (signal: HeartbeatSignal) => Promise<HeartbeatCycleResult>;
|