@usine/durable 0.0.0-stage → 0.2.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 +661 -0
- package/README.md +83 -2
- package/dist/attempt/documents.d.ts +86 -0
- package/dist/attempt/documents.d.ts.map +1 -0
- package/dist/attempt/documents.js +30 -0
- package/dist/attempt/documents.js.map +1 -0
- package/dist/attempt/events.d.ts +22 -0
- package/dist/attempt/events.d.ts.map +1 -0
- package/dist/attempt/events.js +110 -0
- package/dist/attempt/events.js.map +1 -0
- package/dist/attempt/extension.d.ts +48 -0
- package/dist/attempt/extension.d.ts.map +1 -0
- package/dist/attempt/extension.js +34 -0
- package/dist/attempt/extension.js.map +1 -0
- package/dist/attempt/hubs.d.ts +133 -0
- package/dist/attempt/hubs.d.ts.map +1 -0
- package/dist/attempt/hubs.js +146 -0
- package/dist/attempt/hubs.js.map +1 -0
- package/dist/attempt/outcome.d.ts +22 -0
- package/dist/attempt/outcome.d.ts.map +1 -0
- package/dist/attempt/outcome.js +84 -0
- package/dist/attempt/outcome.js.map +1 -0
- package/dist/attempt/parent.d.ts +27 -0
- package/dist/attempt/parent.d.ts.map +1 -0
- package/dist/attempt/parent.js +109 -0
- package/dist/attempt/parent.js.map +1 -0
- package/dist/attempt/relay.d.ts +41 -0
- package/dist/attempt/relay.d.ts.map +1 -0
- package/dist/attempt/relay.js +457 -0
- package/dist/attempt/relay.js.map +1 -0
- package/dist/attempt/repair.d.ts +14 -0
- package/dist/attempt/repair.d.ts.map +1 -0
- package/dist/attempt/repair.js +150 -0
- package/dist/attempt/repair.js.map +1 -0
- package/dist/attempt/request.d.ts +18 -0
- package/dist/attempt/request.d.ts.map +1 -0
- package/dist/attempt/request.js +24 -0
- package/dist/attempt/request.js.map +1 -0
- package/dist/attempt/runtime.d.ts +10 -0
- package/dist/attempt/runtime.d.ts.map +1 -0
- package/dist/attempt/runtime.js +429 -0
- package/dist/attempt/runtime.js.map +1 -0
- package/dist/attempt/services.d.ts +15 -0
- package/dist/attempt/services.d.ts.map +1 -0
- package/dist/attempt/services.js +2 -0
- package/dist/attempt/services.js.map +1 -0
- package/dist/attempt/subagent.d.ts +17 -0
- package/dist/attempt/subagent.d.ts.map +1 -0
- package/dist/attempt/subagent.js +208 -0
- package/dist/attempt/subagent.js.map +1 -0
- package/dist/attempt/task.d.ts +61 -0
- package/dist/attempt/task.d.ts.map +1 -0
- package/dist/attempt/task.js +302 -0
- package/dist/attempt/task.js.map +1 -0
- package/dist/attempt/watch.d.ts +8 -0
- package/dist/attempt/watch.d.ts.map +1 -0
- package/dist/attempt/watch.js +25 -0
- package/dist/attempt/watch.js.map +1 -0
- package/dist/attempt-runtime.d.ts +128 -0
- package/dist/attempt-runtime.d.ts.map +1 -0
- package/dist/attempt-runtime.js +78 -0
- package/dist/attempt-runtime.js.map +1 -0
- package/dist/backup.d.ts +26 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +100 -0
- package/dist/backup.js.map +1 -0
- package/dist/harness.d.ts +101 -0
- package/dist/harness.d.ts.map +1 -0
- package/dist/harness.js +298 -0
- package/dist/harness.js.map +1 -0
- package/dist/live.d.ts +15 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +51 -0
- package/dist/live.js.map +1 -0
- package/dist/storage-path.d.ts +4 -0
- package/dist/storage-path.d.ts.map +1 -0
- package/dist/storage-path.js +2 -0
- package/dist/storage-path.js.map +1 -0
- package/dist/testing.d.ts +116 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +314 -0
- package/dist/testing.js.map +1 -0
- package/package.json +72 -3
package/dist/harness.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
|
|
2
|
+
import { createRegistry, Harness, SessionFailed, } from "@earendil-works/pi-durable";
|
|
3
|
+
import { Context, Deferred, Effect, Layer, Option, Result, Schema } from "effect";
|
|
4
|
+
/** A failed pi-durable call. */
|
|
5
|
+
export class DurableHarnessError extends Schema.TaggedError("@usine/durable/DurableHarnessError")("DurableHarnessError", {
|
|
6
|
+
/**
|
|
7
|
+
* A description of the failed operation, such as `open the durable harness`, or the
|
|
8
|
+
* `operation` passed to `use`.
|
|
9
|
+
*/
|
|
10
|
+
operation: Schema.NonEmptyString,
|
|
11
|
+
/** The error message, or the storage error's message if a storage error failed the harness. */
|
|
12
|
+
message: Schema.NonEmptyString,
|
|
13
|
+
cause: Schema.Defect(),
|
|
14
|
+
}) {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A storage error that failed the pi-durable Session. pi-durable then aborts the harness's running
|
|
18
|
+
* tasks and closes it, and every later call on it fails.
|
|
19
|
+
*/
|
|
20
|
+
export class DurableStorageFailed extends Schema.TaggedError("@usine/durable/DurableStorageFailed")("DurableStorageFailed", {
|
|
21
|
+
/** The failed harness's generation: 1 for the first open, and one more for each reopen. */
|
|
22
|
+
generation: Schema.Int,
|
|
23
|
+
/** The storage error's message. */
|
|
24
|
+
message: Schema.NonEmptyString,
|
|
25
|
+
cause: Schema.Defect(),
|
|
26
|
+
}) {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The pi-durable Harness over one storage. After a storage error fails the harness, reopens the
|
|
30
|
+
* storage and resumes the tasks, unless `resume` hasn't completed yet. Stops if the reopen fails
|
|
31
|
+
* or if the reopened harness fails within a minute.
|
|
32
|
+
*/
|
|
33
|
+
export class DurableHarness extends Context.Service()("@usine/durable/DurableHarness") {
|
|
34
|
+
}
|
|
35
|
+
/** The interval in which repeats of a reported failure are counted and then logged once. */
|
|
36
|
+
const REPORT_LOG_INTERVAL_MILLIS = 5_000;
|
|
37
|
+
/** A reopened harness that fails within this time stops instead of reopening. */
|
|
38
|
+
const REFAIL_MILLIS = 60_000;
|
|
39
|
+
const RESUME_OPERATION = "resume the durable tasks";
|
|
40
|
+
const messageOf = (cause) => cause instanceof Error && cause.message.length > 0 ? cause.message : String(cause) || "unknown";
|
|
41
|
+
/**
|
|
42
|
+
* Returns a `DurableHarnessError` with the message of `cause`. For a `SessionFailed`, uses the
|
|
43
|
+
* message of the storage error that failed the harness.
|
|
44
|
+
*/
|
|
45
|
+
export const durableError = (operation, cause) => new DurableHarnessError({
|
|
46
|
+
operation,
|
|
47
|
+
message: messageOf(cause instanceof SessionFailed ? cause.cause : cause),
|
|
48
|
+
cause,
|
|
49
|
+
});
|
|
50
|
+
const make = Effect.fn("DurableHarness.make")(function* (options) {
|
|
51
|
+
const services = yield* Effect.context();
|
|
52
|
+
const fork = Effect.runForkWith(services);
|
|
53
|
+
const scope = yield* Effect.scope;
|
|
54
|
+
const registry = createRegistry();
|
|
55
|
+
const listeners = new Set();
|
|
56
|
+
let resumed = Option.none();
|
|
57
|
+
let finalizing = false;
|
|
58
|
+
let stopped = false;
|
|
59
|
+
/**
|
|
60
|
+
* Set while the current harness has failed. Succeeds with the reopened harness, or fails with the
|
|
61
|
+
* storage failure if no reopen follows.
|
|
62
|
+
*/
|
|
63
|
+
let failed = Option.none();
|
|
64
|
+
const logRepeats = (generation, message, repeats) => {
|
|
65
|
+
fork(Effect.logWarning("pi-durable reported the same failure again", {
|
|
66
|
+
generation,
|
|
67
|
+
cause: message,
|
|
68
|
+
repeats: repeats.unlogged,
|
|
69
|
+
}));
|
|
70
|
+
repeats.unlogged = 0;
|
|
71
|
+
repeats.loggedAt = Date.now();
|
|
72
|
+
};
|
|
73
|
+
// Called synchronously from inside pi-durable.
|
|
74
|
+
function report(generation, cause) {
|
|
75
|
+
const message = messageOf(cause);
|
|
76
|
+
// pi-durable also reports the error that fails the Session; the failure handling logs it.
|
|
77
|
+
if (generation.failing) {
|
|
78
|
+
fork(Effect.logDebug("pi-durable reported a failure of a failed harness", {
|
|
79
|
+
generation: generation.number,
|
|
80
|
+
cause: message,
|
|
81
|
+
}));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const repeats = generation.reports.get(message);
|
|
85
|
+
if (repeats === undefined) {
|
|
86
|
+
generation.reports.set(message, { unlogged: 0, loggedAt: Date.now() });
|
|
87
|
+
fork(Effect.logWarning("pi-durable reported a failure that did not fail its caller", {
|
|
88
|
+
generation: generation.number,
|
|
89
|
+
cause: message,
|
|
90
|
+
}));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
repeats.unlogged += 1;
|
|
94
|
+
if (Date.now() - repeats.loggedAt >= REPORT_LOG_INTERVAL_MILLIS) {
|
|
95
|
+
logRepeats(generation.number, message, repeats);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const open = Effect.fn("DurableHarness.open")(function* (number) {
|
|
99
|
+
yield* Effect.annotateCurrentSpan({ generation: number });
|
|
100
|
+
const storage = yield* options.openStorage;
|
|
101
|
+
const generation = {
|
|
102
|
+
number,
|
|
103
|
+
reports: new Map(),
|
|
104
|
+
closing: false,
|
|
105
|
+
failing: false,
|
|
106
|
+
handled: false,
|
|
107
|
+
};
|
|
108
|
+
const harness = yield* Effect.tryPromise({
|
|
109
|
+
try: () => Harness.open(storage, { models: options.models, registry, onReport: (error) => report(generation, error) }, BACKGROUND_CONTEXT),
|
|
110
|
+
catch: (cause) => durableError("open the durable harness", cause),
|
|
111
|
+
});
|
|
112
|
+
const opened = { generation, harness, storage, openedAt: Date.now() };
|
|
113
|
+
harness.subscribeClose(() => {
|
|
114
|
+
if (generation.closing)
|
|
115
|
+
return;
|
|
116
|
+
generation.failing = true;
|
|
117
|
+
handleFailure(opened);
|
|
118
|
+
});
|
|
119
|
+
harness.subscribeCommits((publication) => {
|
|
120
|
+
for (const [message, repeats] of generation.reports) {
|
|
121
|
+
if (repeats.unlogged === 0)
|
|
122
|
+
generation.reports.delete(message);
|
|
123
|
+
}
|
|
124
|
+
for (const listener of listeners)
|
|
125
|
+
listener.onCommit(publication);
|
|
126
|
+
});
|
|
127
|
+
if (Option.isSome(resumed)) {
|
|
128
|
+
yield* resumed.value(harness, storage);
|
|
129
|
+
yield* Effect.try({
|
|
130
|
+
try: () => harness.resume(),
|
|
131
|
+
catch: (cause) => durableError(RESUME_OPERATION, cause),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
yield* Effect.logInfo("Opened the durable harness", {
|
|
135
|
+
generation: number,
|
|
136
|
+
resumed: Option.isSome(resumed),
|
|
137
|
+
});
|
|
138
|
+
return opened;
|
|
139
|
+
});
|
|
140
|
+
const flushReports = (generation) => {
|
|
141
|
+
for (const [message, repeats] of generation.reports) {
|
|
142
|
+
if (repeats.unlogged > 0)
|
|
143
|
+
logRepeats(generation.number, message, repeats);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const close = Effect.fn("DurableHarness.close")(function* (opened) {
|
|
147
|
+
const generation = opened.generation;
|
|
148
|
+
yield* Effect.annotateCurrentSpan({ generation: generation.number });
|
|
149
|
+
generation.closing = true;
|
|
150
|
+
flushReports(generation);
|
|
151
|
+
yield* Effect.tryPromise({
|
|
152
|
+
try: () => opened.harness.close(BACKGROUND_CONTEXT),
|
|
153
|
+
catch: (cause) => durableError("close", cause),
|
|
154
|
+
}).pipe(Effect.tapError((error) => Effect.logError("Could not close the durable harness", {
|
|
155
|
+
generation: generation.number,
|
|
156
|
+
message: error.message,
|
|
157
|
+
})), Effect.ignore);
|
|
158
|
+
});
|
|
159
|
+
const stop = Effect.fn("DurableHarness.stop")(function* (failure, ready) {
|
|
160
|
+
stopped = true;
|
|
161
|
+
yield* Effect.logError("Stopped the durable harness: the storage failed again on reopening; durable calls fail until the orchestrator restarts", { generation: failure.generation, cause: failure.message });
|
|
162
|
+
yield* Deferred.fail(ready, failure);
|
|
163
|
+
});
|
|
164
|
+
const reopen = Effect.fn("DurableHarness.reopen")(function* (previous, ready) {
|
|
165
|
+
const number = previous.generation.number + 1;
|
|
166
|
+
yield* Effect.annotateCurrentSpan({ generation: number });
|
|
167
|
+
yield* Effect.logInfo("Reopening the durable harness", { generation: number });
|
|
168
|
+
const next = yield* open(number).pipe(Effect.result);
|
|
169
|
+
if (Result.isFailure(next)) {
|
|
170
|
+
return yield* stop(new DurableStorageFailed({
|
|
171
|
+
generation: number,
|
|
172
|
+
message: next.failure.message,
|
|
173
|
+
cause: next.failure,
|
|
174
|
+
}), ready);
|
|
175
|
+
}
|
|
176
|
+
current = next.success;
|
|
177
|
+
failed = Option.none();
|
|
178
|
+
yield* Deferred.succeed(ready, next.success);
|
|
179
|
+
yield* Effect.logInfo("Reopened the durable harness", { generation: number });
|
|
180
|
+
// A failure while opening found another harness current.
|
|
181
|
+
if (next.success.generation.failing)
|
|
182
|
+
handleFailure(next.success);
|
|
183
|
+
}, Effect.uninterruptible);
|
|
184
|
+
/** Waits until the failed harness has closed, then reopens it or completes `ready` with the failure. */
|
|
185
|
+
const recover = Effect.fn("DurableHarness.recover")(function* (opened, ready) {
|
|
186
|
+
const number = opened.generation.number;
|
|
187
|
+
yield* Effect.annotateCurrentSpan({ generation: number });
|
|
188
|
+
const end = yield* Effect.promise(() => opened.harness.closed);
|
|
189
|
+
flushReports(opened.generation);
|
|
190
|
+
const cause = end.reason === "failed" ? end.error : new Error("pi-durable closed the harness");
|
|
191
|
+
const failure = new DurableStorageFailed({
|
|
192
|
+
generation: number,
|
|
193
|
+
message: messageOf(cause),
|
|
194
|
+
cause,
|
|
195
|
+
});
|
|
196
|
+
yield* Effect.logError("A storage error failed the durable harness, and pi-durable closed it", {
|
|
197
|
+
generation: number,
|
|
198
|
+
cause: failure.message,
|
|
199
|
+
});
|
|
200
|
+
for (const listener of listeners)
|
|
201
|
+
listener.onFailure(failure);
|
|
202
|
+
if (finalizing)
|
|
203
|
+
return yield* Deferred.fail(ready, failure);
|
|
204
|
+
if (Option.isNone(resumed)) {
|
|
205
|
+
yield* Effect.logError("The durable harness failed before its tasks resumed; it stays closed", {
|
|
206
|
+
generation: number,
|
|
207
|
+
cause: failure.message,
|
|
208
|
+
});
|
|
209
|
+
return yield* Deferred.fail(ready, failure);
|
|
210
|
+
}
|
|
211
|
+
if (number > 1 && Date.now() - opened.openedAt < REFAIL_MILLIS) {
|
|
212
|
+
return yield* stop(failure, ready);
|
|
213
|
+
}
|
|
214
|
+
yield* reopen(opened, ready);
|
|
215
|
+
});
|
|
216
|
+
let current = yield* open(1);
|
|
217
|
+
// Called synchronously from inside pi-durable; the recovery runs on its own fiber.
|
|
218
|
+
function handleFailure(opened) {
|
|
219
|
+
if (opened.generation.handled || opened !== current || Option.isSome(failed))
|
|
220
|
+
return;
|
|
221
|
+
opened.generation.handled = true;
|
|
222
|
+
const ready = Deferred.makeUnsafe();
|
|
223
|
+
failed = Option.some(ready);
|
|
224
|
+
fork(recover(opened, ready).pipe(Effect.forkIn(scope)));
|
|
225
|
+
}
|
|
226
|
+
/** Returns the open harness, waiting for a reopen. Fails if the harness stays closed. */
|
|
227
|
+
const openHarness = (operation) => Effect.suspend(() => Option.match(failed, {
|
|
228
|
+
onNone: () => Effect.succeed(current),
|
|
229
|
+
onSome: (ready) => Deferred.await(ready).pipe(Effect.mapError((failure) => new DurableHarnessError({
|
|
230
|
+
operation,
|
|
231
|
+
message: stopped
|
|
232
|
+
? `The durable harness stopped after repeated storage errors: ${failure.message}. Restart the orchestrator.`
|
|
233
|
+
: failure.message,
|
|
234
|
+
cause: failure,
|
|
235
|
+
}))),
|
|
236
|
+
}));
|
|
237
|
+
/** Whether `cause` failed the call because a storage error failed `opened`'s harness. */
|
|
238
|
+
const failedHarness = (opened, cause) => opened.generation.failing || cause instanceof SessionFailed;
|
|
239
|
+
const use = (operation, run) => Effect.gen(function* () {
|
|
240
|
+
for (let attempt = 1;; attempt += 1) {
|
|
241
|
+
const target = yield* openHarness(operation);
|
|
242
|
+
const outcome = yield* Effect.tryPromise({
|
|
243
|
+
try: (signal) => run(target.harness, withAbortSignal(signal, BACKGROUND_CONTEXT)),
|
|
244
|
+
catch: (cause) => cause,
|
|
245
|
+
}).pipe(Effect.result);
|
|
246
|
+
if (Result.isSuccess(outcome))
|
|
247
|
+
return outcome.success;
|
|
248
|
+
const cause = outcome.failure;
|
|
249
|
+
if (!failedHarness(target, cause))
|
|
250
|
+
return yield* durableError(operation, cause);
|
|
251
|
+
if (attempt === 1) {
|
|
252
|
+
yield* Effect.logInfo("Repeating a durable call after its harness failed", {
|
|
253
|
+
operation,
|
|
254
|
+
generation: target.generation.number,
|
|
255
|
+
});
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
return yield* durableError(operation, cause);
|
|
259
|
+
}
|
|
260
|
+
}).pipe(Effect.withSpan(`DurableHarness.use.${operation}`));
|
|
261
|
+
yield* Effect.addFinalizer(() => Effect.gen(function* () {
|
|
262
|
+
finalizing = true;
|
|
263
|
+
yield* close(current);
|
|
264
|
+
yield* Effect.logInfo("Closed the durable harness", {
|
|
265
|
+
generation: current.generation.number,
|
|
266
|
+
});
|
|
267
|
+
}));
|
|
268
|
+
return DurableHarness.of({
|
|
269
|
+
models: options.models,
|
|
270
|
+
defaultModel: options.defaultModel,
|
|
271
|
+
install: (extension) => Effect.sync(() => registry.install(extension)).pipe(Effect.tap(() => Effect.logDebug("Installed a durable extension", { name: extension.name }))),
|
|
272
|
+
resume: Effect.fn("DurableHarness.resume")(function* (beforeResume) {
|
|
273
|
+
const target = yield* openHarness(RESUME_OPERATION);
|
|
274
|
+
yield* beforeResume(target.harness, target.storage);
|
|
275
|
+
const started = yield* Effect.try({
|
|
276
|
+
try: () => target.harness.resume(),
|
|
277
|
+
catch: (cause) => cause,
|
|
278
|
+
}).pipe(Effect.result);
|
|
279
|
+
if (Result.isFailure(started)) {
|
|
280
|
+
if (failedHarness(target, started.failure))
|
|
281
|
+
yield* openHarness(RESUME_OPERATION);
|
|
282
|
+
return yield* durableError(RESUME_OPERATION, started.failure);
|
|
283
|
+
}
|
|
284
|
+
resumed = Option.some(beforeResume);
|
|
285
|
+
yield* Effect.logInfo("Resumed durable task scheduling", {
|
|
286
|
+
generation: target.generation.number,
|
|
287
|
+
});
|
|
288
|
+
}),
|
|
289
|
+
use,
|
|
290
|
+
subscribe: (listener) => Effect.acquireRelease(Effect.sync(() => listeners.add(listener)), () => Effect.sync(() => listeners.delete(listener))).pipe(Effect.asVoid),
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
/**
|
|
294
|
+
* Opens the harness for the layer's lifetime. Closes it on release without writing any task
|
|
295
|
+
* outcome.
|
|
296
|
+
*/
|
|
297
|
+
export const layer = (options) => Layer.effect(DurableHarness, make(options));
|
|
298
|
+
//# sourceMappingURL=harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.js","sourceRoot":"","sources":["../src/harness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAEL,cAAc,EAEd,OAAO,EAEP,aAAa,GAEd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAE9F,gCAAgC;AAChC,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,CACzD,oCAAoC,CACrC,CAAC,qBAAqB,EAAE;IACvB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC,cAAc;IAChC,+FAA+F;IAC/F,OAAO,EAAE,MAAM,CAAC,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;CACvB,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,CAC1D,qCAAqC,CACtC,CAAC,sBAAsB,EAAE;IACxB,2FAA2F;IAC3F,UAAU,EAAE,MAAM,CAAC,GAAG;IACtB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;CACvB,CAAC;CAAG;AAmCL;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,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AM,CAAC,QAAQ,CAAC,CAAC,CACpD,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;KACxB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,OAA8B,EACoB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
package/dist/live.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { InstanceDirectory } from "@usine/core/instance";
|
|
2
|
+
import { Layer } from "effect";
|
|
3
|
+
/**
|
|
4
|
+
* Provides the durable harness on `.usine/durable.sqlite` with Pi's configured models and
|
|
5
|
+
* credentials.
|
|
6
|
+
*/
|
|
7
|
+
export declare const harnessLayer: (instanceDirectory: InstanceDirectory) => Layer.Layer<import("./harness.ts").DurableHarness, import("./harness.ts").DurableHarnessError, never>;
|
|
8
|
+
/** Provides the Claude Code, Codex, and Pi child backends, selected by the Agent's harness. */
|
|
9
|
+
export declare const childBackendLayer: Layer.Layer<import("@usine/agents/runtime").ChildBackend, never, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("@usine/agents/runtime").ClaudeLoginLock>;
|
|
10
|
+
/**
|
|
11
|
+
* Provides the Node `AttemptRuntime` with the real child backends. Building it resumes every
|
|
12
|
+
* unfinished Attempt.
|
|
13
|
+
*/
|
|
14
|
+
export declare const layer: (instanceDirectory: InstanceDirectory) => Layer.Layer<import("./attempt-runtime.ts").AttemptRuntime | import("./harness.ts").DurableHarness, import("./harness.ts").DurableHarnessError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("@usine/agents/runtime").ClaudeLoginLock>;
|
|
15
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAsB,KAAK,EAAgB,MAAM,QAAQ,CAAC;AA+CjE;;;GAGG;AACH,eAAO,MAAM,YAAY,sBAAuB,iBAAiB,0GACc,CAAC;AAQhF,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,sLAAiE,CAAC;AAEhG;;;GAGG;AACH,eAAO,MAAM,KAAK,sBAAuB,iBAAiB,uQAIvD,CAAC"}
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { NodeServices } from "@effect/platform-node";
|
|
2
|
+
import { getAgentDir, ModelRuntime, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { openNodeSqliteStorage } from "@earendil-works/pi-durable/storage/sqlite/node";
|
|
4
|
+
import { childDispatcherLayer } from "@usine/agents/children";
|
|
5
|
+
import { claudeChildBackendLayer, claudeSdkLive } from "@usine/agents/claude";
|
|
6
|
+
import { codexAppServerLive, codexChildBackendLayer } from "@usine/agents/codex";
|
|
7
|
+
import { piChildBackendLayer, piSdkLive } from "@usine/agents/pi";
|
|
8
|
+
import { Effect, FileSystem, Layer, Option, Path } from "effect";
|
|
9
|
+
import { layer as attemptRuntimeLayer } from "./attempt/runtime.js";
|
|
10
|
+
import { durableError, layer as durableHarnessLayer, } from "./harness.js";
|
|
11
|
+
import { durableStoragePath } from "./storage-path.js";
|
|
12
|
+
const nodeOptions = Effect.fn("DurableHarness.nodeOptions")(function* (instanceDirectory) {
|
|
13
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
14
|
+
const path = yield* Path.Path;
|
|
15
|
+
const file = durableStoragePath(path, instanceDirectory);
|
|
16
|
+
const models = yield* Effect.tryPromise({
|
|
17
|
+
try: (signal) => ModelRuntime.create({ signal }),
|
|
18
|
+
catch: (cause) => durableError("load the Pi model runtime", cause),
|
|
19
|
+
});
|
|
20
|
+
// Only the Pi user's global settings: the instance folder's own `.pi/` is not trusted.
|
|
21
|
+
const settings = SettingsManager.create(instanceDirectory, getAgentDir(), {
|
|
22
|
+
projectTrusted: false,
|
|
23
|
+
});
|
|
24
|
+
const defaultModel = Option.flatMap(Option.fromNullishOr(settings.getDefaultProvider()), (provider) => Option.map(Option.fromNullishOr(settings.getDefaultModel()), (modelId) => ({
|
|
25
|
+
provider,
|
|
26
|
+
modelId,
|
|
27
|
+
})));
|
|
28
|
+
yield* Effect.logInfo("Durable harness storage", { file });
|
|
29
|
+
return {
|
|
30
|
+
openStorage: fileSystem.makeDirectory(path.dirname(file), { recursive: true }).pipe(Effect.mapError((cause) => durableError("create the durable storage folder", cause)), Effect.andThen(Effect.tryPromise({
|
|
31
|
+
try: () => openNodeSqliteStorage(file),
|
|
32
|
+
catch: (cause) => durableError("open the durable storage", cause),
|
|
33
|
+
}))),
|
|
34
|
+
models,
|
|
35
|
+
defaultModel,
|
|
36
|
+
};
|
|
37
|
+
}, Effect.provide(NodeServices.layer));
|
|
38
|
+
/**
|
|
39
|
+
* Provides the durable harness on `.usine/durable.sqlite` with Pi's configured models and
|
|
40
|
+
* credentials.
|
|
41
|
+
*/
|
|
42
|
+
export const harnessLayer = (instanceDirectory) => Layer.unwrap(Effect.map(nodeOptions(instanceDirectory), durableHarnessLayer));
|
|
43
|
+
const childImplementations = Layer.mergeAll(claudeChildBackendLayer.pipe(Layer.provide(claudeSdkLive)), codexChildBackendLayer.pipe(Layer.provide(codexAppServerLive)), piChildBackendLayer.pipe(Layer.provide(piSdkLive)));
|
|
44
|
+
/** Provides the Claude Code, Codex, and Pi child backends, selected by the Agent's harness. */
|
|
45
|
+
export const childBackendLayer = childDispatcherLayer.pipe(Layer.provide(childImplementations));
|
|
46
|
+
/**
|
|
47
|
+
* Provides the Node `AttemptRuntime` with the real child backends. Building it resumes every
|
|
48
|
+
* unfinished Attempt.
|
|
49
|
+
*/
|
|
50
|
+
export const layer = (instanceDirectory) => attemptRuntimeLayer.pipe(Layer.provideMerge(harnessLayer(instanceDirectory)), Layer.provide(childBackend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KAAG,MACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-path.js","sourceRoot":"","sources":["../src/storage-path.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAe,EAAE,iBAAoC,EAAU,EAAE,CAClG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
2
|
+
import { type FauxResponseStep } from "@earendil-works/pi-ai/providers/faux";
|
|
3
|
+
import { ChildBackend, type ChildRequest } from "@usine/agents/runtime";
|
|
4
|
+
import { type AgentSessionEvent, ParentSession } from "@usine/core/agent/session";
|
|
5
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
6
|
+
import { type AttemptFailure } from "@usine/core/attempt/failure";
|
|
7
|
+
import { StepResult } from "@usine/core/step/result";
|
|
8
|
+
import { Context, Duration, Effect, Layer, Option } from "effect";
|
|
9
|
+
import { AttemptReport, type AttemptRequest, AttemptRuntime } from "./attempt-runtime.ts";
|
|
10
|
+
import { type DurableHarnessOptions } from "./harness.ts";
|
|
11
|
+
export type ParentStep = FauxResponseStep;
|
|
12
|
+
/** The model ID that the testing layer serves. */
|
|
13
|
+
export declare const PARENT_MODEL: string & import("effect/Brand").Brand<"ModelId">;
|
|
14
|
+
/** Returns a parent turn that calls the `subagent` tool with `task`. */
|
|
15
|
+
export declare const delegate: (task: string) => AssistantMessage;
|
|
16
|
+
/** Returns a parent turn whose final answer is `text`. */
|
|
17
|
+
export declare const answer: (text: string) => AssistantMessage;
|
|
18
|
+
/**
|
|
19
|
+
* Returns pi-ai model access that answers requests with `steps` in order, at any reasoning effort
|
|
20
|
+
* up to `high`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const fauxParent: (steps: ReadonlyArray<ParentStep>) => Pick<DurableHarnessOptions, "models" | "defaultModel">;
|
|
23
|
+
/** A child launched by the stub backend and finished by the test. */
|
|
24
|
+
export interface StubChild {
|
|
25
|
+
readonly request: ChildRequest;
|
|
26
|
+
readonly emit: (event: AgentSessionEvent) => Effect.Effect<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Reads the queued operator messages, then finishes with `message` as the report. Under a Hold,
|
|
29
|
+
* the report is delayed until release.
|
|
30
|
+
*/
|
|
31
|
+
readonly reply: (message: string) => Effect.Effect<void>;
|
|
32
|
+
/** Reads the queued operator messages, as a harness does at a turn boundary. */
|
|
33
|
+
readonly readQueued: Effect.Effect<void>;
|
|
34
|
+
/** Finishes with a blocked report, which fails the Attempt unless the parent relays it. */
|
|
35
|
+
readonly block: (message: string) => Effect.Effect<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Finishes by asking the operator `question`, which fails the Attempt unless the parent relays
|
|
38
|
+
* it.
|
|
39
|
+
*/
|
|
40
|
+
readonly ask: (question: string) => Effect.Effect<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Finishes with a harness failure, which fails the Attempt with `AgentFailure` unless the parent
|
|
43
|
+
* reports otherwise.
|
|
44
|
+
*/
|
|
45
|
+
readonly fail: (message: string) => Effect.Effect<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Ends without a result, as a Claude child whose output stream fails: the parent's `subagent`
|
|
48
|
+
* call fails with a `stream` `SessionOperationError` whose message is `message`.
|
|
49
|
+
*/
|
|
50
|
+
readonly crash: (message: string) => Effect.Effect<void>;
|
|
51
|
+
/** Completes when the parent's tool call interrupts the child (abort, cancel, or shutdown). */
|
|
52
|
+
readonly interrupted: Effect.Effect<void>;
|
|
53
|
+
readonly interventions: Effect.Effect<ReadonlyArray<AttemptChannel.OperatorAction>>;
|
|
54
|
+
}
|
|
55
|
+
declare const StubChildren_base: Context.ServiceClass<StubChildren, "@usine/durable/testing/StubChildren", {
|
|
56
|
+
readonly next: Effect.Effect<StubChild>;
|
|
57
|
+
}>;
|
|
58
|
+
/** The children launched by the stub backend, in launch order. */
|
|
59
|
+
export declare class StubChildren extends StubChildren_base {
|
|
60
|
+
}
|
|
61
|
+
/** A `ChildBackend` whose children the test drives through `StubChildren`. */
|
|
62
|
+
export declare const stubChildBackendLayer: Layer.Layer<ChildBackend | StubChildren>;
|
|
63
|
+
export interface DurableTestingOptions {
|
|
64
|
+
/** The SQLite file path. To simulate a restart, build another layer on the same file. */
|
|
65
|
+
readonly database: string;
|
|
66
|
+
/** The parent model's answers, one per request. */
|
|
67
|
+
readonly parent: ReadonlyArray<ParentStep>;
|
|
68
|
+
}
|
|
69
|
+
/** Returns a durable Attempt runtime with a scripted parent model and stub children. */
|
|
70
|
+
export declare const layer: (options: DurableTestingOptions) => Layer.Layer<AttemptRuntime | ChildBackend | import("./harness.ts").DurableHarness | StubChildren, import("./harness.ts").DurableHarnessError, never>;
|
|
71
|
+
export interface StubParentContext {
|
|
72
|
+
/**
|
|
73
|
+
* The request passed to this `execute` call, which differs from the stored request on reattach.
|
|
74
|
+
*/
|
|
75
|
+
readonly request: AttemptRequest;
|
|
76
|
+
/** Records an outbound envelope with the task's next sequence number. */
|
|
77
|
+
readonly emit: (payload: AttemptChannel.OutboundPayload) => Effect.Effect<void, AttemptFailure>;
|
|
78
|
+
readonly session: ParentSession;
|
|
79
|
+
/** Whether this call reattached a task started by a previous runtime. */
|
|
80
|
+
readonly reattached: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** The stub parent's work after `Started`, returning the final message or a full report. */
|
|
83
|
+
export type StubParent = (context: StubParentContext) => Effect.Effect<string | AttemptReport, AttemptFailure>;
|
|
84
|
+
type StubTaskState = {
|
|
85
|
+
readonly _tag: "live";
|
|
86
|
+
} | {
|
|
87
|
+
readonly _tag: "finished";
|
|
88
|
+
readonly report: AttemptReport;
|
|
89
|
+
result: Option.Option<StepResult>;
|
|
90
|
+
} | {
|
|
91
|
+
readonly _tag: "canceled";
|
|
92
|
+
};
|
|
93
|
+
interface StubTask {
|
|
94
|
+
readonly request: AttemptRequest;
|
|
95
|
+
state: StubTaskState;
|
|
96
|
+
outbound: number;
|
|
97
|
+
inbound: number;
|
|
98
|
+
}
|
|
99
|
+
/** Stub runtime storage that persists across runtime rebuilds, to simulate a restart. */
|
|
100
|
+
export declare class StubStorage {
|
|
101
|
+
/** The stub tasks by Attempt ID, with their creating request and state. */
|
|
102
|
+
readonly tasks: Map<string & import("effect/Brand").Brand<"AttemptId">, StubTask>;
|
|
103
|
+
/** The time stored by `recordUnsupervised`, by Attempt ID. */
|
|
104
|
+
readonly unsupervised: Map<string & import("effect/Brand").Brand<"AttemptId">, Duration.Duration>;
|
|
105
|
+
}
|
|
106
|
+
/** Completes immediately with `Completed: <task>`. */
|
|
107
|
+
export declare const completes: StubParent;
|
|
108
|
+
/** Waits `millis` milliseconds, then completes like `completes`. */
|
|
109
|
+
export declare const worksFor: (millis: number) => StubParent;
|
|
110
|
+
/**
|
|
111
|
+
* Returns an in-memory `AttemptRuntime` over `storage` for tests that need no parent model. An
|
|
112
|
+
* interrupted `execute` or a failing parent leaves the task live until it is canceled.
|
|
113
|
+
*/
|
|
114
|
+
export declare const stubAttemptRuntime: (storage: StubStorage, parent?: StubParent) => Layer.Layer<AttemptRuntime, never, never>;
|
|
115
|
+
export {};
|
|
116
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EACL,KAAK,gBAAgB,EAKtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAML,YAAY,EACZ,KAAK,YAAY,EAMlB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,KAAK,iBAAiB,EAEtB,aAAa,EAMd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,E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