@haaaiawd/second-nature 0.1.34 → 0.1.39

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.
Files changed (72) hide show
  1. package/agent-inner-guide.md +43 -0
  2. package/index.js +1270 -1262
  3. package/openclaw.plugin.json +29 -29
  4. package/package.json +55 -55
  5. package/runtime/cli/commands/goal.d.ts +1 -0
  6. package/runtime/cli/commands/goal.js +1 -0
  7. package/runtime/cli/index.js +3 -3
  8. package/runtime/cli/ops/heartbeat-surface.d.ts +75 -54
  9. package/runtime/cli/ops/heartbeat-surface.js +97 -81
  10. package/runtime/cli/ops/ops-router.js +1428 -1182
  11. package/runtime/cli/ops/workspace-heartbeat-runner.d.ts +24 -0
  12. package/runtime/cli/ops/workspace-heartbeat-runner.js +236 -150
  13. package/runtime/connectors/base/contract.d.ts +10 -0
  14. package/runtime/core/second-nature/guidance/apply-guidance.d.ts +12 -10
  15. package/runtime/core/second-nature/guidance/apply-guidance.js +15 -10
  16. package/runtime/core/second-nature/guidance/user-reply-continuity.d.ts +50 -50
  17. package/runtime/core/second-nature/guidance/user-reply-continuity.js +89 -80
  18. package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +7 -1
  19. package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +25 -0
  20. package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +5 -0
  21. package/runtime/core/second-nature/heartbeat/runtime-snapshot.js +10 -1
  22. package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +5 -0
  23. package/runtime/core/second-nature/orchestrator/guard-layer.js +24 -1
  24. package/runtime/core/second-nature/quiet/run-source-backed-quiet.d.ts +20 -0
  25. package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +32 -2
  26. package/runtime/core/second-nature/runtime/service-entry.d.ts +39 -36
  27. package/runtime/core/second-nature/runtime/service-entry.js +44 -45
  28. package/runtime/dream/dream-engine.d.ts +14 -0
  29. package/runtime/dream/dream-engine.js +306 -0
  30. package/runtime/dream/dream-input-loader.d.ts +37 -0
  31. package/runtime/dream/dream-input-loader.js +155 -0
  32. package/runtime/dream/dream-scheduler.d.ts +75 -0
  33. package/runtime/dream/dream-scheduler.js +131 -0
  34. package/runtime/dream/index.d.ts +16 -0
  35. package/runtime/dream/index.js +14 -0
  36. package/runtime/dream/insight-extractor.d.ts +32 -0
  37. package/runtime/dream/insight-extractor.js +135 -0
  38. package/runtime/dream/memory-consolidator.d.ts +45 -0
  39. package/runtime/dream/memory-consolidator.js +140 -0
  40. package/runtime/dream/narrative-update-proposal.d.ts +34 -0
  41. package/runtime/dream/narrative-update-proposal.js +83 -0
  42. package/runtime/dream/output-validator.d.ts +20 -0
  43. package/runtime/dream/output-validator.js +110 -0
  44. package/runtime/dream/redaction-gate.d.ts +31 -0
  45. package/runtime/dream/redaction-gate.js +109 -0
  46. package/runtime/dream/relationship-update-proposal.d.ts +27 -0
  47. package/runtime/dream/relationship-update-proposal.js +119 -0
  48. package/runtime/dream/sampler.d.ts +30 -0
  49. package/runtime/dream/sampler.js +65 -0
  50. package/runtime/dream/types.d.ts +187 -0
  51. package/runtime/dream/types.js +11 -0
  52. package/runtime/guidance/capability-class.d.ts +38 -0
  53. package/runtime/guidance/capability-class.js +65 -0
  54. package/runtime/guidance/fallback.js +20 -17
  55. package/runtime/guidance/guidance-assembler.d.ts +2 -0
  56. package/runtime/guidance/guidance-assembler.js +76 -62
  57. package/runtime/guidance/guidance-draft-service.js +5 -5
  58. package/runtime/guidance/impulse-assembler.d.ts +71 -0
  59. package/runtime/guidance/impulse-assembler.js +103 -0
  60. package/runtime/guidance/index.d.ts +2 -0
  61. package/runtime/guidance/index.js +2 -0
  62. package/runtime/guidance/output-guard.d.ts +13 -10
  63. package/runtime/guidance/output-guard.js +53 -29
  64. package/runtime/guidance/outreach-strategy-selector.d.ts +13 -0
  65. package/runtime/guidance/outreach-strategy-selector.js +2 -2
  66. package/runtime/guidance/template-registry.d.ts +20 -3
  67. package/runtime/guidance/template-registry.js +123 -45
  68. package/runtime/guidance/types.d.ts +98 -72
  69. package/runtime/observability/projections/guidance-audit.js +38 -35
  70. package/runtime/storage/goal/agent-goal-store.d.ts +2 -0
  71. package/runtime/storage/goal/agent-goal-store.js +28 -1
  72. package/runtime/storage/services/tool-experience-store.js +11 -11
