Download src/shell/gate.ts from uos1231234/agent-shell: direct link, hf CLI and curl.
- Browser
- Download file 851 Bytes
-
https://huggingface.co/uos1231234/agent-shell/resolve/main/src/shell/gate.ts
- Command line
-
hf download hf://uos1231234/agent-shell/src/shell/gate.ts
-
curl -L -o gate.ts https://huggingface.co/uos1231234/agent-shell/resolve/main/src/shell/gate.ts
851 Bytes
| // ADR-002: the gate is the funnel's valve. | |
| // Running → flow continues. | |
| // Tripped → the valve is closed; the caller (IM) MUST terminate. | |
| import type { State } from './state.js' | |
| import type { GuardHit } from './guards.js' | |
| export type GateOk = { ok: true } | |
| export class ShellTerminatedError extends Error { | |
| readonly state: State | |
| readonly hits: GuardHit[] | |
| constructor(state: State, hits: GuardHit[]) { | |
| const summary = hits.length > 0 | |
| ? hits.map(h => `${h.id}:${h.reason}`).join('; ') | |
| : 'shell terminated' | |
| super(`Shell terminated (${state}) — ${summary}`) | |
| this.name = 'ShellTerminatedError' | |
| this.state = state | |
| this.hits = hits | |
| } | |
| } | |
| export const gate = (state: State, hits: GuardHit[]): GateOk => { | |
| if (state === 'Running') { | |
| return { ok: true } | |
| } | |
| throw new ShellTerminatedError(state, hits) | |
| } | |