@sealant/sdk-next 0.40.0-next.983 → 0.40.0-next.984
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/facade/record.d.ts +6 -0
- package/dist/facade/record.js +34 -18
- package/package.json +3 -3
package/dist/facade/record.d.ts
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
import { type TimelineEntry as WireTimelineEntry } from "@sealant/api-contracts";
|
|
9
9
|
import type { RunCommand, RunRecord, TimelineEntry } from "../types.js";
|
|
10
10
|
import { type SdkContext } from "./context.js";
|
|
11
|
+
/**
|
|
12
|
+
* Entries asked for per timeline read: the server's largest page. A read that answers a full page
|
|
13
|
+
* is followed by the next, from the sequence after its last entry, until one answers short, so a
|
|
14
|
+
* record longer than any one page is read whole.
|
|
15
|
+
*/
|
|
16
|
+
export declare const TIMELINE_PAGE_SIZE = 5000;
|
|
11
17
|
/**
|
|
12
18
|
* Maps a wire entry to the public DISCRIMINATED entry: the contract's payload schemas fold
|
|
13
19
|
* `(kind, ref)` into typed `data`, degrading to the `unknown` case (raw kind + payload preserved)
|
package/dist/facade/record.js
CHANGED
|
@@ -15,6 +15,12 @@ import { bindPolling } from "./context.js";
|
|
|
15
15
|
// The transport swaps to SSE over Postgres LISTEN/NOTIFY in Stage 5 behind this same signature.
|
|
16
16
|
const TERMINAL_RUN_STATUSES = new Set(["completed", "failed", "cancelled"]);
|
|
17
17
|
const STREAM_POLL_INTERVAL_MS = 500;
|
|
18
|
+
/**
|
|
19
|
+
* Entries asked for per timeline read: the server's largest page. A read that answers a full page
|
|
20
|
+
* is followed by the next, from the sequence after its last entry, until one answers short, so a
|
|
21
|
+
* record longer than any one page is read whole.
|
|
22
|
+
*/
|
|
23
|
+
export const TIMELINE_PAGE_SIZE = 5000;
|
|
18
24
|
/**
|
|
19
25
|
* Maps a wire entry to the public DISCRIMINATED entry: the contract's payload schemas fold
|
|
20
26
|
* `(kind, ref)` into typed `data`, degrading to the `unknown` case (raw kind + payload preserved)
|
|
@@ -150,10 +156,33 @@ export const renderTranscript = (commands) => {
|
|
|
150
156
|
return `${blocks.join("\n\n")}\n`;
|
|
151
157
|
};
|
|
152
158
|
export const makeRunRecord = (ctx, runId) => {
|
|
153
|
-
const
|
|
159
|
+
const timelinePage = (from) => getRunTimelineOp(runId, {
|
|
154
160
|
ownerUserId: ctx.config.hostLocal.ownerUserId,
|
|
161
|
+
limit: String(TIMELINE_PAGE_SIZE),
|
|
155
162
|
...(from === undefined ? {} : { fromSequence: from.toString() }),
|
|
156
|
-
})
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* Every entry from `from` on, page by page, through `call`: each page's entries are yielded
|
|
166
|
+
* before the next page is asked for.
|
|
167
|
+
*/
|
|
168
|
+
async function* timelinePages(call, from) {
|
|
169
|
+
let next = from;
|
|
170
|
+
for (;;) {
|
|
171
|
+
const page = await call(timelinePage(next));
|
|
172
|
+
yield* page;
|
|
173
|
+
const last = page.at(-1);
|
|
174
|
+
if (page.length < TIMELINE_PAGE_SIZE || last === undefined)
|
|
175
|
+
return;
|
|
176
|
+
next = BigInt(last.sequence) + 1n;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const inCallerTrace = (effect) => ctx.runtime.run(effect);
|
|
180
|
+
const fetchTimeline = async (from) => {
|
|
181
|
+
const entries = [];
|
|
182
|
+
for await (const entry of timelinePages(inCallerTrace, from))
|
|
183
|
+
entries.push(entry);
|
|
184
|
+
return entries;
|
|
185
|
+
};
|
|
157
186
|
return {
|
|
158
187
|
runId,
|
|
159
188
|
replay: async (options) => {
|
|
@@ -198,11 +227,7 @@ export const makeRunRecord = (ctx, runId) => {
|
|
|
198
227
|
for (;;) {
|
|
199
228
|
if (signal?.aborted === true)
|
|
200
229
|
return;
|
|
201
|
-
const
|
|
202
|
-
ownerUserId: ctx.config.hostLocal.ownerUserId,
|
|
203
|
-
...(from === undefined ? {} : { fromSequence: from.toString() }),
|
|
204
|
-
}));
|
|
205
|
-
for (const entry of wire) {
|
|
230
|
+
for await (const entry of timelinePages(call, from)) {
|
|
206
231
|
const mapped = toTimelineEntry(entry);
|
|
207
232
|
yield mapped;
|
|
208
233
|
from = mapped.sequence + 1n;
|
|
@@ -212,11 +237,7 @@ export const makeRunRecord = (ctx, runId) => {
|
|
|
212
237
|
const run = await call(getRunOp(runId, ctx.config.hostLocal.ownerUserId));
|
|
213
238
|
call = polling.poll;
|
|
214
239
|
if (TERMINAL_RUN_STATUSES.has(run.status)) {
|
|
215
|
-
const
|
|
216
|
-
ownerUserId: ctx.config.hostLocal.ownerUserId,
|
|
217
|
-
...(from === undefined ? {} : { fromSequence: from.toString() }),
|
|
218
|
-
}));
|
|
219
|
-
for (const entry of tail) {
|
|
240
|
+
for await (const entry of timelinePages(polling.run, from)) {
|
|
220
241
|
yield toTimelineEntry(entry);
|
|
221
242
|
}
|
|
222
243
|
return;
|
|
@@ -230,13 +251,8 @@ export const makeRunRecord = (ctx, runId) => {
|
|
|
230
251
|
return iterate();
|
|
231
252
|
},
|
|
232
253
|
timeline: (options) => {
|
|
233
|
-
const run = ctx.runtime;
|
|
234
254
|
async function* iterate() {
|
|
235
|
-
const
|
|
236
|
-
ownerUserId: ctx.config.hostLocal.ownerUserId,
|
|
237
|
-
...(options?.from === undefined ? {} : { fromSequence: options.from.toString() }),
|
|
238
|
-
}));
|
|
239
|
-
for (const entry of wire) {
|
|
255
|
+
for await (const entry of timelinePages(inCallerTrace, options?.from)) {
|
|
240
256
|
yield toTimelineEntry(entry);
|
|
241
257
|
}
|
|
242
258
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealant/sdk-next",
|
|
3
|
-
"version": "0.40.0-next.
|
|
3
|
+
"version": "0.40.0-next.984",
|
|
4
4
|
"description": "The fluent public SDK for Sealant — create a workspace, run a harness, replay the record.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"node": ">=20"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.
|
|
29
|
+
"@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.984"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"effect": "^4.0.5"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "55136581c9c4b246ae59f0a65cc0d75e36084a65",
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
}
|