@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.
- package/agent-inner-guide.md +25 -0
- package/index.js +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/runtime/cli/commands/goal.d.ts +1 -0
- package/runtime/cli/commands/goal.js +1 -0
- package/runtime/cli/index.js +3 -3
- package/runtime/cli/ops/heartbeat-surface.d.ts +6 -0
- package/runtime/cli/ops/heartbeat-surface.js +2 -0
- package/runtime/cli/ops/ops-router.js +101 -1
- package/runtime/cli/ops/workspace-heartbeat-runner.d.ts +24 -0
- package/runtime/cli/ops/workspace-heartbeat-runner.js +42 -1
- package/runtime/connectors/base/contract.d.ts +10 -0
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +7 -1
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +25 -0
- package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +5 -0
- package/runtime/core/second-nature/heartbeat/runtime-snapshot.js +10 -1
- package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +5 -0
- package/runtime/core/second-nature/orchestrator/guard-layer.js +24 -1
- package/runtime/core/second-nature/quiet/run-source-backed-quiet.d.ts +20 -0
- package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +32 -2
- package/runtime/guidance/capability-class.d.ts +38 -0
- package/runtime/guidance/capability-class.js +65 -0
- package/runtime/guidance/guidance-assembler.d.ts +2 -0
- package/runtime/guidance/guidance-assembler.js +16 -4
- package/runtime/guidance/guidance-draft-service.js +5 -5
- package/runtime/guidance/impulse-assembler.d.ts +71 -0
- package/runtime/guidance/impulse-assembler.js +103 -0
- package/runtime/guidance/index.d.ts +2 -0
- package/runtime/guidance/index.js +2 -0
- package/runtime/guidance/outreach-strategy-selector.d.ts +13 -0
- package/runtime/guidance/outreach-strategy-selector.js +2 -2
- package/runtime/guidance/template-registry.d.ts +15 -2
- package/runtime/guidance/template-registry.js +38 -1
- package/runtime/guidance/types.d.ts +13 -1
- package/runtime/storage/goal/agent-goal-store.d.ts +2 -0
- package/runtime/storage/goal/agent-goal-store.js +28 -1
- 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
|
-
|
|
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,
|