@haaaiawd/second-nature 0.2.9 → 0.2.13
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 +102 -6
- package/openclaw.plugin.json +2 -5
- package/package.json +1 -1
- package/runtime/cli/commands/index.js +85 -11
- package/runtime/cli/host-capability/host-discovery-port.d.ts +85 -0
- package/runtime/cli/host-capability/host-discovery-port.js +137 -0
- 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 +5 -3
- package/runtime/cli/ops/heartbeat-surface.js +38 -8
- package/runtime/cli/ops/ops-router.d.ts +6 -2
- package/runtime/cli/ops/ops-router.js +1275 -1147
- package/runtime/cli/ops/workspace-heartbeat-runner.js +2 -5
- package/runtime/connectors/base/normalized-evidence-content.d.ts +4 -0
- package/runtime/connectors/base/normalized-evidence-content.js +21 -2
- package/runtime/connectors/evidence-normalizer.js +32 -1
- 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 +4 -0
- package/runtime/core/second-nature/action/action-closure-recorder.js +51 -38
- package/runtime/core/second-nature/action/action-proposal-builder.js +8 -34
- package/runtime/core/second-nature/action/policy-bound-dispatch.d.ts +2 -0
- package/runtime/core/second-nature/action/policy-bound-dispatch.js +10 -5
- package/runtime/core/second-nature/control-plane/accepted-projection-loader.js +1 -11
- package/runtime/core/second-nature/control-plane/cycle-finalizer.d.ts +82 -0
- package/runtime/core/second-nature/control-plane/cycle-finalizer.js +187 -0
- package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.d.ts +1 -0
- package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.js +23 -15
- 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 +2 -1
- package/runtime/core/second-nature/guidance/guidance-proposal-consumer.d.ts +2 -1
- package/runtime/core/second-nature/guidance/guidance-proposal-consumer.js +4 -2
- 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 +10 -16
- package/runtime/core/second-nature/perception/perception-builder.js +15 -11
- package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +13 -15
- package/runtime/core/second-nature/quiet-dream/daily-rhythm-scheduler.js +40 -16
- package/runtime/core/second-nature/quiet-dream/dream-consolidation-runner.d.ts +5 -1
- package/runtime/core/second-nature/quiet-dream/dream-consolidation-runner.js +68 -29
- package/runtime/core/second-nature/quiet-dream/dream-scheduler.js +2 -3
- package/runtime/core/second-nature/quiet-dream/memory-projection-lifecycle.js +2 -13
- package/runtime/core/second-nature/quiet-dream/quiet-daily-review-builder.d.ts +1 -0
- package/runtime/core/second-nature/quiet-dream/quiet-daily-review-builder.js +34 -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/causal-loop-health.d.ts +2 -1
- package/runtime/observability/causal-loop-health.js +7 -0
- package/runtime/observability/living-loop-health-gate.js +2 -8
- package/runtime/observability/loop-stage-event-sink.js +6 -2
- package/runtime/observability/loop-status.d.ts +2 -0
- package/runtime/observability/loop-status.js +14 -1
- package/runtime/observability/services/heartbeat-digest-assembler.d.ts +3 -0
- package/runtime/observability/services/heartbeat-digest-assembler.js +9 -0
- package/runtime/observability/services/lived-experience-audit.d.ts +7 -7
- package/runtime/shared/degraded-status-classifier.d.ts +16 -0
- package/runtime/shared/degraded-status-classifier.js +68 -0
- package/runtime/shared/evidence-level-classifier.d.ts +61 -0
- package/runtime/shared/evidence-level-classifier.js +116 -0
- package/runtime/shared/provenance-tier.d.ts +37 -0
- package/runtime/shared/provenance-tier.js +97 -0
- package/runtime/shared/serialization.d.ts +17 -0
- package/runtime/shared/serialization.js +27 -0
- package/runtime/shared/setup-ack.d.ts +54 -0
- package/runtime/shared/setup-ack.js +108 -0
- package/runtime/shared/source-ref-compat.d.ts +26 -0
- package/runtime/shared/source-ref-compat.js +64 -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 +13 -2
- package/runtime/storage/db/index.js +60 -12
- 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/migrations/v8-006-loop-stage-event-proof-trace-columns.d.ts +9 -0
- package/runtime/storage/db/migrations/v8-006-loop-stage-event-proof-trace-columns.js +15 -0
- package/runtime/storage/db/schema/v8-entities.d.ts +65 -84
- package/runtime/storage/db/schema/v8-entities.js +8 -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 +15 -3
- 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 +15 -3
- package/runtime/storage/v8-state-stores.js +60 -39
|
@@ -35,7 +35,7 @@ export interface HeartbeatSurfaceResult {
|
|
|
35
35
|
/** True when structured fields mirror a fake adapter for schema parity only */
|
|
36
36
|
schemaParityOnly?: boolean;
|
|
37
37
|
/** T-CP.R.2: v8 real runtime spine result when state-backed action-closure spine ran */
|
|
38
|
-
v8Spine?: RealRuntimeSpineResult & {
|
|
38
|
+
v8Spine?: Partial<RealRuntimeSpineResult> & {
|
|
39
39
|
degradedReason?: string;
|
|
40
40
|
};
|
|
41
41
|
/** T-GVS.R.1: agent-facing impulse context artifact read pointer */
|
|
@@ -45,6 +45,8 @@ export interface HeartbeatSurfaceResult {
|
|
|
45
45
|
capabilityClass?: string | null;
|
|
46
46
|
impulseText?: string | null;
|
|
47
47
|
atmosphereText?: string | null;
|
|
48
|
+
expressionBoundaryConstraints?: string[] | null;
|
|
49
|
+
expressionBoundaryStyle?: string | null;
|
|
48
50
|
freshnessMs?: number;
|
|
49
51
|
missingReason?: string;
|
|
50
52
|
};
|
|
@@ -99,8 +101,8 @@ export interface HeartbeatCheckInput {
|
|
|
99
101
|
/** T-OBS.R.1: shared audit sink for connector/Quiet events consumed by heartbeat_digest. */
|
|
100
102
|
auditStore?: AppendOnlyAuditStore;
|
|
101
103
|
/**
|
|
102
|
-
* T-CP.R.
|
|
103
|
-
*
|
|
104
|
+
* T-CP.R.5: v8 living-loop spine is the default operator-facing heartbeat model.
|
|
105
|
+
* Explicit false can be used by legacy callers to force a carrier-only path.
|
|
104
106
|
*/
|
|
105
107
|
v8SpineEnabled?: boolean;
|
|
106
108
|
}
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { createWorkspaceHeartbeatRunner } from "./workspace-heartbeat-runner.js";
|
|
2
2
|
// T-CP.R.2: v8 real runtime spine bridge
|
|
3
3
|
import { runRealRuntimeHeartbeatCycle, } from "../../core/second-nature/control-plane/real-runtime-spine.js";
|
|
4
|
+
async function refreshHeartbeatImpulseContext(state, now) {
|
|
5
|
+
const { assembleImpulseSync } = await import("../../guidance/impulse-assembler.js");
|
|
6
|
+
const { buildExpressionBoundary } = await import("../../guidance/output-guard.js");
|
|
7
|
+
const { getShortAtmosphereTemplate } = await import("../../guidance/template-registry.js");
|
|
8
|
+
const { writeImpulseContext } = await import("../../core/second-nature/guidance/impulse-context-writer.js");
|
|
9
|
+
const impulseResult = assembleImpulseSync({ sceneType: "heartbeat" });
|
|
10
|
+
const atmosphere = getShortAtmosphereTemplate("active", "low");
|
|
11
|
+
const expressionBoundary = buildExpressionBoundary("heartbeat");
|
|
12
|
+
const result = await writeImpulseContext(state, {
|
|
13
|
+
sceneType: "heartbeat",
|
|
14
|
+
impulseResult,
|
|
15
|
+
atmosphereText: atmosphere.text,
|
|
16
|
+
expressionBoundaryConstraints: expressionBoundary.constraints,
|
|
17
|
+
expressionBoundaryStyle: expressionBoundary.style,
|
|
18
|
+
}, { now });
|
|
19
|
+
return "id" in result ? result.id : undefined;
|
|
20
|
+
}
|
|
4
21
|
function mapCycleToSurface(cycle, surfaceMode) {
|
|
5
22
|
const status = cycle.status === "runtime_carrier_only"
|
|
6
23
|
? "runtime_carrier_only"
|
|
@@ -89,8 +106,9 @@ export async function heartbeatCheck(input) {
|
|
|
89
106
|
try {
|
|
90
107
|
const cycle = await run(signal);
|
|
91
108
|
const surfaceResult = mapCycleToSurface(cycle, "workspace_full_runtime");
|
|
92
|
-
// T-CP.R.
|
|
93
|
-
|
|
109
|
+
// T-CP.R.5: v8 living-loop spine is the default operator-facing model when state is wired
|
|
110
|
+
const v8SpineEnabled = input.v8SpineEnabled !== false && Boolean(input.state && input.workspaceRoot);
|
|
111
|
+
if (v8SpineEnabled && input.state && input.workspaceRoot) {
|
|
94
112
|
try {
|
|
95
113
|
const v8Result = await runRealRuntimeHeartbeatCycle({
|
|
96
114
|
workspaceRoot: input.workspaceRoot,
|
|
@@ -98,10 +116,10 @@ export async function heartbeatCheck(input) {
|
|
|
98
116
|
requestedAt: timestamp,
|
|
99
117
|
trigger: "host",
|
|
100
118
|
});
|
|
101
|
-
if ("status" in v8Result &&
|
|
119
|
+
if ("status" in v8Result && "operatorNextAction" in v8Result) {
|
|
120
|
+
// T-CP.R.6: degraded path must not fabricate cycleId/cycleSequence.
|
|
121
|
+
// Only set degradedReason; cycleId/cycleSequence remain absent.
|
|
102
122
|
surfaceResult.v8Spine = {
|
|
103
|
-
cycleId: "",
|
|
104
|
-
cycleSequence: 0,
|
|
105
123
|
degradedReason: v8Result.reason,
|
|
106
124
|
};
|
|
107
125
|
surfaceResult.reasons = [
|
|
@@ -111,6 +129,11 @@ export async function heartbeatCheck(input) {
|
|
|
111
129
|
}
|
|
112
130
|
else {
|
|
113
131
|
const spine = v8Result;
|
|
132
|
+
const artifactId = await refreshHeartbeatImpulseContext(input.state, timestamp);
|
|
133
|
+
if (artifactId) {
|
|
134
|
+
spine.impulseContextArtifactId = artifactId;
|
|
135
|
+
surfaceResult.reasons.push(`impulse_context_refreshed:${artifactId}`);
|
|
136
|
+
}
|
|
114
137
|
surfaceResult.v8Spine = spine;
|
|
115
138
|
surfaceResult.livedExperienceLoopClaimed = Boolean(spine.cycleId && (spine.closureRef || spine.noActionReason));
|
|
116
139
|
surfaceResult.reasons = [
|
|
@@ -134,7 +157,7 @@ export async function heartbeatCheck(input) {
|
|
|
134
157
|
if (input.state) {
|
|
135
158
|
try {
|
|
136
159
|
const { readImpulseContext } = await import("../../core/second-nature/guidance/impulse-context-reader.js");
|
|
137
|
-
const ctx = await readImpulseContext(input.state, "
|
|
160
|
+
const ctx = await readImpulseContext(input.state, "heartbeat");
|
|
138
161
|
if (ctx.available) {
|
|
139
162
|
surfaceResult.impulseContext = {
|
|
140
163
|
available: true,
|
|
@@ -142,6 +165,8 @@ export async function heartbeatCheck(input) {
|
|
|
142
165
|
capabilityClass: ctx.artifact.capabilityClass,
|
|
143
166
|
impulseText: ctx.artifact.impulseText,
|
|
144
167
|
atmosphereText: ctx.artifact.atmosphereText,
|
|
168
|
+
expressionBoundaryConstraints: ctx.artifact.expressionBoundaryConstraints,
|
|
169
|
+
expressionBoundaryStyle: ctx.artifact.expressionBoundaryStyle,
|
|
145
170
|
freshnessMs: ctx.freshnessMs,
|
|
146
171
|
};
|
|
147
172
|
surfaceResult.reasons.push(`impulse_context:${ctx.artifact.id}`);
|
|
@@ -154,8 +179,13 @@ export async function heartbeatCheck(input) {
|
|
|
154
179
|
surfaceResult.reasons.push(`impulse_context_missing:${ctx.reason}`);
|
|
155
180
|
}
|
|
156
181
|
}
|
|
157
|
-
catch {
|
|
158
|
-
|
|
182
|
+
catch (readErr) {
|
|
183
|
+
const msg = readErr instanceof Error ? readErr.message : String(readErr);
|
|
184
|
+
surfaceResult.impulseContext = {
|
|
185
|
+
available: false,
|
|
186
|
+
missingReason: `read_exception:${msg.slice(0, 120)}`,
|
|
187
|
+
};
|
|
188
|
+
surfaceResult.reasons.push(`impulse_context_read_failed:${msg.slice(0, 120)}`);
|
|
159
189
|
}
|
|
160
190
|
}
|
|
161
191
|
return surfaceResult;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HeartbeatCheckInput, type HeartbeatSurfaceResult } from "./heartbeat-surface.js";
|
|
2
|
+
import type { SurfaceMode } from "../runtime/runtime-artifact-boundary.js";
|
|
2
3
|
import type { CliReadModels } from "../read-models/index.js";
|
|
3
4
|
import type { RuntimeDecisionRecorder } from "../../observability/services/runtime-decision-recorder.js";
|
|
4
5
|
import type { StateDatabase } from "../../storage/db/index.js";
|
|
@@ -12,12 +13,13 @@ import { AppendOnlyAuditStore } from "../../observability/audit/append-only-audi
|
|
|
12
13
|
import type { RestoreSnapshotStore } from "../../storage/services/restore-snapshot-store.js";
|
|
13
14
|
import type { CapabilityContractRegistry } from "../../connectors/base/manifest.js";
|
|
14
15
|
import type { AffordanceAssembler } from "../../core/second-nature/body/tool-affordance/affordance-assembler.js";
|
|
15
|
-
|
|
16
|
+
import type { EvidenceLevel } from "../../shared/types/v8-contracts.js";
|
|
17
|
+
/** Unified response envelope for all v7/v8 runtime-ops commands. */
|
|
16
18
|
export interface RuntimeOpsEnvelope<T = unknown> {
|
|
17
19
|
ok: boolean;
|
|
18
20
|
command: string;
|
|
19
21
|
runtimeMode: "host_safe_carrier" | "workspace_full_runtime" | "unavailable";
|
|
20
|
-
surfaceMode: "cli" | "openclaw_tool" | "plugin_command" | "cron_probe";
|
|
22
|
+
surfaceMode: SurfaceMode | "cli" | "openclaw_tool" | "plugin_command" | "cron_probe";
|
|
21
23
|
generatedAt: string;
|
|
22
24
|
data?: T;
|
|
23
25
|
error?: {
|
|
@@ -27,6 +29,8 @@ export interface RuntimeOpsEnvelope<T = unknown> {
|
|
|
27
29
|
};
|
|
28
30
|
warnings: string[];
|
|
29
31
|
sourceRefs: string[];
|
|
32
|
+
/** T-OBS.R.7: how strongly this response is backed by runtime proof. */
|
|
33
|
+
evidenceLevel?: EvidenceLevel;
|
|
30
34
|
}
|
|
31
35
|
export interface OpsRouterDeps {
|
|
32
36
|
/** When true, packaged runtime artifacts resolved and full graph is loadable */
|