@open-mercato/cezar 0.1.5-pr506.357
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +573 -0
- package/dist/config.d.ts +144 -0
- package/dist/config.js +106 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-runner.d.ts +169 -0
- package/dist/core/agent-runner.js +23 -0
- package/dist/core/agent-runner.js.map +1 -0
- package/dist/core/backend-detect.d.ts +16 -0
- package/dist/core/backend-detect.js +118 -0
- package/dist/core/backend-detect.js.map +1 -0
- package/dist/core/claude-cli-runner.d.ts +56 -0
- package/dist/core/claude-cli-runner.js +416 -0
- package/dist/core/claude-cli-runner.js.map +1 -0
- package/dist/core/claude-ui-mapper.d.ts +71 -0
- package/dist/core/claude-ui-mapper.js +567 -0
- package/dist/core/claude-ui-mapper.js.map +1 -0
- package/dist/core/codex-app-server-runner.d.ts +29 -0
- package/dist/core/codex-app-server-runner.js +489 -0
- package/dist/core/codex-app-server-runner.js.map +1 -0
- package/dist/core/codex-ui-mapper.d.ts +63 -0
- package/dist/core/codex-ui-mapper.js +491 -0
- package/dist/core/codex-ui-mapper.js.map +1 -0
- package/dist/core/ndjson.d.ts +6 -0
- package/dist/core/ndjson.js +23 -0
- package/dist/core/ndjson.js.map +1 -0
- package/dist/core/opencode-server-runner.d.ts +30 -0
- package/dist/core/opencode-server-runner.js +488 -0
- package/dist/core/opencode-server-runner.js.map +1 -0
- package/dist/core/opencode-ui-mapper.d.ts +105 -0
- package/dist/core/opencode-ui-mapper.js +588 -0
- package/dist/core/opencode-ui-mapper.js.map +1 -0
- package/dist/core/process-usage.d.ts +63 -0
- package/dist/core/process-usage.js +181 -0
- package/dist/core/process-usage.js.map +1 -0
- package/dist/core/runner-factory.d.ts +8 -0
- package/dist/core/runner-factory.js +22 -0
- package/dist/core/runner-factory.js.map +1 -0
- package/dist/core/tool-display.d.ts +30 -0
- package/dist/core/tool-display.js +156 -0
- package/dist/core/tool-display.js.map +1 -0
- package/dist/core/ui-events.d.ts +308 -0
- package/dist/core/ui-events.js +25 -0
- package/dist/core/ui-events.js.map +1 -0
- package/dist/core/usage.d.ts +11 -0
- package/dist/core/usage.js +15 -0
- package/dist/core/usage.js.map +1 -0
- package/dist/git-worktree.d.ts +88 -0
- package/dist/git-worktree.js +297 -0
- package/dist/git-worktree.js.map +1 -0
- package/dist/handoff.d.ts +62 -0
- package/dist/handoff.js +147 -0
- package/dist/handoff.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +466 -0
- package/dist/index.js.map +1 -0
- package/dist/install-as-command.d.ts +39 -0
- package/dist/install-as-command.js +51 -0
- package/dist/install-as-command.js.map +1 -0
- package/dist/pack-check.d.ts +17 -0
- package/dist/pack-check.js +27 -0
- package/dist/pack-check.js.map +1 -0
- package/dist/paths.d.ts +23 -0
- package/dist/paths.js +34 -0
- package/dist/paths.js.map +1 -0
- package/dist/planner.d.ts +17 -0
- package/dist/planner.js +248 -0
- package/dist/planner.js.map +1 -0
- package/dist/release/snapshot.d.ts +64 -0
- package/dist/release/snapshot.js +75 -0
- package/dist/release/snapshot.js.map +1 -0
- package/dist/release/stable.d.ts +46 -0
- package/dist/release/stable.js +57 -0
- package/dist/release/stable.js.map +1 -0
- package/dist/runs/auto-name.d.ts +75 -0
- package/dist/runs/auto-name.js +168 -0
- package/dist/runs/auto-name.js.map +1 -0
- package/dist/runs/retention.d.ts +60 -0
- package/dist/runs/retention.js +86 -0
- package/dist/runs/retention.js.map +1 -0
- package/dist/runs/review-gate.d.ts +18 -0
- package/dist/runs/review-gate.js +21 -0
- package/dist/runs/review-gate.js.map +1 -0
- package/dist/runs/store.d.ts +408 -0
- package/dist/runs/store.js +526 -0
- package/dist/runs/store.js.map +1 -0
- package/dist/runs/task-refs.d.ts +24 -0
- package/dist/runs/task-refs.js +74 -0
- package/dist/runs/task-refs.js.map +1 -0
- package/dist/runs/ui-event-sink.d.ts +81 -0
- package/dist/runs/ui-event-sink.js +210 -0
- package/dist/runs/ui-event-sink.js.map +1 -0
- package/dist/server/capabilities.d.ts +33 -0
- package/dist/server/capabilities.js +43 -0
- package/dist/server/capabilities.js.map +1 -0
- package/dist/server/forge/github.d.ts +70 -0
- package/dist/server/forge/github.js +375 -0
- package/dist/server/forge/github.js.map +1 -0
- package/dist/server/forge/index.d.ts +24 -0
- package/dist/server/forge/index.js +45 -0
- package/dist/server/forge/index.js.map +1 -0
- package/dist/server/forge/types.d.ts +80 -0
- package/dist/server/forge/types.js +2 -0
- package/dist/server/forge/types.js.map +1 -0
- package/dist/server/git-changes.d.ts +195 -0
- package/dist/server/git-changes.js +497 -0
- package/dist/server/git-changes.js.map +1 -0
- package/dist/server/git.d.ts +26 -0
- package/dist/server/git.js +103 -0
- package/dist/server/git.js.map +1 -0
- package/dist/server/github.d.ts +8 -0
- package/dist/server/github.js +8 -0
- package/dist/server/github.js.map +1 -0
- package/dist/server/launch-key.d.ts +7 -0
- package/dist/server/launch-key.js +33 -0
- package/dist/server/launch-key.js.map +1 -0
- package/dist/server/open-in-app.d.ts +51 -0
- package/dist/server/open-in-app.js +189 -0
- package/dist/server/open-in-app.js.map +1 -0
- package/dist/server/open-in-terminal.d.ts +25 -0
- package/dist/server/open-in-terminal.js +120 -0
- package/dist/server/open-in-terminal.js.map +1 -0
- package/dist/server/pr.d.ts +7 -0
- package/dist/server/pr.js +7 -0
- package/dist/server/pr.js.map +1 -0
- package/dist/server/server.d.ts +41 -0
- package/dist/server/server.js +1390 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/static-ui.d.ts +49 -0
- package/dist/server/static-ui.js +92 -0
- package/dist/server/static-ui.js.map +1 -0
- package/dist/server/wsl.d.ts +25 -0
- package/dist/server/wsl.js +92 -0
- package/dist/server/wsl.js.map +1 -0
- package/dist/server-install/engine.d.ts +33 -0
- package/dist/server-install/engine.js +314 -0
- package/dist/server-install/engine.js.map +1 -0
- package/dist/server-install/platforms/macosx-ngrok.d.ts +6 -0
- package/dist/server-install/platforms/macosx-ngrok.js +345 -0
- package/dist/server-install/platforms/macosx-ngrok.js.map +1 -0
- package/dist/server-install/platforms/ubuntu-vps.d.ts +39 -0
- package/dist/server-install/platforms/ubuntu-vps.js +746 -0
- package/dist/server-install/platforms/ubuntu-vps.js.map +1 -0
- package/dist/server-install/state.d.ts +26 -0
- package/dist/server-install/state.js +125 -0
- package/dist/server-install/state.js.map +1 -0
- package/dist/server-install/steps.d.ts +109 -0
- package/dist/server-install/steps.js +330 -0
- package/dist/server-install/steps.js.map +1 -0
- package/dist/server-install/strategies.d.ts +4 -0
- package/dist/server-install/strategies.js +20 -0
- package/dist/server-install/strategies.js.map +1 -0
- package/dist/server-install/types.d.ts +597 -0
- package/dist/server-install/types.js +98 -0
- package/dist/server-install/types.js.map +1 -0
- package/dist/server-install/ui.d.ts +42 -0
- package/dist/server-install/ui.js +130 -0
- package/dist/server-install/ui.js.map +1 -0
- package/dist/skills-banner.d.ts +21 -0
- package/dist/skills-banner.js +40 -0
- package/dist/skills-banner.js.map +1 -0
- package/dist/skills-remote.d.ts +35 -0
- package/dist/skills-remote.js +266 -0
- package/dist/skills-remote.js.map +1 -0
- package/dist/skills.d.ts +45 -0
- package/dist/skills.js +182 -0
- package/dist/skills.js.map +1 -0
- package/dist/todos.d.ts +63 -0
- package/dist/todos.js +168 -0
- package/dist/todos.js.map +1 -0
- package/dist/ui-state.d.ts +12 -0
- package/dist/ui-state.js +25 -0
- package/dist/ui-state.js.map +1 -0
- package/dist/update-check.d.ts +12 -0
- package/dist/update-check.js +41 -0
- package/dist/update-check.js.map +1 -0
- package/dist/workflows/load.d.ts +15 -0
- package/dist/workflows/load.js +56 -0
- package/dist/workflows/load.js.map +1 -0
- package/dist/workflows/run.d.ts +281 -0
- package/dist/workflows/run.js +1511 -0
- package/dist/workflows/run.js.map +1 -0
- package/dist/workflows/types.d.ts +307 -0
- package/dist/workflows/types.js +171 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +90 -0
- package/scripts/check-pack.mjs +46 -0
- package/scripts/dev.mjs +74 -0
- package/scripts/install-as-command.mjs +120 -0
- package/scripts/mock-claude.mjs +310 -0
- package/scripts/release-snapshot.mjs +130 -0
- package/scripts/release.mjs +119 -0
- package/scripts/test-process-usage.mjs +47 -0
- package/web/dist/assets/arrow-left-BE957rJs.js +1 -0
- package/web/dist/assets/bundle-mjs-DLPpRFyl.js +1 -0
- package/web/dist/assets/centered-state-BddhEEtO.js +43 -0
- package/web/dist/assets/chunk-BO2N2NFS-f5igTtpB.js +131 -0
- package/web/dist/assets/command-CjhFbABo.js +1 -0
- package/web/dist/assets/compare-variants-Cs52IAEG.js +1 -0
- package/web/dist/assets/core-BuMqAF_1.js +12 -0
- package/web/dist/assets/css-BsVw1vtW.js +1 -0
- package/web/dist/assets/dialog-DFvXTkFv.js +1 -0
- package/web/dist/assets/diff-view-C9b8AITq.js +4 -0
- package/web/dist/assets/diff-woXpYk--.js +1 -0
- package/web/dist/assets/dist-FBs4wmIY.js +1 -0
- package/web/dist/assets/dist-o_kVMXjg.js +1 -0
- package/web/dist/assets/engine-javascript-FQvzRocB.js +141 -0
- package/web/dist/assets/file-BVuztAOd.js +1 -0
- package/web/dist/assets/folder-0pJ1NZ_S.js +1 -0
- package/web/dist/assets/git-pull-request-DJkAMT0f.js +1 -0
- package/web/dist/assets/git-toolbar-CwhQdx3J.js +1 -0
- package/web/dist/assets/github-D0rAX4-r.js +1 -0
- package/web/dist/assets/go-rLFTqkRN.js +1 -0
- package/web/dist/assets/highlighted-body-OFNGDK62-DGHHie_q.js +1 -0
- package/web/dist/assets/highlighter-BKVEsACy.js +3 -0
- package/web/dist/assets/html-BY76lXLH.js +1 -0
- package/web/dist/assets/index-CEkI7QxN.css +2 -0
- package/web/dist/assets/index-CO2lH2et.js +11 -0
- package/web/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/web/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/web/dist/assets/javascript-BgS3c2Ky.js +1 -0
- package/web/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/web/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/web/dist/assets/json-qhed-kSA.js +1 -0
- package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
- package/web/dist/assets/jsx-Bz0zcwM4.js +1 -0
- package/web/dist/assets/lib-CNGa3Dig.js +1 -0
- package/web/dist/assets/loader-circle-BV3DO9mE.js +1 -0
- package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
- package/web/dist/assets/markdown-D4-ADgH9.js +1 -0
- package/web/dist/assets/mermaid-GHXKKRXX-DM2VsGBG.js +1 -0
- package/web/dist/assets/open-mercato-toBr6SOa.svg +11 -0
- package/web/dist/assets/prompt-templates-C7ptKvDd.js +15 -0
- package/web/dist/assets/python-gzcpVVnB.js +1 -0
- package/web/dist/assets/react-dom-Ddtik4qM.js +1 -0
- package/web/dist/assets/refresh-cw-DCa-Rlwz.js +1 -0
- package/web/dist/assets/repo-git-DIhryGDx.js +1 -0
- package/web/dist/assets/run-diff-Dyow8B1q.js +3 -0
- package/web/dist/assets/run-header-jx9-18b8.js +1 -0
- package/web/dist/assets/rust-Cfkwpbl8.js +1 -0
- package/web/dist/assets/search-x-CoCyl7zT.js +1 -0
- package/web/dist/assets/shellscript-CLZ0U2zV.js +1 -0
- package/web/dist/assets/skill-detail-DB7x_FQp.js +1 -0
- package/web/dist/assets/skills-98vCroU8.js +1 -0
- package/web/dist/assets/skills-BKIoqD6K.js +1 -0
- package/web/dist/assets/sql-BsFa4tDR.js +1 -0
- package/web/dist/assets/square-terminal-B6PZX4Qp.js +1 -0
- package/web/dist/assets/tab-link-C5--YMQd.js +1 -0
- package/web/dist/assets/task-changes-ejxPGVJw.js +1 -0
- package/web/dist/assets/task-commits-C6GO5qT-.js +1 -0
- package/web/dist/assets/task-files-CatpCBXa.js +2 -0
- package/web/dist/assets/task-thread-BMbXDM3d.js +5 -0
- package/web/dist/assets/tasks-table-dgezlCcg.js +1 -0
- package/web/dist/assets/trash-2-CDtxmmc8.js +1 -0
- package/web/dist/assets/triangle-alert-6su4Js5O.js +1 -0
- package/web/dist/assets/tsx-udAQXfEw.js +1 -0
- package/web/dist/assets/typescript-bsJCZSQ-.js +1 -0
- package/web/dist/assets/upload-Bp7hQxll.js +1 -0
- package/web/dist/assets/use-desktop-CvTwojOJ.js +3 -0
- package/web/dist/assets/utils-rQGbOrwc.js +1 -0
- package/web/dist/assets/workflows-Dy2c6790.js +11 -0
- package/web/dist/assets/x-Br_jIDBw.js +1 -0
- package/web/dist/assets/yaml-rwi0_p6S.js +1 -0
- package/web/dist/index.html +70 -0
- package/web/open-mercato.svg +11 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import { extname, join, resolve } from 'node:path';
|
|
3
|
+
import { parse as parseYaml } from 'yaml';
|
|
4
|
+
import { QUICK_TASK_WORKFLOW, normalizeWorkflowDoc, stepsIssue, workflowFileSchema, } from './types.js';
|
|
5
|
+
export const WORKFLOWS_DIR = '.ai/cezar/workflows';
|
|
6
|
+
/**
|
|
7
|
+
* Load the workflow catalog: the built-in `quick-task` plus every
|
|
8
|
+
* `.ai/cezar/workflows/*.{yaml,yml}` in the repo. File workflows win name
|
|
9
|
+
* collisions with built-ins. Invalid files are reported, never fatal.
|
|
10
|
+
*/
|
|
11
|
+
export async function loadWorkflows(repoRoot) {
|
|
12
|
+
const dir = resolve(repoRoot, WORKFLOWS_DIR);
|
|
13
|
+
const issues = [];
|
|
14
|
+
const fromFiles = [];
|
|
15
|
+
let entries = [];
|
|
16
|
+
try {
|
|
17
|
+
entries = await readdir(dir);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// no workflows dir — built-ins only
|
|
21
|
+
}
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
const ext = extname(entry).toLowerCase();
|
|
24
|
+
if (ext !== '.yaml' && ext !== '.yml')
|
|
25
|
+
continue;
|
|
26
|
+
const path = join(dir, entry);
|
|
27
|
+
try {
|
|
28
|
+
const raw = await readFile(path, 'utf8');
|
|
29
|
+
const parsed = workflowFileSchema.safeParse(parseYaml(raw));
|
|
30
|
+
if (!parsed.success) {
|
|
31
|
+
issues.push({ path, message: parsed.error.issues.map((i) => i.message).join('; ') });
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
// `skills:` shorthand files become plain agent steps here (spec 012).
|
|
35
|
+
const normalized = normalizeWorkflowDoc(parsed.data);
|
|
36
|
+
// Steps referenced by onFail.retry must exist and come earlier; ids unique.
|
|
37
|
+
const issue = stepsIssue(normalized.steps);
|
|
38
|
+
if (issue) {
|
|
39
|
+
issues.push({ path, message: issue });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
fromFiles.push({ ...normalized, source: 'file', path });
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
issues.push({ path, message: err instanceof Error ? err.message : String(err) });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const fileNames = new Set(fromFiles.map((w) => w.name));
|
|
49
|
+
const workflows = [
|
|
50
|
+
...fromFiles,
|
|
51
|
+
...[QUICK_TASK_WORKFLOW].filter((w) => !fileNames.has(w.name)),
|
|
52
|
+
];
|
|
53
|
+
workflows.sort((a, b) => a.name.localeCompare(b.name));
|
|
54
|
+
return { workflows, issues };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/workflows/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,M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{ RunnerId } from '../core/agent-runner.js';
|
|
2
|
+
import type { ContentBlock } from '../core/agent-runner.js';
|
|
3
|
+
import { type Skill } from '../skills.js';
|
|
4
|
+
import type { RunRecord, RunStore } from '../runs/store.js';
|
|
5
|
+
import { type WorkflowDef } from './types.js';
|
|
6
|
+
/** An interactive session that hears nothing from the user closes itself. */
|
|
7
|
+
export declare const IDLE_TIMEOUT_MS: number;
|
|
8
|
+
/** Periodic "cezar autosave" commit in the task worktree (spec 006). */
|
|
9
|
+
export declare const AUTOSAVE_INTERVAL_MS = 90000;
|
|
10
|
+
/** The periodic autosave timer is opt-in (#471): off, a task branch carries only the
|
|
11
|
+
* agent's own commits plus the turn-end/pre-PR flushes — no mid-run "cezar autosave"
|
|
12
|
+
* noise interleaving PR history. The flushes (`autosaveCommit` at turn end and before
|
|
13
|
+
* a draft PR) are NOT gated: the branch must still end holding the finished state. */
|
|
14
|
+
export declare function periodicAutosaveEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
15
|
+
export interface StartRunInput {
|
|
16
|
+
task: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
/** Agent backend chosen for this task (GUI). Unset = the config default. */
|
|
19
|
+
runner?: RunnerId;
|
|
20
|
+
/** Screenshots pasted into the new-task form — delivered once, with the
|
|
21
|
+
* first agent step's opening message. */
|
|
22
|
+
images?: ContentBlock[];
|
|
23
|
+
/** Per-run system-prompt override (`POST /api/runs`, programmatic callers).
|
|
24
|
+
* Replaces the `config.json` default for this run — see
|
|
25
|
+
* `resolveExtraSystemPrompt` for the precedence contract. */
|
|
26
|
+
systemPrompt?: string;
|
|
27
|
+
/** Composer opt-out (#worktree-toggle): `false` runs the task in the repo
|
|
28
|
+
* working tree instead of an isolated worktree — for read-only skills that
|
|
29
|
+
* don't need a branch. Undefined/`true` keeps the default per-task worktree.
|
|
30
|
+
* Ignored for variants (they always isolate). */
|
|
31
|
+
worktree?: boolean;
|
|
32
|
+
/** Autonomous mode (#autonomous): the run never parks at `waiting` for the
|
|
33
|
+
* user — turn-ends auto-continue until the agent signals done or the safety
|
|
34
|
+
* cap is hit. No "needs you" is ever raised. */
|
|
35
|
+
autonomous?: boolean;
|
|
36
|
+
/** Follow-up inbox generation (spec 007, #444). Omitted means enabled for
|
|
37
|
+
* compatibility; the handoff journal runs either way. */
|
|
38
|
+
generateFollowups?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The effective "extra" system prompt for a run (spec §protocol v2, R2 2.3):
|
|
42
|
+
* the per-run override (`POST /api/runs` `systemPrompt`) REPLACES the
|
|
43
|
+
* `config.json` default — they are the same knob at two scopes, so the more
|
|
44
|
+
* specific one wins outright; they never concatenate. Whichever wins is
|
|
45
|
+
* ADDITIVE to the skill body and the handoff contract, which always ride
|
|
46
|
+
* along (see `composeSystemPrompt`). Blank strings count as unset.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveExtraSystemPrompt(override: string | undefined, configDefault: string | undefined): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Joins the parts of one agent step's system prompt in fixed order — skill
|
|
51
|
+
* body (most task-specific), then the run's extra prompt (user guidance, can
|
|
52
|
+
* amend the skill), then the handoff contract (always last, never optional in
|
|
53
|
+
* practice). Blank parts drop out; survivors join with the same `\n\n---\n\n`
|
|
54
|
+
* divider the skill+handoff composition has always used.
|
|
55
|
+
*/
|
|
56
|
+
export declare function composeSystemPrompt(...parts: Array<string | undefined>): string;
|
|
57
|
+
/** Variant letters + the fixed diversification hints (spec 010). A runs the
|
|
58
|
+
* task verbatim; B/C get one constant sentence each — zero configuration. */
|
|
59
|
+
export declare const VARIANT_LETTERS: readonly ["A", "B", "C"];
|
|
60
|
+
/**
|
|
61
|
+
* The mini workflow engine: executes a `WorkflowDef` against a repo, one step
|
|
62
|
+
* at a time, persisting every event to the RunStore (which the SSE endpoints
|
|
63
|
+
* relay live to the GUI). No GitHub choreography — agent steps and shell
|
|
64
|
+
* checks with bounded retry loops, plus live sessions: the last agent step
|
|
65
|
+
* stays open for follow-ups (`waiting`) until "finish", idle timeout, or
|
|
66
|
+
* cancel. Runs queue behind `maxParallel` slots and each run executes in its
|
|
67
|
+
* own git worktree on a `cez/<id8>` branch (spec 006), autosave-committed at
|
|
68
|
+
* turn end and before a draft PR — plus every 90 s when opted in via
|
|
69
|
+
* CEZ_AUTOSAVE=1 (#471). The user's working tree is never touched.
|
|
70
|
+
*/
|
|
71
|
+
export declare class RunManager {
|
|
72
|
+
private readonly store;
|
|
73
|
+
private readonly repoRoot;
|
|
74
|
+
private readonly active;
|
|
75
|
+
private readonly queue;
|
|
76
|
+
private readonly starting;
|
|
77
|
+
private readonly waiting;
|
|
78
|
+
private readonly pendingJobs;
|
|
79
|
+
private pumping;
|
|
80
|
+
/**
|
|
81
|
+
* Runs normally isolate in worktrees and may execute in parallel. When that
|
|
82
|
+
* isolation is unavailable (or explicitly disabled), serialize access to
|
|
83
|
+
* `repoRoot` so two agents can never edit/revert the same files (#438).
|
|
84
|
+
*/
|
|
85
|
+
private repoRootTail;
|
|
86
|
+
/** `.ai/cezar` — where the per-task handoff files and todos.json live. */
|
|
87
|
+
private readonly dataDir;
|
|
88
|
+
/** Runs currently being paused by the memory guard — dedupes the ~2 s samples so one breach
|
|
89
|
+
* triggers one pause, not a burst. Cleared in dropActive when the run leaves the registry. */
|
|
90
|
+
private readonly memoryPausing;
|
|
91
|
+
constructor(store: RunStore, repoRoot: string);
|
|
92
|
+
/**
|
|
93
|
+
* Pause any active run whose whole process tree exceeds `config.memoryLimitMb`, freeing its
|
|
94
|
+
* slot so the queue advances (#memory-guard). "Pause" closes the session — freeing the tree's
|
|
95
|
+
* memory — and leaves the run resumable via Continue; a loud warning explains why. No-op when
|
|
96
|
+
* no limit is set or the sampler has no data (e.g. `ps`/PowerShell unavailable).
|
|
97
|
+
*/
|
|
98
|
+
private enforceMemoryLimit;
|
|
99
|
+
/** Env the spawned claude gets so the agent can find its handoff file and
|
|
100
|
+
* the global inbox (spec 007; the inbox only when the run opted in).
|
|
101
|
+
*
|
|
102
|
+
* `CEZ_TODOS_FILE` is set to `''` rather than omitted when follow-ups are
|
|
103
|
+
* off: runners spawn with `{ ...process.env, ...spec.env }`, so omitting the
|
|
104
|
+
* key would let a value inherited from *this* process through — a nested
|
|
105
|
+
* cezar (an agent running `cez serve`/`cez run`/the test suite) would then
|
|
106
|
+
* write follow-ups into the parent's inbox despite the opt-out. Empty is the
|
|
107
|
+
* established "absent" spelling — consumers guard with `if (todosFile)`. */
|
|
108
|
+
private agentEnv;
|
|
109
|
+
startRun(workflow: WorkflowDef, input: StartRunInput, group?: {
|
|
110
|
+
groupId: string;
|
|
111
|
+
variant: string;
|
|
112
|
+
}): RunRecord;
|
|
113
|
+
/**
|
|
114
|
+
* Parallel variants (spec 010): N runs of the same workflow on the same
|
|
115
|
+
* task, sharing a groupId. Variant A gets the task verbatim; B and C get a
|
|
116
|
+
* fixed one-line approach hint appended to the *task input* (not the step
|
|
117
|
+
* template), so diversification works with any workflow. The normal queue
|
|
118
|
+
* applies — with maxParallel=2 a third variant simply waits.
|
|
119
|
+
*/
|
|
120
|
+
startVariants(workflow: WorkflowDef, input: StartRunInput, count: number): RunRecord[];
|
|
121
|
+
/**
|
|
122
|
+
* Start queued runs while parallel slots are free. `maxParallel` comes from
|
|
123
|
+
* `.ai/cezar/config.json` (default 2); a non-git directory degrades to 1
|
|
124
|
+
* sequential run in the repo root (spec 006 degradation rule).
|
|
125
|
+
*/
|
|
126
|
+
private pump;
|
|
127
|
+
/**
|
|
128
|
+
* Startup recovery (#367) — re-adopt runs that were live when the previous
|
|
129
|
+
* cezar process exited (requires the store opened with `keepLive`):
|
|
130
|
+
* - `queued` → back into the queue (FIFO by createdAt), from the persisted
|
|
131
|
+
* workflowDef (or the catalog by name for older records);
|
|
132
|
+
* - `waiting` → the turn was over and the ball was in the user's court —
|
|
133
|
+
* settle exactly like a closed session (review/done, Continue still works);
|
|
134
|
+
* - `running` → mark interrupted, then immediately resume the last agent
|
|
135
|
+
* session via the Continue path, pointing the agent at its handoff file.
|
|
136
|
+
* Call once, before the server starts taking requests.
|
|
137
|
+
*/
|
|
138
|
+
recover(): Promise<void>;
|
|
139
|
+
/** The persisted definition when it looks sane, else the catalog by name. */
|
|
140
|
+
private reviveWorkflow;
|
|
141
|
+
/** Remove a run from the live registries — keeps `waiting ⊆ active`. */
|
|
142
|
+
private dropActive;
|
|
143
|
+
/** Reclaim finished worktrees beyond the keep-limit (#483) — directory only,
|
|
144
|
+
* `cez/<id8>` branch kept. Best-effort; a failure never affects run
|
|
145
|
+
* lifecycle. `review`/live runs are excluded by the selector. */
|
|
146
|
+
private enforceRetention;
|
|
147
|
+
/** Last live-refresh namer inputs per run — unchanged inputs skip the call. */
|
|
148
|
+
private lastNamerKey;
|
|
149
|
+
/**
|
|
150
|
+
* Acquire the one-at-a-time lease for runs executing in `repoRoot`.
|
|
151
|
+
*
|
|
152
|
+
* A lease waiter is idle, so it parks in `waiting` and gives its
|
|
153
|
+
* `maxParallel` slot back (the #347 rule): isolated worktrees keep using
|
|
154
|
+
* every configured slot while root runs line up. The store status stays
|
|
155
|
+
* `running` — only the queue's busy count changes, so the GUI never shows a
|
|
156
|
+
* lease-blocked run as awaiting user input.
|
|
157
|
+
*
|
|
158
|
+
* The lease is held for the run's whole lifetime, including the idle
|
|
159
|
+
* `waiting` parks between agent turns. A parked session is still live and
|
|
160
|
+
* writes to the working tree the moment it resumes, so handing the tree to
|
|
161
|
+
* another run there would reintroduce the concurrent-edit bug (#438) this
|
|
162
|
+
* lease exists to prevent.
|
|
163
|
+
*
|
|
164
|
+
* Returns false when the run was cancelled while waiting: the lease was
|
|
165
|
+
* never granted and the caller must not touch the working tree.
|
|
166
|
+
*/
|
|
167
|
+
private acquireRepoRoot;
|
|
168
|
+
cancel(runId: string): boolean;
|
|
169
|
+
isActive(runId: string): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Deliver a user message into the run's live claude session (mid-turn or
|
|
172
|
+
* while `waiting`). Returns false when there is no open session — the GUI
|
|
173
|
+
* then offers "Continue" instead.
|
|
174
|
+
*/
|
|
175
|
+
sendMessage(runId: string, content: ContentBlock[]): boolean;
|
|
176
|
+
/** Close the open session gracefully — the run then completes as `done`
|
|
177
|
+
* (or rests at `review` when the worktree holds changes, spec 009).
|
|
178
|
+
* On a run already resting at `review` (no session — the engine loop is
|
|
179
|
+
* over), "Finish" is the third review exit: accept the changes without a
|
|
180
|
+
* PR and flip straight to `done`. */
|
|
181
|
+
finish(runId: string): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* "Continue" (spec 003): reopen a finished run's claude session in-process
|
|
184
|
+
* (`claude --resume <sessionId>`) as a new synthetic step. The session then
|
|
185
|
+
* behaves exactly like an interactive step: `waiting` after each turn,
|
|
186
|
+
* messages via sendMessage, closed by finish/idle/cancel.
|
|
187
|
+
*/
|
|
188
|
+
continueRun(runId: string, text?: string): {
|
|
189
|
+
ok: boolean;
|
|
190
|
+
error?: string;
|
|
191
|
+
};
|
|
192
|
+
private runContinuation;
|
|
193
|
+
private execute;
|
|
194
|
+
/** Returns an error message, or null on success. */
|
|
195
|
+
private runAgentStep;
|
|
196
|
+
/**
|
|
197
|
+
* Protocol-v2 sink for one agent session (R2 step 2.1): the runner's
|
|
198
|
+
* `onUiEvent` stream flows through here. Persisted snapshots ride the same
|
|
199
|
+
* NDJSON file as v1 (the store stamps `seq`/`ts`, `appendEvent` fans them
|
|
200
|
+
* out live too); coalesced `item.delta` flushes go out live-only via
|
|
201
|
+
* `emitEphemeral` — raw deltas never hit disk (spec §performance
|
|
202
|
+
* guardrails). One sink per session: cumulative usage dedup and the
|
|
203
|
+
* item-shape cache are session-scoped, like the mapper state feeding them.
|
|
204
|
+
*/
|
|
205
|
+
private makeUiSink;
|
|
206
|
+
/**
|
|
207
|
+
* Turn-end bookkeeping (#389), shared by `runAgentStep` and
|
|
208
|
+
* `runContinuation` — called (fire-and-forget) from every `turn-end` event:
|
|
209
|
+
*
|
|
210
|
+
* - `titleSummary`: derived from the turn's text, set ONCE — only while the
|
|
211
|
+
* record has none. A user's inline edit also lands in `titleSummary`
|
|
212
|
+
* (see `PATCH /api/runs/:id`), so an edit is never overwritten either.
|
|
213
|
+
* - `diffStat`: cheap `git diff --shortstat` vs the base, refreshed every
|
|
214
|
+
* turn. Async and best-effort — a git failure becomes at most a `note`
|
|
215
|
+
* event, NEVER a run failure. `updateRun` fans the record out over SSE,
|
|
216
|
+
* so the list views pick both up with no extra wiring.
|
|
217
|
+
*
|
|
218
|
+
* Not `private` so the integration tests can drive a turn-end directly —
|
|
219
|
+
* a real agent session is the only other way to reach this path.
|
|
220
|
+
*/
|
|
221
|
+
/**
|
|
222
|
+
* The namer's apply path (task auto-naming spec). Fire-and-forget: called
|
|
223
|
+
* without await from `startRun` (creation) and `recordTurnEnd` (live
|
|
224
|
+
* refresh). A user-owned title (`titleOrigin: 'user'`) is never overwritten;
|
|
225
|
+
* namer-owned titles may be replaced by fresher namer results.
|
|
226
|
+
*/
|
|
227
|
+
private autoNameRun;
|
|
228
|
+
recordTurnEnd(runId: string, turnText: string): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Live title refresh (task auto-naming spec, step 3): re-run the namer with
|
|
231
|
+
* the turn's context. Skips: toggle off (`liveTitleUpdates` config over
|
|
232
|
+
* `CEZ_TITLE_UPDATES` env, default ON), user-owned title, dry-run mocks
|
|
233
|
+
* (canned answers add nothing), empty turn text, unchanged namer inputs.
|
|
234
|
+
*/
|
|
235
|
+
private maybeRefreshTitle;
|
|
236
|
+
/**
|
|
237
|
+
* End-of-session telemetry (#348): stop sampling the run's process tree and
|
|
238
|
+
* fold the session's peaks into the run record. `max` with existing values —
|
|
239
|
+
* a run can hold several sessions (multiple agent steps, Continue) and the
|
|
240
|
+
* record keeps the highest water mark across all of them.
|
|
241
|
+
*/
|
|
242
|
+
private recordUsagePeaks;
|
|
243
|
+
/**
|
|
244
|
+
* Diff-first review gate (spec 009), shared by `execute` and
|
|
245
|
+
* `runContinuation`: a *successful* run whose worktree holds changes rests
|
|
246
|
+
* at `review` instead of `done` — the user inspects the diff first, then
|
|
247
|
+
* sends feedback back, opens a draft PR, or just finishes. Failed/cancelled
|
|
248
|
+
* runs never enter review; no worktree or an empty diff means plain `done`.
|
|
249
|
+
*
|
|
250
|
+
* The gate is opt-in (#489): the review park happens only when it is enabled
|
|
251
|
+
* (`reviewGateEnabled` — config toggle over the `CEZ_REVIEW_GATE` env, default
|
|
252
|
+
* OFF) AND the run is not autonomous. Autonomous runs — and runs with the gate
|
|
253
|
+
* off — settle straight to `done`, leaving the diff in the worktree untouched.
|
|
254
|
+
*/
|
|
255
|
+
private settleSuccess;
|
|
256
|
+
/**
|
|
257
|
+
* Agent screenshot (an image block inside a tool result): the base64 data
|
|
258
|
+
* never enters the NDJSON event log — it lands as a file under
|
|
259
|
+
* `.ai/cezar/runs/<id>-images/` and the transcript event carries only the
|
|
260
|
+
* name + serving URL. Best effort: on failure the screenshot is dropped,
|
|
261
|
+
* the transcript still shows the tool result's `[screenshot]` placeholder.
|
|
262
|
+
*/
|
|
263
|
+
private persistImage;
|
|
264
|
+
private armIdleTimer;
|
|
265
|
+
private clearIdleTimer;
|
|
266
|
+
/** Autosave-commit the worktree every 90 s while the run lives (spec 006).
|
|
267
|
+
* Opt-in via CEZ_AUTOSAVE=1 (#471) — see periodicAutosaveEnabled. */
|
|
268
|
+
private armAutosave;
|
|
269
|
+
private clearAutosaveTimer;
|
|
270
|
+
private runCheckStep;
|
|
271
|
+
private finishStep;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Immediate title shown while a run is queued. The namer's `titleSummary`
|
|
275
|
+
* replaces it once the model answers; this is the honest, permanent fallback
|
|
276
|
+
* when no model is available (#432, spec 2026-07-17-task-auto-naming). When
|
|
277
|
+
* the task references a PR/issue, the number leads: `469: /om-auto-review-pr`.
|
|
278
|
+
*/
|
|
279
|
+
export declare function makeRunTitle(task: string, workflow: WorkflowDef): string;
|
|
280
|
+
/** Skill identity is context, while the Markdown body remains instructions. */
|
|
281
|
+
export declare function skillSystemPrompt(skill: Pick<Skill, 'name' | 'description' | 'body'>): string;
|