@obversa/runtime 0.1.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/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/api.d.ts +72 -0
- package/dist/api.js +9775 -0
- package/dist/api.js.map +1 -0
- package/dist/artifacts/conformance.d.ts +1 -0
- package/dist/artifacts/file-store.d.ts +8 -0
- package/dist/artifacts/store.d.ts +1 -0
- package/dist/callback/approval.d.ts +8 -0
- package/dist/callback/client.d.ts +38 -0
- package/dist/callback/gate.d.ts +1 -0
- package/dist/callback/stored-client.d.ts +5 -0
- package/dist/chunk-3L6YNPN6.js +3 -0
- package/dist/chunk-3L6YNPN6.js.map +1 -0
- package/dist/chunk-5GLEABOU.js +3 -0
- package/dist/chunk-5GLEABOU.js.map +1 -0
- package/dist/chunk-DEW5R23M.js +338 -0
- package/dist/chunk-DEW5R23M.js.map +1 -0
- package/dist/chunk-DV5P4QLI.js +3056 -0
- package/dist/chunk-DV5P4QLI.js.map +1 -0
- package/dist/chunk-NIBHM5I5.js +34 -0
- package/dist/chunk-NIBHM5I5.js.map +1 -0
- package/dist/chunk-RZLMX3IA.js +368 -0
- package/dist/chunk-RZLMX3IA.js.map +1 -0
- package/dist/core/agent-md.d.ts +36 -0
- package/dist/core/agent.d.ts +86 -0
- package/dist/core/approval-job.d.ts +43 -0
- package/dist/core/assert-graph.d.ts +34 -0
- package/dist/core/budget.d.ts +49 -0
- package/dist/core/concurrency.d.ts +2 -0
- package/dist/core/condition.d.ts +209 -0
- package/dist/core/context.d.ts +36 -0
- package/dist/core/cost.d.ts +59 -0
- package/dist/core/dag.d.ts +20 -0
- package/dist/core/decision.d.ts +29 -0
- package/dist/core/describe.d.ts +56 -0
- package/dist/core/engine-meta.d.ts +5 -0
- package/dist/core/env-overlay.d.ts +35 -0
- package/dist/core/errors.d.ts +46 -0
- package/dist/core/feedback.d.ts +68 -0
- package/dist/core/git.d.ts +152 -0
- package/dist/core/guards.d.ts +70 -0
- package/dist/core/isolated.d.ts +40 -0
- package/dist/core/job.d.ts +134 -0
- package/dist/core/limits.d.ts +22 -0
- package/dist/core/loop.d.ts +24 -0
- package/dist/core/merge.d.ts +30 -0
- package/dist/core/pipeline.d.ts +35 -0
- package/dist/core/process.d.ts +11 -0
- package/dist/core/progress.d.ts +82 -0
- package/dist/core/redact.d.ts +1 -0
- package/dist/core/stats.d.ts +63 -0
- package/dist/core/team.d.ts +34 -0
- package/dist/core/text.d.ts +8 -0
- package/dist/core/tournament.d.ts +25 -0
- package/dist/core/types.d.ts +650 -0
- package/dist/engines/command-runner.d.ts +1 -0
- package/dist/engines/conformance.d.ts +1 -0
- package/dist/engines/engine.d.ts +4 -0
- package/dist/engines/failure.d.ts +1 -0
- package/dist/engines/fallback.d.ts +35 -0
- package/dist/engines/message-map.d.ts +1 -0
- package/dist/engines/mock.d.ts +1 -0
- package/dist/engines/preflight.d.ts +36 -0
- package/dist/env/command.d.ts +50 -0
- package/dist/env/command.js +65 -0
- package/dist/env/command.js.map +1 -0
- package/dist/env/environment.d.ts +4 -0
- package/dist/env/mock.d.ts +24 -0
- package/dist/events/conformance.d.ts +1 -0
- package/dist/events/envelope.d.ts +1 -0
- package/dist/events/jsonl-store.d.ts +8 -0
- package/dist/events/store.d.ts +1 -0
- package/dist/graph/commands.d.ts +5 -0
- package/dist/graph/conformance.d.ts +32 -0
- package/dist/graph/kernel.d.ts +5 -0
- package/dist/graph/plan.d.ts +1 -0
- package/dist/graph/type.d.ts +7 -0
- package/dist/graph/value.d.ts +1 -0
- package/dist/graph-types/dag.d.ts +137 -0
- package/dist/graph-types/loop.d.ts +194 -0
- package/dist/graph-types/team.d.ts +68 -0
- package/dist/memory.d.ts +82 -0
- package/dist/memory.js +397 -0
- package/dist/memory.js.map +1 -0
- package/dist/proof/acceptance.d.ts +5 -0
- package/dist/proof/artifact.d.ts +6 -0
- package/dist/proof/cache.d.ts +4 -0
- package/dist/runtime/attempt.d.ts +19 -0
- package/dist/runtime/budget.d.ts +4 -0
- package/dist/runtime/engine-availability.d.ts +18 -0
- package/dist/runtime/graph-executor.d.ts +7 -0
- package/dist/runtime/monitor.d.ts +80 -0
- package/dist/runtime/node-lifecycle.d.ts +84 -0
- package/dist/runtime/paths.d.ts +2 -0
- package/dist/runtime/persist.d.ts +31 -0
- package/dist/runtime/preflight-record.d.ts +149 -0
- package/dist/runtime/process-tree.d.ts +1 -0
- package/dist/runtime/result-contract.d.ts +4 -0
- package/dist/runtime/result-parts.d.ts +1 -0
- package/dist/runtime/run-definition.d.ts +24 -0
- package/dist/runtime/run-event.d.ts +9 -0
- package/dist/runtime/runner.d.ts +139 -0
- package/dist/runtime/supervisor.d.ts +111 -0
- package/dist/runtime/team-rooms.d.ts +13 -0
- package/dist/runtime/workspace-policy.d.ts +25 -0
- package/dist/storage/error.d.ts +1 -0
- package/dist/storage/id.d.ts +1 -0
- package/dist/storage/local.d.ts +12 -0
- package/dist/storage/local.js +1492 -0
- package/dist/storage/local.js.map +1 -0
- package/dist/testing.d.ts +15 -0
- package/dist/testing.js +274 -0
- package/dist/testing.js.map +1 -0
- package/dist/workflow-agent-response.d.ts +3 -0
- package/dist/workflow-support.d.ts +36 -0
- package/dist/workflow-support.js +5 -0
- package/dist/workflow-support.js.map +1 -0
- package/dist/workflow.d.ts +73 -0
- package/dist/workspace/conformance.d.ts +1 -0
- package/dist/workspace/git-provider.d.ts +26 -0
- package/dist/workspace/provider.d.ts +2 -0
- package/package.json +91 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The convergence graph type (roadmap D7): fresh-context convergence with
|
|
3
|
+
* real done checks, narrow repair rounds, and no repeated reviews whose
|
|
4
|
+
* evidence is still valid.
|
|
5
|
+
*
|
|
6
|
+
* Nodes: `generator` (the body), `evaluator` (a data-only done gate), one
|
|
7
|
+
* node per review seat — seats are separate nodes, one node bound to one
|
|
8
|
+
* lane — and `repair` (the fixer). The convergence cycle is legal: repair
|
|
9
|
+
* re-enters the body.
|
|
10
|
+
*
|
|
11
|
+
* Terminal mapping (decided with the runtime owner): pass → `complete`;
|
|
12
|
+
* iterations, review restarts, or a recurring finding exhausted → `fail`
|
|
13
|
+
* with a typed exhaustion code; `ABORTED` → `pause` with a reason; and
|
|
14
|
+
* `ENGINE_UNAVAILABLE` skips a declared skippable seat or pauses a required
|
|
15
|
+
* seat. Other executor failures are not review verdicts: a seat that fails
|
|
16
|
+
* consumes no repair attempt, reruns within the declared retry cap, then
|
|
17
|
+
* pauses as unresolved. A skipped seat never weakens the remaining quorum
|
|
18
|
+
* and provider-diversity rules.
|
|
19
|
+
*
|
|
20
|
+
* This is the pure form only: definition validation, state reduction,
|
|
21
|
+
* decisions, bounds, and the plan description. Panel policy helpers,
|
|
22
|
+
* review acceptance records, and the source of evaluator fingerprints are
|
|
23
|
+
* the runtime owner's.
|
|
24
|
+
*
|
|
25
|
+
* Event vocabulary (all JSON, recorded into the durable `graph:`
|
|
26
|
+
* namespace):
|
|
27
|
+
* - `node-dispatched` / `node-completed` / `node-failed` /
|
|
28
|
+
* `node-paused` / `node-resumed` — the standard node events; a seat's
|
|
29
|
+
* completed result carries the verdict record: verdict (`pass` |
|
|
30
|
+
* `findings` | `low-confidence`), confidence, the reviewed input hashes,
|
|
31
|
+
* the workspace fingerprint, and any findings; provider and model-family
|
|
32
|
+
* diversity comes from recorded engine reports. The evaluator's
|
|
33
|
+
* completed result carries `gateMet` with the same evidence identity; the
|
|
34
|
+
* generator's and repair's results carry the work summaries.
|
|
35
|
+
* - `engine-attempt-recorded` — one reported engine identity per call, or
|
|
36
|
+
* unknown. Writer history excludes matching reviewer providers or model
|
|
37
|
+
* families, including cached passes. Unknown writer fields count as all
|
|
38
|
+
* declared targets for that field. Data-only nodes have no engine identity.
|
|
39
|
+
* - `seat-invalidated` — a seat's recorded verdict is no longer current
|
|
40
|
+
* (watched paths or fingerprints changed): the seat reruns.
|
|
41
|
+
*
|
|
42
|
+
* A dispatch, completion, or failure counts only for the node's attempt
|
|
43
|
+
* currently in flight at that exact position; a stale event from an
|
|
44
|
+
* earlier attempt is ignored. Positions are minted per recorded dispatch:
|
|
45
|
+
* `convergence/${iteration}/${node}` for the loop nodes and
|
|
46
|
+
* `review/${round}/${seat}` for seats, so a retry or a rerun always takes
|
|
47
|
+
* a fresh position. Retry is graph policy, declared as a per-node cap:
|
|
48
|
+
* decide offers a fresh dispatch for a failed node while the cap allows,
|
|
49
|
+
* then a failed body node ends the run while an unresolved seat pauses it.
|
|
50
|
+
*
|
|
51
|
+
* Each review decision dispatches every seat that is pending or invalid
|
|
52
|
+
* and fits the declared seat concurrency, in declaration order. Seats
|
|
53
|
+
* whose recorded verdicts are still valid are never re-emitted — the D2
|
|
54
|
+
* rule that a graph does not re-emit an occurrence already recorded in
|
|
55
|
+
* the folded event history.
|
|
56
|
+
*/
|
|
57
|
+
import type { GraphDefinition, NodeId } from '../graph/kernel.js';
|
|
58
|
+
import type { EngineAttemptRecordedPayload, GraphEvent, GraphType } from '../graph/type.js';
|
|
59
|
+
import { type JsonObject, type JsonValue, type Sha256Digest } from '../graph/value.js';
|
|
60
|
+
type ConvergenceExecutionTargetData = {
|
|
61
|
+
readonly adapter: string;
|
|
62
|
+
readonly provider: string;
|
|
63
|
+
readonly modelFamily: string;
|
|
64
|
+
readonly model: string;
|
|
65
|
+
readonly tools: readonly string[];
|
|
66
|
+
};
|
|
67
|
+
type ConvergenceExecutionLaneData = {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly requested: ConvergenceExecutionTargetData;
|
|
70
|
+
readonly knownSubstitutions: readonly ConvergenceExecutionTargetData[];
|
|
71
|
+
};
|
|
72
|
+
export type ConvergenceNodeData = JsonObject & {
|
|
73
|
+
/** `generator`, `evaluator`, `repair`, or `seat`. */
|
|
74
|
+
readonly role: 'generator' | 'evaluator' | 'repair' | 'seat';
|
|
75
|
+
/** Engine lane for this node; omit it for a data-only node. */
|
|
76
|
+
readonly lane?: ConvergenceExecutionLaneData;
|
|
77
|
+
/** Input-hash keys reviewed by this seat; omit to review every key. */
|
|
78
|
+
readonly evidencePaths?: readonly string[];
|
|
79
|
+
};
|
|
80
|
+
export interface ConvergenceEdgeData extends JsonObject {
|
|
81
|
+
}
|
|
82
|
+
export interface ConvergenceFinding extends JsonObject {
|
|
83
|
+
readonly id: string;
|
|
84
|
+
readonly kind: 'patch' | 'decision';
|
|
85
|
+
readonly evidence: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ConvergenceData extends JsonObject {
|
|
88
|
+
/** Body iterations bound. */
|
|
89
|
+
readonly maxIterations: number;
|
|
90
|
+
/** Repair rounds bound. */
|
|
91
|
+
readonly maxReviewRestarts: number;
|
|
92
|
+
/** Valid passing seats required to accept. */
|
|
93
|
+
readonly quorum: number;
|
|
94
|
+
/** Require distinct providers and model families among accepted seats. */
|
|
95
|
+
readonly requireDiversity: boolean;
|
|
96
|
+
/** Seat node ids that may be skipped for exhausted credit. */
|
|
97
|
+
readonly skippableSeats: readonly string[];
|
|
98
|
+
/** Review seats dispatchable at once. */
|
|
99
|
+
readonly seatConcurrency: number;
|
|
100
|
+
/** Retries offered per failed node before a body failure or unresolved-seat pause. */
|
|
101
|
+
readonly retryCapPerNode: number;
|
|
102
|
+
}
|
|
103
|
+
export type ConvergenceDefinition = GraphDefinition<ConvergenceNodeData, ConvergenceEdgeData, ConvergenceData>;
|
|
104
|
+
export interface NodeDispatchedPayload extends JsonObject {
|
|
105
|
+
readonly nodeId: NodeId;
|
|
106
|
+
readonly position: string;
|
|
107
|
+
}
|
|
108
|
+
export interface NodeCompletedPayload extends JsonObject {
|
|
109
|
+
readonly nodeId: NodeId;
|
|
110
|
+
readonly position: string;
|
|
111
|
+
readonly result: JsonValue;
|
|
112
|
+
}
|
|
113
|
+
export interface NodeFailedPayload extends JsonObject {
|
|
114
|
+
readonly nodeId: NodeId;
|
|
115
|
+
readonly position: string;
|
|
116
|
+
readonly code: string;
|
|
117
|
+
}
|
|
118
|
+
export interface NodePausedPayload extends JsonObject {
|
|
119
|
+
readonly nodeId: NodeId;
|
|
120
|
+
readonly position: string;
|
|
121
|
+
readonly reason: string;
|
|
122
|
+
readonly request: JsonValue;
|
|
123
|
+
}
|
|
124
|
+
export interface NodeResumedPayload extends JsonObject {
|
|
125
|
+
readonly nodeId: NodeId;
|
|
126
|
+
readonly position: string;
|
|
127
|
+
}
|
|
128
|
+
export interface LimitPausedPayload extends JsonObject {
|
|
129
|
+
readonly reason: string;
|
|
130
|
+
}
|
|
131
|
+
export interface SeatInvalidatedPayload extends JsonObject {
|
|
132
|
+
readonly seatId: NodeId;
|
|
133
|
+
readonly reason: string;
|
|
134
|
+
}
|
|
135
|
+
export type ConvergenceEvent = GraphEvent<'node-dispatched', NodeDispatchedPayload> | GraphEvent<'engine-attempt-recorded', EngineAttemptRecordedPayload> | GraphEvent<'node-completed', NodeCompletedPayload> | GraphEvent<'node-failed', NodeFailedPayload> | GraphEvent<'node-paused', NodePausedPayload> | GraphEvent<'node-resumed', NodeResumedPayload> | GraphEvent<'seat-invalidated', SeatInvalidatedPayload> | GraphEvent<'limit-paused', LimitPausedPayload>;
|
|
136
|
+
export type LoopNodeStatus = 'pending' | 'in-flight' | 'paused' | 'passed' | 'failed';
|
|
137
|
+
export interface LoopNodeState extends JsonObject {
|
|
138
|
+
readonly status: LoopNodeStatus;
|
|
139
|
+
readonly attempts: number;
|
|
140
|
+
readonly inFlight: string | null;
|
|
141
|
+
}
|
|
142
|
+
export type SeatOutcome = 'valid' | 'invalid' | 'skipped' | 'non-verdict' | null;
|
|
143
|
+
export interface SeatRecord extends JsonObject {
|
|
144
|
+
readonly outcome: SeatOutcome;
|
|
145
|
+
readonly verdict: 'pass' | 'findings' | 'low-confidence' | null;
|
|
146
|
+
readonly confidence: number | null;
|
|
147
|
+
readonly provider: string | null;
|
|
148
|
+
readonly modelFamily: string | null;
|
|
149
|
+
readonly inputHashes: JsonObject | null;
|
|
150
|
+
readonly workspaceFingerprint: string | null;
|
|
151
|
+
readonly proofArtifactDigest: Sha256Digest | null;
|
|
152
|
+
readonly findings: readonly ConvergenceFinding[];
|
|
153
|
+
/** Set when the seat was invalidated while its attempt was in flight; the late verdict is discarded. */
|
|
154
|
+
readonly stale: boolean;
|
|
155
|
+
}
|
|
156
|
+
export interface EngineReceiptRejection extends JsonObject {
|
|
157
|
+
readonly code: 'INVALID_ENGINE_RECEIPT';
|
|
158
|
+
readonly nodeId: NodeId;
|
|
159
|
+
readonly position: string;
|
|
160
|
+
readonly sequence: number;
|
|
161
|
+
readonly reason: 'unsupported-version' | 'no-engine-lane' | 'not-in-flight' | 'position-mismatch' | 'sequence-mismatch';
|
|
162
|
+
}
|
|
163
|
+
export type ConvergenceStatus = JsonObject & {
|
|
164
|
+
readonly phase: 'body' | 'review' | 'settled';
|
|
165
|
+
readonly iteration: number;
|
|
166
|
+
readonly restarts: number;
|
|
167
|
+
readonly nodes: Readonly<Record<NodeId, LoopNodeState>>;
|
|
168
|
+
readonly seats: Readonly<Record<NodeId, SeatRecord>>;
|
|
169
|
+
/** Latest engine call at each recorded position. */
|
|
170
|
+
readonly engineAttempts: Readonly<Record<string, EngineAttemptRecordedPayload>>;
|
|
171
|
+
/** Scripted engine receipts refused by the reducer; absent until the first rejection. */
|
|
172
|
+
readonly engineReceiptRejections?: readonly EngineReceiptRejection[];
|
|
173
|
+
/** All reported writer identities, with declared targets for unknown fields. */
|
|
174
|
+
readonly writerProviders: readonly string[];
|
|
175
|
+
readonly writerModelFamilies: readonly string[];
|
|
176
|
+
readonly reviewEvidence: ConvergenceReviewEvidence | null;
|
|
177
|
+
/** Times each finding id has been reported across review rounds. */
|
|
178
|
+
readonly findingRounds: Readonly<Record<string, number>>;
|
|
179
|
+
/** A typed pause reason set by a limit or credit failure, or null. */
|
|
180
|
+
readonly pauseReason: string | null;
|
|
181
|
+
};
|
|
182
|
+
export interface ConvergenceReviewEvidence extends JsonObject {
|
|
183
|
+
readonly inputHashes: JsonObject;
|
|
184
|
+
readonly workspaceFingerprint: string;
|
|
185
|
+
readonly proofArtifactDigest: Sha256Digest;
|
|
186
|
+
}
|
|
187
|
+
export type ConvergenceRequirements = {
|
|
188
|
+
readonly memory: 'unused';
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* The convergence graph type. Pure data operations only (the D2 contract).
|
|
192
|
+
*/
|
|
193
|
+
export declare const convergence: GraphType<ConvergenceDefinition, ConvergenceStatus, ConvergenceEvent, ConvergenceRequirements>;
|
|
194
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { GraphDefinition } from '../graph/kernel.js';
|
|
2
|
+
import type { ExecutionLaneDescription } from '../graph/plan.js';
|
|
3
|
+
import type { GraphEvent, GraphType } from '../graph/type.js';
|
|
4
|
+
import { type JsonObject, type JsonValue } from '../graph/value.js';
|
|
5
|
+
export type TeamNodeData = JsonObject & {
|
|
6
|
+
role: string;
|
|
7
|
+
brief: string;
|
|
8
|
+
initialTurn?: boolean;
|
|
9
|
+
lane?: ExecutionLaneDescription;
|
|
10
|
+
};
|
|
11
|
+
export interface TeamRoom extends JsonObject {
|
|
12
|
+
id: string;
|
|
13
|
+
members: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export interface TeamCommunication extends JsonObject {
|
|
16
|
+
rooms: readonly TeamRoom[];
|
|
17
|
+
tailMessages: number;
|
|
18
|
+
}
|
|
19
|
+
export type TeamGraphData = JsonObject & {
|
|
20
|
+
task: string;
|
|
21
|
+
globalConcurrency: number;
|
|
22
|
+
maxTurnsPerMember: number;
|
|
23
|
+
communication?: TeamCommunication;
|
|
24
|
+
};
|
|
25
|
+
export type TeamDefinition = GraphDefinition<TeamNodeData, JsonObject, TeamGraphData>;
|
|
26
|
+
export interface TeamPost extends JsonObject {
|
|
27
|
+
roomId: string;
|
|
28
|
+
text: string;
|
|
29
|
+
mentions: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
export type TeamTurnResult = JsonObject & {
|
|
32
|
+
summary: string;
|
|
33
|
+
data?: JsonValue;
|
|
34
|
+
posts?: readonly TeamPost[];
|
|
35
|
+
};
|
|
36
|
+
export interface TeamMessage extends TeamPost {
|
|
37
|
+
id: string;
|
|
38
|
+
sender: string;
|
|
39
|
+
position: string;
|
|
40
|
+
}
|
|
41
|
+
export interface TeamGraphResult extends JsonObject {
|
|
42
|
+
task: string;
|
|
43
|
+
agents: readonly {
|
|
44
|
+
name: string;
|
|
45
|
+
role: string;
|
|
46
|
+
result: TeamTurnResult | null;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
interface TeamMemberState extends JsonObject {
|
|
50
|
+
readonly status: 'idle' | 'in-flight' | 'paused' | 'failed';
|
|
51
|
+
readonly turns: number;
|
|
52
|
+
readonly inFlight: string | null;
|
|
53
|
+
readonly pauseReason: string | null;
|
|
54
|
+
readonly failureCode: string | null;
|
|
55
|
+
readonly result: TeamTurnResult | null;
|
|
56
|
+
readonly queued: boolean;
|
|
57
|
+
readonly triggers: readonly string[];
|
|
58
|
+
}
|
|
59
|
+
/** Saved messages are the accepted record for host room projections. */
|
|
60
|
+
export interface TeamGraphState extends JsonObject {
|
|
61
|
+
readonly nodes: Readonly<Record<string, TeamMemberState>>;
|
|
62
|
+
readonly messages: readonly TeamMessage[];
|
|
63
|
+
}
|
|
64
|
+
/** Pure member turns; only matching saved completions deliver posts. */
|
|
65
|
+
export declare const teamGraphType: GraphType<TeamDefinition, TeamGraphState, GraphEvent, {
|
|
66
|
+
readonly memory: 'unused';
|
|
67
|
+
}>;
|
|
68
|
+
export {};
|
package/dist/memory.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type Memory, type MemoryError, type MemoryPath } from '@obversa/api';
|
|
2
|
+
type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
export interface MemorySource {
|
|
4
|
+
readonly path: MemoryPath;
|
|
5
|
+
readonly optional?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface GroundDocument {
|
|
8
|
+
readonly path: MemoryPath;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
readonly truncated: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface GroundedMemory {
|
|
13
|
+
readonly documents: readonly GroundDocument[];
|
|
14
|
+
readonly missing: readonly MemoryPath[];
|
|
15
|
+
readonly prompt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface GroundLimits {
|
|
18
|
+
readonly maxFiles: number;
|
|
19
|
+
readonly maxCharsPerFile: number;
|
|
20
|
+
readonly maxTotalChars: number;
|
|
21
|
+
}
|
|
22
|
+
export interface GroundOptions {
|
|
23
|
+
readonly sources: readonly MemorySource[];
|
|
24
|
+
readonly limits?: Partial<GroundLimits>;
|
|
25
|
+
}
|
|
26
|
+
export interface MechanicError {
|
|
27
|
+
readonly code: 'read_failed' | 'callback_failed' | 'invalid_callback_result' | 'write_failed';
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly path?: MemoryPath;
|
|
30
|
+
readonly cause?: MemoryError;
|
|
31
|
+
}
|
|
32
|
+
export type MechanicResult<T> = {
|
|
33
|
+
readonly ok: true;
|
|
34
|
+
readonly value: T;
|
|
35
|
+
} | {
|
|
36
|
+
readonly ok: false;
|
|
37
|
+
readonly error: MechanicError;
|
|
38
|
+
};
|
|
39
|
+
export interface CurateRequest {
|
|
40
|
+
readonly intent: string;
|
|
41
|
+
readonly documents: readonly GroundDocument[];
|
|
42
|
+
readonly prompt: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CurateDecision {
|
|
45
|
+
readonly brief: string;
|
|
46
|
+
readonly sources: readonly MemoryPath[];
|
|
47
|
+
}
|
|
48
|
+
export type CuratedMemory = {
|
|
49
|
+
readonly mode: 'curated';
|
|
50
|
+
readonly brief: string;
|
|
51
|
+
readonly sources: readonly MemoryPath[];
|
|
52
|
+
readonly prompt: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly mode: 'grounded';
|
|
55
|
+
readonly reason: 'callback_failed' | 'invalid_decision';
|
|
56
|
+
readonly prompt: string;
|
|
57
|
+
};
|
|
58
|
+
export interface CurateOptions {
|
|
59
|
+
readonly intent: string;
|
|
60
|
+
readonly decide: (request: CurateRequest) => Awaitable<CurateDecision>;
|
|
61
|
+
readonly maxBriefChars?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ConsolidateRequest {
|
|
64
|
+
readonly prior: string | undefined;
|
|
65
|
+
readonly documents: readonly GroundDocument[];
|
|
66
|
+
readonly prompt: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ConsolidatedMemory {
|
|
69
|
+
readonly target: MemoryPath;
|
|
70
|
+
readonly text: string;
|
|
71
|
+
readonly prompt: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ConsolidateOptions {
|
|
74
|
+
readonly target: MemoryPath;
|
|
75
|
+
readonly sources: readonly MemorySource[];
|
|
76
|
+
readonly fold: (request: ConsolidateRequest) => Awaitable<string>;
|
|
77
|
+
readonly maxOutputChars?: number;
|
|
78
|
+
}
|
|
79
|
+
export declare function ground(memory: Memory, options: GroundOptions): Promise<MechanicResult<GroundedMemory>>;
|
|
80
|
+
export declare function curate(grounded: GroundedMemory, options: CurateOptions): Promise<CuratedMemory>;
|
|
81
|
+
export declare function consolidate(memory: Memory, options: ConsolidateOptions): Promise<MechanicResult<ConsolidatedMemory>>;
|
|
82
|
+
export {};
|