@haaaiawd/second-nature 0.1.18 → 0.1.20

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 (190) hide show
  1. package/index.js +911 -855
  2. package/openclaw.plugin.json +29 -29
  3. package/package.json +52 -52
  4. package/runtime/cli/commands/index.d.ts +14 -14
  5. package/runtime/cli/commands/index.js +224 -193
  6. package/runtime/cli/explain/explain-surface-subject.d.ts +8 -8
  7. package/runtime/cli/explain/explain-surface-subject.js +9 -9
  8. package/runtime/cli/explain/format-explanation.d.ts +12 -12
  9. package/runtime/cli/explain/format-explanation.js +12 -12
  10. package/runtime/cli/explain/resolve-subject.js +41 -41
  11. package/runtime/cli/host-capability/classify-delivery.d.ts +14 -14
  12. package/runtime/cli/host-capability/classify-delivery.js +20 -20
  13. package/runtime/cli/host-capability/probe-host-capability.d.ts +2 -2
  14. package/runtime/cli/host-capability/probe-host-capability.js +58 -58
  15. package/runtime/cli/host-capability/record-host-capability.d.ts +6 -6
  16. package/runtime/cli/host-capability/record-host-capability.js +14 -14
  17. package/runtime/cli/host-capability/types.d.ts +71 -71
  18. package/runtime/cli/host-capability/types.js +6 -6
  19. package/runtime/cli/host-smoke/run-host-smoke.d.ts +2 -2
  20. package/runtime/cli/host-smoke/run-host-smoke.js +40 -40
  21. package/runtime/cli/host-smoke/types.d.ts +35 -35
  22. package/runtime/cli/host-smoke/types.js +6 -6
  23. package/runtime/cli/index.js +67 -58
  24. package/runtime/cli/ops/heartbeat-surface.d.ts +45 -38
  25. package/runtime/cli/ops/heartbeat-surface.js +79 -73
  26. package/runtime/cli/ops/ops-router.d.ts +32 -19
  27. package/runtime/cli/ops/ops-router.js +188 -89
  28. package/runtime/cli/ops/show-operator-fallback.d.ts +13 -13
  29. package/runtime/cli/ops/show-operator-fallback.js +22 -22
  30. package/runtime/cli/ops/workspace-heartbeat-runner.d.ts +40 -19
  31. package/runtime/cli/ops/workspace-heartbeat-runner.js +93 -39
  32. package/runtime/cli/read-models/index.d.ts +46 -29
  33. package/runtime/cli/read-models/index.js +391 -256
  34. package/runtime/cli/read-models/operator-explain-map.d.ts +6 -6
  35. package/runtime/cli/read-models/operator-explain-map.js +10 -10
  36. package/runtime/cli/read-models/types.d.ts +129 -79
  37. package/runtime/cli/runtime/runtime-artifact-boundary.d.ts +28 -28
  38. package/runtime/cli/runtime/runtime-artifact-boundary.js +94 -94
  39. package/runtime/connectors/base/contract.d.ts +87 -87
  40. package/runtime/connectors/base/execution-policy.d.ts +47 -47
  41. package/runtime/connectors/base/execution-policy.js +82 -82
  42. package/runtime/connectors/base/index.d.ts +8 -8
  43. package/runtime/connectors/base/index.js +8 -8
  44. package/runtime/connectors/base/manifest.d.ts +64 -64
  45. package/runtime/connectors/base/manifest.js +86 -86
  46. package/runtime/connectors/base/map-life-evidence.d.ts +16 -16
  47. package/runtime/connectors/base/map-life-evidence.js +79 -79
  48. package/runtime/connectors/base/policy-layer.d.ts +29 -29
  49. package/runtime/connectors/base/policy-layer.js +198 -198
  50. package/runtime/connectors/base/route-planner.js +99 -99
  51. package/runtime/connectors/index.d.ts +5 -5
  52. package/runtime/connectors/index.js +5 -5
  53. package/runtime/connectors/near-real/near-real-connector-smoke.d.ts +19 -19
  54. package/runtime/connectors/near-real/near-real-connector-smoke.js +152 -152
  55. package/runtime/core/second-nature/heartbeat/heartbeat-executor.js +114 -114
  56. package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +63 -63
  57. package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +162 -139
  58. package/runtime/core/second-nature/heartbeat/index.d.ts +8 -8
  59. package/runtime/core/second-nature/heartbeat/index.js +7 -7
  60. package/runtime/core/second-nature/heartbeat/run-heartbeat-cycle.d.ts +21 -21
  61. package/runtime/core/second-nature/heartbeat/run-heartbeat-cycle.js +35 -35
  62. package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +28 -28
  63. package/runtime/core/second-nature/heartbeat/runtime-snapshot.js +35 -35
  64. package/runtime/core/second-nature/heartbeat/signal.d.ts +42 -42
  65. package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +51 -51
  66. package/runtime/core/second-nature/index.d.ts +22 -22
  67. package/runtime/core/second-nature/index.js +22 -22
  68. package/runtime/core/second-nature/orchestrator/effect-dispatcher.d.ts +100 -100
  69. package/runtime/core/second-nature/orchestrator/effect-dispatcher.js +144 -144
  70. package/runtime/core/second-nature/orchestrator/guard-layer.d.ts +8 -8
  71. package/runtime/core/second-nature/orchestrator/guard-layer.js +110 -110
  72. package/runtime/core/second-nature/orchestrator/intent-planner.d.ts +13 -13
  73. package/runtime/core/second-nature/orchestrator/intent-planner.js +199 -199
  74. package/runtime/core/second-nature/orchestrator/lease-manager.d.ts +14 -14
  75. package/runtime/core/second-nature/orchestrator/lease-manager.js +58 -58
  76. package/runtime/core/second-nature/outreach/build-outreach-draft-request.d.ts +6 -6
  77. package/runtime/core/second-nature/outreach/build-outreach-draft-request.js +63 -63
  78. package/runtime/core/second-nature/outreach/delivery-target.d.ts +26 -26
  79. package/runtime/core/second-nature/outreach/delivery-target.js +70 -70
  80. package/runtime/core/second-nature/outreach/dispatch-user-outreach.d.ts +38 -38
  81. package/runtime/core/second-nature/outreach/dispatch-user-outreach.js +119 -119
  82. package/runtime/core/second-nature/outreach/judge-input-from-snapshot.d.ts +7 -7
  83. package/runtime/core/second-nature/outreach/judge-input-from-snapshot.js +45 -45
  84. package/runtime/core/second-nature/outreach/judge-outreach.d.ts +40 -40
  85. package/runtime/core/second-nature/outreach/judge-outreach.js +121 -121
  86. package/runtime/core/second-nature/quiet/run-source-backed-quiet.d.ts +21 -21
  87. package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +123 -123
  88. package/runtime/core/second-nature/rhythm/planner-rhythm-window.d.ts +15 -15
  89. package/runtime/core/second-nature/rhythm/planner-rhythm-window.js +52 -52
  90. package/runtime/core/second-nature/rhythm/policy-bridge.d.ts +19 -19
  91. package/runtime/core/second-nature/rhythm/policy-bridge.js +34 -34
  92. package/runtime/core/second-nature/runtime/service-entry.js +45 -45
  93. package/runtime/core/second-nature/types.d.ts +51 -51
  94. package/runtime/guidance/draft-outreach-message.d.ts +7 -7
  95. package/runtime/guidance/draft-outreach-message.js +42 -42
  96. package/runtime/guidance/evidence-guidance.d.ts +40 -40
  97. package/runtime/guidance/evidence-guidance.js +52 -52
  98. package/runtime/guidance/index.d.ts +11 -11
  99. package/runtime/guidance/index.js +11 -11
  100. package/runtime/guidance/outreach-draft-schema.d.ts +228 -228
  101. package/runtime/guidance/outreach-draft-schema.js +80 -80
  102. package/runtime/observability/audit/append-only-audit-store.d.ts +14 -14
  103. package/runtime/observability/audit/append-only-audit-store.js +21 -21
  104. package/runtime/observability/audit/audit-envelope.d.ts +51 -51
  105. package/runtime/observability/audit/audit-envelope.js +130 -130
  106. package/runtime/observability/audit/verify-audit-hash-chain.d.ts +23 -23
  107. package/runtime/observability/audit/verify-audit-hash-chain.js +83 -83
  108. package/runtime/observability/db/index.js +47 -47
  109. package/runtime/observability/db/schema/host-capability-reports.d.ts +180 -180
  110. package/runtime/observability/db/schema/host-capability-reports.js +12 -12
  111. package/runtime/observability/db/schema/index.d.ts +947 -947
  112. package/runtime/observability/db/schema/index.js +71 -71
  113. package/runtime/observability/index.d.ts +20 -20
  114. package/runtime/observability/index.js +19 -19
  115. package/runtime/observability/query/explain-query.d.ts +48 -48
  116. package/runtime/observability/query/explain-query.js +114 -114
  117. package/runtime/observability/query/export-audit-bundle.d.ts +22 -22
  118. package/runtime/observability/query/export-audit-bundle.js +27 -27
  119. package/runtime/observability/services/decision-ledger.d.ts +46 -46
  120. package/runtime/observability/services/decision-ledger.js +161 -161
  121. package/runtime/observability/services/governance-audit.d.ts +41 -41
  122. package/runtime/observability/services/governance-audit.js +163 -163
  123. package/runtime/observability/services/governance-plane-recorder.d.ts +47 -47
  124. package/runtime/observability/services/governance-plane-recorder.js +55 -55
  125. package/runtime/observability/services/lived-experience-audit.d.ts +97 -97
  126. package/runtime/observability/services/lived-experience-audit.js +162 -162
  127. package/runtime/observability/services/observability-retention.d.ts +10 -0
  128. package/runtime/observability/services/observability-retention.js +37 -0
  129. package/runtime/observability/services/runtime-decision-recorder.d.ts +29 -29
  130. package/runtime/observability/services/runtime-decision-recorder.js +94 -94
  131. package/runtime/storage/bootstrap/native-sqlite-probe.d.ts +7 -7
  132. package/runtime/storage/bootstrap/native-sqlite-probe.js +28 -28
  133. package/runtime/storage/bootstrap/repair-gate.d.ts +17 -17
  134. package/runtime/storage/bootstrap/repair-gate.js +71 -71
  135. package/runtime/storage/bootstrap/storage-mode-smoke.d.ts +38 -38
  136. package/runtime/storage/bootstrap/storage-mode-smoke.js +85 -85
  137. package/runtime/storage/db/index.js +61 -61
  138. package/runtime/storage/db/schema/delivery-attempts.d.ts +199 -199
  139. package/runtime/storage/db/schema/delivery-attempts.js +13 -13
  140. package/runtime/storage/db/schema/index.d.ts +9 -9
  141. package/runtime/storage/db/schema/index.js +9 -9
  142. package/runtime/storage/db/schema/life-evidence-index.d.ts +161 -161
  143. package/runtime/storage/db/schema/life-evidence-index.js +11 -11
  144. package/runtime/storage/db/schema/operator-fallback-artifacts.d.ts +161 -161
  145. package/runtime/storage/db/schema/operator-fallback-artifacts.js +11 -11
  146. package/runtime/storage/db/schema/policies.d.ts +98 -98
  147. package/runtime/storage/db/schema/policies.js +8 -8
  148. package/runtime/storage/delivery/query-delivery-attempts.d.ts +3 -3
  149. package/runtime/storage/delivery/query-delivery-attempts.js +32 -32
  150. package/runtime/storage/delivery/types.d.ts +27 -27
  151. package/runtime/storage/delivery/types.js +1 -1
  152. package/runtime/storage/delivery/write-delivery-attempt.d.ts +6 -6
  153. package/runtime/storage/delivery/write-delivery-attempt.js +36 -36
  154. package/runtime/storage/fallback/load-operator-fallback.d.ts +14 -14
  155. package/runtime/storage/fallback/load-operator-fallback.js +47 -47
  156. package/runtime/storage/fallback/operator-fallback-types.d.ts +9 -9
  157. package/runtime/storage/fallback/operator-fallback-types.js +1 -1
  158. package/runtime/storage/fallback/operator-fallback-view.d.ts +11 -11
  159. package/runtime/storage/fallback/operator-fallback-view.js +1 -1
  160. package/runtime/storage/fallback/write-operator-fallback.d.ts +6 -6
  161. package/runtime/storage/fallback/write-operator-fallback.js +21 -21
  162. package/runtime/storage/index.d.ts +37 -37
  163. package/runtime/storage/index.js +30 -30
  164. package/runtime/storage/life-evidence/append-life-evidence.d.ts +7 -7
  165. package/runtime/storage/life-evidence/append-life-evidence.js +64 -64
  166. package/runtime/storage/life-evidence/types.d.ts +45 -45
  167. package/runtime/storage/life-evidence/types.js +6 -6
  168. package/runtime/storage/quiet/persist-quiet-artifact.d.ts +7 -7
  169. package/runtime/storage/quiet/persist-quiet-artifact.js +22 -22
  170. package/runtime/storage/quiet/quiet-artifact-types.d.ts +18 -18
  171. package/runtime/storage/quiet/quiet-artifact-types.js +1 -1
  172. package/runtime/storage/quiet/quiet-artifact-writer.d.ts +15 -15
  173. package/runtime/storage/quiet/quiet-artifact-writer.js +56 -56
  174. package/runtime/storage/repositories/credential-repository.js +30 -30
  175. package/runtime/storage/rhythm/rhythm-policy-snapshot.d.ts +10 -10
  176. package/runtime/storage/rhythm/rhythm-policy-snapshot.js +34 -34
  177. package/runtime/storage/services/credential-vault.d.ts +13 -13
  178. package/runtime/storage/services/credential-vault.js +116 -116
  179. package/runtime/storage/snapshots/continuity-snapshot.d.ts +9 -9
  180. package/runtime/storage/snapshots/continuity-snapshot.js +41 -41
  181. package/runtime/storage/snapshots/life-evidence-snapshot.d.ts +6 -6
  182. package/runtime/storage/snapshots/life-evidence-snapshot.js +114 -114
  183. package/runtime/storage/snapshots/types.d.ts +58 -58
  184. package/runtime/storage/snapshots/types.js +1 -1
  185. package/runtime/storage/state-api.js +104 -104
  186. package/runtime/storage/user-interest/load-user-interest-snapshot.d.ts +2 -2
  187. package/runtime/storage/user-interest/load-user-interest-snapshot.js +150 -150
  188. package/runtime/storage/user-interest/types.d.ts +25 -25
  189. package/runtime/storage/user-interest/types.js +1 -1
  190. package/workspace-ops-bridge.js +90 -81
