mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-20 14:05:11 +00:00
Configure lefthook formatter checks (#231)
* Add lefthook formatter checks * Fix SDK mode hydration * Stabilize SDK mode integration test
This commit is contained in:
parent
0471214d65
commit
d2346bafb3
282 changed files with 5840 additions and 8399 deletions
|
|
@ -23,12 +23,7 @@ interface PollingActorContext<TState extends PollingControlState> {
|
|||
state: TState;
|
||||
abortSignal: AbortSignal;
|
||||
queue: {
|
||||
nextBatch(options: {
|
||||
names: readonly string[];
|
||||
timeout: number;
|
||||
count: number;
|
||||
completable: true;
|
||||
}): Promise<PollingQueueMessage[]>;
|
||||
nextBatch(options: { names: readonly string[]; timeout: number; count: number; completable: true }): Promise<PollingQueueMessage[]>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -39,21 +34,16 @@ interface RunPollingOptions<TState extends PollingControlState> {
|
|||
|
||||
export async function runPollingControlLoop<TState extends PollingControlState>(
|
||||
c: PollingActorContext<TState>,
|
||||
options: RunPollingOptions<TState>
|
||||
options: RunPollingOptions<TState>,
|
||||
): Promise<void> {
|
||||
while (!c.abortSignal.aborted) {
|
||||
const messages = normalizeMessages(
|
||||
await c.queue.nextBatch({
|
||||
names: [
|
||||
options.control.start,
|
||||
options.control.stop,
|
||||
options.control.setInterval,
|
||||
options.control.force
|
||||
],
|
||||
names: [options.control.start, options.control.stop, options.control.setInterval, options.control.force],
|
||||
timeout: Math.max(500, c.state.intervalMs),
|
||||
count: 16,
|
||||
completable: true
|
||||
})
|
||||
completable: true,
|
||||
}),
|
||||
) as PollingQueueMessage[];
|
||||
|
||||
if (messages.length === 0) {
|
||||
|
|
@ -94,12 +84,7 @@ export async function runPollingControlLoop<TState extends PollingControlState>(
|
|||
|
||||
interface WorkflowPollingActorContext<TState extends PollingControlState> {
|
||||
state: TState;
|
||||
loop(config: {
|
||||
name: string;
|
||||
historyEvery: number;
|
||||
historyKeep: number;
|
||||
run(ctx: WorkflowPollingActorContext<TState>): Promise<unknown>;
|
||||
}): Promise<void>;
|
||||
loop(config: { name: string; historyEvery: number; historyKeep: number; run(ctx: WorkflowPollingActorContext<TState>): Promise<unknown> }): Promise<void>;
|
||||
}
|
||||
|
||||
interface WorkflowPollingQueueMessage extends PollingQueueMessage {}
|
||||
|
|
@ -107,12 +92,15 @@ interface WorkflowPollingQueueMessage extends PollingQueueMessage {}
|
|||
interface WorkflowPollingLoopContext<TState extends PollingControlState> {
|
||||
state: TState;
|
||||
queue: {
|
||||
nextBatch(name: string, options: {
|
||||
names: readonly string[];
|
||||
timeout: number;
|
||||
count: number;
|
||||
completable: true;
|
||||
}): Promise<WorkflowPollingQueueMessage[]>;
|
||||
nextBatch(
|
||||
name: string,
|
||||
options: {
|
||||
names: readonly string[];
|
||||
timeout: number;
|
||||
count: number;
|
||||
completable: true;
|
||||
},
|
||||
): Promise<WorkflowPollingQueueMessage[]>;
|
||||
};
|
||||
step<T>(
|
||||
nameOrConfig:
|
||||
|
|
@ -138,12 +126,7 @@ export async function runWorkflowPollingLoop<TState extends PollingControlState>
|
|||
|
||||
const messages = normalizeMessages(
|
||||
await loopCtx.queue.nextBatch("next-polling-control-batch", {
|
||||
names: [
|
||||
options.control.start,
|
||||
options.control.stop,
|
||||
options.control.setInterval,
|
||||
options.control.force,
|
||||
],
|
||||
names: [options.control.start, options.control.stop, options.control.setInterval, options.control.force],
|
||||
timeout: control.running ? control.intervalMs : 60_000,
|
||||
count: 16,
|
||||
completable: true,
|
||||
|
|
@ -172,37 +155,35 @@ export async function runWorkflowPollingLoop<TState extends PollingControlState>
|
|||
continue;
|
||||
}
|
||||
|
||||
if (msg.name === options.control.stop) {
|
||||
await loopCtx.step("control-stop", async () => {
|
||||
loopCtx.state.running = false;
|
||||
});
|
||||
await msg.complete({ ok: true });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msg.name === options.control.setInterval) {
|
||||
await loopCtx.step("control-set-interval", async () => {
|
||||
const intervalMs = Number((msg.body as { intervalMs?: unknown })?.intervalMs);
|
||||
loopCtx.state.intervalMs = Number.isFinite(intervalMs)
|
||||
? Math.max(500, intervalMs)
|
||||
: loopCtx.state.intervalMs;
|
||||
});
|
||||
await msg.complete({ ok: true });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msg.name === options.control.force) {
|
||||
await loopCtx.step({
|
||||
name: "control-force",
|
||||
timeout: 5 * 60_000,
|
||||
run: async () => {
|
||||
await options.onPoll(loopCtx as unknown as PollingActorContext<TState>);
|
||||
},
|
||||
});
|
||||
await msg.complete({ ok: true });
|
||||
}
|
||||
if (msg.name === options.control.stop) {
|
||||
await loopCtx.step("control-stop", async () => {
|
||||
loopCtx.state.running = false;
|
||||
});
|
||||
await msg.complete({ ok: true });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msg.name === options.control.setInterval) {
|
||||
await loopCtx.step("control-set-interval", async () => {
|
||||
const intervalMs = Number((msg.body as { intervalMs?: unknown })?.intervalMs);
|
||||
loopCtx.state.intervalMs = Number.isFinite(intervalMs) ? Math.max(500, intervalMs) : loopCtx.state.intervalMs;
|
||||
});
|
||||
await msg.complete({ ok: true });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msg.name === options.control.force) {
|
||||
await loopCtx.step({
|
||||
name: "control-force",
|
||||
timeout: 5 * 60_000,
|
||||
run: async () => {
|
||||
await options.onPoll(loopCtx as unknown as PollingActorContext<TState>);
|
||||
},
|
||||
});
|
||||
await msg.complete({ ok: true });
|
||||
}
|
||||
}
|
||||
|
||||
return Loop.continue(undefined);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue