feat: add scoped history and artifacts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export type InputDelivery = "steer" | "queue";
|
||||
export type ResponseInput = { id: string; text: string; delivery: InputDelivery; status: "pending" | "delivered" };
|
||||
export type ResponseInput = { id: string; text: string; delivery: InputDelivery; status: "pending" | "delivered" | "cancelled" };
|
||||
type InboxRuntime = {
|
||||
enqueueUserInput: (sessionId: string, input: ResponseInput) => Promise<void>;
|
||||
listPendingUserInputs: (sessionId: string) => Promise<ResponseInput[]>;
|
||||
@@ -19,7 +19,7 @@ export class ResponseInputTracker {
|
||||
|
||||
markReady() { this.releaseReady(); }
|
||||
close() { this.accepting = false; this.releaseReady(); }
|
||||
get hasAdditionalInput() { return this.items.size > 0; }
|
||||
get hasAdditionalInput() { return [...this.items.values()].some((input) => input.status !== "cancelled"); }
|
||||
|
||||
async restore() {
|
||||
for (const input of await this.runtime.listPendingUserInputs(this.sessionId)) this.items.set(input.id, input);
|
||||
@@ -53,8 +53,9 @@ export class ResponseInputTracker {
|
||||
|
||||
observe(type: string, data: { inboxID?: string; delivery?: InputDelivery }) {
|
||||
const input = data.inboxID ? this.items.get(data.inboxID) : undefined;
|
||||
if (!input) return;
|
||||
if (!input || input.status !== "pending") return;
|
||||
if (type === "session.inbox.delivered") input.status = "delivered";
|
||||
else if (type === "session.inbox.cancelled") input.status = "cancelled";
|
||||
else if (type === "session.inbox.delivery.changed" && data.delivery) input.delivery = data.delivery;
|
||||
else return;
|
||||
this.changed({ ...input });
|
||||
|
||||
Reference in New Issue
Block a user