feat: package Pi extensions as Bun workspaces
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
interface ContinuationAssignment {
|
||||
status: string;
|
||||
executionToken?: string;
|
||||
}
|
||||
|
||||
interface ContinuationGate {
|
||||
id: string;
|
||||
kind: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
interface ContinuationContext {
|
||||
gateId: string;
|
||||
runRevision: number;
|
||||
planRevision: number;
|
||||
activeParentSessionId: string;
|
||||
strategy?: string;
|
||||
status: string;
|
||||
method?: string;
|
||||
outcome?: string;
|
||||
}
|
||||
|
||||
export interface ContinuationState {
|
||||
revision: number;
|
||||
status: string;
|
||||
planArtifact?: { revision: number };
|
||||
implementationContext?: ContinuationContext;
|
||||
openGate?: ContinuationGate;
|
||||
assignments: ContinuationAssignment[];
|
||||
}
|
||||
|
||||
export function isValidContextContinuation(
|
||||
run: ContinuationState,
|
||||
sessionId?: string,
|
||||
) {
|
||||
const context = run.implementationContext;
|
||||
const gate = run.openGate;
|
||||
if (
|
||||
run.status !== "waiting" ||
|
||||
!context ||
|
||||
gate?.status !== "open" ||
|
||||
gate.kind !== "implementation-context" ||
|
||||
gate.id !== context.gateId ||
|
||||
run.planArtifact?.revision !== context.planRevision ||
|
||||
context.runRevision > run.revision ||
|
||||
run.revision - context.runRevision > 1 ||
|
||||
(sessionId && context.activeParentSessionId !== sessionId) ||
|
||||
run.assignments.some(
|
||||
(assignment) =>
|
||||
assignment.status === "running" ||
|
||||
(assignment.status === "queued" && Boolean(assignment.executionToken)),
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
(context.status === "handoff-pending" &&
|
||||
context.strategy === "fresh-session" &&
|
||||
context.method === "fresh-session") ||
|
||||
(context.status === "normal-compact-pending" &&
|
||||
context.strategy === "smart-compact" &&
|
||||
context.method === "smart_compact" &&
|
||||
context.outcome === "unavailable")
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user