@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
69 lines • 2.22 kB
JavaScript
import { JobWidgetRuntime } from "./runtime.js";
export class JobWidgetJob {
#matcher;
#redact;
#asked;
#authoring;
#skippedAtMs;
constructor(input, matcher, redact) {
this.settled = false;
this.#asked = false;
this.#authoring = false;
this.id = input.id;
this.kind = input.kind;
this.startTime = input.startedAtMs ?? Date.now();
this.sources = input.sources;
this.brief = { ...input.brief, kind: input.kind };
this.#matcher = matcher;
this.#redact = redact;
this.runtime = this.#newRuntime(undefined);
}
#newRuntime(spec) {
return new JobWidgetRuntime({
spec,
matcher: this.#matcher,
startTime: this.startTime,
redactSource: () => this.#redact.source(),
});
}
ingest() {
this.runtime.ingest(this.sources, this.settled);
}
requestStarted() {
this.#asked = true;
this.#authoring = true;
}
requestSettled(outcome) {
this.#authoring = false;
if (outcome.kind === "installed") {
this.runtime = this.#newRuntime(outcome.spec);
this.ingest();
}
else if (outcome.kind === "skipped" && !this.runtime.spec) {
this.#skippedAtMs = Date.now();
}
}
entry() {
if (this.#skippedAtMs !== undefined) {
return { id: this.id, kind: this.kind, state: "skipped", updatedAtMs: this.#skippedAtMs };
}
if (!this.#asked)
return undefined;
const brief = this.brief;
const derived = this.runtime.derive({
label: this.#redact.text(brief.intent ?? brief.task ?? brief.command ?? this.id),
...(brief.stage === undefined ? {} : { stage: this.#redact.text(brief.stage) }),
lineStage: this.kind === "bash",
authoring: this.#authoring,
settled: this.settled,
});
return {
id: this.id,
kind: this.kind,
state: derived.state,
view: derived.view,
updatedAtMs: derived.updatedAtMs,
};
}
}
//# sourceMappingURL=registry-job.js.map