@haaaiawd/second-nature 0.1.34 → 0.1.38

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 (38) hide show
  1. package/agent-inner-guide.md +25 -0
  2. package/index.js +1 -1
  3. package/openclaw.plugin.json +1 -1
  4. package/package.json +1 -1
  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 +6 -0
  9. package/runtime/cli/ops/heartbeat-surface.js +2 -0
  10. package/runtime/cli/ops/ops-router.js +101 -1
  11. package/runtime/cli/ops/workspace-heartbeat-runner.d.ts +24 -0
  12. package/runtime/cli/ops/workspace-heartbeat-runner.js +42 -1
  13. package/runtime/connectors/base/contract.d.ts +10 -0
  14. package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +7 -1
  15. package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +25 -0
  16. package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +5 -0
  17. package/runtime/core/second-nature/heartbeat/runtime-snapshot.js +10 -1
  18. package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +5 -0
  19. package/runtime/core/second-nature/orchestrator/guard-layer.js +24 -1
  20. package/runtime/core/second-nature/quiet/run-source-backed-quiet.d.ts +20 -0
  21. package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +32 -2
  22. package/runtime/guidance/capability-class.d.ts +38 -0
  23. package/runtime/guidance/capability-class.js +65 -0
  24. package/runtime/guidance/guidance-assembler.d.ts +2 -0
  25. package/runtime/guidance/guidance-assembler.js +16 -4
  26. package/runtime/guidance/guidance-draft-service.js +5 -5
  27. package/runtime/guidance/impulse-assembler.d.ts +71 -0
  28. package/runtime/guidance/impulse-assembler.js +103 -0
  29. package/runtime/guidance/index.d.ts +2 -0
  30. package/runtime/guidance/index.js +2 -0
  31. package/runtime/guidance/outreach-strategy-selector.d.ts +13 -0
  32. package/runtime/guidance/outreach-strategy-selector.js +2 -2
  33. package/runtime/guidance/template-registry.d.ts +15 -2
  34. package/runtime/guidance/template-registry.js +38 -1
  35. package/runtime/guidance/types.d.ts +13 -1
  36. package/runtime/storage/goal/agent-goal-store.d.ts +2 -0
  37. package/runtime/storage/goal/agent-goal-store.js +28 -1
  38. package/runtime/storage/services/tool-experience-store.js +11 -11
@@ -12,6 +12,7 @@ function rowToGoal(row) {
12
12
  return {
13
13
  goalId: row.goalId,
14
14
  kind: row.kind,
15
+ scope: row.scope ?? undefined,
15
16
  status: row.status,
16
17
  origin: row.origin,
17
18
  description: row.description,
@@ -28,6 +29,21 @@ export function createAgentGoalStore(database) {
28
29
  const db = database.db;
29
30
  return {
30
31
  async upsertAgentGoal(goal) {
32
+ // T-V7C.C.4: dedupe — same kind+scope accepted goals → mark old as replaced
33
+ if (goal.status === "accepted") {
34
+ const oldGoals = await db
35
+ .select()
36
+ .from(agentGoal)
37
+ .where(and(eq(agentGoal.kind, goal.kind), eq(agentGoal.scope, goal.scope ?? "global"), eq(agentGoal.status, "accepted")));
38
+ for (const old of oldGoals) {
39
+ if (old.goalId !== goal.goalId) {
40
+ await db
41
+ .update(agentGoal)
42
+ .set({ status: "replaced", updatedAt: goal.updatedAt })
43
+ .where(eq(agentGoal.goalId, old.goalId));
44
+ }
45
+ }
46
+ }
31
47
  const existing = await db
32
48
  .select()
33
49
  .from(agentGoal)
@@ -38,6 +54,7 @@ export function createAgentGoalStore(database) {
38
54
  .update(agentGoal)
39
55
  .set({
40
56
  kind: goal.kind,
57
+ scope: goal.scope ?? "global",
41
58
  status: goal.status,
42
59
  origin: goal.origin,
43
60
  description: goal.description,
@@ -54,6 +71,7 @@ export function createAgentGoalStore(database) {
54
71
  await db.insert(agentGoal).values({
55
72
  goalId: goal.goalId,
56
73
  kind: goal.kind,
74
+ scope: goal.scope ?? "global",
57
75
  status: goal.status,
58
76
  origin: goal.origin,
59
77
  description: goal.description,
@@ -82,7 +100,16 @@ export function createAgentGoalStore(database) {
82
100
  .where(conditions.length > 0 ? and(...conditions) : undefined)
83
101
  .orderBy(desc(agentGoal.updatedAt))
84
102
  .limit(query.limit ?? 100);
85
- return rows.map(rowToGoal);
103
+ // T-V7C.C.4: dedupe by kind+scope — keep newest (rows already sorted by updatedAt desc)
104
+ const seen = new Map();
105
+ for (const row of rows) {
106
+ const goal = rowToGoal(row);
107
+ const key = `${goal.kind}:${goal.scope ?? "global"}`;
108
+ if (!seen.has(key)) {
109
+ seen.set(key, goal);
110
+ }
111
+ }
112
+ return Array.from(seen.values());
86
113
  },
87
114
  async transitionGoalStatus(input) {
88
115
  await db
@@ -78,17 +78,17 @@ export function createCapabilityProbeResultStore(database) {
78
78
  const { sqlite } = database;
79
79
  return {
80
80
  async appendProbeResult(result) {
81
- sqlite.run(`INSERT INTO capability_probe_result
82
- (probe_result_id, capability_id, connector_id, actual_status,
83
- http_status, sample_response_ref, probe_config_ref, created_at)
84
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
85
- ON CONFLICT(probe_result_id) DO UPDATE SET
86
- capability_id = excluded.capability_id,
87
- connector_id = excluded.connector_id,
88
- actual_status = excluded.actual_status,
89
- http_status = excluded.http_status,
90
- sample_response_ref = excluded.sample_response_ref,
91
- probe_config_ref = excluded.probe_config_ref,
81
+ sqlite.run(`INSERT INTO capability_probe_result
82
+ (probe_result_id, capability_id, connector_id, actual_status,
83
+ http_status, sample_response_ref, probe_config_ref, created_at)
84
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
85
+ ON CONFLICT(probe_result_id) DO UPDATE SET
86
+ capability_id = excluded.capability_id,
87
+ connector_id = excluded.connector_id,
88
+ actual_status = excluded.actual_status,
89
+ http_status = excluded.http_status,
90
+ sample_response_ref = excluded.sample_response_ref,
91
+ probe_config_ref = excluded.probe_config_ref,
92
92
  created_at = excluded.created_at`, [
93
93
  result.probeResultId,
94
94
  result.capabilityId,