@@ -1,29 +1,29 @@
1
- {
2
- "id": "second-nature",
3
- "name": "Second Nature",
4
- "version": "0.1.18",
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 (see README / T1.1.4 ops norm).",
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.20",
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 (see README / T1.1.4 ops norm).",
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,52 +1,52 @@
1
- {
2
- "name": "@haaaiawd/second-nature",
3
- "version": "0.1.18",
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
- "runtime/"
23
- ],
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
- "openclaw": {
28
- "manifest": "./openclaw.plugin.json",
29
- "extensions": [
30
- "./index.js"
31
- ],
32
- "runtimeExtensions": [
33
- "./index.js"
34
- ],
35
- "compat": {
36
- "pluginApi": ">=2026.5.4"
37
- }
38
- },
39
- "peerDependencies": {
40
- "openclaw": ">=2026.5.4"
41
- },
42
- "peerDependenciesMeta": {
43
- "openclaw": {
44
- "optional": true
45
- }
46
- },
47
- "dependencies": {
48
- "drizzle-orm": "^0.44.4",
49
- "sql.js": "^1.14.1",
50
- "zod": "^4.1.5"
51
- }
52
- }
1
+ {
2
+ "name": "@haaaiawd/second-nature",
3
+ "version": "0.1.20",
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
+ "runtime/"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "openclaw": {
28
+ "manifest": "./openclaw.plugin.json",
29
+ "extensions": [
30
+ "./index.js"
31
+ ],
32
+ "runtimeExtensions": [
33
+ "./index.js"
34
+ ],
35
+ "compat": {
36
+ "pluginApi": ">=2026.5.4"
37
+ }
38
+ },
39
+ "peerDependencies": {
40
+ "openclaw": ">=2026.5.4"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "openclaw": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "dependencies": {
48
+ "drizzle-orm": "^0.44.4",
49
+ "sql.js": "^1.14.1",
50
+ "zod": "^4.1.5"
51
+ }
52
+ }
@@ -1,14 +1,14 @@
1
- import type { ActionBridge } from "../action-bridge.js";
2
- import type { OpsRouter } from "../ops/ops-router.js";
3
- import type { CliReadModels } from "../read-models/index.js";
4
- export interface CliCommandDefinition {
5
- name: string;
6
- description: string;
7
- execute(input?: Record<string, unknown>): Promise<Record<string, unknown>>;
8
- }
9
- export interface CliCommandDeps {
10
- readModels: CliReadModels;
11
- actionBridge: ActionBridge;
12
- opsRouter: OpsRouter;
13
- }
14
- export declare function createCliCommands(deps: CliCommandDeps): CliCommandDefinition[];
1
+ import type { ActionBridge } from "../action-bridge.js";
2
+ import type { OpsRouter } from "../ops/ops-router.js";
3
+ import type { CliReadModels } from "../read-models/index.js";
4
+ export interface CliCommandDefinition {
5
+ name: string;
6
+ description: string;
7
+ execute(input?: Record<string, unknown>): Promise<Record<string, unknown>>;
8
+ }
9
+ export interface CliCommandDeps {
10
+ readModels: CliReadModels;
11
+ actionBridge: ActionBridge;
12
+ opsRouter: OpsRouter;
13
+ }
14
+ export declare function createCliCommands(deps: CliCommandDeps): CliCommandDefinition[];
@@ -1,193 +1,224 @@
1
- import { credentialVerify } from "./credential.js";
2
- import { formatExplanation } from "../explain/format-explanation.js";
3
- import { explainSurfaceSubject } from "../explain/explain-surface-subject.js";
4
- import { showOperatorFallback, OperatorFallbackNotFoundError } from "../ops/show-operator-fallback.js";
5
- import { runStorageModeSmoke } from "../../storage/bootstrap/storage-mode-smoke.js";
6
- import { policySet } from "./policy.js";
7
- const notImplemented = async (command) => ({
8
- ok: false,
9
- command,
10
- message: "Command shell registered. Implementation lands in later Wave tasks.",
11
- });
12
- function explainSubjectError(code, message) {
13
- return {
14
- ok: false,
15
- error: {
16
- code,
17
- message,
18
- requiredUserInput: ["subject"],
19
- nextStep: "reinvoke_explain_with_supported_subject",
20
- },
21
- };
22
- }
23
- export function createCliCommands(deps) {
24
- const { readModels, actionBridge, opsRouter } = deps;
25
- return [
26
- {
27
- name: "status",
28
- description: "Show aggregated Second Nature status",
29
- execute: async (input) => {
30
- const scope = typeof input?.scope === "string" ? input.scope : undefined;
31
- const data = await readModels.loadStatus(scope);
32
- return { ok: true, data };
33
- },
34
- },
35
- {
36
- name: "policy",
37
- description: "Write or inspect policy state",
38
- execute: async (input) => {
39
- const action = typeof input?.action === "string" ? input.action : "show";
40
- if (action === "set") {
41
- return policySet(actionBridge, input);
42
- }
43
- return notImplemented("policy");
44
- },
45
- },
46
- {
47
- name: "credential",
48
- description: "Inspect or recover credential state",
49
- execute: async (input) => {
50
- const action = typeof input?.action === "string" ? input.action : "show";
51
- if (action === "verify") {
52
- return credentialVerify(actionBridge, input);
53
- }
54
- const platformId = typeof input?.platformId === "string" ? input.platformId : "unknown";
55
- const data = await readModels.loadCredential(platformId);
56
- return { ok: true, data };
57
- },
58
- },
59
- {
60
- name: "quiet",
61
- description: "Inspect Quiet lifecycle state",
62
- execute: async (input) => {
63
- const scope = typeof input?.scope === "string" ? input.scope : undefined;
64
- const data = await readModels.loadQuiet(scope);
65
- return { ok: true, data };
66
- },
67
- },
68
- {
69
- name: "report",
70
- description: "Show daily report artifacts",
71
- execute: async (input) => {
72
- const day = typeof input?.day === "string" ? input.day : new Date().toISOString().slice(0, 10);
73
- const data = await readModels.loadDailyReport(day);
74
- return { ok: true, data };
75
- },
76
- },
77
- {
78
- name: "session",
79
- description: "Inspect continuity session details",
80
- execute: async (input) => {
81
- const sessionId = typeof input?.sessionId === "string" ? input.sessionId : "";
82
- if (!sessionId) {
83
- return {
84
- ok: false,
85
- error: {
86
- code: "MISSING_SESSION_ID",
87
- message: "session show requires sessionId",
88
- requiredUserInput: ["session_id"],
89
- nextStep: "reinvoke_session_with_session_id",
90
- },
91
- };
92
- }
93
- const data = await readModels.loadSession(sessionId);
94
- return { ok: true, data };
95
- },
96
- },
97
- {
98
- name: "audit",
99
- description: "Inspect audit and evidence views",
100
- execute: () => notImplemented("audit"),
101
- },
102
- {
103
- name: "explain",
104
- description: "Answer why-question explain requests",
105
- execute: async (input) => {
106
- const subjectRaw = typeof input?.subject === "string" ? input.subject.trim() : "";
107
- if (!subjectRaw) {
108
- return {
109
- ok: false,
110
- error: {
111
- code: "MISSING_EXPLAIN_SUBJECT",
112
- message: "explain requires subject",
113
- requiredUserInput: ["subject"],
114
- nextStep: "reinvoke_explain_with_subject",
115
- },
116
- };
117
- }
118
- let model;
119
- try {
120
- model = await explainSurfaceSubject(subjectRaw, readModels);
121
- }
122
- catch (error) {
123
- const code = error.message;
124
- if (code === "explain_subject_requires_id") {
125
- return explainSubjectError("EXPLAIN_SUBJECT_REQUIRES_ID", "subject must include identifier");
126
- }
127
- if (code === "explain_subject_unsupported") {
128
- return explainSubjectError("EXPLAIN_SUBJECT_UNSUPPORTED", "supported subjects include decision:, platform:, outreach:, soul:, fallback:, delivery:, probe:, report:, source:");
129
- }
130
- return explainSubjectError("EXPLAIN_SUBJECT_INVALID", "invalid explain subject");
131
- }
132
- return {
133
- ok: true,
134
- data: formatExplanation(model),
135
- };
136
- },
137
- },
138
- {
139
- name: "heartbeat_check",
140
- description: "Workspace heartbeat_check ops surface (v5 HeartbeatSurfaceResult)",
141
- execute: async (input) => {
142
- const surface = await Promise.resolve(opsRouter.dispatch("heartbeat_check", input));
143
- return surface;
144
- },
145
- },
146
- {
147
- name: "storage_smoke",
148
- description: "T4.1.4 — report sql.js vs native SQLite probe and optional artifact→index repair fixture",
149
- execute: async (input) => {
150
- const runRepairFixture = Boolean(input?.runRepairFixture);
151
- const workspaceRoot = typeof input?.workspaceRoot === "string" ? input.workspaceRoot : undefined;
152
- const data = await runStorageModeSmoke({ runRepairFixture, workspaceRoot });
153
- return { ok: true, data };
154
- },
155
- },
156
- {
157
- name: "fallback",
158
- description: "Operator-visible delivery fallback view (status always not_sent)",
159
- execute: async (input) => {
160
- const ref = typeof input?.ref === "string" ? input.ref.trim() : "";
161
- if (!ref) {
162
- return {
163
- ok: false,
164
- error: {
165
- code: "MISSING_FALLBACK_REF",
166
- message: "fallback requires ref (e.g. fallback:…)",
167
- requiredUserInput: ["ref"],
168
- nextStep: "reinvoke_with_ref",
169
- },
170
- };
171
- }
172
- try {
173
- const data = await showOperatorFallback(ref, readModels);
174
- return { ok: true, data };
175
- }
176
- catch (error) {
177
- if (error instanceof OperatorFallbackNotFoundError) {
178
- return {
179
- ok: false,
180
- error: {
181
- code: error.code,
182
- message: error.message,
183
- requiredUserInput: ["ref"],
184
- nextStep: "verify_fallback_ref_from_delivery_audit",
185
- },
186
- };
187
- }
188
- throw error;
189
- }
190
- },
191
- },
192
- ];
193
- }
1
+ import { credentialVerify } from "./credential.js";
2
+ import { formatExplanation } from "../explain/format-explanation.js";
3
+ import { explainSurfaceSubject } from "../explain/explain-surface-subject.js";
4
+ import { showOperatorFallback, OperatorFallbackNotFoundError, } from "../ops/show-operator-fallback.js";
5
+ import { runStorageModeSmoke } from "../../storage/bootstrap/storage-mode-smoke.js";
6
+ import { policySet } from "./policy.js";
7
+ const notImplemented = async (command) => ({
8
+ ok: false,
9
+ command,
10
+ message: "Command shell registered. Implementation lands in later Wave tasks.",
11
+ });
12
+ function explainSubjectError(code, message) {
13
+ return {
14
+ ok: false,
15
+ error: {
16
+ code,
17
+ message,
18
+ requiredUserInput: ["subject"],
19
+ nextStep: "reinvoke_explain_with_supported_subject",
20
+ },
21
+ };
22
+ }
23
+ export function createCliCommands(deps) {
24
+ const { readModels, actionBridge, opsRouter } = deps;
25
+ return [
26
+ {
27
+ name: "status",
28
+ description: "Show aggregated Second Nature status",
29
+ execute: async (input) => {
30
+ const scope = typeof input?.scope === "string" ? input.scope : undefined;
31
+ const data = await readModels.loadStatus(scope);
32
+ return { ok: true, data };
33
+ },
34
+ },
35
+ {
36
+ name: "policy",
37
+ description: "Write or inspect policy state",
38
+ execute: async (input) => {
39
+ const action = typeof input?.action === "string" ? input.action : "show";
40
+ if (action === "set") {
41
+ return policySet(actionBridge, input);
42
+ }
43
+ // T1.2.6 (SN-CODE-01): `policy show` (default) returns the current rhythm policy
44
+ // snapshot. Returns workspace defaults when no policy row has been persisted yet.
45
+ const data = await readModels.loadPolicy();
46
+ return { ok: true, data };
47
+ },
48
+ },
49
+ {
50
+ name: "credential",
51
+ description: "Inspect or recover credential state",
52
+ execute: async (input) => {
53
+ const action = typeof input?.action === "string" ? input.action : "show";
54
+ if (action === "verify") {
55
+ return credentialVerify(actionBridge, input);
56
+ }
57
+ const platformId = typeof input?.platformId === "string" ? input.platformId : "unknown";
58
+ const data = await readModels.loadCredential(platformId);
59
+ return { ok: true, data };
60
+ },
61
+ },
62
+ {
63
+ name: "quiet",
64
+ description: "Inspect Quiet lifecycle state",
65
+ execute: async (input) => {
66
+ const scope = typeof input?.scope === "string" ? input.scope : undefined;
67
+ const data = await readModels.loadQuiet(scope);
68
+ return { ok: true, data };
69
+ },
70
+ },
71
+ {
72
+ name: "report",
73
+ description: "Show daily report artifacts",
74
+ execute: async (input) => {
75
+ const day = typeof input?.day === "string"
76
+ ? input.day
77
+ : new Date().toISOString().slice(0, 10);
78
+ const data = await readModels.loadDailyReport(day);
79
+ return { ok: true, data };
80
+ },
81
+ },
82
+ {
83
+ name: "session",
84
+ description: "Inspect continuity session details",
85
+ execute: async (input) => {
86
+ const sessionId = typeof input?.sessionId === "string" ? input.sessionId : "";
87
+ if (!sessionId) {
88
+ return {
89
+ ok: false,
90
+ error: {
91
+ code: "MISSING_SESSION_ID",
92
+ message: "session show requires sessionId",
93
+ requiredUserInput: ["session_id"],
94
+ nextStep: "reinvoke_session_with_session_id",
95
+ },
96
+ };
97
+ }
98
+ const data = await readModels.loadSession(sessionId);
99
+ return { ok: true, data };
100
+ },
101
+ },
102
+ {
103
+ name: "audit",
104
+ description: "Inspect audit and evidence views",
105
+ execute: async () => {
106
+ // T1.2.7 (SN-CODE-02): minimal read-side view list all in-memory audit events.
107
+ // Empty store returns { totalEvents: 0, events: [] } (honest empty, not an error).
108
+ const data = await readModels.loadAuditSummary();
109
+ return { ok: true, data };
110
+ },
111
+ },
112
+ {
113
+ name: "explain",
114
+ description: "Answer why-question explain requests",
115
+ execute: async (input) => {
116
+ const subjectRaw = typeof input?.subject === "string" ? input.subject.trim() : "";
117
+ if (!subjectRaw) {
118
+ return {
119
+ ok: false,
120
+ error: {
121
+ code: "MISSING_EXPLAIN_SUBJECT",
122
+ message: "explain requires subject",
123
+ requiredUserInput: ["subject"],
124
+ nextStep: "reinvoke_explain_with_subject",
125
+ },
126
+ };
127
+ }
128
+ let model;
129
+ try {
130
+ model = await explainSurfaceSubject(subjectRaw, readModels);
131
+ }
132
+ catch (error) {
133
+ const code = error.message;
134
+ if (code === "explain_subject_requires_id") {
135
+ return explainSubjectError("EXPLAIN_SUBJECT_REQUIRES_ID", "subject must include identifier");
136
+ }
137
+ if (code === "explain_subject_unsupported") {
138
+ return explainSubjectError("EXPLAIN_SUBJECT_UNSUPPORTED", "supported subjects include decision:, platform:, outreach:, soul:, fallback:, delivery:, probe:, report:, source:");
139
+ }
140
+ return explainSubjectError("EXPLAIN_SUBJECT_INVALID", "invalid explain subject");
141
+ }
142
+ return {
143
+ ok: true,
144
+ data: formatExplanation(model),
145
+ };
146
+ },
147
+ },
148
+ {
149
+ name: "heartbeat_check",
150
+ description: "Workspace heartbeat_check ops surface (v5 HeartbeatSurfaceResult)",
151
+ execute: async (input) => {
152
+ const surface = await Promise.resolve(opsRouter.dispatch("heartbeat_check", input));
153
+ return surface;
154
+ },
155
+ },
156
+ {
157
+ name: "storage_smoke",
158
+ description: "T4.1.4 report sql.js vs native SQLite probe and optional artifact→index repair fixture",
159
+ execute: async (input) => {
160
+ const runRepairFixture = Boolean(input?.runRepairFixture);
161
+ const workspaceRoot = typeof input?.workspaceRoot === "string"
162
+ ? input.workspaceRoot
163
+ : undefined;
164
+ const data = await runStorageModeSmoke({
165
+ runRepairFixture,
166
+ workspaceRoot,
167
+ });
168
+ return { ok: true, data };
169
+ },
170
+ },
171
+ {
172
+ name: "fallback",
173
+ description: "Operator-visible delivery fallback view (status always not_sent)",
174
+ execute: async (input) => {
175
+ const ref = typeof input?.ref === "string" ? input.ref.trim() : "";
176
+ if (!ref) {
177
+ return {
178
+ ok: false,
179
+ error: {
180
+ code: "MISSING_FALLBACK_REF",
181
+ message: "fallback requires ref (e.g. fallback:…)",
182
+ requiredUserInput: ["ref"],
183
+ nextStep: "reinvoke_with_ref",
184
+ },
185
+ };
186
+ }
187
+ try {
188
+ const data = await showOperatorFallback(ref, readModels);
189
+ return { ok: true, data };
190
+ }
191
+ catch (error) {
192
+ if (error instanceof OperatorFallbackNotFoundError) {
193
+ return {
194
+ ok: false,
195
+ error: {
196
+ code: error.code,
197
+ message: error.message,
198
+ requiredUserInput: ["ref"],
199
+ nextStep: "verify_fallback_ref_from_delivery_audit",
200
+ },
201
+ };
202
+ }
203
+ throw error;
204
+ }
205
+ },
206
+ },
207
+ {
208
+ name: "capability_probe",
209
+ description: "T1.2.8 — probe host capabilities and persist report (static unknown adapter in CLI context)",
210
+ execute: async (input) => {
211
+ const surface = await Promise.resolve(opsRouter.dispatch("capability_probe", input));
212
+ return surface;
213
+ },
214
+ },
215
+ {
216
+ name: "near_real_smoke",
217
+ description: "T3.3.2 — run near-real connector smoke (sentinel Moltbook + EvoMap, no live HTTP)",
218
+ execute: async (input) => {
219
+ const surface = await Promise.resolve(opsRouter.dispatch("near_real_smoke", input));
220
+ return surface;
221
+ },
222
+ },
223
+ ];
224
+ }
@@ -1,8 +1,8 @@
1
- /**
2
- * Stable operator explain entry matching cli-system.detail §3.8 (T1.2.1).
3
- *
4
- * Core logic: parse subject string via resolveExplainSubject, delegate to read models.
5
- */
6
- import type { CliReadModels } from "../read-models/index.js";
7
- import type { ExplainReadModel } from "../read-models/types.js";
8
- export declare function explainSurfaceSubject(subjectRaw: string, readModels: CliReadModels): Promise<ExplainReadModel>;
1
+ /**
2
+ * Stable operator explain entry matching cli-system.detail §3.8 (T1.2.1).
3
+ *
4
+ * Core logic: parse subject string via resolveExplainSubject, delegate to read models.
5
+ */
6
+ import type { CliReadModels } from "../read-models/index.js";
7
+ import type { ExplainReadModel } from "../read-models/types.js";
8
+ export declare function explainSurfaceSubject(subjectRaw: string, readModels: CliReadModels): Promise<ExplainReadModel>;