@haaaiawd/second-nature 0.1.39 → 0.1.41

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 (51) hide show
  1. package/index.js +1270 -1270
  2. package/openclaw.plugin.json +29 -29
  3. package/package.json +55 -55
  4. package/runtime/cli/commands/connector-init.js +11 -4
  5. package/runtime/cli/index.js +6 -1
  6. package/runtime/cli/ops/heartbeat-surface.d.ts +75 -75
  7. package/runtime/cli/ops/heartbeat-surface.js +97 -97
  8. package/runtime/cli/ops/ops-router.js +1428 -1428
  9. package/runtime/cli/ops/workspace-heartbeat-runner.js +236 -236
  10. package/runtime/connectors/services/connector-executor-adapter.js +192 -41
  11. package/runtime/core/second-nature/body/tool-affordance/affordance-context-scope.d.ts +1 -1
  12. package/runtime/core/second-nature/body/tool-affordance/affordance-context-scope.js +2 -1
  13. package/runtime/core/second-nature/guidance/apply-guidance.d.ts +12 -12
  14. package/runtime/core/second-nature/guidance/apply-guidance.js +15 -15
  15. package/runtime/core/second-nature/guidance/user-reply-continuity.d.ts +50 -50
  16. package/runtime/core/second-nature/guidance/user-reply-continuity.js +89 -89
  17. package/runtime/core/second-nature/orchestrator/intent-planner.js +15 -0
  18. package/runtime/core/second-nature/runtime/service-entry.d.ts +39 -39
  19. package/runtime/core/second-nature/runtime/service-entry.js +44 -44
  20. package/runtime/dream/dream-engine.d.ts +14 -14
  21. package/runtime/dream/dream-engine.js +306 -306
  22. package/runtime/dream/dream-input-loader.d.ts +37 -37
  23. package/runtime/dream/dream-input-loader.js +150 -150
  24. package/runtime/dream/dream-scheduler.d.ts +75 -75
  25. package/runtime/dream/dream-scheduler.js +131 -131
  26. package/runtime/dream/index.d.ts +16 -16
  27. package/runtime/dream/index.js +14 -14
  28. package/runtime/dream/insight-extractor.d.ts +32 -32
  29. package/runtime/dream/insight-extractor.js +135 -135
  30. package/runtime/dream/memory-consolidator.d.ts +45 -45
  31. package/runtime/dream/memory-consolidator.js +140 -140
  32. package/runtime/dream/narrative-update-proposal.d.ts +34 -34
  33. package/runtime/dream/narrative-update-proposal.js +83 -83
  34. package/runtime/dream/output-validator.d.ts +20 -20
  35. package/runtime/dream/output-validator.js +110 -110
  36. package/runtime/dream/redaction-gate.d.ts +31 -31
  37. package/runtime/dream/redaction-gate.js +109 -109
  38. package/runtime/dream/relationship-update-proposal.d.ts +27 -27
  39. package/runtime/dream/relationship-update-proposal.js +119 -119
  40. package/runtime/dream/sampler.d.ts +30 -30
  41. package/runtime/dream/sampler.js +65 -65
  42. package/runtime/dream/types.d.ts +187 -187
  43. package/runtime/dream/types.js +11 -11
  44. package/runtime/guidance/fallback.js +20 -20
  45. package/runtime/guidance/guidance-assembler.js +76 -76
  46. package/runtime/guidance/output-guard.d.ts +13 -13
  47. package/runtime/guidance/output-guard.js +53 -53
  48. package/runtime/guidance/template-registry.d.ts +20 -20
  49. package/runtime/guidance/template-registry.js +93 -93
  50. package/runtime/guidance/types.d.ts +98 -98
  51. package/runtime/observability/projections/guidance-audit.js +38 -38
@@ -120,6 +120,11 @@ export function planIntentWithKind(kind, basePriority, runtime, context, registr
120
120
  }));
121
121
  }
122
122
  const refs = kind === "work" ? [...OBLIGATION_SOURCE] : evidenceRefsForConnector(runtime);
123
+ const capabilityIntent = kind === "exploration" ? "feed.read"
124
+ : kind === "social" ? "comment.reply"
125
+ : kind === "work" ? "work.discover"
126
+ : kind === "outreach" ? "message.send"
127
+ : undefined;
123
128
  return [
124
129
  {
125
130
  id: platformId ? `${config.idPrefix}-${platformId}` : config.idPrefix,
@@ -134,6 +139,7 @@ export function planIntentWithKind(kind, basePriority, runtime, context, registr
134
139
  ? `${config.idempotencyPrefix}:${platformId}`
135
140
  : `${config.idempotencyPrefix}:${config.summary(undefined)}`,
136
141
  goalInfluenceRefs: [],
142
+ ...(capabilityIntent ? { capabilityIntent } : {}),
137
143
  },
138
144
  ];
139
145
  }
