@oharness/engine 0.11.0 → 0.14.0
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/dist/agent/agent.d.ts +3 -0
- package/dist/agent/agent.js +32 -12
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/background-usage.d.ts +34 -0
- package/dist/agent/background-usage.js +53 -0
- package/dist/agent/background-usage.js.map +1 -0
- package/dist/agent/background.d.ts +2 -0
- package/dist/agent/background.js +11 -0
- package/dist/agent/background.js.map +1 -1
- package/dist/agent/memory-backup.d.ts +1 -1
- package/dist/agent/memory-backup.js +1 -1
- package/dist/agent/memory-backup.js.map +1 -1
- package/dist/agent/memory-digest.d.ts +107 -0
- package/dist/agent/memory-digest.js +208 -0
- package/dist/agent/memory-digest.js.map +1 -0
- package/dist/agent/memory-dream.d.ts +106 -0
- package/dist/agent/memory-dream.js +237 -0
- package/dist/agent/memory-dream.js.map +1 -0
- package/dist/agent/memory-ledger.d.ts +154 -0
- package/dist/agent/memory-ledger.js +179 -0
- package/dist/agent/memory-ledger.js.map +1 -0
- package/dist/agent/memory-provider.d.ts +12 -0
- package/dist/agent/memory-recall.d.ts +2 -0
- package/dist/agent/memory-recall.js +5 -2
- package/dist/agent/memory-recall.js.map +1 -1
- package/dist/agent/memory-usage.d.ts +20 -0
- package/dist/agent/memory-usage.js +16 -1
- package/dist/agent/memory-usage.js.map +1 -1
- package/dist/agent/memory.d.ts +3 -0
- package/dist/agent/memory.js +24 -4
- package/dist/agent/memory.js.map +1 -1
- package/dist/agent/skills.d.ts +16 -3
- package/dist/agent/skills.js +36 -2
- package/dist/agent/skills.js.map +1 -1
- package/dist/agent/store.d.ts +7 -0
- package/dist/agent/store.js +14 -1
- package/dist/agent/store.js.map +1 -1
- package/dist/agent/subagent.d.ts +15 -2
- package/dist/agent/subagent.js +70 -16
- package/dist/agent/subagent.js.map +1 -1
- package/dist/config-files.d.ts +6 -1
- package/dist/config-files.js +7 -2
- package/dist/config-files.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/foreign.d.ts +81 -0
- package/dist/foreign.js +198 -0
- package/dist/foreign.js.map +1 -0
- package/dist/harness.d.ts +47 -0
- package/dist/harness.js +186 -13
- package/dist/harness.js.map +1 -1
- package/dist/mcp/registry.d.ts +2 -0
- package/dist/mcp/registry.js +1 -0
- package/dist/mcp/registry.js.map +1 -1
- package/dist/mcp/registry.json +394 -1
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +38 -0
- package/dist/paths.js.map +1 -1
- package/dist/plugin-market.d.ts +57 -0
- package/dist/plugin-market.js +229 -0
- package/dist/plugin-market.js.map +1 -0
- package/dist/plugin-market.json +1246 -0
- package/dist/plugins.d.ts +49 -2
- package/dist/plugins.js +252 -10
- package/dist/plugins.js.map +1 -1
- package/dist/runtime-plugins/builtin/dreaming-coordinator.d.ts +244 -0
- package/dist/runtime-plugins/builtin/dreaming-coordinator.js +548 -0
- package/dist/runtime-plugins/builtin/dreaming-coordinator.js.map +1 -0
- package/dist/runtime-plugins/builtin/dreaming.d.ts +30 -0
- package/dist/runtime-plugins/builtin/dreaming.js +231 -0
- package/dist/runtime-plugins/builtin/dreaming.js.map +1 -0
- package/dist/runtime-plugins/builtin/memory.d.ts +89 -2
- package/dist/runtime-plugins/builtin/memory.js +186 -5
- package/dist/runtime-plugins/builtin/memory.js.map +1 -1
- package/dist/runtime-plugins/host.js +2 -0
- package/dist/runtime-plugins/host.js.map +1 -1
- package/dist/util/toml.d.ts +22 -0
- package/dist/util/toml.js +305 -0
- package/dist/util/toml.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { Message } from "../../core/types.ts";
|
|
2
|
+
import type { DreamNote, DreamOp } from "../../agent/memory-dream.ts";
|
|
3
|
+
import { DreamStore } from "../../agent/memory-ledger.ts";
|
|
4
|
+
import type { AppliedChange, EvidenceSnapshot } from "../../agent/memory-ledger.ts";
|
|
5
|
+
import type { ExtractedSummary } from "../../agent/memory-provider.ts";
|
|
6
|
+
import type { DreamChange, DreamCommitted } from "./memory.ts";
|
|
7
|
+
import type { MemoryScope } from "../../agent/memory-limits.ts";
|
|
8
|
+
import { RoutineLock } from "../../schedule/lock.ts";
|
|
9
|
+
import type { Logger } from "../../util/logger.ts";
|
|
10
|
+
/**
|
|
11
|
+
* When dreaming happens, for a whole process.
|
|
12
|
+
*
|
|
13
|
+
* A local server opens a harness per project, and each has a `dreaming`
|
|
14
|
+
* plugin. They all register here, so there is one tick, one budget and one
|
|
15
|
+
* pass over the user's own notes, however many projects are open. Across
|
|
16
|
+
* processes, a lock file decides which one ticks.
|
|
17
|
+
*
|
|
18
|
+
* Each tick, in order: digest due conversations, then dream each scope that
|
|
19
|
+
* has gathered enough claims and has not dreamed today. A dream writes what
|
|
20
|
+
* may be applied without asking through memory's commit path, and records the
|
|
21
|
+
* rest as suggestions for a person.
|
|
22
|
+
*/
|
|
23
|
+
export interface DreamingSettings {
|
|
24
|
+
/** Whether passes run on their own: always, never, or for paid plans. */
|
|
25
|
+
auto: boolean | "subscribers";
|
|
26
|
+
idleHours: number;
|
|
27
|
+
minUserTurns: number;
|
|
28
|
+
startDelayMinutes: number;
|
|
29
|
+
minClaims: number;
|
|
30
|
+
maxWaitHours: number;
|
|
31
|
+
maxClaims: number;
|
|
32
|
+
/** Model tokens a day, estimated at four characters each. */
|
|
33
|
+
dailyTokens: number;
|
|
34
|
+
}
|
|
35
|
+
export declare const DEFAULT_DREAMING: DreamingSettings;
|
|
36
|
+
export interface DreamSessions {
|
|
37
|
+
list(): Promise<Array<{
|
|
38
|
+
id: string;
|
|
39
|
+
routine?: string;
|
|
40
|
+
updatedAt: number;
|
|
41
|
+
}>>;
|
|
42
|
+
records(id: string): Promise<Array<{
|
|
43
|
+
message: Message;
|
|
44
|
+
device: string;
|
|
45
|
+
}>>;
|
|
46
|
+
archive(id: string): Promise<Message[]>;
|
|
47
|
+
/** This machine, as the session store names it in records. */
|
|
48
|
+
device(): Promise<string>;
|
|
49
|
+
}
|
|
50
|
+
export interface GenerateReply {
|
|
51
|
+
text: string;
|
|
52
|
+
model: string;
|
|
53
|
+
usage: {
|
|
54
|
+
inputTokens: number;
|
|
55
|
+
outputTokens: number;
|
|
56
|
+
cacheReadTokens?: number;
|
|
57
|
+
cacheWriteTokens?: number;
|
|
58
|
+
};
|
|
59
|
+
costUsd: number;
|
|
60
|
+
}
|
|
61
|
+
/** What one run spent on the model. */
|
|
62
|
+
interface Meter {
|
|
63
|
+
calls: number;
|
|
64
|
+
input: number;
|
|
65
|
+
output: number;
|
|
66
|
+
costUsd: number;
|
|
67
|
+
model?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface DreamTarget {
|
|
70
|
+
/** The project's id. */
|
|
71
|
+
projectId: string;
|
|
72
|
+
sessions: DreamSessions;
|
|
73
|
+
/** Every note in a scope, as the dream sees it; absent when the scope is. */
|
|
74
|
+
notes(scope: MemoryScope): Promise<DreamNote[] | undefined>;
|
|
75
|
+
/** One reply from the small model, with what it cost. */
|
|
76
|
+
generate(system: string, prompt: string, signal?: AbortSignal): Promise<GenerateReply>;
|
|
77
|
+
settings(): DreamingSettings;
|
|
78
|
+
/** Whether automatic passes are on now (settings and plan together). */
|
|
79
|
+
autoOn(): boolean;
|
|
80
|
+
/** Write changes to one scope through memory, as one batch. */
|
|
81
|
+
commit(scope: MemoryScope, changes: readonly DreamChange[]): Promise<DreamCommitted[]>;
|
|
82
|
+
/** Tell the next run in this project what changed. */
|
|
83
|
+
announce(notes: ExtractedSummary[]): void;
|
|
84
|
+
}
|
|
85
|
+
/** What one dream of one scope did. */
|
|
86
|
+
export interface ScopeRun {
|
|
87
|
+
scope: MemoryScope;
|
|
88
|
+
claims: number;
|
|
89
|
+
applied: AppliedChange[];
|
|
90
|
+
proposals: number;
|
|
91
|
+
/** Set when the batch was refused (stale) or the model call failed. */
|
|
92
|
+
error?: string;
|
|
93
|
+
/** The batch was refused: another edit came first. */
|
|
94
|
+
refused?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface DreamRun {
|
|
97
|
+
id: string;
|
|
98
|
+
at: number;
|
|
99
|
+
digested: number;
|
|
100
|
+
scopes: ScopeRun[];
|
|
101
|
+
meter: Meter;
|
|
102
|
+
/** Set when the day's budget stopped the run part way. */
|
|
103
|
+
budgetStopped?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/** The suggestions and log of one scope, as the page shows them. */
|
|
106
|
+
export interface ScopeState {
|
|
107
|
+
proposals: Array<{
|
|
108
|
+
id: string;
|
|
109
|
+
scope: MemoryScope;
|
|
110
|
+
at: number;
|
|
111
|
+
op: DreamOp;
|
|
112
|
+
why?: string;
|
|
113
|
+
evidence: EvidenceSnapshot[];
|
|
114
|
+
}>;
|
|
115
|
+
log: Array<{
|
|
116
|
+
scope: MemoryScope;
|
|
117
|
+
at: number;
|
|
118
|
+
change: AppliedChange;
|
|
119
|
+
undone: boolean;
|
|
120
|
+
}>;
|
|
121
|
+
}
|
|
122
|
+
export declare const projectLedgerKey: (projectId: string) => string;
|
|
123
|
+
export declare const USER_LEDGER_KEY = "user";
|
|
124
|
+
export declare class DreamCoordinator {
|
|
125
|
+
/** The process's coordinator. Tests construct their own. */
|
|
126
|
+
static readonly shared: DreamCoordinator;
|
|
127
|
+
readonly store: DreamStore;
|
|
128
|
+
private readonly targets;
|
|
129
|
+
private readonly fixedLock?;
|
|
130
|
+
private homeLock?;
|
|
131
|
+
private readonly now;
|
|
132
|
+
private logger?;
|
|
133
|
+
private startedAt;
|
|
134
|
+
private lastActivity;
|
|
135
|
+
private timer?;
|
|
136
|
+
private running?;
|
|
137
|
+
private readonly runs;
|
|
138
|
+
constructor(options?: {
|
|
139
|
+
store?: DreamStore;
|
|
140
|
+
lock?: RoutineLock;
|
|
141
|
+
now?: () => number;
|
|
142
|
+
});
|
|
143
|
+
/** Resolved on use, like the store, so a changed `OHARNESS_HOME` is honoured. */
|
|
144
|
+
private get lock();
|
|
145
|
+
register(target: DreamTarget, logger?: Logger): () => void;
|
|
146
|
+
/** Someone is sending a message or a run just ended: background work waits. */
|
|
147
|
+
activity(): void;
|
|
148
|
+
lastRun(target: DreamTarget): DreamRun | undefined;
|
|
149
|
+
isRunning(): boolean;
|
|
150
|
+
private schedule;
|
|
151
|
+
/** One work item at a time, whether a tick or a person's request. */
|
|
152
|
+
private exclusive;
|
|
153
|
+
/**
|
|
154
|
+
* The background pass: digest every due session of every project whose
|
|
155
|
+
* automatic passes are on. Waits while a run is in progress or another
|
|
156
|
+
* process holds the lock.
|
|
157
|
+
*/
|
|
158
|
+
tick(signal?: AbortSignal): Promise<{
|
|
159
|
+
digested: number;
|
|
160
|
+
dreamed: number;
|
|
161
|
+
skipped?: "busy" | "locked";
|
|
162
|
+
}>;
|
|
163
|
+
private key;
|
|
164
|
+
private claimsOf;
|
|
165
|
+
/**
|
|
166
|
+
* Whether a scope dreams this tick: not yet today (a local calendar day, not
|
|
167
|
+
* a rolling 24 hours, which would drift into the working morning), and
|
|
168
|
+
* enough claims gathered, or the oldest waiting long enough.
|
|
169
|
+
*/
|
|
170
|
+
private due;
|
|
171
|
+
/** Whether a prompt of `chars` characters may still be sent today. */
|
|
172
|
+
private affordable;
|
|
173
|
+
/**
|
|
174
|
+
* The model, as a dream or a digest calls it: the reply's text, with what it
|
|
175
|
+
* cost added to the run and to the day's budget, in the tokens the provider
|
|
176
|
+
* reported.
|
|
177
|
+
*/
|
|
178
|
+
private metered;
|
|
179
|
+
private newRun;
|
|
180
|
+
/** Write a run to the project's history. */
|
|
181
|
+
private finish;
|
|
182
|
+
/**
|
|
183
|
+
* Digest a project's sessions. Unforced, only sessions quiet for
|
|
184
|
+
* `idleHours` with `minUserTurns` new user messages; forced (Dream now),
|
|
185
|
+
* every session with anything new the user typed.
|
|
186
|
+
*/
|
|
187
|
+
digestTarget(target: DreamTarget, options: {
|
|
188
|
+
force: boolean;
|
|
189
|
+
meter?: Meter;
|
|
190
|
+
signal?: AbortSignal;
|
|
191
|
+
}): Promise<{
|
|
192
|
+
digested: number;
|
|
193
|
+
budgetStopped?: boolean;
|
|
194
|
+
more?: boolean;
|
|
195
|
+
}>;
|
|
196
|
+
/**
|
|
197
|
+
* Dream now: read everything new, however recently said, then dream both
|
|
198
|
+
* scopes regardless of the day or the batch threshold.
|
|
199
|
+
*/
|
|
200
|
+
dreamNow(target: DreamTarget, signal?: AbortSignal): Promise<DreamRun>;
|
|
201
|
+
/** Hashes dreams last left notes at, from the ledger, for the hand-edit rule. */
|
|
202
|
+
private dreamWrote;
|
|
203
|
+
/**
|
|
204
|
+
* One dream of one scope: claims in, changes out. What may be applied is
|
|
205
|
+
* committed as one batch; the rest becomes suggestions. The day is marked
|
|
206
|
+
* whether or not the batch lands, so a refused batch is not retried every
|
|
207
|
+
* tick at the price of a model call; the claims behind it stay for the next
|
|
208
|
+
* dream instead of being consumed.
|
|
209
|
+
*/
|
|
210
|
+
private dreamScope;
|
|
211
|
+
/** Commit operations as one batch, record them, and tell the next run. */
|
|
212
|
+
private commitOps;
|
|
213
|
+
/** Open suggestions and recent changes, both scopes, newest first. */
|
|
214
|
+
state(target: DreamTarget): Promise<ScopeState>;
|
|
215
|
+
private proposal;
|
|
216
|
+
/** A person applies a suggestion; refused, and closed as stale, if its notes changed since. */
|
|
217
|
+
applyProposal(target: DreamTarget, scope: MemoryScope, id: string): Promise<AppliedChange[]>;
|
|
218
|
+
dismissProposal(target: DreamTarget, scope: MemoryScope, id: string): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Put back what a change replaced. Refused if any of its notes changed
|
|
221
|
+
* since, rather than overwriting someone's newer edit; the page then points
|
|
222
|
+
* at the backups.
|
|
223
|
+
*/
|
|
224
|
+
undo(target: DreamTarget, scope: MemoryScope, changeId: string): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* What decides the next automatic dream, per scope, for the page: whether it
|
|
227
|
+
* already dreamed today, and how many claims wait and since when.
|
|
228
|
+
*/
|
|
229
|
+
nextDream(target: DreamTarget): Promise<{
|
|
230
|
+
spentToday: number;
|
|
231
|
+
scopes: Array<{
|
|
232
|
+
scope: MemoryScope;
|
|
233
|
+
dreamedToday: boolean;
|
|
234
|
+
waiting: number;
|
|
235
|
+
oldestAt?: number;
|
|
236
|
+
}>;
|
|
237
|
+
}>;
|
|
238
|
+
/** Claims waiting, per scope, for the page. */
|
|
239
|
+
pending(target: DreamTarget): Promise<{
|
|
240
|
+
project: number;
|
|
241
|
+
user: number;
|
|
242
|
+
}>;
|
|
243
|
+
}
|
|
244
|
+
export {};
|