@modelprofile.com/flexharness 18.0.0 → 18.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.flexharness.core.d.ts +58 -2
- package/dist_ts/classes.flexharness.core.js +391 -177
- package/dist_ts/classes.flexharness.d.ts +6 -1
- package/dist_ts/classes.flexharness.js +8 -1
- package/dist_ts/classes.flexharness.sessions.d.ts +8 -1
- package/dist_ts/classes.flexharness.sessions.js +27 -1
- package/dist_ts/classes.timeslicer.d.ts +21 -0
- package/dist_ts/classes.timeslicer.js +31 -0
- package/dist_ts/interfaces.d.ts +36 -0
- package/dist_ts/interfaces.flexharness.d.ts +20 -1
- package/dist_ts/interfaces.js +1 -1
- package/dist_ts/plugins.d.ts +2 -2
- package/dist_ts/plugins.js +3 -3
- package/dist_ts/utils.json.d.ts +6 -0
- package/dist_ts/utils.json.js +75 -20
- package/dist_ts/utils.scopesnapshot.d.ts +14 -0
- package/dist_ts/utils.scopesnapshot.js +58 -0
- package/package.json +3 -3
- package/readme.md +5 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.flexharness.core.ts +451 -207
- package/ts/classes.flexharness.sessions.ts +30 -0
- package/ts/classes.flexharness.ts +9 -0
- package/ts/classes.timeslicer.ts +32 -0
- package/ts/interfaces.flexharness.ts +22 -0
- package/ts/interfaces.ts +40 -0
- package/ts/plugins.ts +2 -0
- package/ts/readme.md +5 -0
- package/ts/utils.json.ts +70 -18
- package/ts/utils.scopesnapshot.ts +75 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@modelprofile.com/flexharness',
|
|
6
|
-
version: '18.
|
|
6
|
+
version: '18.1.0',
|
|
7
7
|
description: 'The FlexHarness toolbox source repository and shared dependency catalog.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSwrQkFBK0I7SUFDckMsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLDBFQUEwRTtDQUN4RixDQUFBIn0=
|
|
@@ -3,7 +3,7 @@ import { FlexHarnessAbortError } from './errors.js';
|
|
|
3
3
|
import type { IFlexAgentSessionPolicy, IFlexCallbackLimits, IFlexHarnessOptions, IFlexHarnessStores, IFlexMessage, IFlexPartSnapshotEvent, IFlexPromptQueueLimits, IFlexProjectionSnapshotCurrent, IFlexReversionLimits, IFlexResolvedScope, IFlexResultLimits, IFlexSession, IFlexSessionImportLimits, IFlexSubagentDefinition, IFlexToolCatalogOptions, IJsonObject, TFlexExternalErrorSource, TFlexHarnessEventListener, TFlexMessagePart, TFlexProjectionSnapshot, TFlexReversionPolicy } from './interfaces.js';
|
|
4
4
|
import { FlexCodeSandbox } from './classes.codesandbox.js';
|
|
5
5
|
import { type INormalizedBuiltInTools, type INormalizedCacheWarmOptions, type TRegisteredSlashCommand } from './utils.harnessoptions.js';
|
|
6
|
-
import type { TCanonicalOutcome, IStoredSessionState, IStorageState, IActiveRun, IScopeAdmissionState, IFlexMessageCursor, TEventDetails } from './interfaces.flexharness.js';
|
|
6
|
+
import type { TCanonicalOutcome, IStoredSessionState, IStorageState, IActiveRun, IScopeAdmissionState, IFlexMessageCursor, IScopeLoadPass, TEventDetails } from './interfaces.flexharness.js';
|
|
7
7
|
import { FlexHarnessResults } from './classes.flexharness.results.js';
|
|
8
8
|
import { FlexHarnessToolDispatch } from './classes.flexharness.tooldispatch.js';
|
|
9
9
|
import { FlexHarnessToolProviders } from './classes.flexharness.providers.js';
|
|
@@ -50,6 +50,7 @@ export declare class FlexHarnessCore<TScope> {
|
|
|
50
50
|
readonly turnReversionProvider: IFlexHarnessOptions<TScope>['turnReversionProvider'];
|
|
51
51
|
readonly reversionPolicy: TFlexReversionPolicy;
|
|
52
52
|
private readonly externalErrorProjector?;
|
|
53
|
+
private readonly scopeLoadObserver?;
|
|
53
54
|
readonly subagents: ReadonlyMap<string, Readonly<IFlexSubagentDefinition>>;
|
|
54
55
|
readonly builtInTools: INormalizedBuiltInTools;
|
|
55
56
|
readonly cacheWarmOptions: INormalizedCacheWarmOptions;
|
|
@@ -58,6 +59,8 @@ export declare class FlexHarnessCore<TScope> {
|
|
|
58
59
|
readonly maxSubagentDepth: number;
|
|
59
60
|
readonly maxSubagentCallsPerRun: number;
|
|
60
61
|
readonly stateLoads: Map<string, Promise<IStorageState>>;
|
|
62
|
+
/** The state each settled successful load loaded. */
|
|
63
|
+
private readonly loadedStates;
|
|
61
64
|
readonly scopeAdmissions: Map<string, IScopeAdmissionState>;
|
|
62
65
|
readonly listeners: Set<TFlexHarnessEventListener>;
|
|
63
66
|
readonly trustedInternalErrors: WeakSet<object>;
|
|
@@ -95,11 +98,55 @@ export declare class FlexHarnessCore<TScope> {
|
|
|
95
98
|
projectOperationError(error: unknown, source: TFlexExternalErrorSource, scopeId: string, sessionId: string, runId: string): Error;
|
|
96
99
|
trustInternalError<TError extends Error>(error: TError): TError;
|
|
97
100
|
canonicalOutcomes(events: readonly plugins.TAgentEvent[]): Map<string, TCanonicalOutcome>;
|
|
101
|
+
/** Adds the canonical outcomes `event` records to `outcomes`. */
|
|
102
|
+
private rememberCanonicalOutcomes;
|
|
98
103
|
durableCanonicalOutcomes(stored: IStoredSessionState): Promise<Map<string, TCanonicalOutcome>>;
|
|
104
|
+
/**
|
|
105
|
+
* Loads a scope's state for every request of the scope, and reports what the load took to the
|
|
106
|
+
* scope load observer. Its long steps are cut into slices of time, so the event loop keeps
|
|
107
|
+
* running beside it; disposal and the scope's retirement stop it at the next slice (the abort of
|
|
108
|
+
* `compactorLifecycleController`), a request that stops waiting for it does not.
|
|
109
|
+
*/
|
|
99
110
|
private loadState;
|
|
111
|
+
/** Reports a scope load to the scope load observer, which can neither delay nor fail it. */
|
|
112
|
+
private observeScopeLoad;
|
|
113
|
+
private loadStateSliced;
|
|
100
114
|
createUninitializedStoredSession(session: IFlexSession, storageKey: string, compactorLifecycleController?: AbortController): IStoredSessionState;
|
|
101
|
-
loadSessionRuntime(state: IStorageState, metadata: IFlexSession, scopeId: string, scope: TScope, compactorLifecycleController?: AbortController, newSession?: boolean): Promise<IStoredSessionState>;
|
|
115
|
+
loadSessionRuntime(state: IStorageState, metadata: IFlexSession, scopeId: string, scope: TScope, compactorLifecycleController?: AbortController, newSession?: boolean, pass?: IScopeLoadPass): Promise<IStoredSessionState>;
|
|
116
|
+
/**
|
|
117
|
+
* Repairs what a stopped process left in a loaded session: every run gets its terminal, the
|
|
118
|
+
* reversion state its runs' outcomes, the session its latest turn's state. Linear in the
|
|
119
|
+
* session's size, in slices of `slicer`'s time; it saves the projection only if its content
|
|
120
|
+
* changed.
|
|
121
|
+
*/
|
|
102
122
|
private repairLoadedSession;
|
|
123
|
+
/**
|
|
124
|
+
* Gives every run of a loaded session its terminal, in one pass over its messages, and returns
|
|
125
|
+
* the terminal of its latest real turn. A run with an accepted completed stage takes the stage;
|
|
126
|
+
* a run that failed or was stopped keeps the terminal it staged or published; a run that never
|
|
127
|
+
* reached its terminal is repaired as failed or cancelled. Each terminal goes where
|
|
128
|
+
* `runs.replaceVisibleRun()` would put it.
|
|
129
|
+
*/
|
|
130
|
+
private repairRunTerminals;
|
|
131
|
+
/**
|
|
132
|
+
* The messages with each run's terminal in place, built in one pass: what
|
|
133
|
+
* `runs.replaceVisibleRun()` gives for each terminal in turn. A run's projected terminal messages
|
|
134
|
+
* are replaced, its other user messages take the prompt's `keptInContext`, and a terminal
|
|
135
|
+
* message not projected yet goes before the run's first message (its prompt) or after its last
|
|
136
|
+
* (its answer); for a run without messages both go to the end.
|
|
137
|
+
*/
|
|
138
|
+
private placeRunTerminals;
|
|
139
|
+
/**
|
|
140
|
+
* The projection content a repair may change, as it is before the repair. Messages and reversion
|
|
141
|
+
* segments are frozen and replaced, never edited, so the lists keep their entries; the other
|
|
142
|
+
* fields are small and kept encoded.
|
|
143
|
+
*/
|
|
144
|
+
private projectionContent;
|
|
145
|
+
/**
|
|
146
|
+
* Whether the session's projection content differs from `before` as JSON. A list entry that is
|
|
147
|
+
* still the same object is unchanged, so only an entry replaced since is encoded, one at a time.
|
|
148
|
+
*/
|
|
149
|
+
private projectionContentChanged;
|
|
103
150
|
/**
|
|
104
151
|
* The failed or cancelled terminal a run published, read from its projected messages. A run
|
|
105
152
|
* still running has its prompt or its last assistant message streaming; it has none.
|
|
@@ -143,6 +190,15 @@ export declare class FlexHarnessCore<TScope> {
|
|
|
143
190
|
scope: IFlexResolvedScope<TScope>;
|
|
144
191
|
state: IStorageState;
|
|
145
192
|
}>;
|
|
193
|
+
/** Whether `stateLoad` has settled with its loaded state. */
|
|
194
|
+
isStateLoaded(stateLoad: Promise<IStorageState>): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Runs `operation` for the resolved scope `scopeId` while the scope is admitted: not retiring,
|
|
197
|
+
* not retired since, not draining. `admitted()` tells whether that still holds.
|
|
198
|
+
*/
|
|
199
|
+
withScopeAdmission<TValue>(scopeId: string, operation: (scope: IFlexResolvedScope<TScope>, admitted: () => boolean) => Promise<TValue>): Promise<TValue>;
|
|
200
|
+
/** The state `stateLoad` loads, once it is active and the scope still admitted. */
|
|
201
|
+
admittedState(scopeId: string, scope: IFlexResolvedScope<TScope>, stateLoad: Promise<IStorageState>, admitted: () => boolean): Promise<IStorageState>;
|
|
146
202
|
getScopeAdmission(scopeId: string): IScopeAdmissionState;
|
|
147
203
|
pruneScopeAdmission(scopeId: string, admission: IScopeAdmissionState): void;
|
|
148
204
|
createScopeRetirementError(): FlexHarnessAbortError;
|