@@ -242,6 +248,15 @@ export function planCandidateIntents(runtime, options) {
242
248
  if (related.length > 0) {
243
249
  intent.goalInfluenceRefs = related.map((g) => g.goalId);
244
250
  }
251
+ // W80: sourceRefs fallback — when lifeEvidence is empty, bind accepted goals
252
+ // as source refs so hard guard (isSourceBacked) does not deny/defer.
253
+ if (intent.sourceRefs.length === 0 && related.length > 0) {
254
+ intent.sourceRefs = related.slice(0, 4).map((g) => ({
255
+ id: g.goalId,
256
+ kind: "workspace_artifact",
257
+ uri: `goal://${g.goalId}`,
258
+ }));
259
+ }
245
260
  }
246
261
  // CR-02: apply narrative-focus bias globally across all candidate kinds.
247
262
  const adjusted = intents.map((intent) => {
@@ -1,39 +1,39 @@
1
- /**
2
- * Second Nature Runtime Service Entry
3
- *
4
- * This module provides the actual implementation for the `second-nature-runtime` service.
5
- * It serves as the heartbeat host bridge candidate carrier and initializes the
6
- * minimal runtime state needed for the plugin to function.
7
- *
8
- * Per ADR-005: heartbeat is the free-rhythm main entry; this service provides
9
- * the stable runtime state that heartbeat rounds will interact with.
10
- */
11
- export interface RuntimeServiceContext {
12
- /** Workspace root path for state/observability databases */
13
- workspaceRoot?: string;
14
- /** Plugin configuration overrides */
15
- config?: Record<string, unknown>;
16
- /** Runtime version — supplied by the plugin entry from its package manifest.
17
- * Eliminates hard-coded version drift (previously `const version = "0.1.38"`). */
18
- version?: string;
19
- }
20
- export interface RuntimeServiceHandle {
21
- /** Service is ready and accepting requests */
22
- ready: boolean;
23
- /** Runtime version string */
24
- version: string;
25
- /** Close the runtime handle and release resources */
26
- close: () => void;
27
- }
28
- /**
29
- * Start the Second Nature runtime service.
30
- *
31
- * This is the non-empty implementation that replaces the previous `start() { return; }` shell.
32
- * It initializes the minimal runtime state and returns a handle that can be used
33
- * by the heartbeat host bridge.
34
- */
35
- export declare function startRuntimeService(ctx?: RuntimeServiceContext): RuntimeServiceHandle;
36
- /**
37
- * Get the current runtime service handle, or null if not started.
38
- */
39
- export declare function getRuntimeHandle(): RuntimeServiceHandle | null;
1
+ /**
2
+ * Second Nature Runtime Service Entry
3
+ *
4
+ * This module provides the actual implementation for the `second-nature-runtime` service.
5
+ * It serves as the heartbeat host bridge candidate carrier and initializes the
6
+ * minimal runtime state needed for the plugin to function.
7
+ *
8
+ * Per ADR-005: heartbeat is the free-rhythm main entry; this service provides
9
+ * the stable runtime state that heartbeat rounds will interact with.
10
+ */
11
+ export interface RuntimeServiceContext {
12
+ /** Workspace root path for state/observability databases */
13
+ workspaceRoot?: string;
14
+ /** Plugin configuration overrides */
15
+ config?: Record<string, unknown>;
16
+ /** Runtime version — supplied by the plugin entry from its package manifest.
17
+ * Eliminates hard-coded version drift (previously `const version = "0.1.38"`). */
18
+ version?: string;
19
+ }
20
+ export interface RuntimeServiceHandle {
21
+ /** Service is ready and accepting requests */
22
+ ready: boolean;
23
+ /** Runtime version string */
24
+ version: string;
25
+ /** Close the runtime handle and release resources */
26
+ close: () => void;
27
+ }
28
+ /**
29
+ * Start the Second Nature runtime service.
30
+ *
31
+ * This is the non-empty implementation that replaces the previous `start() { return; }` shell.
32
+ * It initializes the minimal runtime state and returns a handle that can be used
33
+ * by the heartbeat host bridge.
34
+ */
35
+ export declare function startRuntimeService(ctx?: RuntimeServiceContext): RuntimeServiceHandle;
36
+ /**
37
+ * Get the current runtime service handle, or null if not started.
38
+ */
39
+ export declare function getRuntimeHandle(): RuntimeServiceHandle | null;
@@ -1,44 +1,44 @@
1
- /**
2
- * Second Nature Runtime Service Entry
3
- *
4
- * This module provides the actual implementation for the `second-nature-runtime` service.
5
- * It serves as the heartbeat host bridge candidate carrier and initializes the
6
- * minimal runtime state needed for the plugin to function.
7
- *
8
- * Per ADR-005: heartbeat is the free-rhythm main entry; this service provides
9
- * the stable runtime state that heartbeat rounds will interact with.
10
- */
11
- let activeHandle = null;
12
- /**
13
- * Start the Second Nature runtime service.
14
- *
15
- * This is the non-empty implementation that replaces the previous `start() { return; }` shell.
16
- * It initializes the minimal runtime state and returns a handle that can be used
17
- * by the heartbeat host bridge.
18
- */
19
- export function startRuntimeService(ctx) {
20
- if (activeHandle?.ready) {
21
- return activeHandle;
22
- }
23
- // Initialize minimal runtime state
24
- // In future iterations, this will connect to:
25
- // - state-system (SQLite database initialization)
26
- // - observability-system (event store setup)
27
- // - control-plane-system (heartbeat bridge preparation)
28
- const workspaceRoot = ctx?.workspaceRoot ?? process.cwd();
29
- const version = ctx?.version ?? "unknown";
30
- activeHandle = {
31
- ready: true,
32
- version,
33
- close() {
34
- activeHandle = null;
35
- },
36
- };
37
- return activeHandle;
38
- }
39
- /**
40
- * Get the current runtime service handle, or null if not started.
41
- */
42
- export function getRuntimeHandle() {
43
- return activeHandle;
44
- }
1
+ /**
2
+ * Second Nature Runtime Service Entry
3
+ *
4
+ * This module provides the actual implementation for the `second-nature-runtime` service.
5
+ * It serves as the heartbeat host bridge candidate carrier and initializes the
6
+ * minimal runtime state needed for the plugin to function.
7
+ *
8
+ * Per ADR-005: heartbeat is the free-rhythm main entry; this service provides
9
+ * the stable runtime state that heartbeat rounds will interact with.
10
+ */
11
+ let activeHandle = null;
12
+ /**
13
+ * Start the Second Nature runtime service.
14
+ *
15
+ * This is the non-empty implementation that replaces the previous `start() { return; }` shell.
16
+ * It initializes the minimal runtime state and returns a handle that can be used
17
+ * by the heartbeat host bridge.
18
+ */
19
+ export function startRuntimeService(ctx) {
20
+ if (activeHandle?.ready) {
21
+ return activeHandle;
22
+ }
23
+ // Initialize minimal runtime state
24
+ // In future iterations, this will connect to:
25
+ // - state-system (SQLite database initialization)
26
+ // - observability-system (event store setup)
27
+ // - control-plane-system (heartbeat bridge preparation)
28
+ const workspaceRoot = ctx?.workspaceRoot ?? process.cwd();
29
+ const version = ctx?.version ?? "unknown";
30
+ activeHandle = {
31
+ ready: true,
32
+ version,
33
+ close() {
34
+ activeHandle = null;
35
+ },
36
+ };
37
+ return activeHandle;
38
+ }
39
+ /**
40
+ * Get the current runtime service handle, or null if not started.
41
+ */
42
+ export function getRuntimeHandle() {
43
+ return activeHandle;
44
+ }
@@ -1,14 +1,14 @@
1
- /**
2
- * Dream Engine — orchestrates the hybrid memory consolidation pipeline.
3
- *
4
- * Pipeline: load inputs → consolidate (rules) → sample → redact →
5
- * optional model insights → merge → validate → write output + trace.
6
- *
7
- * Contract:
8
- * - Input store is never modified.
9
- * - Output is always candidate until validation passes and lifecycle port accepts it.
10
- * - Budget/redaction/timeout failures degrade gracefully with trace.
11
- * Test coverage: tests/integration/dream/t7-1-1-dream-pipeline.test.ts
12
- */
13
- import type { DreamEngineInput, DreamRunResult } from "./types.js";
14
- export declare function runDream(input: DreamEngineInput): Promise<DreamRunResult>;
1
+ /**
2
+ * Dream Engine — orchestrates the hybrid memory consolidation pipeline.
3
+ *
4
+ * Pipeline: load inputs → consolidate (rules) → sample → redact →
5
+ * optional model insights → merge → validate → write output + trace.
6
+ *
7
+ * Contract:
8
+ * - Input store is never modified.
9
+ * - Output is always candidate until validation passes and lifecycle port accepts it.
10
+ * - Budget/redaction/timeout failures degrade gracefully with trace.
11
+ * Test coverage: tests/integration/dream/t7-1-1-dream-pipeline.test.ts
12
+ */
13
+ import type { DreamEngineInput, DreamRunResult } from "./types.js";
14
+ export declare function runDream(input: DreamEngineInput): Promise<DreamRunResult>;