@@ -1,29 +1,29 @@
1
- {
2
- "id": "second-nature",
3
- "name": "Second Nature",
4
- "version": "0.1.34",
5
- "description": "OpenClaw native plugin with synchronous surface registration and bundled runtime spine. Set SECOND_NATURE_WORKSPACE_ROOT or tool workspaceRoot to the same path as the agent workspace. Agent inner guide is packaged as agent-inner-guide.md. v7 ops surface: self_health, tool_affordance, heartbeat_digest, snapshot:capture, narrative:diff, timeline, restore, runtime_secret_bootstrap.",
6
- "activation": {
7
- "onStartup": true,
8
- "onCapabilities": [
9
- "tool"
10
- ]
11
- },
12
- "contracts": {
13
- "commands": [
14
- "second-nature"
15
- ],
16
- "tools": [
17
- "second_nature_ops"
18
- ],
19
- "services": [
20
- "second-nature-runtime",
21
- "second-nature-lifecycle"
22
- ]
23
- },
24
- "configSchema": {
25
- "type": "object",
26
- "additionalProperties": false,
27
- "properties": {}
28
- }
29
- }
1
+ {
2
+ "id": "second-nature",
3
+ "name": "Second Nature",
4
+ "version": "0.1.38",
5
+ "description": "OpenClaw native plugin with synchronous surface registration and bundled runtime spine. Set SECOND_NATURE_WORKSPACE_ROOT or tool workspaceRoot to the same path as the agent workspace. Agent inner guide is packaged as agent-inner-guide.md. v7 ops surface: self_health, tool_affordance, heartbeat_digest, snapshot:capture, narrative:diff, timeline, restore, runtime_secret_bootstrap, connector:run, guidance_payload.",
6
+ "activation": {
7
+ "onStartup": true,
8
+ "onCapabilities": [
9
+ "tool"
10
+ ]
11
+ },
12
+ "contracts": {
13
+ "commands": [
14
+ "second-nature"
15
+ ],
16
+ "tools": [
17
+ "second_nature_ops"
18
+ ],
19
+ "services": [
20
+ "second-nature-runtime",
21
+ "second-nature-lifecycle"
22
+ ]
23
+ },
24
+ "configSchema": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "properties": {}
28
+ }
29
+ }
package/package.json CHANGED
@@ -1,55 +1,55 @@
1
- {
2
- "name": "@haaaiawd/second-nature",
3
- "version": "0.1.34",
4
- "description": "OpenClaw native plugin with synchronous registration, a packaged runtime artifact, and operator-facing status/explain flows.",
5
- "keywords": [
6
- "openclaw",
7
- "plugin",
8
- "agent",
9
- "continuity",
10
- "quiet",
11
- "memory",
12
- "observability",
13
- "operator"
14
- ],
15
- "license": "Apache-2.0",
16
- "type": "module",
17
- "main": "./index.js",
18
- "files": [
19
- "index.js",
20
- "workspace-ops-bridge.js",
21
- "openclaw.plugin.json",
22
- "SKILL.md",
23
- "agent-inner-guide.md",
24
- "runtime/"
25
- ],
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "openclaw": {
30
- "manifest": "./openclaw.plugin.json",
31
- "extensions": [
32
- "./index.js"
33
- ],
34
- "runtimeExtensions": [
35
- "./index.js"
36
- ],
37
- "compat": {
38
- "pluginApi": ">=2026.5.12"
39
- }
40
- },
41
- "peerDependencies": {
42
- "openclaw": ">=2026.5.12"
43
- },
44
- "peerDependenciesMeta": {
45
- "openclaw": {
46
- "optional": true
47
- }
48
- },
49
- "dependencies": {
50
- "drizzle-orm": "^0.45.2",
51
- "js-yaml": "^4.1.1",
52
- "sql.js": "^1.14.1",
53
- "zod": "^4.4.3"
54
- }
55
- }
1
+ {
2
+ "name": "@haaaiawd/second-nature",
3
+ "version": "0.1.39",
4
+ "description": "OpenClaw native plugin with synchronous registration, a packaged runtime artifact, and operator-facing status/explain flows.",
5
+ "keywords": [
6
+ "openclaw",
7
+ "plugin",
8
+ "agent",
9
+ "continuity",
10
+ "quiet",
11
+ "memory",
12
+ "observability",
13
+ "operator"
14
+ ],
15
+ "license": "Apache-2.0",
16
+ "type": "module",
17
+ "main": "./index.js",
18
+ "files": [
19
+ "index.js",
20
+ "workspace-ops-bridge.js",
21
+ "openclaw.plugin.json",
22
+ "SKILL.md",
23
+ "agent-inner-guide.md",
24
+ "runtime/"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "openclaw": {
30
+ "manifest": "./openclaw.plugin.json",
31
+ "extensions": [
32
+ "./index.js"
33
+ ],
34
+ "runtimeExtensions": [
35
+ "./index.js"
36
+ ],
37
+ "compat": {
38
+ "pluginApi": ">=2026.5.12"
39
+ }
40
+ },
41
+ "peerDependencies": {
42
+ "openclaw": ">=2026.5.12"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "openclaw": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "dependencies": {
50
+ "drizzle-orm": "^0.45.2",
51
+ "js-yaml": "^4.1.1",
52
+ "sql.js": "^1.14.1",
53
+ "zod": "^4.4.3"
54
+ }
55
+ }
@@ -8,6 +8,7 @@ export interface GoalCommandInput {
8
8
  criteria?: string;
9
9
  risk?: "low" | "medium" | "high";
10
10
  kind?: "short_term" | "long_term";
11
+ scope?: string;
11
12
  statusFilter?: string;
12
13
  originFilter?: string;
13
14
  limit?: number;
@@ -50,6 +50,7 @@ export async function goalCommand(stateDb, input) {
50
50
  await store.upsertAgentGoal({
51
51
  goalId,
52
52
  kind: input.kind ?? "short_term",
53
+ scope: input.scope?.trim() || "global",
53
54
  status: "accepted",
54
55
  origin: "owner_set",
55
56
  description,
@@ -186,9 +186,9 @@ function createSecretAnchorDeps(stateDb) {
186
186
  },
187
187
  credentialPort: {
188
188
  verifySampleDecrypt: async () => {
189
- const result = stateDb.sqlite.exec(`SELECT platform_id, encrypted_value
190
- FROM credential_records
191
- WHERE encrypted_value IS NOT NULL AND encrypted_value != ''
189
+ const result = stateDb.sqlite.exec(`SELECT platform_id, encrypted_value
190
+ FROM credential_records
191
+ WHERE encrypted_value IS NOT NULL AND encrypted_value != ''
192
192
  LIMIT 3`);
193
193
  if (result.length === 0 || result[0].values.length === 0) {
194
194
  return { status: "ok", checkedIds: [] };
@@ -1,54 +1,75 @@
1
- /**
2
- * Stable HeartbeatSurfaceResult for second_nature_ops / CLI (T1.1.3, cli-system / ADR-005).
3
- *
4
- * S1 scope: carrier / probe / runtime-unavailable / fake control-plane passthrough only.
5
- * Workspace full runtime: delegates to `runHeartbeatCycle` when read models are wired (US-001 / CH-09-02).
6
- */
7
- import type { SurfaceMode } from "../runtime/runtime-artifact-boundary.js";
8
- import type { HeartbeatSignal } from "../../core/second-nature/heartbeat/signal.js";
9
- import type { CliReadModels } from "../read-models/index.js";
10
- import type { RuntimeDecisionRecorder } from "../../observability/services/runtime-decision-recorder.js";
11
- import type { StateDatabase } from "../../storage/db/index.js";
12
- import type { ConnectorExecutor } from "../../core/second-nature/orchestrator/effect-dispatcher.js";
13
- import type { CapabilityContractRegistry } from "../../connectors/base/manifest.js";
14
- export type HeartbeatSurfaceStatus = "heartbeat_ok" | "intent_selected" | "denied" | "deferred" | "runtime_carrier_only" | "delivery_unavailable";
15
- export interface HeartbeatSurfaceResult {
16
- ok: boolean;
17
- status: HeartbeatSurfaceStatus;
18
- surfaceMode: SurfaceMode;
19
- decisionId?: string;
20
- deliveryAttemptId?: string;
21
- capabilityReportRef?: string;
22
- fallbackRef?: string;
23
- reasons: string[];
24
- /** When false, callers must not treat the round as lived-experience loop completion */
25
- livedExperienceLoopClaimed: boolean;
26
- /** True when structured fields mirror a fake adapter for schema parity only */
27
- schemaParityOnly?: boolean;
28
- }
29
- export interface HeartbeatCheckInput {
30
- probeOnly?: boolean;
31
- runtimeAvailable: boolean;
32
- fakeControlPlanePassthrough?: Record<string, unknown>;
33
- /** When set, full-runtime heartbeat_check runs the control-plane decision loop (US-001). */
34
- readModels?: CliReadModels;
35
- /** When set, full-runtime cycles are persisted so `loadStatus` exits unknown (T1.2.3). */
36
- runtimeRecorder?: RuntimeDecisionRecorder;
37
- /**
38
- * T2.2.2: when set together with `workspaceRoot`, life evidence from the state DB is loaded
39
- * and merged into SnapshotInputs so planner/guard paths see real source-ref truth.
40
- */
41
- state?: StateDatabase;
42
- workspaceRoot?: string;
43
- timestamp?: string;
44
- sessionContext?: string;
45
- scopeHint?: HeartbeatSignal["scopeHint"];
46
- /**
47
- * When present, guard-allowed connector_action intents are dispatched through the
48
- * connector-system instead of returning connector_dispatch_unwired.
49
- */
50
- connectorExecutor?: ConnectorExecutor;
51
- /** Capability registry used by planner to avoid platform/capability protocol mismatches. */
52
- connectorRegistry?: CapabilityContractRegistry;
53
- }
54
- export declare function heartbeatCheck(input: HeartbeatCheckInput): Promise<HeartbeatSurfaceResult>;
1
+ /**
2
+ * Stable HeartbeatSurfaceResult for second_nature_ops / CLI (T1.1.3, cli-system / ADR-005).
3
+ *
4
+ * S1 scope: carrier / probe / runtime-unavailable / fake control-plane passthrough only.
5
+ * Workspace full runtime: delegates to `runHeartbeatCycle` when read models are wired (US-001 / CH-09-02).
6
+ */
7
+ import type { SurfaceMode } from "../runtime/runtime-artifact-boundary.js";
8
+ import type { HeartbeatSignal } from "../../core/second-nature/heartbeat/signal.js";
9
+ import type { CliReadModels } from "../read-models/index.js";
10
+ import type { RuntimeDecisionRecorder } from "../../observability/services/runtime-decision-recorder.js";
11
+ import type { StateDatabase } from "../../storage/db/index.js";
12
+ import type { ConnectorExecutor } from "../../core/second-nature/orchestrator/effect-dispatcher.js";
13
+ import type { CapabilityContractRegistry } from "../../connectors/base/manifest.js";
14
+ import type { AffordanceMap } from "../../shared/types/v7-entities.js";
15
+ import type { ExperienceWriter } from "../../core/second-nature/body/tool-experience/experience-writer.js";
16
+ import type { QuietDreamSchedulePort } from "../../core/second-nature/quiet/run-source-backed-quiet.js";
17
+ import type { HeartbeatDigestAssemblerDeps } from "../../observability/services/heartbeat-digest-assembler.js";
18
+ export type HeartbeatSurfaceStatus = "heartbeat_ok" | "intent_selected" | "denied" | "deferred" | "runtime_carrier_only" | "delivery_unavailable";
19
+ export interface HeartbeatSurfaceResult {
20
+ ok: boolean;
21
+ status: HeartbeatSurfaceStatus;
22
+ surfaceMode: SurfaceMode;
23
+ decisionId?: string;
24
+ deliveryAttemptId?: string;
25
+ capabilityReportRef?: string;
26
+ fallbackRef?: string;
27
+ reasons: string[];
28
+ /** When false, callers must not treat the round as lived-experience loop completion */
29
+ livedExperienceLoopClaimed: boolean;
30
+ /** True when structured fields mirror a fake adapter for schema parity only */
31
+ schemaParityOnly?: boolean;
32
+ }
33
+ export interface HeartbeatCheckInput {
34
+ probeOnly?: boolean;
35
+ runtimeAvailable: boolean;
36
+ fakeControlPlanePassthrough?: Record<string, unknown>;
37
+ /** When set, full-runtime heartbeat_check runs the control-plane decision loop (US-001). */
38
+ readModels?: CliReadModels;
39
+ /** When set, full-runtime cycles are persisted so `loadStatus` exits unknown (T1.2.3). */
40
+ runtimeRecorder?: RuntimeDecisionRecorder;
41
+ /**
42
+ * T2.2.2: when set together with `workspaceRoot`, life evidence from the state DB is loaded
43
+ * and merged into SnapshotInputs so planner/guard paths see real source-ref truth.
44
+ */
45
+ state?: StateDatabase;
46
+ workspaceRoot?: string;
47
+ timestamp?: string;
48
+ sessionContext?: string;
49
+ scopeHint?: HeartbeatSignal["scopeHint"];
50
+ /**
51
+ * When present, guard-allowed connector_action intents are dispatched through the
52
+ * connector-system instead of returning connector_dispatch_unwired.
53
+ */
54
+ connectorExecutor?: ConnectorExecutor;
55
+ /** Capability registry used by planner to avoid platform/capability protocol mismatches. */
56
+ connectorRegistry?: CapabilityContractRegistry;
57
+ /** v7 T-V7C.C.2: affordance map for breaker-aware guard evaluation. */
58
+ affordanceMap?: AffordanceMap;
59
+ /** v7 T-V7C.C.2: experience writer for heartbeat connector attempts. */
60
+ experienceWriter?: ExperienceWriter;
61
+ /**
62
+ * v7 T-V7C.C.6: when present, a successful Quiet write auto-triggers Dream scheduling.
63
+ * Fixes the production-data gap where dream_output_index does not grow after Quiet.
64
+ */
65
+ dreamSchedulePort?: QuietDreamSchedulePort;
66
+ /**
67
+ * v7 T-V7C.C.6: when present, generates a HeartbeatDigest after each cycle.
68
+ * Fixes the production-data gap where heartbeat_digest does not grow.
69
+ */
70
+ digestOpts?: {
71
+ assemblerDeps: HeartbeatDigestAssemblerDeps;
72
+ digestWindowHour?: number;
73
+ };
74
+ }
75
+ export declare function heartbeatCheck(input: HeartbeatCheckInput): Promise<HeartbeatSurfaceResult>;
@@ -1,81 +1,97 @@
1
- import { createWorkspaceHeartbeatRunner } from "./workspace-heartbeat-runner.js";
2
- function mapCycleToSurface(cycle, surfaceMode) {
3
- const status = cycle.status === "runtime_carrier_only"
4
- ? "runtime_carrier_only"
5
- : cycle.status;
6
- return {
7
- ok: true,
8
- status,
9
- surfaceMode,
10
- decisionId: cycle.decisionId,
11
- deliveryAttemptId: cycle.deliveryAttemptId,
12
- fallbackRef: cycle.fallbackRef,
13
- reasons: cycle.reasons,
14
- livedExperienceLoopClaimed: false,
15
- };
16
- }
17
- export async function heartbeatCheck(input) {
18
- if (!input.runtimeAvailable) {
19
- return {
20
- ok: true,
21
- status: "runtime_carrier_only",
22
- surfaceMode: "host_safe_carrier",
23
- reasons: ["runtime_unavailable_packaged_carrier"],
24
- livedExperienceLoopClaimed: false,
25
- };
26
- }
27
- if (input.probeOnly) {
28
- return {
29
- ok: true,
30
- status: "heartbeat_ok",
31
- surfaceMode: "capability_probe",
32
- reasons: ["probe_only"],
33
- livedExperienceLoopClaimed: false,
34
- };
35
- }
36
- if (input.fakeControlPlanePassthrough) {
37
- const decisionId = typeof input.fakeControlPlanePassthrough.decisionId === "string"
38
- ? input.fakeControlPlanePassthrough.decisionId
39
- : undefined;
40
- return {
41
- ok: true,
42
- status: "intent_selected",
43
- surfaceMode: "host_safe_carrier",
44
- reasons: ["fake_control_plane_passthrough"],
45
- decisionId,
46
- livedExperienceLoopClaimed: false,
47
- schemaParityOnly: true,
48
- };
49
- }
50
- if (!input.readModels) {
51
- return {
52
- ok: true,
53
- status: "runtime_carrier_only",
54
- surfaceMode: "host_safe_carrier",
55
- reasons: ["heartbeat_read_models_unavailable"],
56
- livedExperienceLoopClaimed: false,
57
- };
58
- }
59
- const timestamp = typeof input.timestamp === "string" && input.timestamp.trim().length > 0
60
- ? input.timestamp.trim()
61
- : new Date().toISOString();
62
- const signal = {
63
- trigger: "heartbeat_bridge",
64
- scopeHint: input.scopeHint,
65
- payload: {
66
- timestamp,
67
- sessionContext: typeof input.sessionContext === "string"
68
- ? input.sessionContext
69
- : undefined,
70
- },
71
- };
72
- const run = createWorkspaceHeartbeatRunner(input.readModels, {
73
- runtimeRecorder: input.runtimeRecorder,
74
- state: input.state,
75
- workspaceRoot: input.workspaceRoot ?? process.cwd(),
76
- connectorExecutor: input.connectorExecutor,
77
- connectorRegistry: input.connectorRegistry,
78
- });
79
- const cycle = await run(signal);
80
- return mapCycleToSurface(cycle, "workspace_full_runtime");
81
- }
1
+ import { createWorkspaceHeartbeatRunner } from "./workspace-heartbeat-runner.js";
2
+ function mapCycleToSurface(cycle, surfaceMode) {
3
+ const status = cycle.status === "runtime_carrier_only"
4
+ ? "runtime_carrier_only"
5
+ : cycle.status;
6
+ return {
7
+ ok: true,
8
+ status,
9
+ surfaceMode,
10
+ decisionId: cycle.decisionId,
11
+ deliveryAttemptId: cycle.deliveryAttemptId,
12
+ fallbackRef: cycle.fallbackRef,
13
+ reasons: cycle.reasons,
14
+ livedExperienceLoopClaimed: false,
15
+ };
16
+ }
17
+ export async function heartbeatCheck(input) {
18
+ if (!input.runtimeAvailable) {
19
+ return {
20
+ ok: true,
21
+ status: "runtime_carrier_only",
22
+ surfaceMode: "host_safe_carrier",
23
+ reasons: ["runtime_unavailable_packaged_carrier"],
24
+ livedExperienceLoopClaimed: false,
25
+ };
26
+ }
27
+ if (input.probeOnly) {
28
+ return {
29
+ ok: true,
30
+ status: "heartbeat_ok",
31
+ surfaceMode: "capability_probe",
32
+ reasons: ["probe_only"],
33
+ livedExperienceLoopClaimed: false,
34
+ };
35
+ }
36
+ if (input.fakeControlPlanePassthrough) {
37
+ const decisionId = typeof input.fakeControlPlanePassthrough.decisionId === "string"
38
+ ? input.fakeControlPlanePassthrough.decisionId
39
+ : undefined;
40
+ return {
41
+ ok: true,
42
+ status: "intent_selected",
43
+ surfaceMode: "host_safe_carrier",
44
+ reasons: ["fake_control_plane_passthrough"],
45
+ decisionId,
46
+ livedExperienceLoopClaimed: false,
47
+ schemaParityOnly: true,
48
+ };
49
+ }
50
+ if (!input.readModels) {
51
+ return {
52
+ ok: true,
53
+ status: "runtime_carrier_only",
54
+ surfaceMode: "host_safe_carrier",
55
+ reasons: ["heartbeat_read_models_unavailable"],
56
+ livedExperienceLoopClaimed: false,
57
+ };
58
+ }
59
+ const timestamp = typeof input.timestamp === "string" && input.timestamp.trim().length > 0
60
+ ? input.timestamp.trim()
61
+ : new Date().toISOString();
62
+ const signal = {
63
+ trigger: "heartbeat_bridge",
64
+ scopeHint: input.scopeHint,
65
+ payload: {
66
+ timestamp,
67
+ sessionContext: typeof input.sessionContext === "string"
68
+ ? input.sessionContext
69
+ : undefined,
70
+ },
71
+ };
72
+ const run = createWorkspaceHeartbeatRunner(input.readModels, {
73
+ runtimeRecorder: input.runtimeRecorder,
74
+ state: input.state,
75
+ workspaceRoot: input.workspaceRoot ?? process.cwd(),
76
+ connectorExecutor: input.connectorExecutor,
77
+ connectorRegistry: input.connectorRegistry,
78
+ affordanceMap: input.affordanceMap,
79
+ experienceWriter: input.experienceWriter,
80
+ dreamSchedulePort: input.dreamSchedulePort,
81
+ digestOpts: input.digestOpts,
82
+ });
83
+ try {
84
+ const cycle = await run(signal);
85
+ return mapCycleToSurface(cycle, "workspace_full_runtime");
86
+ }
87
+ catch (err) {
88
+ const msg = err instanceof Error ? err.message : String(err);
89
+ return {
90
+ ok: false,
91
+ status: "denied",
92
+ surfaceMode: "workspace_full_runtime",
93
+ reasons: [`heartbeat_cycle_exception:${msg.slice(0, 120)}`],
94
+ livedExperienceLoopClaimed: false,
95
+ };
96
+ }
97
+ }