@usine/engine 0.0.1 → 0.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/README.md +66 -2
- package/dist/cursor/model.d.ts +5 -0
- package/dist/cursor/model.d.ts.map +1 -0
- package/dist/cursor/model.js +4 -0
- package/dist/cursor/model.js.map +1 -0
- package/dist/cursor/store.d.ts +18 -0
- package/dist/cursor/store.d.ts.map +1 -0
- package/dist/cursor/store.js +54 -0
- package/dist/cursor/store.js.map +1 -0
- package/dist/database/database.d.ts +15 -0
- package/dist/database/database.d.ts.map +1 -0
- package/dist/database/database.js +5 -0
- package/dist/database/database.js.map +1 -0
- package/dist/database/local-sqlite.d.ts +17 -0
- package/dist/database/local-sqlite.d.ts.map +1 -0
- package/dist/database/local-sqlite.js +45 -0
- package/dist/database/local-sqlite.js.map +1 -0
- package/dist/database/schema.d.ts +1096 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +171 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/engine.d.ts +39 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +179 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/item-projection/model.d.ts +21 -0
- package/dist/item-projection/model.d.ts.map +1 -0
- package/dist/item-projection/model.js +16 -0
- package/dist/item-projection/model.js.map +1 -0
- package/dist/item-projection/service.d.ts +25 -0
- package/dist/item-projection/service.d.ts.map +1 -0
- package/dist/item-projection/service.js +98 -0
- package/dist/item-projection/service.js.map +1 -0
- package/dist/loop-control.d.ts +16 -0
- package/dist/loop-control.d.ts.map +1 -0
- package/dist/loop-control.js +69 -0
- package/dist/loop-control.js.map +1 -0
- package/dist/model.d.ts +185 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +174 -0
- package/dist/model.js.map +1 -0
- package/dist/repository-label-projection/model.d.ts +10 -0
- package/dist/repository-label-projection/model.d.ts.map +1 -0
- package/dist/repository-label-projection/model.js +11 -0
- package/dist/repository-label-projection/model.js.map +1 -0
- package/dist/repository-label-projection/service.d.ts +20 -0
- package/dist/repository-label-projection/service.d.ts.map +1 -0
- package/dist/repository-label-projection/service.js +73 -0
- package/dist/repository-label-projection/service.js.map +1 -0
- package/dist/run-reader.d.ts +20 -0
- package/dist/run-reader.d.ts.map +1 -0
- package/dist/run-reader.js +19 -0
- package/dist/run-reader.js.map +1 -0
- package/dist/step-executor.d.ts +21 -0
- package/dist/step-executor.d.ts.map +1 -0
- package/dist/step-executor.js +8 -0
- package/dist/step-executor.js.map +1 -0
- package/dist/store/codec.d.ts +431 -0
- package/dist/store/codec.d.ts.map +1 -0
- package/dist/store/codec.js +140 -0
- package/dist/store/codec.js.map +1 -0
- package/dist/store/queries.d.ts +75 -0
- package/dist/store/queries.d.ts.map +1 -0
- package/dist/store/queries.js +508 -0
- package/dist/store/queries.js.map +1 -0
- package/dist/store/store.d.ts +83 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +374 -0
- package/dist/store/store.js.map +1 -0
- package/dist/workflow.d.ts +14 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +105 -0
- package/dist/workflow.js.map +1 -0
- package/drizzle/20260825055549_initial_runtime/migration.sql +73 -0
- package/drizzle/20260825055549_initial_runtime/snapshot.json +592 -0
- package/drizzle/20260830191125_polling_cursors/migration.sql +5 -0
- package/drizzle/20260830191125_polling_cursors/snapshot.json +629 -0
- package/drizzle/20260831073158_attempt_channel/migration.sql +36 -0
- package/drizzle/20260831073158_attempt_channel/snapshot.json +845 -0
- package/drizzle/20260831133534_agent_context/migration.sql +49 -0
- package/drizzle/20260831133534_agent_context/snapshot.json +897 -0
- package/drizzle/20260831134612_attempt_brain/migration.sql +26 -0
- package/drizzle/20260831134612_attempt_brain/snapshot.json +923 -0
- package/drizzle/20260831194605_loop_runtime/migration.sql +4 -0
- package/drizzle/20260831194605_loop_runtime/snapshot.json +954 -0
- package/drizzle/20260901073233_projection_revision/migration.sql +55 -0
- package/drizzle/20260901073233_projection_revision/snapshot.json +991 -0
- package/drizzle/20260901180433_item_projections/migration.sql +22 -0
- package/drizzle/20260901180433_item_projections/snapshot.json +1110 -0
- package/drizzle/20260901185146_repository_label_projections/migration.sql +17 -0
- package/drizzle/20260901185146_repository_label_projections/snapshot.json +1147 -0
- package/package.json +21 -3
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Repository } from "@usine/core";
|
|
2
|
+
import { desc, eq, ne } from "drizzle-orm";
|
|
3
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
|
+
import { RunDatabase } from "../database/database.js";
|
|
5
|
+
import { itemProjections } from "../database/schema.js";
|
|
6
|
+
import { EnginePersistenceError } from "../model.js";
|
|
7
|
+
import { ItemContentHash, ItemNumber, ItemProjection, ItemProjectionSource } from "./model.js";
|
|
8
|
+
const ItemProjectionRow = Schema.Struct({
|
|
9
|
+
itemKey: ItemProjection.fields.itemKey,
|
|
10
|
+
repository: Repository.Name,
|
|
11
|
+
source: ItemProjectionSource,
|
|
12
|
+
number: ItemNumber,
|
|
13
|
+
contentHash: ItemContentHash,
|
|
14
|
+
payload: Schema.JsonObject,
|
|
15
|
+
});
|
|
16
|
+
const decodeRows = Schema.decodeUnknownEffect(Schema.Array(ItemProjectionRow));
|
|
17
|
+
const encodePayload = Schema.encodeSync(Schema.JsonObject);
|
|
18
|
+
const persistence = (operation) => (effect) => Effect.mapError(effect, (cause) => new EnginePersistenceError({ operation, cause }));
|
|
19
|
+
const makeReader = Effect.gen(function* () {
|
|
20
|
+
const database = yield* RunDatabase;
|
|
21
|
+
return {
|
|
22
|
+
list: Effect.fn("ItemProjectionReader.list")(function* (repository, options) {
|
|
23
|
+
yield* Effect.annotateCurrentSpan({ repository, limit: options.limit });
|
|
24
|
+
const rows = yield* database
|
|
25
|
+
.select({
|
|
26
|
+
itemKey: itemProjections.itemKey,
|
|
27
|
+
repository: itemProjections.repository,
|
|
28
|
+
source: itemProjections.source,
|
|
29
|
+
number: itemProjections.itemNumber,
|
|
30
|
+
contentHash: itemProjections.contentHash,
|
|
31
|
+
payload: itemProjections.payloadJson,
|
|
32
|
+
})
|
|
33
|
+
.from(itemProjections)
|
|
34
|
+
.where(eq(itemProjections.repository, repository))
|
|
35
|
+
.orderBy(desc(itemProjections.itemNumber))
|
|
36
|
+
.limit(options.limit)
|
|
37
|
+
.execute();
|
|
38
|
+
return (yield* decodeRows(rows, { onExcessProperty: "error" })).map((row) => new ItemProjection(row));
|
|
39
|
+
}, persistence("list Item projections")),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
const makeWriter = Effect.gen(function* () {
|
|
43
|
+
const database = yield* RunDatabase;
|
|
44
|
+
return {
|
|
45
|
+
upsert: Effect.fn("ItemProjectionWriter.upsert")(function* (item) {
|
|
46
|
+
yield* Effect.annotateCurrentSpan({
|
|
47
|
+
repository: item.repository,
|
|
48
|
+
item: item.number,
|
|
49
|
+
itemKey: item.itemKey,
|
|
50
|
+
});
|
|
51
|
+
const changed = yield* database
|
|
52
|
+
.insert(itemProjections)
|
|
53
|
+
.values({
|
|
54
|
+
itemKey: item.itemKey,
|
|
55
|
+
repository: item.repository,
|
|
56
|
+
source: item.source,
|
|
57
|
+
itemNumber: item.number,
|
|
58
|
+
contentHash: item.contentHash,
|
|
59
|
+
payloadJson: encodePayload(item.payload),
|
|
60
|
+
})
|
|
61
|
+
.onConflictDoUpdate({
|
|
62
|
+
target: itemProjections.itemKey,
|
|
63
|
+
set: {
|
|
64
|
+
repository: item.repository,
|
|
65
|
+
source: item.source,
|
|
66
|
+
itemNumber: item.number,
|
|
67
|
+
contentHash: item.contentHash,
|
|
68
|
+
payloadJson: encodePayload(item.payload),
|
|
69
|
+
},
|
|
70
|
+
setWhere: ne(itemProjections.contentHash, item.contentHash),
|
|
71
|
+
})
|
|
72
|
+
.returning({ itemKey: itemProjections.itemKey })
|
|
73
|
+
.execute();
|
|
74
|
+
if (changed.length === 0) {
|
|
75
|
+
yield* Effect.logDebug("Item projection already matched the observed snapshot", {
|
|
76
|
+
repository: item.repository,
|
|
77
|
+
item: item.number,
|
|
78
|
+
contentHash: item.contentHash,
|
|
79
|
+
});
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
yield* Effect.logDebug("Item projection updated from trigger polling", {
|
|
83
|
+
repository: item.repository,
|
|
84
|
+
item: item.number,
|
|
85
|
+
source: item.source,
|
|
86
|
+
contentHash: item.contentHash,
|
|
87
|
+
});
|
|
88
|
+
return true;
|
|
89
|
+
}, persistence("write Item projection")),
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
export class ItemProjectionReader extends Context.Service()("@usine/engine/ItemProjectionReader") {
|
|
93
|
+
static layer = Layer.effect(ItemProjectionReader, makeReader);
|
|
94
|
+
}
|
|
95
|
+
export class ItemProjectionWriter extends Context.Service()("@usine/engine/ItemProjectionWriter") {
|
|
96
|
+
static layer = Layer.effect(ItemProjectionWriter, makeWriter);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/item-projection/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB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AC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,OAAO,oBAAqB,SAAQ,OAAO,CAAC,OAAO,EAStD,CAAC,oCAAoC,CAAC;IACvC,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;CACxE;AAED,MAAM,OAAO,oBAAqB,SAAQ,OAAO,CAAC,OAAO,EAMtD,CAAC,oCAAoC,CAAC;IACvC,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Loop } from "@usine/core";
|
|
2
|
+
import { Context, Effect, Layer } from "effect";
|
|
3
|
+
import { RunDatabase } from "./database/database.ts";
|
|
4
|
+
import { EnginePersistenceError, LoopRuntimeState } from "./model.ts";
|
|
5
|
+
declare const LoopControl_base: Context.ServiceClass<LoopControl, "@usine/engine/LoopControl", {
|
|
6
|
+
readonly isPaused: (loop: Loop.LoopName) => Effect.Effect<boolean, EnginePersistenceError>;
|
|
7
|
+
readonly pause: (loop: Loop.LoopName) => Effect.Effect<LoopRuntimeState, EnginePersistenceError>;
|
|
8
|
+
readonly states: Effect.Effect<ReadonlyArray<LoopRuntimeState>, EnginePersistenceError>;
|
|
9
|
+
readonly unpause: (loop: Loop.LoopName) => Effect.Effect<LoopRuntimeState, EnginePersistenceError>;
|
|
10
|
+
}>;
|
|
11
|
+
/** Durable operator control over Loop runtime state. It never edits the instance repo. */
|
|
12
|
+
export declare class LoopControl extends LoopControl_base {
|
|
13
|
+
static readonly layer: Layer.Layer<LoopControl, never, RunDatabase>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=loop-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-control.d.ts","sourceRoot":"","sources":["../src/loop-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;;uBA6E/C,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC;oBAC1E,CACd,IAAI,EAAE,IAAI,CAAC,QAAQ,KAChB,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;qBAC3C,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;sBACrE,CAChB,IAAI,EAAE,IAAI,CAAC,QAAQ,KAChB,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;;AAXhE,0FAA0F;AAC1F,qBAAa,WAAY,SAAQ,gBAYD;IAC9B,MAAM,CAAC,QAAQ,CAAC,KAAK,+CAA8C;CACpE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Loop } from "@usine/core";
|
|
2
|
+
import { asc, eq } from "drizzle-orm";
|
|
3
|
+
import { Context, Effect, Layer } from "effect";
|
|
4
|
+
import { RunDatabase } from "./database/database.js";
|
|
5
|
+
import { loopRuntime } from "./database/schema.js";
|
|
6
|
+
import { EnginePersistenceError, LoopRuntimeState } from "./model.js";
|
|
7
|
+
const persistence = (operation) => (effect) => effect.pipe(Effect.mapError((cause) => new EnginePersistenceError({ operation, cause })));
|
|
8
|
+
const makeLoopControl = Effect.gen(function* () {
|
|
9
|
+
const database = yield* RunDatabase;
|
|
10
|
+
const stateFor = Effect.fn("LoopControl.stateFor")(function* (loop) {
|
|
11
|
+
yield* Effect.annotateCurrentSpan({ loop });
|
|
12
|
+
const rows = yield* database
|
|
13
|
+
.select({ loop: loopRuntime.loopName, paused: loopRuntime.paused })
|
|
14
|
+
.from(loopRuntime)
|
|
15
|
+
.where(eq(loopRuntime.loopName, loop))
|
|
16
|
+
.limit(1)
|
|
17
|
+
.execute();
|
|
18
|
+
const stored = rows[0];
|
|
19
|
+
return stored === undefined
|
|
20
|
+
? new LoopRuntimeState({ loop, paused: false })
|
|
21
|
+
: new LoopRuntimeState(stored);
|
|
22
|
+
}, persistence("read Loop runtime state"));
|
|
23
|
+
const states = Effect.fn("LoopControl.states")(function* () {
|
|
24
|
+
const rows = yield* database
|
|
25
|
+
.select({ loop: loopRuntime.loopName, paused: loopRuntime.paused })
|
|
26
|
+
.from(loopRuntime)
|
|
27
|
+
.orderBy(asc(loopRuntime.loopName))
|
|
28
|
+
.execute();
|
|
29
|
+
return rows.map((row) => new LoopRuntimeState(row));
|
|
30
|
+
}, persistence("list Loop runtime states"));
|
|
31
|
+
const write = Effect.fn("LoopControl.write")(function* (next) {
|
|
32
|
+
yield* Effect.annotateCurrentSpan({ loop: next.loop });
|
|
33
|
+
const current = yield* stateFor(next.loop);
|
|
34
|
+
if (current.paused === next.paused) {
|
|
35
|
+
yield* Effect.logDebug("Loop runtime state was already set", {
|
|
36
|
+
loop: next.loop,
|
|
37
|
+
paused: next.paused,
|
|
38
|
+
});
|
|
39
|
+
return current;
|
|
40
|
+
}
|
|
41
|
+
yield* database
|
|
42
|
+
.insert(loopRuntime)
|
|
43
|
+
.values({ loopName: next.loop, paused: next.paused })
|
|
44
|
+
.onConflictDoUpdate({
|
|
45
|
+
target: loopRuntime.loopName,
|
|
46
|
+
set: { paused: next.paused },
|
|
47
|
+
})
|
|
48
|
+
.execute()
|
|
49
|
+
.pipe(persistence("write Loop runtime state"));
|
|
50
|
+
yield* Effect.logInfo(next.paused ? "Loop paused" : "Loop unpaused", {
|
|
51
|
+
loop: next.loop,
|
|
52
|
+
paused: next.paused,
|
|
53
|
+
});
|
|
54
|
+
return next;
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
isPaused: Effect.fn("LoopControl.isPaused")(function* (loop) {
|
|
58
|
+
return (yield* stateFor(loop)).paused;
|
|
59
|
+
}),
|
|
60
|
+
pause: Effect.fn("LoopControl.pause")((loop) => write(new LoopRuntimeState({ loop, paused: true }))),
|
|
61
|
+
states: states(),
|
|
62
|
+
unpause: Effect.fn("LoopControl.unpause")((loop) => write(new LoopRuntimeState({ loop, paused: false }))),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
/** Durable operator control over Loop runtime state. It never edits the instance repo. */
|
|
66
|
+
export class LoopControl extends Context.Service()("@usine/engine/LoopControl") {
|
|
67
|
+
static layer = Layer.effect(LoopControl, makeLoopControl);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=loop-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-control.js","sourceRoot":"","sources":["../src/loop-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,WAAW,GACf,CAAC,SAAiB,EAAE,EAAE,CACtB,CAAU,MAA8B,EAA+C,EAAE,CACvF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAE9F,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,QAA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ACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAmB;YACxE,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;QACxC,CAAC,CAAC;QACF,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAmB,EAAE,EAAE,CAC5D,KAAK,CAAC,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACpD;QACD,MAAM,EAAE,MAAM,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAmB,EAAE,EAAE,CAChE,KAAK,CAAC,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CACrD;KACO,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,0FAA0F;AAC1F,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAY7C,CAAC,2BAA2B,CAAC;IAC9B,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;CACpE"}
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Agent, Attempt, AttemptChannel, Event, Instance, Loop, Run, Step } from "@usine/core";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
/** Whether a loop parks new runs until an approval Event arrives. */
|
|
4
|
+
export declare const APPROVAL_REQUIREMENTS: readonly ["none", "required"];
|
|
5
|
+
export declare const ApprovalRequirement: Schema.Literals<readonly ["none", "required"]>;
|
|
6
|
+
export type ApprovalRequirement = Loop.ApprovalRequirement;
|
|
7
|
+
/** Absolute or caller-resolved path to the instance folder. */
|
|
8
|
+
export declare const InstanceDirectory: Schema.brand<Schema.NonEmptyString, "InstanceDirectory">;
|
|
9
|
+
export type InstanceDirectory = Instance.Directory;
|
|
10
|
+
declare const LoopRuntimeState_base: Schema.Class<LoopRuntimeState, Schema.Struct<{
|
|
11
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
12
|
+
readonly paused: Schema.Boolean;
|
|
13
|
+
}>, {}>;
|
|
14
|
+
/** Durable runtime state for one Loop. Authored loop files never carry this toggle. */
|
|
15
|
+
export declare class LoopRuntimeState extends LoopRuntimeState_base {
|
|
16
|
+
}
|
|
17
|
+
declare const Submission_base: Schema.Class<Submission, Schema.Struct<{
|
|
18
|
+
readonly event: typeof Event.Event;
|
|
19
|
+
readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
20
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
21
|
+
readonly step: Schema.brand<Schema.NonEmptyString, "StepName">;
|
|
22
|
+
readonly approval: Schema.Literals<readonly ["none", "required"]>;
|
|
23
|
+
readonly repository: Schema.brand<Schema.String, "RepoName">;
|
|
24
|
+
readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
|
|
25
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
26
|
+
readonly agent: typeof Agent.Agent;
|
|
27
|
+
readonly parentModel: Schema.Option<Schema.brand<Schema.String, "ModelId">>;
|
|
28
|
+
}>, {}>;
|
|
29
|
+
/** The complete routing context needed to turn one Event into a Run. */
|
|
30
|
+
export declare class Submission extends Submission_base {
|
|
31
|
+
}
|
|
32
|
+
declare const Claimed_base: Schema.Class<Claimed, Schema.TaggedStruct<"Claimed", {
|
|
33
|
+
readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
|
|
34
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
35
|
+
}>, {}>;
|
|
36
|
+
/** The Event owns a Run and repeated submissions return the same identity. */
|
|
37
|
+
export declare class Claimed extends Claimed_base {
|
|
38
|
+
}
|
|
39
|
+
declare const Queued_base: Schema.Class<Queued, Schema.TaggedStruct<"Queued", {
|
|
40
|
+
readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
|
|
41
|
+
}>, {}>;
|
|
42
|
+
/** A running Attempt on the same Item must finish before this Event is reconsidered. */
|
|
43
|
+
export declare class Queued extends Queued_base {
|
|
44
|
+
}
|
|
45
|
+
export declare const IGNORED_REASONS: readonly ["superseded", "revoked"];
|
|
46
|
+
export declare const IgnoreReason: Schema.Literals<readonly ["superseded", "revoked"]>;
|
|
47
|
+
export type IgnoreReason = typeof IgnoreReason.Type;
|
|
48
|
+
/** Durable one-shot requests from the store to the workflow runtime. */
|
|
49
|
+
export declare const WORKFLOW_COMMANDS: readonly ["Approve", "Continue", "Interrupt", "Resume"];
|
|
50
|
+
export declare const WorkflowCommand: Schema.Literals<readonly ["Approve", "Continue", "Interrupt", "Resume"]>;
|
|
51
|
+
export type WorkflowCommand = typeof WorkflowCommand.Type;
|
|
52
|
+
/**
|
|
53
|
+
* Replay order after a restart, first delivered first. Interrupt must precede
|
|
54
|
+
* Continue: on a cancel replay the canceled workflow stops before the next
|
|
55
|
+
* queued Event opens, preserving one open Run per Item. The length constraint
|
|
56
|
+
* forces this list to name every command exactly once.
|
|
57
|
+
*/
|
|
58
|
+
export declare const WORKFLOW_COMMAND_PRIORITY: readonly ["Resume", "Interrupt", "Continue", "Approve"];
|
|
59
|
+
declare const Ignored_base: Schema.Class<Ignored, Schema.TaggedStruct<"Ignored", {
|
|
60
|
+
readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
|
|
61
|
+
readonly reason: Schema.Literals<readonly ["superseded", "revoked"]>;
|
|
62
|
+
}>, {}>;
|
|
63
|
+
/** The Event remains in the permanent ledger but can no longer open a Run. */
|
|
64
|
+
export declare class Ignored extends Ignored_base {
|
|
65
|
+
}
|
|
66
|
+
export declare const SubmissionResult: Schema.Union<readonly [typeof Claimed, typeof Queued, typeof Ignored]>;
|
|
67
|
+
export type SubmissionResult = typeof SubmissionResult.Type;
|
|
68
|
+
declare const RunSnapshot_base: Schema.Class<RunSnapshot, Schema.Struct<{
|
|
69
|
+
readonly event: typeof Event.Event;
|
|
70
|
+
readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
71
|
+
readonly run: typeof Run.Run;
|
|
72
|
+
readonly step: typeof Step.Step;
|
|
73
|
+
readonly attempts: Schema.$Array<typeof Attempt.Attempt>;
|
|
74
|
+
readonly repository: Schema.brand<Schema.String, "RepoName">;
|
|
75
|
+
readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
|
|
76
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
77
|
+
readonly agent: typeof Agent.Agent;
|
|
78
|
+
readonly parentModel: Schema.Option<Schema.brand<Schema.String, "ModelId">>;
|
|
79
|
+
}>, {}>;
|
|
80
|
+
/** Observable durable projection for one Run. */
|
|
81
|
+
export declare class RunSnapshot extends RunSnapshot_base {
|
|
82
|
+
}
|
|
83
|
+
declare const RunSummary_base: Schema.Class<RunSummary, Schema.Struct<{
|
|
84
|
+
readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
85
|
+
readonly run: typeof Run.Run;
|
|
86
|
+
readonly step: typeof Step.Step;
|
|
87
|
+
readonly attempts: Schema.$Array<typeof Attempt.Attempt>;
|
|
88
|
+
readonly repository: Schema.brand<Schema.String, "RepoName">;
|
|
89
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
90
|
+
readonly agent: typeof Agent.Agent;
|
|
91
|
+
}>, {}>;
|
|
92
|
+
/** Lightweight durable projection used when listing Runs for operators. */
|
|
93
|
+
export declare class RunSummary extends RunSummary_base {
|
|
94
|
+
}
|
|
95
|
+
/** Monotonic version of the durable operator projection. */
|
|
96
|
+
export declare const ProjectionRevision: Schema.brand<Schema.Int, "ProjectionRevision">;
|
|
97
|
+
export type ProjectionRevision = typeof ProjectionRevision.Type;
|
|
98
|
+
declare const StepExecution_base: Schema.Class<StepExecution, Schema.Struct<{
|
|
99
|
+
readonly attempt: typeof Attempt.Attempt;
|
|
100
|
+
readonly event: typeof Event.Event;
|
|
101
|
+
readonly run: typeof Run.Run;
|
|
102
|
+
readonly step: typeof Step.Step;
|
|
103
|
+
readonly repository: Schema.brand<Schema.String, "RepoName">;
|
|
104
|
+
readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
|
|
105
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
106
|
+
readonly agent: typeof Agent.Agent;
|
|
107
|
+
readonly parentModel: Schema.Option<Schema.brand<Schema.String, "ModelId">>;
|
|
108
|
+
}>, {}>;
|
|
109
|
+
/** Input passed to the attempt-execution port. */
|
|
110
|
+
export declare class StepExecution extends StepExecution_base {
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Value object: global append order of the persisted transcript — the tail
|
|
114
|
+
* cursor. Distinct from `AttemptChannel.Sequence`, which orders messages
|
|
115
|
+
* within one Attempt's channel direction.
|
|
116
|
+
*/
|
|
117
|
+
export declare const TranscriptSequence: Schema.brand<Schema.Int, "TranscriptSequence">;
|
|
118
|
+
export type TranscriptSequence = typeof TranscriptSequence.Type;
|
|
119
|
+
declare const TranscriptEntry_base: Schema.Class<TranscriptEntry, Schema.Struct<{
|
|
120
|
+
readonly sequence: Schema.brand<Schema.Int, "TranscriptSequence">;
|
|
121
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
122
|
+
readonly direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
123
|
+
readonly envelope: Schema.Union<readonly [typeof AttemptChannel.OutboundEnvelope, typeof AttemptChannel.InboundEnvelope]>;
|
|
124
|
+
readonly receivedAt: Schema.DateTimeUtc;
|
|
125
|
+
}>, {}>;
|
|
126
|
+
/** One append-only row in an Attempt transcript. */
|
|
127
|
+
export declare class TranscriptEntry extends TranscriptEntry_base {
|
|
128
|
+
}
|
|
129
|
+
declare const TranscriptAllQuery_base: Schema.Class<TranscriptAllQuery, Schema.TaggedStruct<"TranscriptAllQuery", {
|
|
130
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
131
|
+
}>, {}>;
|
|
132
|
+
/** Read every row for one Attempt. Intended for execution and diagnostic consumers. */
|
|
133
|
+
export declare class TranscriptAllQuery extends TranscriptAllQuery_base {
|
|
134
|
+
}
|
|
135
|
+
declare const TranscriptTailQuery_base: Schema.Class<TranscriptTailQuery, Schema.TaggedStruct<"TranscriptTailQuery", {
|
|
136
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
137
|
+
readonly after: Schema.brand<Schema.Int, "TranscriptSequence">;
|
|
138
|
+
readonly limit: Schema.Int;
|
|
139
|
+
}>, {}>;
|
|
140
|
+
/** Read rows appended after a cursor while tailing a live Attempt. */
|
|
141
|
+
export declare class TranscriptTailQuery extends TranscriptTailQuery_base {
|
|
142
|
+
}
|
|
143
|
+
declare const TranscriptPageQuery_base: Schema.Class<TranscriptPageQuery, Schema.TaggedStruct<"TranscriptPageQuery", {
|
|
144
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
145
|
+
readonly before: Schema.Option<Schema.brand<Schema.Int, "TranscriptSequence">>;
|
|
146
|
+
readonly limit: Schema.Int;
|
|
147
|
+
}>, {}>;
|
|
148
|
+
/** Read the newest bounded page before a cursor, or from the current tail. */
|
|
149
|
+
export declare class TranscriptPageQuery extends TranscriptPageQuery_base {
|
|
150
|
+
}
|
|
151
|
+
/** Illegal combinations of full, tail, and backward-page reads are unrepresentable. */
|
|
152
|
+
export declare const TranscriptQuery: Schema.Union<readonly [typeof TranscriptAllQuery, typeof TranscriptTailQuery, typeof TranscriptPageQuery]>;
|
|
153
|
+
export type TranscriptQuery = typeof TranscriptQuery.Type;
|
|
154
|
+
declare const RunNotFoundError_base: Schema.Class<RunNotFoundError, Schema.TaggedStruct<"RunNotFoundError", {
|
|
155
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
156
|
+
}>, import("effect/Cause").YieldableError>;
|
|
157
|
+
export declare class RunNotFoundError extends RunNotFoundError_base {
|
|
158
|
+
}
|
|
159
|
+
declare const RunOperationRejectedError_base: Schema.Class<RunOperationRejectedError, Schema.TaggedStruct<"RunOperationRejectedError", {
|
|
160
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
161
|
+
readonly operation: Schema.Literals<readonly ["approve", "retry"]>;
|
|
162
|
+
readonly state: Schema.String;
|
|
163
|
+
}>, import("effect/Cause").YieldableError>;
|
|
164
|
+
export declare class RunOperationRejectedError extends RunOperationRejectedError_base {
|
|
165
|
+
}
|
|
166
|
+
declare const EnginePersistenceError_base: Schema.Class<EnginePersistenceError, Schema.TaggedStruct<"EnginePersistenceError", {
|
|
167
|
+
readonly operation: Schema.String;
|
|
168
|
+
readonly cause: Schema.Defect;
|
|
169
|
+
}>, import("effect/Cause").YieldableError>;
|
|
170
|
+
export declare class EnginePersistenceError extends EnginePersistenceError_base {
|
|
171
|
+
}
|
|
172
|
+
declare const AttemptCancellationError_base: Schema.Class<AttemptCancellationError, Schema.TaggedStruct<"AttemptCancellationError", {
|
|
173
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
174
|
+
readonly cause: Schema.Defect;
|
|
175
|
+
}>, import("effect/Cause").YieldableError>;
|
|
176
|
+
export declare class AttemptCancellationError extends AttemptCancellationError_base {
|
|
177
|
+
}
|
|
178
|
+
/** Everything the store itself can fail with. */
|
|
179
|
+
export declare const RunStoreError: Schema.Union<readonly [typeof RunNotFoundError, typeof RunOperationRejectedError, typeof EnginePersistenceError]>;
|
|
180
|
+
export type RunStoreError = typeof RunStoreError.Type;
|
|
181
|
+
/** The store's failures plus the engine-only cancellation handshake failure. */
|
|
182
|
+
export declare const RunEngineError: Schema.Union<readonly [typeof RunNotFoundError, typeof RunOperationRejectedError, typeof EnginePersistenceError, typeof AttemptCancellationError]>;
|
|
183
|
+
export type RunEngineError = typeof RunEngineError.Type;
|
|
184
|
+
export {};
|
|
185
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,cAAc,EACd,KAAK,EACL,QAAQ,EAER,IAAI,EAEJ,GAAG,EACH,IAAI,EACL,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,+BAA6B,CAAC;AAChE,eAAO,MAAM,mBAAmB,gDAA2B,CAAC;AAC5D,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;AAE3D,+DAA+D;AAC/D,eAAO,MAAM,iBAAiB,0DAAqB,CAAC;AACpD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC;;;;;AAEnD,uFAAuF;AACvF,qBAAa,gBAAiB,SAAQ,qBAKpC;CAAG;;;;;;;;;;;;;AAEL,wEAAwE;AACxE,qBAAa,UAAW,SAAQ,eAW9B;CAAG;;;;;AAEL,8EAA8E;AAC9E,qBAAa,OAAQ,SAAQ,YAG3B;CAAG;;;;AAEL,wFAAwF;AACxF,qBAAa,MAAO,SAAQ,WAE1B;CAAG;AAEL,eAAO,MAAM,eAAe,YAAI,YAAY,EAAE,SAAS,CAAU,CAAC;AAClE,eAAO,MAAM,YAAY,qDAAmC,CAAC;AAC7D,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAEpD,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,YAAI,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC;AACzF,eA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;;;AAEL,qBAAa,sBAAuB,SAAQ,2BAK1C;CAAG;;;;;AAEL,qBAAa,wBAAyB,SAAQ,6BAK5C;CAAG;AAEL,iDAAiD;AACjD,eAAO,MAAM,aAAa,mHAIxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,cAAc,oJAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC"}
|
package/dist/model.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Agent, Attempt, AttemptChannel, Event, Instance, Item, Loop, Repository, Run, Step, } from "@usine/core";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
/** Whether a loop parks new runs until an approval Event arrives. */
|
|
4
|
+
export const APPROVAL_REQUIREMENTS = Loop.APPROVAL_REQUIREMENTS;
|
|
5
|
+
export const ApprovalRequirement = Loop.ApprovalRequirement;
|
|
6
|
+
/** Absolute or caller-resolved path to the instance folder. */
|
|
7
|
+
export const InstanceDirectory = Instance.Directory;
|
|
8
|
+
/** Durable runtime state for one Loop. Authored loop files never carry this toggle. */
|
|
9
|
+
export class LoopRuntimeState extends Schema.Class("@usine/engine/LoopRuntimeState")({
|
|
10
|
+
loop: Loop.LoopName,
|
|
11
|
+
paused: Schema.Boolean,
|
|
12
|
+
}) {
|
|
13
|
+
}
|
|
14
|
+
/** The complete routing context needed to turn one Event into a Run. */
|
|
15
|
+
export class Submission extends Schema.Class("@usine/engine/Submission")({
|
|
16
|
+
event: Event.Event,
|
|
17
|
+
itemKey: Item.ItemKey,
|
|
18
|
+
loop: Loop.LoopName,
|
|
19
|
+
step: Step.StepName,
|
|
20
|
+
approval: ApprovalRequirement,
|
|
21
|
+
repository: Repository.Name,
|
|
22
|
+
revision: Repository.Revision,
|
|
23
|
+
task: AttemptChannel.Task,
|
|
24
|
+
agent: Agent.Agent,
|
|
25
|
+
parentModel: Schema.Option(Agent.ModelId),
|
|
26
|
+
}) {
|
|
27
|
+
}
|
|
28
|
+
/** The Event owns a Run and repeated submissions return the same identity. */
|
|
29
|
+
export class Claimed extends Schema.TaggedClass("@usine/engine/Claimed")("Claimed", {
|
|
30
|
+
eventId: Event.EventId,
|
|
31
|
+
runId: Run.RunId,
|
|
32
|
+
}) {
|
|
33
|
+
}
|
|
34
|
+
/** A running Attempt on the same Item must finish before this Event is reconsidered. */
|
|
35
|
+
export class Queued extends Schema.TaggedClass("@usine/engine/Queued")("Queued", {
|
|
36
|
+
eventId: Event.EventId,
|
|
37
|
+
}) {
|
|
38
|
+
}
|
|
39
|
+
export const IGNORED_REASONS = ["superseded", "revoked"];
|
|
40
|
+
export const IgnoreReason = Schema.Literals(IGNORED_REASONS);
|
|
41
|
+
/** Durable one-shot requests from the store to the workflow runtime. */
|
|
42
|
+
export const WORKFLOW_COMMANDS = ["Approve", "Continue", "Interrupt", "Resume"];
|
|
43
|
+
export const WorkflowCommand = Schema.Literals(WORKFLOW_COMMANDS);
|
|
44
|
+
/**
|
|
45
|
+
* Replay order after a restart, first delivered first. Interrupt must precede
|
|
46
|
+
* Continue: on a cancel replay the canceled workflow stops before the next
|
|
47
|
+
* queued Event opens, preserving one open Run per Item. The length constraint
|
|
48
|
+
* forces this list to name every command exactly once.
|
|
49
|
+
*/
|
|
50
|
+
export const WORKFLOW_COMMAND_PRIORITY = [
|
|
51
|
+
"Resume",
|
|
52
|
+
"Interrupt",
|
|
53
|
+
"Continue",
|
|
54
|
+
"Approve",
|
|
55
|
+
];
|
|
56
|
+
/** The Event remains in the permanent ledger but can no longer open a Run. */
|
|
57
|
+
export class Ignored extends Schema.TaggedClass("@usine/engine/Ignored")("Ignored", {
|
|
58
|
+
eventId: Event.EventId,
|
|
59
|
+
reason: IgnoreReason,
|
|
60
|
+
}) {
|
|
61
|
+
}
|
|
62
|
+
export const SubmissionResult = Schema.Union([Claimed, Queued, Ignored]);
|
|
63
|
+
/** Observable durable projection for one Run. */
|
|
64
|
+
export class RunSnapshot extends Schema.Class("@usine/engine/RunSnapshot")({
|
|
65
|
+
event: Event.Event,
|
|
66
|
+
itemKey: Item.ItemKey,
|
|
67
|
+
run: Run.Run,
|
|
68
|
+
step: Step.Step,
|
|
69
|
+
attempts: Schema.Array(Attempt.Attempt),
|
|
70
|
+
repository: Repository.Name,
|
|
71
|
+
revision: Repository.Revision,
|
|
72
|
+
task: AttemptChannel.Task,
|
|
73
|
+
agent: Agent.Agent,
|
|
74
|
+
parentModel: Schema.Option(Agent.ModelId),
|
|
75
|
+
}) {
|
|
76
|
+
}
|
|
77
|
+
/** Lightweight durable projection used when listing Runs for operators. */
|
|
78
|
+
export class RunSummary extends Schema.Class("@usine/engine/RunSummary")({
|
|
79
|
+
itemKey: Item.ItemKey,
|
|
80
|
+
run: Run.Run,
|
|
81
|
+
step: Step.Step,
|
|
82
|
+
attempts: Schema.Array(Attempt.Attempt),
|
|
83
|
+
repository: Repository.Name,
|
|
84
|
+
task: AttemptChannel.Task,
|
|
85
|
+
agent: Agent.Agent,
|
|
86
|
+
}) {
|
|
87
|
+
}
|
|
88
|
+
/** Monotonic version of the durable operator projection. */
|
|
89
|
+
export const ProjectionRevision = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("ProjectionRevision"));
|
|
90
|
+
/** Input passed to the attempt-execution port. */
|
|
91
|
+
export class StepExecution extends Schema.Class("@usine/engine/StepExecution")({
|
|
92
|
+
attempt: Attempt.Attempt,
|
|
93
|
+
event: Event.Event,
|
|
94
|
+
run: Run.Run,
|
|
95
|
+
step: Step.Step,
|
|
96
|
+
repository: Repository.Name,
|
|
97
|
+
revision: Repository.Revision,
|
|
98
|
+
task: AttemptChannel.Task,
|
|
99
|
+
agent: Agent.Agent,
|
|
100
|
+
parentModel: Schema.Option(Agent.ModelId),
|
|
101
|
+
}) {
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Value object: global append order of the persisted transcript — the tail
|
|
105
|
+
* cursor. Distinct from `AttemptChannel.Sequence`, which orders messages
|
|
106
|
+
* within one Attempt's channel direction.
|
|
107
|
+
*/
|
|
108
|
+
export const TranscriptSequence = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("TranscriptSequence"));
|
|
109
|
+
/** One append-only row in an Attempt transcript. */
|
|
110
|
+
export class TranscriptEntry extends Schema.Class("@usine/engine/TranscriptEntry")({
|
|
111
|
+
sequence: TranscriptSequence,
|
|
112
|
+
attemptId: Attempt.AttemptId,
|
|
113
|
+
direction: AttemptChannel.Direction,
|
|
114
|
+
envelope: AttemptChannel.Envelope,
|
|
115
|
+
receivedAt: Schema.DateTimeUtc,
|
|
116
|
+
}) {
|
|
117
|
+
}
|
|
118
|
+
/** Read every row for one Attempt. Intended for execution and diagnostic consumers. */
|
|
119
|
+
export class TranscriptAllQuery extends Schema.TaggedClass("@usine/engine/TranscriptAllQuery")("TranscriptAllQuery", { attemptId: Attempt.AttemptId }) {
|
|
120
|
+
}
|
|
121
|
+
/** Read rows appended after a cursor while tailing a live Attempt. */
|
|
122
|
+
export class TranscriptTailQuery extends Schema.TaggedClass("@usine/engine/TranscriptTailQuery")("TranscriptTailQuery", {
|
|
123
|
+
attemptId: Attempt.AttemptId,
|
|
124
|
+
after: TranscriptSequence,
|
|
125
|
+
limit: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
|
|
126
|
+
}) {
|
|
127
|
+
}
|
|
128
|
+
/** Read the newest bounded page before a cursor, or from the current tail. */
|
|
129
|
+
export class TranscriptPageQuery extends Schema.TaggedClass("@usine/engine/TranscriptPageQuery")("TranscriptPageQuery", {
|
|
130
|
+
attemptId: Attempt.AttemptId,
|
|
131
|
+
before: Schema.Option(TranscriptSequence),
|
|
132
|
+
limit: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
|
|
133
|
+
}) {
|
|
134
|
+
}
|
|
135
|
+
/** Illegal combinations of full, tail, and backward-page reads are unrepresentable. */
|
|
136
|
+
export const TranscriptQuery = Schema.Union([
|
|
137
|
+
TranscriptAllQuery,
|
|
138
|
+
TranscriptTailQuery,
|
|
139
|
+
TranscriptPageQuery,
|
|
140
|
+
]);
|
|
141
|
+
export class RunNotFoundError extends Schema.TaggedError("@usine/engine/RunNotFoundError")("RunNotFoundError", {
|
|
142
|
+
runId: Run.RunId,
|
|
143
|
+
}) {
|
|
144
|
+
}
|
|
145
|
+
export class RunOperationRejectedError extends Schema.TaggedError("@usine/engine/RunOperationRejectedError")("RunOperationRejectedError", {
|
|
146
|
+
runId: Run.RunId,
|
|
147
|
+
operation: Schema.Literals(["approve", "retry"]),
|
|
148
|
+
state: Schema.String,
|
|
149
|
+
}) {
|
|
150
|
+
}
|
|
151
|
+
export class EnginePersistenceError extends Schema.TaggedError("@usine/engine/EnginePersistenceError")("EnginePersistenceError", {
|
|
152
|
+
operation: Schema.String,
|
|
153
|
+
cause: Schema.Defect(),
|
|
154
|
+
}) {
|
|
155
|
+
}
|
|
156
|
+
export class AttemptCancellationError extends Schema.TaggedError("@usine/engine/AttemptCancellationError")("AttemptCancellationError", {
|
|
157
|
+
attemptId: Attempt.AttemptId,
|
|
158
|
+
cause: Schema.Defect(),
|
|
159
|
+
}) {
|
|
160
|
+
}
|
|
161
|
+
/** Everything the store itself can fail with. */
|
|
162
|
+
export const RunStoreError = Schema.Union([
|
|
163
|
+
RunNotFoundError,
|
|
164
|
+
RunOperationRejectedError,
|
|
165
|
+
EnginePersistenceError,
|
|
166
|
+
]);
|
|
167
|
+
/** The store's failures plus the engine-only cancellation handshake failure. */
|
|
168
|
+
export const RunEngineError = Schema.Union([
|
|
169
|
+
RunNotFoundError,
|
|
170
|
+
RunOperationRejectedError,
|
|
171
|
+
EnginePersistenceError,
|
|
172
|
+
AttemptCancellationError,
|
|
173
|
+
]);
|
|
174
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"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CAAC,CAAC;AAGH,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;IACzC,gBAAgB;IAChB,yBAAyB;IACzB,sBAAsB;IACtB,wBAAwB;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const RepositoryLabelProjection_base: Schema.Class<RepositoryLabelProjection, Schema.Struct<{
|
|
3
|
+
readonly repository: Schema.brand<Schema.String, "RepoName">;
|
|
4
|
+
readonly labels: Schema.$Array<Schema.String>;
|
|
5
|
+
}>, {}>;
|
|
6
|
+
/** Latest complete repository label catalog observed by trigger polling. */
|
|
7
|
+
export declare class RepositoryLabelProjection extends RepositoryLabelProjection_base {
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/repository-label-projection/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAOhC,4EAA4E;AAC5E,qBAAa,yBAA0B,SAAQ,8BAK7C;CAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Repository } from "@usine/core";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
const RepositoryLabel = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank repository label" }));
|
|
4
|
+
const RepositoryLabels = Schema.Array(RepositoryLabel).check(Schema.isUnique());
|
|
5
|
+
/** Latest complete repository label catalog observed by trigger polling. */
|
|
6
|
+
export class RepositoryLabelProjection extends Schema.Class("@usine/engine/RepositoryLabelProjection")({
|
|
7
|
+
repository: Repository.Name,
|
|
8
|
+
labels: RepositoryLabels,
|
|
9
|
+
}) {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/repository-label-projection/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACzC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC,CAC9E,CAAC;AACF,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAEhF,4EAA4E;AAC5E,MAAM,OAAO,yBAA0B,SAAQ,MAAM,CAAC,KAAK,CACzD,yCAAyC,CAC1C,CAAC;IACA,UAAU,EAAE,UAAU,CAAC,IAAI;IAC3B,MAAM,EAAE,gBAAgB;CACzB,CAAC;CAAG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Repository } from "@usine/core";
|
|
2
|
+
import { Context, Effect, Layer, Option } from "effect";
|
|
3
|
+
import { RunDatabase } from "../database/database.ts";
|
|
4
|
+
import { EnginePersistenceError } from "../model.ts";
|
|
5
|
+
import { RepositoryLabelProjection } from "./model.ts";
|
|
6
|
+
declare const RepositoryLabelProjectionReader_base: Context.ServiceClass<RepositoryLabelProjectionReader, "@usine/engine/RepositoryLabelProjectionReader", {
|
|
7
|
+
readonly get: (repository: Repository.Name) => Effect.Effect<Option.Option<RepositoryLabelProjection>, EnginePersistenceError>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class RepositoryLabelProjectionReader extends RepositoryLabelProjectionReader_base {
|
|
10
|
+
static readonly layer: Layer.Layer<RepositoryLabelProjectionReader, never, RunDatabase>;
|
|
11
|
+
}
|
|
12
|
+
declare const RepositoryLabelProjectionWriter_base: Context.ServiceClass<RepositoryLabelProjectionWriter, "@usine/engine/RepositoryLabelProjectionWriter", {
|
|
13
|
+
/** `true` means the durable projection changed. */
|
|
14
|
+
readonly replace: (projection: RepositoryLabelProjection) => Effect.Effect<boolean, EnginePersistenceError>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare class RepositoryLabelProjectionWriter extends RepositoryLabelProjectionWriter_base {
|
|
17
|
+
static readonly layer: Layer.Layer<RepositoryLabelProjectionWriter, never, RunDatabase>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/repository-label-projection/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;;kBA0ErC,CACZ,UAAU,EAAE,UAAU,CAAC,IAAI,KACxB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,yBAAyB,CAAC,EAAE,sBAAsB,CAAC;;AALxF,qBAAa,+BAAgC,SAAQ,oCAOD;IAClD,MAAM,CAAC,QAAQ,CAAC,KAAK,mEAA6D;CACnF;;IAKG,mDAAmD;sBACjC,CAChB,UAAU,EAAE,yBAAyB,KAClC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC;;AANvD,qBAAa,+BAAgC,SAAQ,oCAQD;IAClD,MAAM,CAAC,QAAQ,CAAC,KAAK,mEAA6D;CACnF"}
|