@modelprofile.com/flexharness 3.6.0 → 3.8.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/changelog.md +18 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.flexharness.d.ts +71 -1
- package/dist_ts/classes.flexharness.js +2374 -138
- package/dist_ts/classes.stores.js +1 -1
- package/dist_ts/errors.d.ts +8 -0
- package/dist_ts/errors.js +17 -1
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/interfaces.d.ts +272 -5
- package/dist_ts/interfaces.js +18 -2
- package/dist_ts/plugins.d.ts +2 -2
- package/dist_ts/plugins.js +3 -3
- package/dist_ts/utils.json.d.ts +5 -2
- package/dist_ts/utils.json.js +485 -10
- package/dist_ts/utils.slashcommands.d.ts +7 -0
- package/dist_ts/utils.slashcommands.js +164 -0
- package/dist_ts_migration/v3_legacyflexharness.js +6 -2
- package/package.json +1 -1
- package/readme.hints.md +4 -0
- package/readme.md +190 -3
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.flexharness.ts +3210 -190
- package/ts/classes.stores.ts +9 -8
- package/ts/errors.ts +25 -0
- package/ts/index.ts +4 -0
- package/ts/interfaces.ts +378 -5
- package/ts/plugins.ts +2 -0
- package/ts/utils.json.ts +543 -12
- package/ts/utils.slashcommands.ts +178 -0
- package/ts_migration/v3_legacyflexharness.ts +10 -5
package/ts/classes.stores.ts
CHANGED
|
@@ -10,11 +10,12 @@ import type {
|
|
|
10
10
|
IFlexHarnessStores,
|
|
11
11
|
IFlexPermissionSnapshot,
|
|
12
12
|
IFlexPermissionStore,
|
|
13
|
-
|
|
13
|
+
IFlexProjectionSnapshotV3,
|
|
14
14
|
IFlexProjectionStore,
|
|
15
15
|
IFlexScopeSnapshot,
|
|
16
16
|
IFlexScopeStore,
|
|
17
17
|
IFlexToolJobStoreProvider,
|
|
18
|
+
TFlexProjectionSnapshot,
|
|
18
19
|
} from './interfaces.js';
|
|
19
20
|
import {
|
|
20
21
|
assertFlexPermissionSnapshot,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
cloneSerializable,
|
|
25
26
|
} from './utils.json.js';
|
|
26
27
|
|
|
27
|
-
type TSnapshot = IFlexScopeSnapshot |
|
|
28
|
+
type TSnapshot = IFlexScopeSnapshot | TFlexProjectionSnapshot | IFlexPermissionSnapshot;
|
|
28
29
|
type TSnapshotValidator<TSnapshotValue extends TSnapshot> = (
|
|
29
30
|
value: unknown,
|
|
30
31
|
) => asserts value is TSnapshotValue;
|
|
@@ -62,7 +63,7 @@ function providerKey(storageKey: string, sessionId: string): string {
|
|
|
62
63
|
return JSON.stringify([storageKey, sessionId]);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
function assertProjectionSession(snapshot:
|
|
66
|
+
function assertProjectionSession(snapshot: TFlexProjectionSnapshot, sessionId: string): void {
|
|
66
67
|
for (const message of snapshot.messages) {
|
|
67
68
|
if (message.sessionId !== sessionId) {
|
|
68
69
|
throw new FlexHarnessStoreFormatError(
|
|
@@ -350,12 +351,12 @@ class InMemoryScopeStore implements IFlexScopeStore {
|
|
|
350
351
|
}
|
|
351
352
|
|
|
352
353
|
class InMemoryProjectionStore implements IFlexProjectionStore {
|
|
353
|
-
private readonly snapshots = new Map<string,
|
|
354
|
+
private readonly snapshots = new Map<string, TFlexProjectionSnapshot>();
|
|
354
355
|
|
|
355
356
|
public async load(
|
|
356
357
|
storageKey: string,
|
|
357
358
|
sessionId: string,
|
|
358
|
-
): Promise<
|
|
359
|
+
): Promise<TFlexProjectionSnapshot | undefined> {
|
|
359
360
|
const key = providerKey(storageKey, sessionId);
|
|
360
361
|
const snapshot = this.snapshots.get(key);
|
|
361
362
|
return snapshot ? cloneSerializable(snapshot) : undefined;
|
|
@@ -364,7 +365,7 @@ class InMemoryProjectionStore implements IFlexProjectionStore {
|
|
|
364
365
|
public async save(
|
|
365
366
|
storageKey: string,
|
|
366
367
|
sessionId: string,
|
|
367
|
-
snapshot:
|
|
368
|
+
snapshot: IFlexProjectionSnapshotV3,
|
|
368
369
|
expectedRevision: number,
|
|
369
370
|
): Promise<void> {
|
|
370
371
|
const key = providerKey(storageKey, sessionId);
|
|
@@ -972,7 +973,7 @@ class JsonProjectionStore implements IFlexProjectionStore {
|
|
|
972
973
|
public async load(
|
|
973
974
|
storageKey: string,
|
|
974
975
|
sessionId: string,
|
|
975
|
-
): Promise<
|
|
976
|
+
): Promise<TFlexProjectionSnapshot | undefined> {
|
|
976
977
|
const filePath = this.root.sessionPath('projections', storageKey, sessionId);
|
|
977
978
|
return JsonFileRoot.inQueue(filePath, async () => {
|
|
978
979
|
const snapshot = await this.root.read(filePath, (value) => {
|
|
@@ -987,7 +988,7 @@ class JsonProjectionStore implements IFlexProjectionStore {
|
|
|
987
988
|
public async save(
|
|
988
989
|
storageKey: string,
|
|
989
990
|
sessionId: string,
|
|
990
|
-
snapshot:
|
|
991
|
+
snapshot: IFlexProjectionSnapshotV3,
|
|
991
992
|
expectedRevision: number,
|
|
992
993
|
): Promise<void> {
|
|
993
994
|
const validated = validateSnapshotSave(snapshot, expectedRevision, assertFlexProjectionSnapshot);
|
package/ts/errors.ts
CHANGED
|
@@ -38,6 +38,31 @@ export class FlexHarnessSessionBusyError extends FlexHarnessError {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export class FlexHarnessSlashCommandUnavailableError extends FlexHarnessError {
|
|
42
|
+
public readonly commandName: string;
|
|
43
|
+
public readonly unavailableReason: string;
|
|
44
|
+
|
|
45
|
+
constructor(commandName: string, unavailableReason: string) {
|
|
46
|
+
super(
|
|
47
|
+
'FLEX_SLASH_COMMAND_UNAVAILABLE',
|
|
48
|
+
`Slash command "/${commandName}" is unavailable: ${unavailableReason}`,
|
|
49
|
+
);
|
|
50
|
+
this.name = 'FlexHarnessSlashCommandUnavailableError';
|
|
51
|
+
this.commandName = commandName;
|
|
52
|
+
this.unavailableReason = unavailableReason;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class FlexHarnessSlashCommandReentryError extends FlexHarnessError {
|
|
57
|
+
constructor(sessionId: string) {
|
|
58
|
+
super(
|
|
59
|
+
'FLEX_SLASH_COMMAND_REENTRY',
|
|
60
|
+
`Session "${sessionId}" cannot reenter slash command execution.`,
|
|
61
|
+
);
|
|
62
|
+
this.name = 'FlexHarnessSlashCommandReentryError';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
41
66
|
export class FlexHarnessQueueFullError extends FlexHarnessError {
|
|
42
67
|
constructor(message: string) {
|
|
43
68
|
super('FLEX_QUEUE_FULL', message);
|
package/ts/index.ts
CHANGED
package/ts/interfaces.ts
CHANGED
|
@@ -164,6 +164,109 @@ export interface IFlexPromptOptions {
|
|
|
164
164
|
maxSteps?: number;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
export interface IFlexSlashCommandInvocation {
|
|
168
|
+
input: string;
|
|
169
|
+
name: string;
|
|
170
|
+
rawArguments: string;
|
|
171
|
+
arguments: string[];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface IFlexSlashCommandNotCommandResult {
|
|
175
|
+
type: 'not-command';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface IFlexSlashCommandMalformedResult {
|
|
179
|
+
type: 'malformed';
|
|
180
|
+
reason: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface IFlexParsedSlashCommand extends IFlexSlashCommandInvocation {
|
|
184
|
+
type: 'parsed';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export type TFlexSlashCommandParseResult =
|
|
188
|
+
| IFlexSlashCommandNotCommandResult
|
|
189
|
+
| IFlexSlashCommandMalformedResult
|
|
190
|
+
| IFlexParsedSlashCommand;
|
|
191
|
+
|
|
192
|
+
export type TFlexSlashCommandKind = 'builtin' | 'template' | 'handler';
|
|
193
|
+
export type TFlexSlashCommandWorkspaceReversion = 'supported' | 'unsupported' | 'not-applicable';
|
|
194
|
+
|
|
195
|
+
export interface IFlexSlashCommandDescriptor {
|
|
196
|
+
name: string;
|
|
197
|
+
description: string;
|
|
198
|
+
kind: TFlexSlashCommandKind;
|
|
199
|
+
hints: string[];
|
|
200
|
+
available: boolean;
|
|
201
|
+
unavailableReason?: string;
|
|
202
|
+
workspaceReversion: TFlexSlashCommandWorkspaceReversion;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface IFlexSlashCommandHandlerContext<TScope> {
|
|
206
|
+
readonly scopeId: string;
|
|
207
|
+
readonly scope: TScope;
|
|
208
|
+
readonly storageKey: string;
|
|
209
|
+
readonly sessionId: string;
|
|
210
|
+
readonly rawArguments: string;
|
|
211
|
+
readonly arguments: readonly string[];
|
|
212
|
+
readonly signal: AbortSignal;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export type TFlexSlashCommandHandler<TScope> = (
|
|
216
|
+
context: IFlexSlashCommandHandlerContext<TScope>,
|
|
217
|
+
) => TJsonValue | void | Promise<TJsonValue | void>;
|
|
218
|
+
|
|
219
|
+
export interface IFlexSlashCommandTemplateRegistration {
|
|
220
|
+
name: string;
|
|
221
|
+
description?: string;
|
|
222
|
+
template: string;
|
|
223
|
+
handler?: never;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface IFlexSlashCommandHandlerRegistration<TScope> {
|
|
227
|
+
name: string;
|
|
228
|
+
description?: string;
|
|
229
|
+
handler: TFlexSlashCommandHandler<TScope>;
|
|
230
|
+
template?: never;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export type TFlexSlashCommandRegistration<TScope> =
|
|
234
|
+
| IFlexSlashCommandTemplateRegistration
|
|
235
|
+
| IFlexSlashCommandHandlerRegistration<TScope>;
|
|
236
|
+
|
|
237
|
+
export interface IFlexSlashCommandExecutionOptions extends IFlexPromptOptions {
|
|
238
|
+
signal?: AbortSignal;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface IFlexSlashCommandUnknownResult extends IFlexSlashCommandInvocation {
|
|
242
|
+
type: 'unknown';
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface IFlexSlashCommandOperationResult {
|
|
246
|
+
type: 'operation';
|
|
247
|
+
name: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface IFlexSlashCommandHandlerResult {
|
|
251
|
+
type: 'handler-result';
|
|
252
|
+
name: string;
|
|
253
|
+
result: TJsonValue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface IFlexSlashCommandPromptAdmissionResult {
|
|
257
|
+
type: 'prompt-admission';
|
|
258
|
+
name: string;
|
|
259
|
+
admission: IFlexPromptAdmission;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export type TFlexSlashCommandExecutionResult =
|
|
263
|
+
| IFlexSlashCommandNotCommandResult
|
|
264
|
+
| IFlexSlashCommandMalformedResult
|
|
265
|
+
| IFlexSlashCommandUnknownResult
|
|
266
|
+
| IFlexSlashCommandOperationResult
|
|
267
|
+
| IFlexSlashCommandHandlerResult
|
|
268
|
+
| IFlexSlashCommandPromptAdmissionResult;
|
|
269
|
+
|
|
167
270
|
export type TFlexPromptQueueStatus =
|
|
168
271
|
| 'queued'
|
|
169
272
|
| 'starting'
|
|
@@ -349,13 +452,112 @@ export interface IFlexTerminalProjection {
|
|
|
349
452
|
steps?: number;
|
|
350
453
|
}
|
|
351
454
|
|
|
352
|
-
export interface
|
|
455
|
+
export interface IFlexProjectionSnapshotV1 {
|
|
353
456
|
schemaVersion: 1;
|
|
354
457
|
revision: number;
|
|
355
458
|
messages: IFlexMessage[];
|
|
356
459
|
stagedTerminals: IFlexTerminalProjection[];
|
|
357
460
|
}
|
|
358
461
|
|
|
462
|
+
export type TFlexReversionSegmentStatus = 'capturing' | 'completed' | 'failed' | 'cancelled';
|
|
463
|
+
export type TFlexReversionProtocolVersion = 1 | 2;
|
|
464
|
+
export type TFlexReversionProvenance = 'transcript' | 'workspace';
|
|
465
|
+
export type TFlexReversionDisposition = 'pending' | 'revertible' | 'no-change' | 'nonrevertible';
|
|
466
|
+
|
|
467
|
+
export interface IFlexAffectedWorkspace {
|
|
468
|
+
readonly id: string;
|
|
469
|
+
readonly label: string;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
interface IFlexReversionSegmentV2 {
|
|
473
|
+
runId: string;
|
|
474
|
+
userMessageId: string;
|
|
475
|
+
status: TFlexReversionSegmentStatus;
|
|
476
|
+
contextAvailable: boolean;
|
|
477
|
+
eventIds: string[];
|
|
478
|
+
workspaceCaptured: boolean;
|
|
479
|
+
captureId?: string;
|
|
480
|
+
workspaceReference?: TJsonValue;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export interface IFlexReversionSegment extends IFlexReversionSegmentV2 {
|
|
484
|
+
protocolVersion: TFlexReversionProtocolVersion;
|
|
485
|
+
provenance: TFlexReversionProvenance;
|
|
486
|
+
disposition?: TFlexReversionDisposition;
|
|
487
|
+
affectedWorkspaces?: IFlexAffectedWorkspace[];
|
|
488
|
+
reasonCode?: string;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
interface IFlexPendingCaptureReversionV2 {
|
|
492
|
+
kind: 'capture';
|
|
493
|
+
runId: string;
|
|
494
|
+
captureId: string;
|
|
495
|
+
state: 'preparing' | 'prepared' | 'finalizing';
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export interface IFlexPendingCaptureReversion extends IFlexPendingCaptureReversionV2 {
|
|
499
|
+
protocolVersion: TFlexReversionProtocolVersion;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export interface IFlexPendingApplyReversion {
|
|
503
|
+
kind: 'apply';
|
|
504
|
+
operationId: string;
|
|
505
|
+
direction: 'undo' | 'redo';
|
|
506
|
+
fromCursor: number;
|
|
507
|
+
toCursor: number;
|
|
508
|
+
segmentRunIds: string[];
|
|
509
|
+
appliedRunIds: string[];
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
type TFlexPendingReversionV2 =
|
|
513
|
+
| IFlexPendingCaptureReversionV2
|
|
514
|
+
| IFlexPendingApplyReversion;
|
|
515
|
+
|
|
516
|
+
export type TFlexPendingReversion =
|
|
517
|
+
| IFlexPendingCaptureReversion
|
|
518
|
+
| IFlexPendingApplyReversion;
|
|
519
|
+
|
|
520
|
+
interface IFlexPendingReversionReleaseV2 {
|
|
521
|
+
runId: string;
|
|
522
|
+
captureId: string;
|
|
523
|
+
reference: TJsonValue;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export interface IFlexPendingReversionRelease extends IFlexPendingReversionReleaseV2 {
|
|
527
|
+
protocolVersion: TFlexReversionProtocolVersion;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export interface IFlexProjectionSnapshotV2 {
|
|
531
|
+
schemaVersion: 2;
|
|
532
|
+
revision: number;
|
|
533
|
+
messages: IFlexMessage[];
|
|
534
|
+
stagedTerminals: IFlexTerminalProjection[];
|
|
535
|
+
reversionSegments: IFlexReversionSegmentV2[];
|
|
536
|
+
revertCursor: number;
|
|
537
|
+
excludedRunIds: string[];
|
|
538
|
+
pendingReversion?: TFlexPendingReversionV2;
|
|
539
|
+
pendingReversionReleases: IFlexPendingReversionReleaseV2[];
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export interface IFlexProjectionSnapshotV3 {
|
|
543
|
+
schemaVersion: 3;
|
|
544
|
+
revision: number;
|
|
545
|
+
messages: IFlexMessage[];
|
|
546
|
+
stagedTerminals: IFlexTerminalProjection[];
|
|
547
|
+
reversionSegments: IFlexReversionSegment[];
|
|
548
|
+
revertCursor: number;
|
|
549
|
+
excludedRunIds: string[];
|
|
550
|
+
pendingReversion?: TFlexPendingReversion;
|
|
551
|
+
pendingReversionReleases: IFlexPendingReversionRelease[];
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export type IFlexProjectionSnapshot =
|
|
555
|
+
| IFlexProjectionSnapshotV1
|
|
556
|
+
| IFlexProjectionSnapshotV2
|
|
557
|
+
| IFlexProjectionSnapshotV3;
|
|
558
|
+
export type TFlexProjectionSnapshot = IFlexProjectionSnapshot;
|
|
559
|
+
export type IFlexProjectionSnapshotCurrent = IFlexProjectionSnapshotV3;
|
|
560
|
+
|
|
359
561
|
export interface IFlexPermissionSnapshot {
|
|
360
562
|
schemaVersion: 1;
|
|
361
563
|
revision: number;
|
|
@@ -372,11 +574,11 @@ export interface IFlexScopeStore {
|
|
|
372
574
|
}
|
|
373
575
|
|
|
374
576
|
export interface IFlexProjectionStore {
|
|
375
|
-
load(storageKey: string, sessionId: string): Promise<
|
|
577
|
+
load(storageKey: string, sessionId: string): Promise<TFlexProjectionSnapshot | undefined>;
|
|
376
578
|
save(
|
|
377
579
|
storageKey: string,
|
|
378
580
|
sessionId: string,
|
|
379
|
-
snapshot:
|
|
581
|
+
snapshot: IFlexProjectionSnapshotCurrent,
|
|
380
582
|
expectedRevision: number,
|
|
381
583
|
): Promise<void>;
|
|
382
584
|
deleteSession(storageKey: string, sessionId: string): Promise<void>;
|
|
@@ -438,6 +640,164 @@ export interface IFlexPromptQueueLimits {
|
|
|
438
640
|
maxTerminalEntriesPerSession?: number;
|
|
439
641
|
}
|
|
440
642
|
|
|
643
|
+
export interface IFlexReversionLimits {
|
|
644
|
+
maxCompletedTurns?: number;
|
|
645
|
+
maxSegments?: number;
|
|
646
|
+
maxExcludedRunIds?: number;
|
|
647
|
+
maxPendingReversionReleases?: number;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export const FLEX_REVERSION_DEFAULT_LIMITS = Object.freeze({
|
|
651
|
+
maxCompletedTurns: 100,
|
|
652
|
+
maxSegments: 300,
|
|
653
|
+
maxExcludedRunIds: 1000,
|
|
654
|
+
maxPendingReversionReleases: 1000,
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
export const FLEX_REVERSION_MAXIMUM_LIMITS = Object.freeze({
|
|
658
|
+
maxCompletedTurns: 1000,
|
|
659
|
+
maxSegments: 3000,
|
|
660
|
+
maxExcludedRunIds: 10_000,
|
|
661
|
+
maxPendingReversionReleases: 10_000,
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
export const FLEX_REVERSION_REFERENCE_MAX_BYTES = 256 * 1024;
|
|
665
|
+
export const FLEX_REVERSION_MAX_AFFECTED_WORKSPACES = 64;
|
|
666
|
+
export const FLEX_REVERSION_WORKSPACE_ID_MAX_BYTES = 512;
|
|
667
|
+
export const FLEX_REVERSION_WORKSPACE_LABEL_MAX_BYTES = 2048;
|
|
668
|
+
export const FLEX_REVERSION_REASON_CODE_MAX_BYTES = 128;
|
|
669
|
+
|
|
670
|
+
export interface IFlexTurnReversionBaseContext<TScope> {
|
|
671
|
+
readonly scopeId: string;
|
|
672
|
+
readonly scope: TScope;
|
|
673
|
+
readonly storageKey: string;
|
|
674
|
+
readonly sessionId: string;
|
|
675
|
+
readonly runId: string;
|
|
676
|
+
readonly captureId: string;
|
|
677
|
+
readonly signal: AbortSignal;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export interface IFlexTurnReversionCaptureInspection {
|
|
681
|
+
status: 'missing' | 'prepared' | 'finalized' | 'unknown';
|
|
682
|
+
reference?: TJsonValue;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export interface IFlexTurnReversionApplyContext<TScope>
|
|
686
|
+
extends IFlexTurnReversionBaseContext<TScope> {
|
|
687
|
+
readonly reference: TJsonValue;
|
|
688
|
+
readonly operationId: string;
|
|
689
|
+
readonly direction: 'undo' | 'redo';
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export interface IFlexTurnReversionApplyInspection {
|
|
693
|
+
status: 'not-applied' | 'applied' | 'unknown';
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export interface IFlexTurnReversionReleaseContext<TScope>
|
|
697
|
+
extends IFlexTurnReversionBaseContext<TScope> {
|
|
698
|
+
readonly reference: TJsonValue;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export interface IFlexTurnReversionProvider<TScope> {
|
|
702
|
+
prepare(
|
|
703
|
+
context: IFlexTurnReversionBaseContext<TScope>,
|
|
704
|
+
): Promise<void> | void;
|
|
705
|
+
inspectCapture(
|
|
706
|
+
context: IFlexTurnReversionBaseContext<TScope>,
|
|
707
|
+
): Promise<IFlexTurnReversionCaptureInspection> | IFlexTurnReversionCaptureInspection;
|
|
708
|
+
finalize(
|
|
709
|
+
context: IFlexTurnReversionBaseContext<TScope>,
|
|
710
|
+
): Promise<TJsonValue> | TJsonValue;
|
|
711
|
+
apply(
|
|
712
|
+
context: IFlexTurnReversionApplyContext<TScope>,
|
|
713
|
+
): Promise<void> | void;
|
|
714
|
+
inspectApply(
|
|
715
|
+
context: IFlexTurnReversionApplyContext<TScope>,
|
|
716
|
+
): Promise<IFlexTurnReversionApplyInspection> | IFlexTurnReversionApplyInspection;
|
|
717
|
+
release(
|
|
718
|
+
context: IFlexTurnReversionReleaseContext<TScope>,
|
|
719
|
+
): Promise<void> | void;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
export interface IFlexTurnReversionRevertibleOutcome {
|
|
723
|
+
readonly disposition: 'revertible';
|
|
724
|
+
readonly reference: TJsonValue;
|
|
725
|
+
readonly affectedWorkspaces: readonly IFlexAffectedWorkspace[];
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
export interface IFlexTurnReversionNoChangeOutcome {
|
|
729
|
+
readonly disposition: 'no-change';
|
|
730
|
+
readonly reference: TJsonValue;
|
|
731
|
+
readonly affectedWorkspaces?: readonly [];
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export interface IFlexTurnReversionNonrevertibleOutcome {
|
|
735
|
+
readonly disposition: 'nonrevertible';
|
|
736
|
+
readonly reference: TJsonValue;
|
|
737
|
+
readonly reasonCode: string;
|
|
738
|
+
readonly affectedWorkspaces?: readonly IFlexAffectedWorkspace[];
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
export type TFlexTurnReversionFinalizedOutcome =
|
|
742
|
+
| IFlexTurnReversionRevertibleOutcome
|
|
743
|
+
| IFlexTurnReversionNoChangeOutcome
|
|
744
|
+
| IFlexTurnReversionNonrevertibleOutcome;
|
|
745
|
+
|
|
746
|
+
export type TFlexTurnReversionCaptureInspectionV2 =
|
|
747
|
+
| { readonly status: 'missing' | 'prepared' | 'unknown' }
|
|
748
|
+
| {
|
|
749
|
+
readonly status: 'finalized';
|
|
750
|
+
readonly outcome: TFlexTurnReversionFinalizedOutcome;
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
export interface IFlexTurnReversionProviderV2<TScope> {
|
|
754
|
+
readonly protocolVersion: 2;
|
|
755
|
+
prepare(
|
|
756
|
+
context: IFlexTurnReversionBaseContext<TScope>,
|
|
757
|
+
): Promise<void> | void;
|
|
758
|
+
inspectCapture(
|
|
759
|
+
context: IFlexTurnReversionBaseContext<TScope>,
|
|
760
|
+
): Promise<TFlexTurnReversionCaptureInspectionV2> | TFlexTurnReversionCaptureInspectionV2;
|
|
761
|
+
finalize(
|
|
762
|
+
context: IFlexTurnReversionBaseContext<TScope>,
|
|
763
|
+
): Promise<TFlexTurnReversionFinalizedOutcome> | TFlexTurnReversionFinalizedOutcome;
|
|
764
|
+
apply(
|
|
765
|
+
context: IFlexTurnReversionApplyContext<TScope>,
|
|
766
|
+
): Promise<void> | void;
|
|
767
|
+
inspectApply(
|
|
768
|
+
context: IFlexTurnReversionApplyContext<TScope>,
|
|
769
|
+
): Promise<IFlexTurnReversionApplyInspection> | IFlexTurnReversionApplyInspection;
|
|
770
|
+
release(
|
|
771
|
+
context: IFlexTurnReversionReleaseContext<TScope>,
|
|
772
|
+
): Promise<void> | void;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
export type TFlexReversionPolicy = 'transcript-optional' | 'workspace-required';
|
|
776
|
+
|
|
777
|
+
export type TFlexSessionReversionGroupKind = 'candidate' | 'barrier' | 'no-change';
|
|
778
|
+
|
|
779
|
+
export interface IFlexSessionReversionGroup {
|
|
780
|
+
readonly runId: string;
|
|
781
|
+
readonly kind: TFlexSessionReversionGroupKind;
|
|
782
|
+
readonly visibility: 'visible' | 'hidden';
|
|
783
|
+
readonly affectedWorkspaces: readonly IFlexAffectedWorkspace[];
|
|
784
|
+
readonly affectedWorkspacesTruncated: boolean;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
export interface IFlexSessionReversionInfo {
|
|
788
|
+
readonly undoAvailable: boolean;
|
|
789
|
+
readonly redoAvailable: boolean;
|
|
790
|
+
readonly groups: readonly IFlexSessionReversionGroup[];
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
export interface IFlexUndoSessionResult {
|
|
794
|
+
revertedRunId: string;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
export interface IFlexRedoSessionResult {
|
|
798
|
+
restoredRunId: string;
|
|
799
|
+
}
|
|
800
|
+
|
|
441
801
|
export type TFlexExternalErrorSource =
|
|
442
802
|
| 'modelResolver'
|
|
443
803
|
| 'toolProvider'
|
|
@@ -445,7 +805,9 @@ export type TFlexExternalErrorSource =
|
|
|
445
805
|
| 'toolCallback'
|
|
446
806
|
| 'toolCleanup'
|
|
447
807
|
| 'agentSession'
|
|
448
|
-
| 'persistence'
|
|
808
|
+
| 'persistence'
|
|
809
|
+
| 'slashCommand'
|
|
810
|
+
| 'turnReversion';
|
|
449
811
|
|
|
450
812
|
export interface IFlexExternalErrorContext {
|
|
451
813
|
source: TFlexExternalErrorSource;
|
|
@@ -524,8 +886,12 @@ export interface IFlexHarnessOptions<TScope> {
|
|
|
524
886
|
toolOutputLimits?: IFlexJsonLimits;
|
|
525
887
|
callbackLimits?: IFlexCallbackLimits;
|
|
526
888
|
promptQueueLimits?: IFlexPromptQueueLimits;
|
|
889
|
+
reversionLimits?: IFlexReversionLimits;
|
|
890
|
+
turnReversionProvider?: IFlexTurnReversionProvider<TScope> | IFlexTurnReversionProviderV2<TScope>;
|
|
891
|
+
reversionPolicy?: TFlexReversionPolicy;
|
|
527
892
|
externalErrorProjector?: TFlexExternalErrorProjector;
|
|
528
893
|
subagents?: IFlexSubagentDefinition[];
|
|
894
|
+
slashCommands?: readonly TFlexSlashCommandRegistration<TScope>[];
|
|
529
895
|
maxSubagentDepth?: number;
|
|
530
896
|
maxSubagentCallsPerRun?: number;
|
|
531
897
|
}
|
|
@@ -645,6 +1011,12 @@ export interface IFlexPromptQueueEvent extends IFlexEventBase {
|
|
|
645
1011
|
readonly entry: IFlexPromptQueueEntry;
|
|
646
1012
|
}
|
|
647
1013
|
|
|
1014
|
+
export interface IFlexSessionHistoryChangedEvent extends IFlexEventBase {
|
|
1015
|
+
readonly type: 'session.history.changed';
|
|
1016
|
+
readonly direction: 'undo' | 'redo' | 'branch';
|
|
1017
|
+
readonly runId?: string;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
648
1020
|
export interface IFlexErrorInfo {
|
|
649
1021
|
name: string;
|
|
650
1022
|
message: string;
|
|
@@ -661,6 +1033,7 @@ export type TFlexHarnessEvent =
|
|
|
661
1033
|
| IFlexPermissionRequestedEvent
|
|
662
1034
|
| IFlexPermissionResolvedEvent
|
|
663
1035
|
| IFlexRunFinishedEvent
|
|
664
|
-
| IFlexPromptQueueEvent
|
|
1036
|
+
| IFlexPromptQueueEvent
|
|
1037
|
+
| IFlexSessionHistoryChangedEvent;
|
|
665
1038
|
|
|
666
1039
|
export type TFlexHarnessEventListener = (event: TFlexHarnessEvent) => void;
|
package/ts/plugins.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
buildModelMessages,
|
|
14
14
|
ToolJobStoreConflictError,
|
|
15
15
|
createAgentEvent,
|
|
16
|
+
filterModelVisibleAgentEvents,
|
|
16
17
|
getAgentGenerationTransactions,
|
|
17
18
|
modelMessagesToAgentEvents,
|
|
18
19
|
tool,
|
|
@@ -27,6 +28,7 @@ export {
|
|
|
27
28
|
buildModelMessages,
|
|
28
29
|
ToolJobStoreConflictError,
|
|
29
30
|
createAgentEvent,
|
|
31
|
+
filterModelVisibleAgentEvents,
|
|
30
32
|
getAgentGenerationTransactions,
|
|
31
33
|
modelMessagesToAgentEvents,
|
|
32
34
|
tool,
|