@floegence/floeterm-terminal-web 0.5.13 → 0.5.15
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/README.md +20 -5
- package/dist/core/PagedTerminalOutputCoordinator.d.ts +29 -2
- package/dist/core/PagedTerminalOutputCoordinator.d.ts.map +1 -1
- package/dist/core/PagedTerminalOutputCoordinator.js +348 -120
- package/dist/core/PagedTerminalOutputCoordinator.js.map +1 -1
- package/dist/core/TerminalCore.d.ts +2 -0
- package/dist/core/TerminalCore.d.ts.map +1 -1
- package/dist/core/TerminalCore.js +9 -1
- package/dist/core/TerminalCore.js.map +1 -1
- package/dist/core/TerminalOutputPipeline.d.ts +1 -0
- package/dist/core/TerminalOutputPipeline.d.ts.map +1 -1
- package/dist/core/TerminalOutputPipeline.js +24 -7
- package/dist/core/TerminalOutputPipeline.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,17 +67,32 @@ Hosts with cursor-paged history APIs can use the framework-neutral coordinator i
|
|
|
67
67
|
|
|
68
68
|
```ts
|
|
69
69
|
const output = createPagedTerminalOutputCoordinator({
|
|
70
|
-
fetchPage: ({ startSequence, cursor, signal }) =>
|
|
71
|
-
transport.historyPage(sessionId,
|
|
72
|
-
|
|
70
|
+
fetchPage: ({ startSequence, endSequence, historyGeneration, cursor, signal }) =>
|
|
71
|
+
transport.historyPage(sessionId, {
|
|
72
|
+
startSequence,
|
|
73
|
+
endSequence,
|
|
74
|
+
historyGeneration,
|
|
75
|
+
cursor,
|
|
76
|
+
signal,
|
|
77
|
+
}),
|
|
78
|
+
write: data => new Promise(resolve => core.write(data, resolve)),
|
|
79
|
+
writeHistory: data => new Promise(resolve => core.writeHistory(data, resolve)),
|
|
73
80
|
clear: () => core.clear(),
|
|
74
81
|
});
|
|
75
82
|
|
|
76
|
-
|
|
83
|
+
void output.attach(1);
|
|
84
|
+
const baseline = await output.waitForBaseline();
|
|
85
|
+
if (!baseline.baselineReady) {
|
|
86
|
+
throw baseline.failure;
|
|
87
|
+
}
|
|
77
88
|
events.onData(sessionId, chunk => output.pushLive(chunk));
|
|
78
89
|
```
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
History pages must explicitly include `coveredThroughSequence`, including the valid empty-history value `0`. A missing or malformed value produces a structured contract failure instead of guessing from the last returned chunk. The first page may also provide `snapshotEndSequence`, `firstRetainedSequence`, and `historyGeneration`; pass the snapshot end and generation through each later request.
|
|
92
|
+
|
|
93
|
+
`baselineReady` becomes true only after the complete fixed history snapshot has been source-sequence merged with retained live output and the final history writer completion has fired. After that fence, catch-up retries preserve baseline readiness and do not need to block input. Structured failures distinguish initial replay from background catch-up and expose stable codes without requiring error-string parsing.
|
|
94
|
+
|
|
95
|
+
Use `TerminalCore.writeHistory` for history batches. Its auto-response suppression is scoped to that parser write and ends at its completion callback, so later live output and user input use normal terminal behavior.
|
|
81
96
|
|
|
82
97
|
## Restorable In-Memory Snapshots
|
|
83
98
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TerminalOutputPipelineChunk, TerminalOutputPipelineScheduler } from './TerminalOutputPipeline';
|
|
2
2
|
export type PagedTerminalOutputState = 'idle' | 'initial-replay' | 'live' | 'catching-up' | 'retry-wait' | 'failed' | 'disposed';
|
|
3
3
|
export interface PagedTerminalHistoryRequest {
|
|
4
4
|
startSequence: number;
|
|
5
|
+
endSequence?: number;
|
|
6
|
+
historyGeneration?: number;
|
|
5
7
|
cursor?: string | number;
|
|
6
8
|
signal: AbortSignal;
|
|
7
9
|
}
|
|
@@ -10,15 +12,32 @@ export interface PagedTerminalHistoryPage {
|
|
|
10
12
|
hasMore: boolean;
|
|
11
13
|
nextCursor?: string | number;
|
|
12
14
|
firstAvailableSequence?: number;
|
|
15
|
+
firstRetainedSequence?: number;
|
|
13
16
|
coveredThroughSequence: number;
|
|
17
|
+
snapshotEndSequence?: number;
|
|
18
|
+
historyGeneration?: number;
|
|
19
|
+
historyReset?: boolean;
|
|
20
|
+
historyTruncated?: boolean;
|
|
14
21
|
coveredBytes?: number;
|
|
15
22
|
totalBytes?: number;
|
|
16
23
|
}
|
|
17
24
|
export type PagedTerminalHistoryTruncationReason = 'history-evicted' | 'retained-live-overflow';
|
|
25
|
+
export type PagedTerminalOutputFailureCode = 'history_fetch_failed' | 'history_coverage_incomplete' | 'history_contract_missing' | 'history_contract_invalid' | 'retained_live_overflow' | 'history_evicted';
|
|
26
|
+
export interface PagedTerminalOutputFailure {
|
|
27
|
+
code: PagedTerminalOutputFailureCode;
|
|
28
|
+
phase: 'initial' | 'catch_up';
|
|
29
|
+
retryable: boolean;
|
|
30
|
+
attempt: number;
|
|
31
|
+
coveredSequence: number;
|
|
32
|
+
firstRetainedSequence?: number;
|
|
33
|
+
attachGeneration: number;
|
|
34
|
+
cause?: unknown;
|
|
35
|
+
}
|
|
18
36
|
export interface PagedTerminalOutputPolicy {
|
|
19
37
|
maxRetainedLiveChunks: number;
|
|
20
38
|
maxRetainedLiveBytes: number;
|
|
21
39
|
retryDelaysMs: readonly number[];
|
|
40
|
+
maxWriteBatchBytes: number;
|
|
22
41
|
}
|
|
23
42
|
export interface PagedTerminalOutputScheduler extends TerminalOutputPipelineScheduler {
|
|
24
43
|
setTimer(callback: () => void, delayMs: number): ReturnType<typeof setTimeout>;
|
|
@@ -27,17 +46,23 @@ export interface PagedTerminalOutputScheduler extends TerminalOutputPipelineSche
|
|
|
27
46
|
export interface PagedTerminalOutputSnapshot {
|
|
28
47
|
state: PagedTerminalOutputState;
|
|
29
48
|
active: boolean;
|
|
49
|
+
baselineReady: boolean;
|
|
30
50
|
coveredThroughSequence: number;
|
|
31
51
|
retainedLiveChunks: number;
|
|
32
52
|
retainedLiveBytes: number;
|
|
33
53
|
retryAttempt: number;
|
|
34
54
|
retryScheduled: boolean;
|
|
55
|
+
failure: PagedTerminalOutputFailure | null;
|
|
56
|
+
/** @deprecated Use failure for stable recovery diagnostics. */
|
|
35
57
|
lastError: unknown;
|
|
58
|
+
attachGeneration: number;
|
|
36
59
|
disposed: boolean;
|
|
37
60
|
}
|
|
61
|
+
type PagedTerminalOutputWriter = (data: Uint8Array, chunks: readonly TerminalOutputPipelineChunk[]) => unknown | Promise<unknown>;
|
|
38
62
|
export interface PagedTerminalOutputCoordinatorOptions {
|
|
39
63
|
fetchPage(request: PagedTerminalHistoryRequest): Promise<PagedTerminalHistoryPage>;
|
|
40
|
-
write
|
|
64
|
+
write: PagedTerminalOutputWriter;
|
|
65
|
+
writeHistory?: PagedTerminalOutputWriter;
|
|
41
66
|
clear?: () => void;
|
|
42
67
|
transformChunk?: (chunk: TerminalOutputPipelineChunk) => Uint8Array | null;
|
|
43
68
|
isInteractive?: () => boolean;
|
|
@@ -48,6 +73,7 @@ export interface PagedTerminalOutputCoordinatorOptions {
|
|
|
48
73
|
}
|
|
49
74
|
export interface PagedTerminalOutputCoordinatorHandle {
|
|
50
75
|
attach(startSequence?: number): Promise<void>;
|
|
76
|
+
waitForBaseline(): Promise<PagedTerminalOutputSnapshot>;
|
|
51
77
|
pushLive(chunk: TerminalOutputPipelineChunk): void;
|
|
52
78
|
setActive(active: boolean): void;
|
|
53
79
|
clear(startSequence?: number): void;
|
|
@@ -56,4 +82,5 @@ export interface PagedTerminalOutputCoordinatorHandle {
|
|
|
56
82
|
dispose(): void;
|
|
57
83
|
}
|
|
58
84
|
export declare const createPagedTerminalOutputCoordinator: (options: PagedTerminalOutputCoordinatorOptions) => PagedTerminalOutputCoordinatorHandle;
|
|
85
|
+
export {};
|
|
59
86
|
//# sourceMappingURL=PagedTerminalOutputCoordinator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PagedTerminalOutputCoordinator.d.ts","sourceRoot":"","sources":["../../src/core/PagedTerminalOutputCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"PagedTerminalOutputCoordinator.d.ts","sourceRoot":"","sources":["../../src/core/PagedTerminalOutputCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,gBAAgB,GAChB,MAAM,GACN,aAAa,GACb,YAAY,GACZ,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,2BAA2B;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,oCAAoC,GAC5C,iBAAiB,GACjB,wBAAwB,CAAC;AAE7B,MAAM,MAAM,8BAA8B,GACtC,sBAAsB,GACtB,6BAA6B,GAC7B,0BAA0B,GAC1B,0BAA0B,GAC1B,wBAAwB,GACxB,iB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