@haaaiawd/second-nature 0.1.39 → 0.1.40
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/index.js +1270 -1270
- package/openclaw.plugin.json +29 -29
- package/package.json +55 -55
- package/runtime/cli/commands/connector-init.js +11 -4
- package/runtime/cli/index.js +6 -1
- package/runtime/cli/ops/heartbeat-surface.d.ts +75 -75
- package/runtime/cli/ops/heartbeat-surface.js +97 -97
- package/runtime/cli/ops/ops-router.js +1428 -1428
- package/runtime/cli/ops/workspace-heartbeat-runner.js +236 -236
- package/runtime/connectors/services/connector-executor-adapter.js +192 -41
- package/runtime/core/second-nature/guidance/apply-guidance.d.ts +12 -12
- package/runtime/core/second-nature/guidance/apply-guidance.js +15 -15
- package/runtime/core/second-nature/guidance/user-reply-continuity.d.ts +50 -50
- package/runtime/core/second-nature/guidance/user-reply-continuity.js +89 -89
- package/runtime/core/second-nature/orchestrator/intent-planner.js +15 -0
- package/runtime/core/second-nature/runtime/service-entry.d.ts +39 -39
- package/runtime/core/second-nature/runtime/service-entry.js +44 -44
- package/runtime/dream/dream-engine.d.ts +14 -14
- package/runtime/dream/dream-engine.js +306 -306
- package/runtime/dream/dream-input-loader.d.ts +37 -37
- package/runtime/dream/dream-input-loader.js +150 -150
- package/runtime/dream/dream-scheduler.d.ts +75 -75
- package/runtime/dream/dream-scheduler.js +131 -131
- package/runtime/dream/index.d.ts +16 -16
- package/runtime/dream/index.js +14 -14
- package/runtime/dream/insight-extractor.d.ts +32 -32
- package/runtime/dream/insight-extractor.js +135 -135
- package/runtime/dream/memory-consolidator.d.ts +45 -45
- package/runtime/dream/memory-consolidator.js +140 -140
- package/runtime/dream/narrative-update-proposal.d.ts +34 -34
- package/runtime/dream/narrative-update-proposal.js +83 -83
- package/runtime/dream/output-validator.d.ts +20 -20
- package/runtime/dream/output-validator.js +110 -110
- package/runtime/dream/redaction-gate.d.ts +31 -31
- package/runtime/dream/redaction-gate.js +109 -109
- package/runtime/dream/relationship-update-proposal.d.ts +27 -27
- package/runtime/dream/relationship-update-proposal.js +119 -119
- package/runtime/dream/sampler.d.ts +30 -30
- package/runtime/dream/sampler.js +65 -65
- package/runtime/dream/types.d.ts +187 -187
- package/runtime/dream/types.js +11 -11
- package/runtime/guidance/fallback.js +20 -20
- package/runtime/guidance/guidance-assembler.js +76 -76
- package/runtime/guidance/output-guard.d.ts +13 -13
- package/runtime/guidance/output-guard.js +53 -53
- package/runtime/guidance/template-registry.d.ts +20 -20
- package/runtime/guidance/template-registry.js +93 -93
- package/runtime/guidance/types.d.ts +98 -98
- package/runtime/observability/projections/guidance-audit.js +38 -38
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dream Scheduler
|
|
3
|
-
*
|
|
4
|
-
* Core logic: trigger Dream runs via cron schedule, evidence threshold, or manual
|
|
5
|
-
* request. Uses DreamRunLock to prevent concurrent runs on the same workspace/input
|
|
6
|
-
* window. Operator timeout is enforced via options in the engine call.
|
|
7
|
-
*
|
|
8
|
-
* - Cron: simplified — checks if a scheduled window is due (last run + interval).
|
|
9
|
-
* - Evidence threshold: triggers when evidence count exceeds threshold since last run.
|
|
10
|
-
* - Manual: always allowed if no active lock.
|
|
11
|
-
* - Lock: in-memory or port-backed; released after run completes or times out.
|
|
12
|
-
* Test coverage: tests/integration/dream/t7-1-2-dream-scheduler.test.ts
|
|
13
|
-
*/
|
|
14
|
-
import { runDream } from "./dream-engine.js";
|
|
15
|
-
const DEFAULT_LOCK_TTL_MS = 35 * 60 * 1000; // 35 min (covers 30 min operator timeout + buffer)
|
|
16
|
-
// In-memory lock fallback when no lockPort is provided
|
|
17
|
-
export function memoryLockPort() {
|
|
18
|
-
const locks = new Map();
|
|
19
|
-
return {
|
|
20
|
-
async acquireLock(input) {
|
|
21
|
-
const key = input.windowKey;
|
|
22
|
-
const existing = locks.get(key);
|
|
23
|
-
if (existing && existing.expiresAt > Date.now()) {
|
|
24
|
-
return { acquired: false, existingRunId: existing.runId };
|
|
25
|
-
}
|
|
26
|
-
locks.set(key, {
|
|
27
|
-
runId: input.runId,
|
|
28
|
-
expiresAt: Date.now() + input.ttlMs,
|
|
29
|
-
});
|
|
30
|
-
return { acquired: true };
|
|
31
|
-
},
|
|
32
|
-
async releaseLock(input) {
|
|
33
|
-
const key = input.windowKey;
|
|
34
|
-
const existing = locks.get(key);
|
|
35
|
-
if (existing && existing.runId === input.runId) {
|
|
36
|
-
locks.delete(key);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export async function scheduleDream(input) {
|
|
42
|
-
const lock = input.lockPort ?? memoryLockPort();
|
|
43
|
-
const windowKey = input.windowKey ?? "dream_lock:default";
|
|
44
|
-
// Acquire lock
|
|
45
|
-
const lockResult = await lock.acquireLock({
|
|
46
|
-
runId: input.runId,
|
|
47
|
-
windowKey,
|
|
48
|
-
ttlMs: DEFAULT_LOCK_TTL_MS,
|
|
49
|
-
});
|
|
50
|
-
if (!lockResult.acquired) {
|
|
51
|
-
const reason = input.triggerKind === "quiet_completion"
|
|
52
|
-
? "skip:lock_held"
|
|
53
|
-
: `lock_held_by:${lockResult.existingRunId ?? "unknown"}`;
|
|
54
|
-
return {
|
|
55
|
-
runId: input.runId,
|
|
56
|
-
status: "skipped",
|
|
57
|
-
reason,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Run Dream asynchronously; do not await so heartbeat is not blocked
|
|
61
|
-
runDream({
|
|
62
|
-
runId: input.runId,
|
|
63
|
-
traceId: input.traceId,
|
|
64
|
-
triggerKind: input.triggerKind,
|
|
65
|
-
statePort: input.statePort,
|
|
66
|
-
modelPort: input.modelPort,
|
|
67
|
-
modelAssistPort: input.modelAssistPort,
|
|
68
|
-
tracePort: input.tracePort,
|
|
69
|
-
budgetPort: input.budgetPort,
|
|
70
|
-
options: input.options,
|
|
71
|
-
})
|
|
72
|
-
.then(async (result) => {
|
|
73
|
-
await lock.releaseLock({ runId: input.runId, windowKey });
|
|
74
|
-
return result;
|
|
75
|
-
})
|
|
76
|
-
.catch(async (err) => {
|
|
77
|
-
console.error("[dream-scheduler] runDream failed:", err);
|
|
78
|
-
await lock.releaseLock({ runId: input.runId, windowKey });
|
|
79
|
-
});
|
|
80
|
-
return {
|
|
81
|
-
runId: input.runId,
|
|
82
|
-
status: "started",
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function isHourInWindow(hour, start, end) {
|
|
86
|
-
if (start < end) {
|
|
87
|
-
return hour >= start && hour < end;
|
|
88
|
-
}
|
|
89
|
-
return hour >= start || hour < end;
|
|
90
|
-
}
|
|
91
|
-
export function shouldTrigger(policy) {
|
|
92
|
-
switch (policy.type) {
|
|
93
|
-
case "cron": {
|
|
94
|
-
if (!policy.lastRunAt) {
|
|
95
|
-
return { shouldRun: true, reason: "first_run" };
|
|
96
|
-
}
|
|
97
|
-
const last = new Date(policy.lastRunAt).getTime();
|
|
98
|
-
const next = last + policy.intervalHours * 60 * 60 * 1000;
|
|
99
|
-
if (Date.now() >= next) {
|
|
100
|
-
return { shouldRun: true, reason: "cron_due" };
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
shouldRun: false,
|
|
104
|
-
reason: `next_run_at:${new Date(next).toISOString()}`,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
case "evidence_threshold": {
|
|
108
|
-
const delta = policy.currentEvidenceCount - policy.lastRunEvidenceCount;
|
|
109
|
-
if (delta >= policy.threshold) {
|
|
110
|
-
return {
|
|
111
|
-
shouldRun: true,
|
|
112
|
-
reason: `threshold_reached:${delta}/${policy.threshold}`,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
shouldRun: false,
|
|
117
|
-
reason: `below_threshold:${delta}/${policy.threshold}`,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
case "manual": {
|
|
121
|
-
return { shouldRun: true, reason: "manual_trigger" };
|
|
122
|
-
}
|
|
123
|
-
case "quiet_completion": {
|
|
124
|
-
const hour = new Date(policy.quietCompletedAt).getUTCHours();
|
|
125
|
-
if (isHourInWindow(hour, policy.windowStartHour, policy.windowEndHour)) {
|
|
126
|
-
return { shouldRun: true, reason: "quiet_completion_in_window" };
|
|
127
|
-
}
|
|
128
|
-
return { shouldRun: false, reason: "skip:out_of_window" };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Dream Scheduler
|
|
3
|
+
*
|
|
4
|
+
* Core logic: trigger Dream runs via cron schedule, evidence threshold, or manual
|
|
5
|
+
* request. Uses DreamRunLock to prevent concurrent runs on the same workspace/input
|
|
6
|
+
* window. Operator timeout is enforced via options in the engine call.
|
|
7
|
+
*
|
|
8
|
+
* - Cron: simplified — checks if a scheduled window is due (last run + interval).
|
|
9
|
+
* - Evidence threshold: triggers when evidence count exceeds threshold since last run.
|
|
10
|
+
* - Manual: always allowed if no active lock.
|
|
11
|
+
* - Lock: in-memory or port-backed; released after run completes or times out.
|
|
12
|
+
* Test coverage: tests/integration/dream/t7-1-2-dream-scheduler.test.ts
|
|
13
|
+
*/
|
|
14
|
+
import { runDream } from "./dream-engine.js";
|
|
15
|
+
const DEFAULT_LOCK_TTL_MS = 35 * 60 * 1000; // 35 min (covers 30 min operator timeout + buffer)
|
|
16
|
+
// In-memory lock fallback when no lockPort is provided
|
|
17
|
+
export function memoryLockPort() {
|
|
18
|
+
const locks = new Map();
|
|
19
|
+
return {
|
|
20
|
+
async acquireLock(input) {
|
|
21
|
+
const key = input.windowKey;
|
|
22
|
+
const existing = locks.get(key);
|
|
23
|
+
if (existing && existing.expiresAt > Date.now()) {
|
|
24
|
+
return { acquired: false, existingRunId: existing.runId };
|
|
25
|
+
}
|
|
26
|
+
locks.set(key, {
|
|
27
|
+
runId: input.runId,
|
|
28
|
+
expiresAt: Date.now() + input.ttlMs,
|
|
29
|
+
});
|
|
30
|
+
return { acquired: true };
|
|
31
|
+
},
|
|
32
|
+
async releaseLock(input) {
|
|
33
|
+
const key = input.windowKey;
|
|
34
|
+
const existing = locks.get(key);
|
|
35
|
+
if (existing && existing.runId === input.runId) {
|
|
36
|
+
locks.delete(key);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export async function scheduleDream(input) {
|
|
42
|
+
const lock = input.lockPort ?? memoryLockPort();
|
|
43
|
+
const windowKey = input.windowKey ?? "dream_lock:default";
|
|
44
|
+
// Acquire lock
|
|
45
|
+
const lockResult = await lock.acquireLock({
|
|
46
|
+
runId: input.runId,
|
|
47
|
+
windowKey,
|
|
48
|
+
ttlMs: DEFAULT_LOCK_TTL_MS,
|
|
49
|
+
});
|
|
50
|
+
if (!lockResult.acquired) {
|
|
51
|
+
const reason = input.triggerKind === "quiet_completion"
|
|
52
|
+
? "skip:lock_held"
|
|
53
|
+
: `lock_held_by:${lockResult.existingRunId ?? "unknown"}`;
|
|
54
|
+
return {
|
|
55
|
+
runId: input.runId,
|
|
56
|
+
status: "skipped",
|
|
57
|
+
reason,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Run Dream asynchronously; do not await so heartbeat is not blocked
|
|
61
|
+
runDream({
|
|
62
|
+
runId: input.runId,
|
|
63
|
+
traceId: input.traceId,
|
|
64
|
+
triggerKind: input.triggerKind,
|
|
65
|
+
statePort: input.statePort,
|
|
66
|
+
modelPort: input.modelPort,
|
|
67
|
+
modelAssistPort: input.modelAssistPort,
|
|
68
|
+
tracePort: input.tracePort,
|
|
69
|
+
budgetPort: input.budgetPort,
|
|
70
|
+
options: input.options,
|
|
71
|
+
})
|
|
72
|
+
.then(async (result) => {
|
|
73
|
+
await lock.releaseLock({ runId: input.runId, windowKey });
|
|
74
|
+
return result;
|
|
75
|
+
})
|
|
76
|
+
.catch(async (err) => {
|
|
77
|
+
console.error("[dream-scheduler] runDream failed:", err);
|
|
78
|
+
await lock.releaseLock({ runId: input.runId, windowKey });
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
runId: input.runId,
|
|
82
|
+
status: "started",
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function isHourInWindow(hour, start, end) {
|
|
86
|
+
if (start < end) {
|
|
87
|
+
return hour >= start && hour < end;
|
|
88
|
+
}
|
|
89
|
+
return hour >= start || hour < end;
|
|
90
|
+
}
|
|
91
|
+
export function shouldTrigger(policy) {
|
|
92
|
+
switch (policy.type) {
|
|
93
|
+
case "cron": {
|
|
94
|
+
if (!policy.lastRunAt) {
|
|
95
|
+
return { shouldRun: true, reason: "first_run" };
|
|
96
|
+
}
|
|
97
|
+
const last = new Date(policy.lastRunAt).getTime();
|
|
98
|
+
const next = last + policy.intervalHours * 60 * 60 * 1000;
|
|
99
|
+
if (Date.now() >= next) {
|
|
100
|
+
return { shouldRun: true, reason: "cron_due" };
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
shouldRun: false,
|
|
104
|
+
reason: `next_run_at:${new Date(next).toISOString()}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
case "evidence_threshold": {
|
|
108
|
+
const delta = policy.currentEvidenceCount - policy.lastRunEvidenceCount;
|
|
109
|
+
if (delta >= policy.threshold) {
|
|
110
|
+
return {
|
|
111
|
+
shouldRun: true,
|
|
112
|
+
reason: `threshold_reached:${delta}/${policy.threshold}`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
shouldRun: false,
|
|
117
|
+
reason: `below_threshold:${delta}/${policy.threshold}`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
case "manual": {
|
|
121
|
+
return { shouldRun: true, reason: "manual_trigger" };
|
|
122
|
+
}
|
|
123
|
+
case "quiet_completion": {
|
|
124
|
+
const hour = new Date(policy.quietCompletedAt).getUTCHours();
|
|
125
|
+
if (isHourInWindow(hour, policy.windowStartHour, policy.windowEndHour)) {
|
|
126
|
+
return { shouldRun: true, reason: "quiet_completion_in_window" };
|
|
127
|
+
}
|
|
128
|
+
return { shouldRun: false, reason: "skip:out_of_window" };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
package/runtime/dream/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dream System public API.
|
|
3
|
-
*/
|
|
4
|
-
export * from "./types.js";
|
|
5
|
-
export { consolidateMemory } from "./memory-consolidator.js";
|
|
6
|
-
export { sampleDreamInput } from "./sampler.js";
|
|
7
|
-
export { redactDreamInput, redactBundle } from "./redaction-gate.js";
|
|
8
|
-
export { validateDreamOutput } from "./output-validator.js";
|
|
9
|
-
export { runDream } from "./dream-engine.js";
|
|
10
|
-
export { scheduleDream, shouldTrigger, memoryLockPort } from "./dream-scheduler.js";
|
|
11
|
-
export type { SchedulerInput, DreamRunLockPort, ScheduleResult, CronPolicy, EvidenceThresholdPolicy, ManualPolicy, QuietCompletionPolicy, TriggerPolicy } from "./dream-scheduler.js";
|
|
12
|
-
export { extractInsights } from "./insight-extractor.js";
|
|
13
|
-
export { draftNarrativeFromDream } from "./narrative-update-proposal.js";
|
|
14
|
-
export { draftRelationshipFromDream } from "./relationship-update-proposal.js";
|
|
15
|
-
export { createDreamInputLoader } from "./dream-input-loader.js";
|
|
16
|
-
export type { DreamInputLoaderOptions } from "./dream-input-loader.js";
|
|
1
|
+
/**
|
|
2
|
+
* Dream System public API.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export { consolidateMemory } from "./memory-consolidator.js";
|
|
6
|
+
export { sampleDreamInput } from "./sampler.js";
|
|
7
|
+
export { redactDreamInput, redactBundle } from "./redaction-gate.js";
|
|
8
|
+
export { validateDreamOutput } from "./output-validator.js";
|
|
9
|
+
export { runDream } from "./dream-engine.js";
|
|
10
|
+
export { scheduleDream, shouldTrigger, memoryLockPort } from "./dream-scheduler.js";
|
|
11
|
+
export type { SchedulerInput, DreamRunLockPort, ScheduleResult, CronPolicy, EvidenceThresholdPolicy, ManualPolicy, QuietCompletionPolicy, TriggerPolicy } from "./dream-scheduler.js";
|
|
12
|
+
export { extractInsights } from "./insight-extractor.js";
|
|
13
|
+
export { draftNarrativeFromDream } from "./narrative-update-proposal.js";
|
|
14
|
+
export { draftRelationshipFromDream } from "./relationship-update-proposal.js";
|
|
15
|
+
export { createDreamInputLoader } from "./dream-input-loader.js";
|
|
16
|
+
export type { DreamInputLoaderOptions } from "./dream-input-loader.js";
|
package/runtime/dream/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dream System public API.
|
|
3
|
-
*/
|
|
4
|
-
export * from "./types.js";
|
|
5
|
-
export { consolidateMemory } from "./memory-consolidator.js";
|
|
6
|
-
export { sampleDreamInput } from "./sampler.js";
|
|
7
|
-
export { redactDreamInput, redactBundle } from "./redaction-gate.js";
|
|
8
|
-
export { validateDreamOutput } from "./output-validator.js";
|
|
9
|
-
export { runDream } from "./dream-engine.js";
|
|
10
|
-
export { scheduleDream, shouldTrigger, memoryLockPort } from "./dream-scheduler.js";
|
|
11
|
-
export { extractInsights } from "./insight-extractor.js";
|
|
12
|
-
export { draftNarrativeFromDream } from "./narrative-update-proposal.js";
|
|
13
|
-
export { draftRelationshipFromDream } from "./relationship-update-proposal.js";
|
|
14
|
-
export { createDreamInputLoader } from "./dream-input-loader.js";
|
|
1
|
+
/**
|
|
2
|
+
* Dream System public API.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export { consolidateMemory } from "./memory-consolidator.js";
|
|
6
|
+
export { sampleDreamInput } from "./sampler.js";
|
|
7
|
+
export { redactDreamInput, redactBundle } from "./redaction-gate.js";
|
|
8
|
+
export { validateDreamOutput } from "./output-validator.js";
|
|
9
|
+
export { runDream } from "./dream-engine.js";
|
|
10
|
+
export { scheduleDream, shouldTrigger, memoryLockPort } from "./dream-scheduler.js";
|
|
11
|
+
export { extractInsights } from "./insight-extractor.js";
|
|
12
|
+
export { draftNarrativeFromDream } from "./narrative-update-proposal.js";
|
|
13
|
+
export { draftRelationshipFromDream } from "./relationship-update-proposal.js";
|
|
14
|
+
export { createDreamInputLoader } from "./dream-input-loader.js";
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Insight Extractor
|
|
3
|
-
*
|
|
4
|
-
* Core logic: extract source-grounded insight candidates from sampled evidence.
|
|
5
|
-
* Rules-based (no LLM required) using keyword patterns, frequency counts, and
|
|
6
|
-
* temporal clustering. Each insight carries type, summary, sourceRefs, and confidence.
|
|
7
|
-
*
|
|
8
|
-
* - Pattern: recurring themes across multiple evidence entries.
|
|
9
|
-
* - Learning: new skills or behaviors observed over time.
|
|
10
|
-
* - Observation: one-off notable events.
|
|
11
|
-
* - Conflict: contradictory claims or repeated failures.
|
|
12
|
-
* Test coverage: tests/unit/dream/t7-1-3-insight-extraction.test.ts
|
|
13
|
-
*/
|
|
14
|
-
import type { DreamInsight } from "./types.js";
|
|
15
|
-
export interface ExtractInsightsInput {
|
|
16
|
-
evidenceSummaries: Array<{
|
|
17
|
-
id: string;
|
|
18
|
-
summary: string;
|
|
19
|
-
createdAt: string;
|
|
20
|
-
kind?: string;
|
|
21
|
-
}>;
|
|
22
|
-
chronicleSummaries: Array<{
|
|
23
|
-
id: string;
|
|
24
|
-
summary: string;
|
|
25
|
-
createdAt: string;
|
|
26
|
-
}>;
|
|
27
|
-
redacted?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export declare function extractInsights(input: ExtractInsightsInput): {
|
|
30
|
-
insights: DreamInsight[];
|
|
31
|
-
unsupportedClaims: string[];
|
|
32
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Insight Extractor
|
|
3
|
+
*
|
|
4
|
+
* Core logic: extract source-grounded insight candidates from sampled evidence.
|
|
5
|
+
* Rules-based (no LLM required) using keyword patterns, frequency counts, and
|
|
6
|
+
* temporal clustering. Each insight carries type, summary, sourceRefs, and confidence.
|
|
7
|
+
*
|
|
8
|
+
* - Pattern: recurring themes across multiple evidence entries.
|
|
9
|
+
* - Learning: new skills or behaviors observed over time.
|
|
10
|
+
* - Observation: one-off notable events.
|
|
11
|
+
* - Conflict: contradictory claims or repeated failures.
|
|
12
|
+
* Test coverage: tests/unit/dream/t7-1-3-insight-extraction.test.ts
|
|
13
|
+
*/
|
|
14
|
+
import type { DreamInsight } from "./types.js";
|
|
15
|
+
export interface ExtractInsightsInput {
|
|
16
|
+
evidenceSummaries: Array<{
|
|
17
|
+
id: string;
|
|
18
|
+
summary: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
kind?: string;
|
|
21
|
+
}>;
|
|
22
|
+
chronicleSummaries: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
summary: string;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}>;
|
|
27
|
+
redacted?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function extractInsights(input: ExtractInsightsInput): {
|
|
30
|
+
insights: DreamInsight[];
|
|
31
|
+
unsupportedClaims: string[];
|
|
32
|
+
};
|