@ngockhoale/ckit 0.0.0-stage → 0.1.0
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/.env.example +42 -0
- package/README.md +116 -2
- package/dist/src/adapters/agent/claude/errors.d.ts +13 -0
- package/dist/src/adapters/agent/claude/errors.js +16 -0
- package/dist/src/adapters/agent/claude/normalize.d.ts +11 -0
- package/dist/src/adapters/agent/claude/normalize.js +83 -0
- package/dist/src/adapters/agent/errors.d.ts +13 -0
- package/dist/src/adapters/agent/errors.js +19 -0
- package/dist/src/adapters/agent/fixtures/claude-transcript.d.ts +70 -0
- package/dist/src/adapters/agent/fixtures/claude-transcript.js +15 -0
- package/dist/src/adapters/agent/fixtures/omp-transcript.d.ts +60 -0
- package/dist/src/adapters/agent/fixtures/omp-transcript.js +14 -0
- package/dist/src/adapters/agent/normalize.d.ts +18 -0
- package/dist/src/adapters/agent/normalize.js +77 -0
- package/dist/src/adapters/agent/transport.d.ts +35 -0
- package/dist/src/adapters/agent/transport.js +39 -0
- package/dist/src/adapters/agent/worker-service.d.ts +49 -0
- package/dist/src/adapters/agent/worker-service.js +77 -0
- package/dist/src/adapters/fake/fake-advisor.d.ts +15 -0
- package/dist/src/adapters/fake/fake-advisor.js +29 -0
- package/dist/src/adapters/fake/fake-agent.d.ts +12 -0
- package/dist/src/adapters/fake/fake-agent.js +21 -0
- package/dist/src/adapters/fake/fake-store.d.ts +13 -0
- package/dist/src/adapters/fake/fake-store.js +23 -0
- package/dist/src/adapters/fake/fake-web.d.ts +12 -0
- package/dist/src/adapters/fake/fake-web.js +21 -0
- package/dist/src/adapters/fake/fault-injector.d.ts +18 -0
- package/dist/src/adapters/fake/fault-injector.js +64 -0
- package/dist/src/adapters/fake/virtual-clock.d.ts +12 -0
- package/dist/src/adapters/fake/virtual-clock.js +35 -0
- package/dist/src/adapters/launch/discover.d.ts +18 -0
- package/dist/src/adapters/launch/discover.js +55 -0
- package/dist/src/adapters/launch/executor.d.ts +117 -0
- package/dist/src/adapters/launch/executor.js +383 -0
- package/dist/src/adapters/launch/profile.d.ts +35 -0
- package/dist/src/adapters/launch/profile.js +73 -0
- package/dist/src/adapters/launch/spawn.d.ts +29 -0
- package/dist/src/adapters/launch/spawn.js +18 -0
- package/dist/src/adapters/openai/openai-advisor.d.ts +56 -0
- package/dist/src/adapters/openai/openai-advisor.js +146 -0
- package/dist/src/cli/ckit.d.ts +5 -0
- package/dist/src/cli/ckit.js +472 -0
- package/dist/src/cli/demo.d.ts +1 -0
- package/dist/src/cli/demo.js +30 -0
- package/dist/src/cli/sessions.d.ts +10 -0
- package/dist/src/cli/sessions.js +381 -0
- package/dist/src/cli/setup.d.ts +11 -0
- package/dist/src/cli/setup.js +115 -0
- package/dist/src/committee/decision.d.ts +84 -0
- package/dist/src/committee/decision.js +167 -0
- package/dist/src/committee/handover.d.ts +115 -0
- package/dist/src/committee/handover.js +191 -0
- package/dist/src/committee/no-progress.d.ts +44 -0
- package/dist/src/committee/no-progress.js +64 -0
- package/dist/src/committee/primary-registry.d.ts +15 -0
- package/dist/src/committee/primary-registry.js +60 -0
- package/dist/src/committee/reply-parser.d.ts +28 -0
- package/dist/src/committee/reply-parser.js +53 -0
- package/dist/src/committee/reviewer-scheduler.d.ts +101 -0
- package/dist/src/committee/reviewer-scheduler.js +163 -0
- package/dist/src/committee/role-epoch.d.ts +91 -0
- package/dist/src/committee/role-epoch.js +154 -0
- package/dist/src/core/control.d.ts +18 -0
- package/dist/src/core/control.js +29 -0
- package/dist/src/core/entities.d.ts +166 -0
- package/dist/src/core/entities.js +119 -0
- package/dist/src/core/errors.d.ts +9 -0
- package/dist/src/core/errors.js +17 -0
- package/dist/src/core/events.d.ts +72 -0
- package/dist/src/core/events.js +125 -0
- package/dist/src/core/ids.d.ts +47 -0
- package/dist/src/core/ids.js +32 -0
- package/dist/src/core/machine.d.ts +55 -0
- package/dist/src/core/machine.js +110 -0
- package/dist/src/core/policy.d.ts +34 -0
- package/dist/src/core/policy.js +59 -0
- package/dist/src/core/provenance.d.ts +20 -0
- package/dist/src/core/provenance.js +21 -0
- package/dist/src/core/record.d.ts +35 -0
- package/dist/src/core/record.js +67 -0
- package/dist/src/core/replay.d.ts +10 -0
- package/dist/src/core/replay.js +36 -0
- package/dist/src/core/run-task.d.ts +20 -0
- package/dist/src/core/run-task.js +48 -0
- package/dist/src/diagnostics/doctor.d.ts +78 -0
- package/dist/src/diagnostics/doctor.js +365 -0
- package/dist/src/diagnostics/journal-lock.d.ts +38 -0
- package/dist/src/diagnostics/journal-lock.js +181 -0
- package/dist/src/evidence/linker.d.ts +44 -0
- package/dist/src/evidence/linker.js +75 -0
- package/dist/src/evidence/report-parser.d.ts +27 -0
- package/dist/src/evidence/report-parser.js +17 -0
- package/dist/src/evidence/store.d.ts +36 -0
- package/dist/src/evidence/store.js +57 -0
- package/dist/src/gui/server.d.ts +27 -0
- package/dist/src/gui/server.js +497 -0
- package/dist/src/host/checkpoint.d.ts +22 -0
- package/dist/src/host/checkpoint.js +74 -0
- package/dist/src/host/export.d.ts +52 -0
- package/dist/src/host/export.js +45 -0
- package/dist/src/host/ipc.d.ts +57 -0
- package/dist/src/host/ipc.js +124 -0
- package/dist/src/host/leases.d.ts +27 -0
- package/dist/src/host/leases.js +40 -0
- package/dist/src/host/retention.d.ts +47 -0
- package/dist/src/host/retention.js +130 -0
- package/dist/src/host/supervisor.d.ts +59 -0
- package/dist/src/host/supervisor.js +64 -0
- package/dist/src/intake/owner-intake.d.ts +31 -0
- package/dist/src/intake/owner-intake.js +97 -0
- package/dist/src/intake/types.d.ts +46 -0
- package/dist/src/intake/types.js +2 -0
- package/dist/src/intent/context-packet.d.ts +68 -0
- package/dist/src/intent/context-packet.js +76 -0
- package/dist/src/intent/idea-ledger.d.ts +50 -0
- package/dist/src/intent/idea-ledger.js +136 -0
- package/dist/src/intent/ledger.d.ts +35 -0
- package/dist/src/intent/ledger.js +40 -0
- package/dist/src/intent/registry.d.ts +51 -0
- package/dist/src/intent/registry.js +44 -0
- package/dist/src/intent/revision.d.ts +37 -0
- package/dist/src/intent/revision.js +48 -0
- package/dist/src/orchestration/dispatcher.d.ts +32 -0
- package/dist/src/orchestration/dispatcher.js +136 -0
- package/dist/src/orchestration/milestone-loop.d.ts +149 -0
- package/dist/src/orchestration/milestone-loop.js +132 -0
- package/dist/src/orchestration/recovery-coordinator.d.ts +74 -0
- package/dist/src/orchestration/recovery-coordinator.js +180 -0
- package/dist/src/orchestration/work-order-contract.d.ts +44 -0
- package/dist/src/orchestration/work-order-contract.js +85 -0
- package/dist/src/orchestration/work-queue.d.ts +56 -0
- package/dist/src/orchestration/work-queue.js +95 -0
- package/dist/src/ports/advisor.d.ts +33 -0
- package/dist/src/ports/advisor.js +2 -0
- package/dist/src/ports/agent.d.ts +31 -0
- package/dist/src/ports/agent.js +2 -0
- package/dist/src/ports/capabilities.d.ts +3 -0
- package/dist/src/ports/capabilities.js +5 -0
- package/dist/src/ports/clock.d.ts +5 -0
- package/dist/src/ports/clock.js +5 -0
- package/dist/src/ports/store.d.ts +13 -0
- package/dist/src/ports/store.js +2 -0
- package/dist/src/ports/web.d.ts +29 -0
- package/dist/src/ports/web.js +2 -0
- package/dist/src/run/api-run.d.ts +49 -0
- package/dist/src/run/api-run.js +173 -0
- package/dist/src/run/plan-run.d.ts +22 -0
- package/dist/src/run/plan-run.js +233 -0
- package/dist/src/run/plan.d.ts +36 -0
- package/dist/src/run/plan.js +119 -0
- package/dist/src/run/verify.d.ts +25 -0
- package/dist/src/run/verify.js +81 -0
- package/dist/src/security/redact.d.ts +7 -0
- package/dist/src/security/redact.js +21 -0
- package/dist/src/settings/env-config.d.ts +64 -0
- package/dist/src/settings/env-config.js +232 -0
- package/dist/src/storage/artifacts.d.ts +30 -0
- package/dist/src/storage/artifacts.js +105 -0
- package/dist/src/storage/audit.d.ts +6 -0
- package/dist/src/storage/audit.js +6 -0
- package/dist/src/storage/db.d.ts +9 -0
- package/dist/src/storage/db.js +43 -0
- package/dist/src/storage/events.d.ts +20 -0
- package/dist/src/storage/events.js +69 -0
- package/dist/src/storage/migrations.d.ts +8 -0
- package/dist/src/storage/migrations.js +48 -0
- package/dist/src/storage/outbox.d.ts +25 -0
- package/dist/src/storage/outbox.js +40 -0
- package/dist/src/storage/projections.d.ts +18 -0
- package/dist/src/storage/projections.js +40 -0
- package/dist/src/storage/reconcile.d.ts +14 -0
- package/dist/src/storage/reconcile.js +93 -0
- package/dist/src/storage/reservations.d.ts +12 -0
- package/dist/src/storage/reservations.js +80 -0
- package/dist/src/storage/store.d.ts +34 -0
- package/dist/src/storage/store.js +105 -0
- package/dist/src/team/attachments.d.ts +22 -0
- package/dist/src/team/attachments.js +211 -0
- package/dist/src/team/cli-models.d.ts +24 -0
- package/dist/src/team/cli-models.js +72 -0
- package/dist/src/team/config.d.ts +20 -0
- package/dist/src/team/config.js +111 -0
- package/dist/src/team/engine.d.ts +28 -0
- package/dist/src/team/engine.js +443 -0
- package/dist/src/team/journal.d.ts +30 -0
- package/dist/src/team/journal.js +70 -0
- package/dist/src/team/runners.d.ts +79 -0
- package/dist/src/team/runners.js +436 -0
- package/dist/src/team/secrets.d.ts +10 -0
- package/dist/src/team/secrets.js +68 -0
- package/dist/src/team/types.d.ts +155 -0
- package/dist/src/team/types.js +5 -0
- package/dist/src/tui/app.d.ts +29 -0
- package/dist/src/tui/app.js +96 -0
- package/dist/src/tui/control-model.d.ts +101 -0
- package/dist/src/tui/control-model.js +109 -0
- package/dist/src/tui/control-screens.d.ts +27 -0
- package/dist/src/tui/control-screens.js +85 -0
- package/dist/src/tui/graph-model.d.ts +34 -0
- package/dist/src/tui/graph-model.js +29 -0
- package/dist/src/tui/graph-screens.d.ts +13 -0
- package/dist/src/tui/graph-screens.js +4 -0
- package/dist/src/tui/inspector-model.d.ts +150 -0
- package/dist/src/tui/inspector-model.js +15 -0
- package/dist/src/tui/inspector-screens.d.ts +14 -0
- package/dist/src/tui/inspector-screens.js +61 -0
- package/dist/src/tui/live.d.ts +16 -0
- package/dist/src/tui/live.js +39 -0
- package/dist/src/tui/mission-action-screens.d.ts +15 -0
- package/dist/src/tui/mission-action-screens.js +105 -0
- package/dist/src/tui/mission-actions.d.ts +46 -0
- package/dist/src/tui/mission-actions.js +53 -0
- package/dist/src/tui/mission-model.d.ts +120 -0
- package/dist/src/tui/mission-model.js +164 -0
- package/dist/src/tui/mission-nav.d.ts +82 -0
- package/dist/src/tui/mission-nav.js +131 -0
- package/dist/src/tui/mission-plan-screens.d.ts +11 -0
- package/dist/src/tui/mission-plan-screens.js +40 -0
- package/dist/src/tui/mission-plan.d.ts +45 -0
- package/dist/src/tui/mission-plan.js +166 -0
- package/dist/src/tui/mission-screens.d.ts +7 -0
- package/dist/src/tui/mission-screens.js +263 -0
- package/dist/src/tui/provenance-label.d.ts +11 -0
- package/dist/src/tui/provenance-label.js +16 -0
- package/dist/src/tui/screens.d.ts +10 -0
- package/dist/src/tui/screens.js +34 -0
- package/dist/src/tui/session-outcome.d.ts +14 -0
- package/dist/src/tui/session-outcome.js +57 -0
- package/dist/src/tui/setup-model.d.ts +159 -0
- package/dist/src/tui/setup-model.js +234 -0
- package/dist/src/tui/setup-screens.d.ts +66 -0
- package/dist/src/tui/setup-screens.js +72 -0
- package/dist/src/tui/team/app.d.ts +24 -0
- package/dist/src/tui/team/app.js +228 -0
- package/dist/src/tui/team/demo-handle.d.ts +22 -0
- package/dist/src/tui/team/demo-handle.js +42 -0
- package/dist/src/tui/team/model.d.ts +81 -0
- package/dist/src/tui/team/model.js +133 -0
- package/gui/app.css +177 -0
- package/gui/app.js +675 -0
- package/gui/index.html +51 -0
- package/gui/network.js +413 -0
- package/package.json +45 -4
- package/src/storage/schema.sql +42 -0
package/.env.example
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# CKit: sao chép file này thành .env trong thư mục dự án (không commit .env) rồi điền giá trị cần dùng.
|
|
2
|
+
# Thứ tự ưu tiên: cờ CLI > biến môi trường shell > file .env này > mặc định.
|
|
3
|
+
# Chỉ dùng "ckit gui" / "ckit team" thì KHÔNG cần điền gì: agent dùng đăng nhập của chính codex / claude / omp.
|
|
4
|
+
|
|
5
|
+
# ---- Giao diện web "ckit gui" (tùy chọn) ----
|
|
6
|
+
# Đổi xong phải dừng (Ctrl+C) và chạy lại "ckit gui"; mở đúng link mà lệnh in ra.
|
|
7
|
+
|
|
8
|
+
# Địa chỉ lắng nghe. Mặc định 127.0.0.1 = chỉ máy này. 0.0.0.0 = máy khác trong mạng LAN mở được
|
|
9
|
+
# (HTTP thường, không mã hóa; ai có link đều điều khiển được agent).
|
|
10
|
+
# CKIT_GUI_HOST=
|
|
11
|
+
|
|
12
|
+
# Cổng cố định (1..65535). Mặc định 4317.
|
|
13
|
+
# CKIT_GUI_PORT=
|
|
14
|
+
|
|
15
|
+
# Token cố định để link không đổi mỗi lần chạy: 16..128 ký tự A-Z a-z 0-9 _ -
|
|
16
|
+
# Bỏ trống = token ngẫu nhiên mỗi lần. Coi như mật khẩu, không commit.
|
|
17
|
+
# CKIT_GUI_TOKEN=
|
|
18
|
+
|
|
19
|
+
# Từ máy khác mở: http://<IP-của-máy-này>:<cổng>/?t=<token>
|
|
20
|
+
|
|
21
|
+
# ---- Advisor API cho "ckit run" (chỉ cần khi dùng ckit run) ----
|
|
22
|
+
# URL gốc endpoint OpenAI-compatible, PHẢI gồm phần phiên bản, ví dụ: https://<host>/v1
|
|
23
|
+
CKIT_OPENAI_BASE_URL=
|
|
24
|
+
|
|
25
|
+
# API key. Chỉ gửi tới endpoint ở trên; không bao giờ gửi cho executor, log hay giao diện.
|
|
26
|
+
# Endpoint không cần key: để trống và đặt CKIT_OPENAI_AUTH=none
|
|
27
|
+
CKIT_OPENAI_API_KEY=
|
|
28
|
+
CKIT_OPENAI_AUTH=
|
|
29
|
+
|
|
30
|
+
# Model của advisor.
|
|
31
|
+
CKIT_OPENAI_MODEL=
|
|
32
|
+
|
|
33
|
+
# Executor chạy việc trong dự án: claude-code (mặc định) hoặc omp; và model của nó (tùy chọn).
|
|
34
|
+
CKIT_EXECUTOR=
|
|
35
|
+
CKIT_EXECUTOR_MODEL=
|
|
36
|
+
|
|
37
|
+
# Cho worker claude-code được ghi file: acceptEdits hoặc dontAsk. Mặc định tắt (không ghi được file).
|
|
38
|
+
# CKIT_EXECUTOR_PERMISSION_MODE=
|
|
39
|
+
|
|
40
|
+
# Nâng cao, hiếm khi cần (xem README): CKIT_ADVISOR_PROVIDER, CKIT_PRIMARY_MODEL, CKIT_REVIEWER_MODEL, CKIT_REVIEWERS,
|
|
41
|
+
# CKIT_OPENAI_TIMEOUT_MS, CKIT_OPENAI_MAX_TOKENS, CKIT_EXECUTOR_PATH, CKIT_EXECUTOR_TIMEOUT_MS, CKIT_VERIFY_ALLOW,
|
|
42
|
+
# CKIT_VERIFY_TIMEOUT_MS, CKIT_MAX_TASKS
|
package/README.md
CHANGED
|
@@ -1,3 +1,117 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CKit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local orchestration core for advisor/worker agent sessions. **Scaffold baseline (T01-01)** —
|
|
4
|
+
nothing here is a released product, and no live provider/agent integration is claimed.
|
|
5
|
+
|
|
6
|
+
## Use it like a normal app
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install -g @ngockhoale/ckit # or `npm link` from this repo
|
|
10
|
+
ckit setup # guided; writes ~/.config/ckit/.env (dir 0700, file 0600); `ckit setup --path` prints the location
|
|
11
|
+
ckit doctor --check-connection
|
|
12
|
+
cd your-project && ckit run "<goal>" # no per-project .env needed
|
|
13
|
+
ckit status # and: ckit tui
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Agent Company (team mode)
|
|
17
|
+
|
|
18
|
+
A Director plus Team BA (2 agents discuss, then write one handoff) → Team Implement → Team QC (2 reviewers; FAIL returns to Implement, up to `limits.qcLoops`) → BA review → Director delivery report. You always talk to the Director; it can continue, redirect or stop the run.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
ckit # no command, in a terminal: opens the GUI. First time in a project it lands on Config so setup is done there
|
|
22
|
+
ckit gui --lan # optional: reachable from other machines on the network. Same via the shell or the project's env file: CKIT_GUI_HOST=0.0.0.0 (plus CKIT_GUI_PORT, CKIT_GUI_TOKEN for a fixed link) or .ckit/gui.json {"host":"0.0.0.0"}; default is this machine only
|
|
23
|
+
# in the GUI: attach any files (images, PDF, Word, Excel, drawio, XML...) to a mission or a message; they are stored in the run folder and handed to every team
|
|
24
|
+
ckit gui # web Mission Control on 127.0.0.1 (random token URL; --port=<n>, --no-open). Config per agent: cli, model, OpenAI-compatible base URL, API key (stored in ~/.config/ckit/team-secrets.json, 0600, never sent to the browser)
|
|
25
|
+
ckit team --demo # same pipeline in the terminal, fully SIMULATED (no model calls, no cost); --speed=<n> to fast-forward
|
|
26
|
+
ckit team "<goal>" # real run with the agents in <project>/.ckit/team.json (codex / claude-code / omp / api)
|
|
27
|
+
ckit team --init # write the default .ckit/team.json (--force overwrites)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Every run is journaled to `.ckit/team/runs/<runId>/` (`events.jsonl`, `handoff-ba.md`, `qc-report-N.md`, `transcript.md`, `report.md`). Real agents use their own CLI login; codex runs `read-only` unless the agent has `access: "write"` (then `workspace-write`), claude uses `acceptEdits` only for write access, never bypass.
|
|
31
|
+
|
|
32
|
+
Settings precedence: CLI flags > process env > `<project>/.env` > user file (`$XDG_CONFIG_HOME/ckit/.env`, default `~/.config/ckit/.env`) > defaults. `ckit run` prints which file it used.
|
|
33
|
+
|
|
34
|
+
## Quick start (API advisor)
|
|
35
|
+
|
|
36
|
+
No browser login is needed. The advisor is any OpenAI-compatible HTTP endpoint; the executor is your own `claude` (Claude Code) or `omp` CLI.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cp .env.example .env # then fill the variables below; never commit .env
|
|
40
|
+
# CKIT_OPENAI_BASE_URL=https://<host>/v1 (must include the version segment; CKit appends only /chat/completions)
|
|
41
|
+
# CKIT_OPENAI_API_KEY=<key> (or CKIT_OPENAI_AUTH=none for a keyless endpoint)
|
|
42
|
+
# CKIT_OPENAI_MODEL=<model>
|
|
43
|
+
# CKIT_EXECUTOR=claude-code (or omp)
|
|
44
|
+
npx ckit doctor # offline config check, no network
|
|
45
|
+
npx ckit doctor --check-connection # optional: exactly one GET <base>/models
|
|
46
|
+
npx ckit run "<goal>" # planned run: Primary plans tasks + acceptance checks -> executor runs each task -> CKit verifies -> reviewers -> Primary verdict
|
|
47
|
+
npx ckit run --single "<goal>" # one instruction, one executor run, no acceptance checks (previous flow)
|
|
48
|
+
npx ckit run --single "<goal>" --project=/path/to/scratch --config-root=/path/with/.env # settings from one folder, worker edits only the other
|
|
49
|
+
npx ckit status # latest session with outcome / advisor delivery / worker execution / acceptance (read-only)
|
|
50
|
+
npx ckit tui # Mission Control, live: in a terminal it re-reads the journal every 0.7 s, so a `ckit run` in another terminal shows up as it happens (read-only, no requests; `q` quits)
|
|
51
|
+
npx ckit sessions # list recorded sessions (read-only)
|
|
52
|
+
npx ckit open <sessionId> # one session's outcome and events (read-only, no requests)
|
|
53
|
+
npx ckit replay <sessionId> # replay the journal (inert: never resends)
|
|
54
|
+
npx ckit backup <dest-dir> # copy .ckit journal + artifacts (regular files only)
|
|
55
|
+
npx ckit restore <backup-dir> # hash-checked restore with rollback; refused while a run holds the lock; a backup from another project needs --allow-other-project
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Pause/resume of a running session is not available yet; Ctrl-C stops the worker (a second Ctrl-C kills its process group).
|
|
59
|
+
|
|
60
|
+
- The config file is `<project root>/.env`, where the project root is the nearest directory with `.ckit/project.json` (then `.git`); `--project=<path>` overrides. Flags `--executor`, `--model`, `--reviewers` override the matching variables.
|
|
61
|
+
- Planned run: the Primary replies with a JSON plan (at most `CKIT_MAX_TASKS`, default 6); each task needs at least one required automatic check (`command` or `file-exists`). CKit runs the checks itself, without a shell, in the project root. A task is `verified` only when every required check passes; a Primary or reviewer ACCEPT never overrides a failed check, and the run exits 0 only when every task is verified and the verdict is ACCEPT.
|
|
62
|
+
- Acceptance commands must start with an entry of `CKIT_VERIFY_ALLOW` (whole-token match; default `npm test`, `npm run build`, `npm run lint`, `npm run typecheck`, `npx tsc --noEmit`, `node --test`, `pytest`, `go test`, `cargo test`, `make test`) and contain no shell metacharacters. `CKIT_VERIFY_TIMEOUT_MS` bounds each check. An invalid plan stops the run with no task executed and no re-request.
|
|
63
|
+
- Supported dialect: Chat Completions, non-streaming only (`stream:false`). No Responses API, no streaming, no tools. `usage` is optional.
|
|
64
|
+
- The executor uses its own login, config and permissions. CKit never passes any `CKIT_*` variable to it and never changes its config. Any other inherited variable whose value equals or contains the advisor key is withheld, except the worker's own credential variable for the selected executor (claude-code: `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_API_KEY`; omp: none) when you set it yourself with exactly that value (ADR-017, 2026-11-08). `ckit doctor` and `ckit run` print the withheld names and `worker auth: present|missing` (never values, validity not checked) before any advisor request.
|
|
65
|
+
- Headless `claude -p` cannot ask anyone to approve a file edit, so by default the worker cannot write files. To let it edit inside the workspace, set `CKIT_EXECUTOR_PERMISSION_MODE=acceptEdits` (or `dontAsk`) in your own `.env`. It is off by default; `bypassPermissions` and `--dangerously-skip-permissions` are refused. omp ignores this field and says so.
|
|
66
|
+
- What is sent to the endpoint: only the goal, the Primary instruction, the executor result text and reviewer opinions, each passed through secret redaction first.
|
|
67
|
+
- One request per step, no automatic resend or retry, and no fallback to another endpoint. A failed or uncertain step stops the run and is journaled.
|
|
68
|
+
- Mock/local test results are OFFLINE evidence only; a live endpoint check needs your own `.env`.
|
|
69
|
+
- Browser advisors are deferred and not part of this flow.
|
|
70
|
+
|
|
71
|
+
## Quick start (contributor)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install # TypeScript dev deps + runtime deps (ink, react)
|
|
75
|
+
npm run build # strict tsc build -> dist/
|
|
76
|
+
npm test # node:test suite over dist/
|
|
77
|
+
npm run demo # minimal task flow through the SIMULATED advisor (offline, no external send)
|
|
78
|
+
npm run demo:fault # same flow with an injected ack-lost fault -> unknown outcome, no resend
|
|
79
|
+
npm run try # walk through the real `ckit run` flow offline: local mock advisor + fake worker in a temp project,
|
|
80
|
+
# then `doctor`, `status`, `sessions`; prints the command to open Mission Control on that run
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Requirements: Node.js >= 22 (observed on v22.22.1, macOS arm64).
|
|
84
|
+
|
|
85
|
+
## Install
|
|
86
|
+
|
|
87
|
+
Published on npm as `@ngockhoale/ckit` (owner decision 2026-11-14; replaces the earlier private-tarball channel).
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install -g @ngockhoale/ckit # update later with the same command
|
|
91
|
+
cd your-project && ckit # opens the GUI; first time it lands on Config
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Each machine needs its own logged-in agent CLIs (`codex`, `claude`, `omp`); CKit ships no credentials.
|
|
95
|
+
|
|
96
|
+
Requirements: Node.js >= 22 (uses `node:sqlite`, which prints an ExperimentalWarning on 22.x). Runtime deps: `ink`, `react` (MIT; lockfile licenses allowlisted by `test/security-supply-chain.test.ts`). Verified clean install on macOS arm64 / Node 22.22.1 only; other platforms are unverified. Live provider/native-agent integration is **not** included (T00-03/T00-04/T10-02 gates), so this package is a local preview, not a finished product.
|
|
97
|
+
|
|
98
|
+
## What exists now
|
|
99
|
+
|
|
100
|
+
- `src/core` — branded IDs, fail-closed event envelope validation (ADR-012 groundwork),
|
|
101
|
+
a pure session/task state machine with deterministic replay, and the minimal task flow.
|
|
102
|
+
- `src/ports` — advisor port contract (T01-04 groundwork; capability-honest per ADR-015).
|
|
103
|
+
- `src/adapters/fake` — **SIMULATED** advisor: offline fixture only. Its output is never
|
|
104
|
+
evidence of live integration; every event is provenance-tagged `simulated`.
|
|
105
|
+
- `test/` — node:test suites (IDs, envelope validation, state machine, task flow).
|
|
106
|
+
|
|
107
|
+
## Design direction
|
|
108
|
+
|
|
109
|
+
The TUI (React + Ink, compatibility-probed; see `docs/research/receipts/ink-probe-*.txt`)
|
|
110
|
+
will render the agent exchange from the **real event stream** — the demo's JSON envelopes are
|
|
111
|
+
the exact shape the UI will consume. ADR-016 records the hand-written state machine decision.
|
|
112
|
+
|
|
113
|
+
## Honesty gates (do not remove)
|
|
114
|
+
|
|
115
|
+
- Published as `@ngockhoale/ckit`; publish only on the owner's request, after `npm test` passes.
|
|
116
|
+
- Simulated adapter output must stay labeled `simulated`; live evidence requires a `live` provenance ref.
|
|
117
|
+
- Unknown external outcomes stop the flow (`needsReconciliation`); the core never blind-resends.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UnknownAgentEventError } from '../normalize.js';
|
|
2
|
+
import { type ClassifiedAgentError } from '../errors.js';
|
|
3
|
+
export interface ClaudeCapabilities {
|
|
4
|
+
readonly version: number;
|
|
5
|
+
readonly capabilities: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class ClaudeShapeMismatchError extends UnknownAgentEventError {
|
|
8
|
+
readonly adapter = "claude";
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export { ClaudeShapeMismatchError as UnknownClaudeEventError };
|
|
12
|
+
export declare function assertClaudeCapabilities(actual: ClaudeCapabilities, expected: ClaudeCapabilities): void;
|
|
13
|
+
export declare function classifyClaudeError(cause: unknown): ClassifiedAgentError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UnknownAgentEventError } from '../normalize.js';
|
|
2
|
+
import { classifyAgentError } from '../errors.js';
|
|
3
|
+
export class ClaudeShapeMismatchError extends UnknownAgentEventError {
|
|
4
|
+
adapter = 'claude';
|
|
5
|
+
constructor(message) { super(message); this.name = 'ClaudeShapeMismatchError'; }
|
|
6
|
+
}
|
|
7
|
+
export { ClaudeShapeMismatchError as UnknownClaudeEventError };
|
|
8
|
+
export function assertClaudeCapabilities(actual, expected) {
|
|
9
|
+
if (actual.version !== expected.version || actual.capabilities.length !== expected.capabilities.length || expected.capabilities.some(cap => !actual.capabilities.includes(cap)))
|
|
10
|
+
throw new ClaudeShapeMismatchError(`Claude event shape mismatch: version/capability mismatch: expected version ${expected.version}, got ${actual.version}`);
|
|
11
|
+
}
|
|
12
|
+
export function classifyClaudeError(cause) {
|
|
13
|
+
const message = cause instanceof Error ? cause.message : String(cause), sentNoAck = /sent[-_ ]no[-_ ]ack/i.test(message);
|
|
14
|
+
return classifyAgentError(sentNoAck ? new Error(`${message}; acknowledgement lost`) : cause, { phase: sentNoAck ? 'after-dispatch' : 'before-dispatch' });
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Envelope } from '../../../core/events.js';
|
|
2
|
+
import type { OmpReplayContext } from '../normalize.js';
|
|
3
|
+
import { type ClaudeCapabilities } from './errors.js';
|
|
4
|
+
export { ClaudeShapeMismatchError, ClaudeShapeMismatchError as UnknownClaudeEventError, classifyClaudeError, assertClaudeCapabilities } from './errors.js';
|
|
5
|
+
export type { ClaudeCapabilities };
|
|
6
|
+
export declare function normalizeClaudeEvent(raw: unknown, context?: OmpReplayContext, sequence?: number): Envelope;
|
|
7
|
+
export declare function replayClaudeTranscript(transcript: {
|
|
8
|
+
readonly label: 'SIMULATED';
|
|
9
|
+
readonly version: 1;
|
|
10
|
+
readonly events: readonly unknown[];
|
|
11
|
+
}, context: OmpReplayContext): readonly Envelope[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { EVENT_SCHEMA_VERSION, validateEnvelope } from '../../../core/events.js';
|
|
2
|
+
import { ClaudeShapeMismatchError as UnknownClaudeEventError, assertClaudeCapabilities } from './errors.js';
|
|
3
|
+
export { ClaudeShapeMismatchError, ClaudeShapeMismatchError as UnknownClaudeEventError, classifyClaudeError, assertClaudeCapabilities } from './errors.js';
|
|
4
|
+
const DEFAULT_CONTEXT = { sessionId: 'session-a1b2c3d4', taskId: 'task-a1b2c3d4', projectId: 'project-demo0001', runId: 'run-demo0001' };
|
|
5
|
+
function record(value) { return typeof value === 'object' && value !== null && !Array.isArray(value); }
|
|
6
|
+
export function normalizeClaudeEvent(raw, context = DEFAULT_CONTEXT, sequence = 1) {
|
|
7
|
+
if (!record(raw))
|
|
8
|
+
throw new UnknownClaudeEventError('event must be an object');
|
|
9
|
+
if (raw['version'] !== 1)
|
|
10
|
+
throw new UnknownClaudeEventError(`unsupported Claude event version ${String(raw['version'])}`);
|
|
11
|
+
const type = raw['type'], subtype = raw['subtype'], at = raw['at'];
|
|
12
|
+
if (typeof type !== 'string' || typeof subtype !== 'string' || typeof at !== 'string')
|
|
13
|
+
throw new UnknownClaudeEventError('required type/subtype/at fields missing');
|
|
14
|
+
const key = `${type}:${subtype}`;
|
|
15
|
+
let eventType, status, payload;
|
|
16
|
+
switch (key) {
|
|
17
|
+
case 'system:init':
|
|
18
|
+
if (typeof raw['session_id'] !== 'string' || !raw['session_id'])
|
|
19
|
+
throw new UnknownClaudeEventError('init requires session_id');
|
|
20
|
+
eventType = 'AdvisorAcked';
|
|
21
|
+
status = 'accepted';
|
|
22
|
+
payload = { type: eventType, adapter: 'claude:SIMULATED' };
|
|
23
|
+
break;
|
|
24
|
+
case 'system:running':
|
|
25
|
+
eventType = 'AdvisorUnknownOutcome';
|
|
26
|
+
status = 'running';
|
|
27
|
+
payload = { type: eventType, reason: 'adapter-fault', note: 'running' };
|
|
28
|
+
break;
|
|
29
|
+
case 'assistant:text':
|
|
30
|
+
if (typeof raw['text'] !== 'string')
|
|
31
|
+
throw new UnknownClaudeEventError('assistant text requires text');
|
|
32
|
+
eventType = 'AdvisorUnknownOutcome';
|
|
33
|
+
status = 'partial-stream';
|
|
34
|
+
payload = { type: eventType, reason: 'adapter-fault', note: `partial-stream:${raw['text']}` };
|
|
35
|
+
break;
|
|
36
|
+
case 'tool:result':
|
|
37
|
+
if (typeof raw['name'] !== 'string' || !raw['name'])
|
|
38
|
+
throw new UnknownClaudeEventError('tool result requires name');
|
|
39
|
+
eventType = 'AdvisorUnknownOutcome';
|
|
40
|
+
status = 'tool-finish';
|
|
41
|
+
payload = { type: eventType, reason: 'adapter-fault', note: 'tool-finish' };
|
|
42
|
+
break;
|
|
43
|
+
case 'control_request:permission':
|
|
44
|
+
if (typeof raw['request_id'] !== 'string' || !raw['request_id'])
|
|
45
|
+
throw new UnknownClaudeEventError('permission request requires request_id');
|
|
46
|
+
eventType = 'AdvisorUnknownOutcome';
|
|
47
|
+
status = 'waiting_input';
|
|
48
|
+
payload = { type: eventType, reason: 'adapter-fault', note: `permission-request:${raw['request_id']}` };
|
|
49
|
+
break;
|
|
50
|
+
case 'result:turn_end':
|
|
51
|
+
eventType = 'AdvisorUnknownOutcome';
|
|
52
|
+
status = 'turn-finish';
|
|
53
|
+
payload = { type: eventType, reason: 'adapter-fault', note: 'turn-finish' };
|
|
54
|
+
break;
|
|
55
|
+
case 'result:run_end':
|
|
56
|
+
if (raw['outcome'] !== 'success' && raw['outcome'] !== 'failed')
|
|
57
|
+
throw new UnknownClaudeEventError('run-end requires explicit outcome');
|
|
58
|
+
eventType = raw['outcome'] === 'success' ? 'AdvisorCompleted' : 'AdvisorUnknownOutcome';
|
|
59
|
+
status = raw['outcome'];
|
|
60
|
+
payload = raw['outcome'] === 'success' ? { type: eventType, resultRef: 'artifact-ompresult01' } : { type: eventType, reason: 'adapter-fault', note: 'explicit run failed' };
|
|
61
|
+
break;
|
|
62
|
+
default: throw new UnknownClaudeEventError(`unknown Claude event ${key}`);
|
|
63
|
+
}
|
|
64
|
+
const seq = Math.max(1, sequence);
|
|
65
|
+
try {
|
|
66
|
+
return validateEnvelope({ schemaVersion: EVENT_SCHEMA_VERSION, seq, sessionSequence: seq, sessionId: context.sessionId, taskId: context.taskId, projectId: context.projectId, runId: context.runId, at, sourceAt: at, causality: null, eventId: `event-claude-${String(seq).padStart(6, '0')}`, parentEventId: null, causationId: null, attemptId: null, traceId: 'trace-claude0001', spanId: `span-claude-${String(seq).padStart(6, '0')}`, actor: { role: 'advisor', adapter: 'claude' }, provenance: { source: 'simulated' }, adapter: 'claude', adapterVersion: '1', eventType, status, reasonCode: null, artifactRefs: [], decisionId: null, requirementIds: [], ckitVersion: '0.0.0', policyVersion: '1', promptTemplateVersion: '1', redactedConfigHash: 'simulated-claude', payload });
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
throw new UnknownClaudeEventError(e instanceof Error ? e.message : String(e));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function replayClaudeTranscript(transcript, context) {
|
|
73
|
+
if (!record(transcript) || transcript.label !== 'SIMULATED' || transcript.version !== 1 || !Array.isArray(transcript.events))
|
|
74
|
+
throw new UnknownClaudeEventError('unsupported Claude transcript version/shape');
|
|
75
|
+
try {
|
|
76
|
+
assertClaudeCapabilities({ version: transcript.version, capabilities: ['events-v1'] }, { version: 1, capabilities: ['events-v1'] });
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
throw new UnknownClaudeEventError(e instanceof Error ? e.message : String(e));
|
|
80
|
+
}
|
|
81
|
+
return Object.freeze(transcript.events.map((event, index) => normalizeClaudeEvent(event, context, index + 1)));
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type AgentErrorKind = 'executable' | 'shape-mismatch' | 'timeout' | 'cancel' | 'hung' | 'unknown-delivery';
|
|
2
|
+
export type ErrorPhase = 'before-dispatch' | 'after-dispatch';
|
|
3
|
+
export interface ClassifiedAgentError {
|
|
4
|
+
readonly kind: AgentErrorKind;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly phase: ErrorPhase;
|
|
7
|
+
readonly reconcileState: 'UNKNOWN_DELIVERY' | null;
|
|
8
|
+
readonly retry: false;
|
|
9
|
+
readonly cause: unknown;
|
|
10
|
+
}
|
|
11
|
+
export declare function classifyAgentError(cause: unknown, context: {
|
|
12
|
+
readonly phase: ErrorPhase;
|
|
13
|
+
}): ClassifiedAgentError;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function classifyAgentError(cause, context) {
|
|
2
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
3
|
+
const text = message.toLowerCase();
|
|
4
|
+
let kind;
|
|
5
|
+
if (/executable|unrunnable|unavailable|version mismatch/.test(text))
|
|
6
|
+
kind = 'executable';
|
|
7
|
+
else if (/timeout|timed out|deadline/.test(text))
|
|
8
|
+
kind = 'timeout';
|
|
9
|
+
else if (/cancel|aborted/.test(text))
|
|
10
|
+
kind = 'cancel';
|
|
11
|
+
else if (/hung|no progress|stalled/.test(text))
|
|
12
|
+
kind = 'hung';
|
|
13
|
+
else if (/\back(?:nowledg(?:e|ement)?)?\b|unknown[-_ ]delivery|sent[-_ ]no[-_ ]ack\b/.test(text))
|
|
14
|
+
kind = 'unknown-delivery';
|
|
15
|
+
else
|
|
16
|
+
kind = 'shape-mismatch'; // unknown delivery requires explicit acknowledgement-loss evidence; never infer it from phase alone.
|
|
17
|
+
return Object.freeze({ kind, message, phase: context.phase, reconcileState: kind === 'unknown-delivery' ? 'UNKNOWN_DELIVERY' : null, retry: false, cause });
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** SIMULATED Claude-shaped fixture only; no live Claude Code protocol capability is asserted. */
|
|
2
|
+
export declare const claudeTranscript: Readonly<{
|
|
3
|
+
label: 'SIMULATED';
|
|
4
|
+
version: 1;
|
|
5
|
+
events: readonly ({
|
|
6
|
+
version: number;
|
|
7
|
+
type: string;
|
|
8
|
+
subtype: string;
|
|
9
|
+
session_id: string;
|
|
10
|
+
at: string;
|
|
11
|
+
text?: never;
|
|
12
|
+
name?: never;
|
|
13
|
+
request_id?: never;
|
|
14
|
+
outcome?: never;
|
|
15
|
+
} | {
|
|
16
|
+
session_id?: never;
|
|
17
|
+
version: number;
|
|
18
|
+
type: string;
|
|
19
|
+
subtype: string;
|
|
20
|
+
text: string;
|
|
21
|
+
at: string;
|
|
22
|
+
name?: never;
|
|
23
|
+
request_id?: never;
|
|
24
|
+
outcome?: never;
|
|
25
|
+
} | {
|
|
26
|
+
session_id?: never;
|
|
27
|
+
text?: never;
|
|
28
|
+
version: number;
|
|
29
|
+
type: string;
|
|
30
|
+
subtype: string;
|
|
31
|
+
name: string;
|
|
32
|
+
at: string;
|
|
33
|
+
request_id?: never;
|
|
34
|
+
outcome?: never;
|
|
35
|
+
} | {
|
|
36
|
+
session_id?: never;
|
|
37
|
+
text?: never;
|
|
38
|
+
name?: never;
|
|
39
|
+
version: number;
|
|
40
|
+
type: string;
|
|
41
|
+
subtype: string;
|
|
42
|
+
request_id: string;
|
|
43
|
+
at: string;
|
|
44
|
+
outcome?: never;
|
|
45
|
+
} | {
|
|
46
|
+
session_id?: never;
|
|
47
|
+
text?: never;
|
|
48
|
+
name?: never;
|
|
49
|
+
request_id?: never;
|
|
50
|
+
version: number;
|
|
51
|
+
type: string;
|
|
52
|
+
subtype: string;
|
|
53
|
+
at: string;
|
|
54
|
+
outcome?: never;
|
|
55
|
+
} | {
|
|
56
|
+
session_id?: never;
|
|
57
|
+
text?: never;
|
|
58
|
+
name?: never;
|
|
59
|
+
request_id?: never;
|
|
60
|
+
version: number;
|
|
61
|
+
type: string;
|
|
62
|
+
subtype: string;
|
|
63
|
+
outcome: string;
|
|
64
|
+
at: string;
|
|
65
|
+
})[];
|
|
66
|
+
deliveryBoundary: Readonly<{
|
|
67
|
+
label: 'SIMULATED';
|
|
68
|
+
state: 'sent-no-ack';
|
|
69
|
+
}>;
|
|
70
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** SIMULATED Claude-shaped fixture only; no live Claude Code protocol capability is asserted. */
|
|
2
|
+
export const claudeTranscript = Object.freeze({
|
|
3
|
+
label: 'SIMULATED',
|
|
4
|
+
version: 1,
|
|
5
|
+
events: Object.freeze([
|
|
6
|
+
{ version: 1, type: 'system', subtype: 'init', session_id: 'session-a1b2c3d4', at: '2026-10-23T00:00:00.000Z' },
|
|
7
|
+
{ version: 1, type: 'assistant', subtype: 'text', text: 'Inspecting repository…', at: '2026-10-23T00:00:01.000Z' },
|
|
8
|
+
{ version: 1, type: 'tool', subtype: 'result', name: 'read', at: '2026-10-23T00:00:02.000Z' },
|
|
9
|
+
{ version: 1, type: 'control_request', subtype: 'permission', request_id: 'permission-demo0001', at: '2026-10-23T00:00:03.000Z' },
|
|
10
|
+
{ version: 1, type: 'result', subtype: 'turn_end', at: '2026-10-23T00:00:04.000Z' },
|
|
11
|
+
{ version: 1, type: 'result', subtype: 'run_end', outcome: 'success', at: '2026-10-23T00:00:05.000Z' },
|
|
12
|
+
]),
|
|
13
|
+
deliveryBoundary: Object.freeze({ label: 'SIMULATED', state: 'sent-no-ack' }),
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=claude-transcript.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** SIMULATED OMP-shaped fixture only; no live OMP protocol capability is asserted. */
|
|
2
|
+
export declare const ompTranscript: Readonly<{
|
|
3
|
+
label: 'SIMULATED';
|
|
4
|
+
version: 1;
|
|
5
|
+
events: readonly ({
|
|
6
|
+
version: number;
|
|
7
|
+
type: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
at: string;
|
|
10
|
+
text?: never;
|
|
11
|
+
tool?: never;
|
|
12
|
+
requestId?: never;
|
|
13
|
+
outcome?: never;
|
|
14
|
+
} | {
|
|
15
|
+
runId?: never;
|
|
16
|
+
version: number;
|
|
17
|
+
type: string;
|
|
18
|
+
text: string;
|
|
19
|
+
at: string;
|
|
20
|
+
tool?: never;
|
|
21
|
+
requestId?: never;
|
|
22
|
+
outcome?: never;
|
|
23
|
+
} | {
|
|
24
|
+
runId?: never;
|
|
25
|
+
text?: never;
|
|
26
|
+
version: number;
|
|
27
|
+
type: string;
|
|
28
|
+
tool: string;
|
|
29
|
+
at: string;
|
|
30
|
+
requestId?: never;
|
|
31
|
+
outcome?: never;
|
|
32
|
+
} | {
|
|
33
|
+
runId?: never;
|
|
34
|
+
text?: never;
|
|
35
|
+
tool?: never;
|
|
36
|
+
version: number;
|
|
37
|
+
type: string;
|
|
38
|
+
requestId: string;
|
|
39
|
+
at: string;
|
|
40
|
+
outcome?: never;
|
|
41
|
+
} | {
|
|
42
|
+
runId?: never;
|
|
43
|
+
text?: never;
|
|
44
|
+
tool?: never;
|
|
45
|
+
requestId?: never;
|
|
46
|
+
version: number;
|
|
47
|
+
type: string;
|
|
48
|
+
at: string;
|
|
49
|
+
outcome?: never;
|
|
50
|
+
} | {
|
|
51
|
+
runId?: never;
|
|
52
|
+
text?: never;
|
|
53
|
+
tool?: never;
|
|
54
|
+
requestId?: never;
|
|
55
|
+
version: number;
|
|
56
|
+
type: string;
|
|
57
|
+
outcome: string;
|
|
58
|
+
at: string;
|
|
59
|
+
})[];
|
|
60
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** SIMULATED OMP-shaped fixture only; no live OMP protocol capability is asserted. */
|
|
2
|
+
export const ompTranscript = Object.freeze({
|
|
3
|
+
label: 'SIMULATED',
|
|
4
|
+
version: 1,
|
|
5
|
+
events: Object.freeze([
|
|
6
|
+
{ version: 1, type: 'accepted', runId: 'run-demo0001', at: '2026-10-23T00:00:00.000Z' },
|
|
7
|
+
{ version: 1, type: 'partial-stream', text: 'Inspecting repository…', at: '2026-10-23T00:00:01.000Z' },
|
|
8
|
+
{ version: 1, type: 'tool-finish', tool: 'read', at: '2026-10-23T00:00:02.000Z' },
|
|
9
|
+
{ version: 1, type: 'permission-request', requestId: 'permission-demo0001', at: '2026-10-23T00:00:03.000Z' },
|
|
10
|
+
{ version: 1, type: 'turn-finish', at: '2026-10-23T00:00:04.000Z' },
|
|
11
|
+
{ version: 1, type: 'run-finish', outcome: 'success', at: '2026-10-23T00:00:05.000Z' },
|
|
12
|
+
]),
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=omp-transcript.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Envelope } from '../../core/events.js';
|
|
2
|
+
export declare class UnknownAgentEventError extends TypeError {
|
|
3
|
+
readonly code = "AGENT_EVENT_SHAPE_MISMATCH";
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export interface OmpReplayContext {
|
|
7
|
+
readonly sessionId: string;
|
|
8
|
+
readonly taskId: string;
|
|
9
|
+
readonly projectId: string;
|
|
10
|
+
readonly runId: string;
|
|
11
|
+
readonly at?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function normalizeOmpEvent(raw: unknown, context?: OmpReplayContext, sequence?: number): Envelope;
|
|
14
|
+
export declare function replayOmpTranscript(transcript: {
|
|
15
|
+
readonly label: 'SIMULATED';
|
|
16
|
+
readonly version: 1;
|
|
17
|
+
readonly events: readonly unknown[];
|
|
18
|
+
}, context: OmpReplayContext): readonly Envelope[];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { EVENT_SCHEMA_VERSION, validateEnvelope } from '../../core/events.js';
|
|
2
|
+
export class UnknownAgentEventError extends TypeError {
|
|
3
|
+
code = 'AGENT_EVENT_SHAPE_MISMATCH';
|
|
4
|
+
constructor(message) { super(message); this.name = 'UnknownAgentEventError'; }
|
|
5
|
+
}
|
|
6
|
+
const REQUIRED_COMMON = ['version', 'type', 'at'];
|
|
7
|
+
function isRecord(value) { return typeof value === 'object' && value !== null && !Array.isArray(value); }
|
|
8
|
+
export function normalizeOmpEvent(raw, context = { sessionId: 'session-a1b2c3d4', taskId: 'task-a1b2c3d4', projectId: 'project-demo0001', runId: 'run-demo0001' }, sequence = 1) {
|
|
9
|
+
if (!isRecord(raw))
|
|
10
|
+
throw new UnknownAgentEventError('OMP event must be an object');
|
|
11
|
+
if (raw['version'] !== 1)
|
|
12
|
+
throw new UnknownAgentEventError(`unsupported OMP event version ${String(raw['version'])}`);
|
|
13
|
+
if (REQUIRED_COMMON.some((key) => !(key in raw)))
|
|
14
|
+
throw new UnknownAgentEventError('OMP event missing required version/type/at shape');
|
|
15
|
+
const type = raw['type'];
|
|
16
|
+
const at = raw['at'];
|
|
17
|
+
if (typeof type !== 'string' || typeof at !== 'string')
|
|
18
|
+
throw new UnknownAgentEventError('OMP event type and at must be strings');
|
|
19
|
+
let payload;
|
|
20
|
+
let eventType;
|
|
21
|
+
let status;
|
|
22
|
+
let actor;
|
|
23
|
+
switch (type) {
|
|
24
|
+
case 'accepted':
|
|
25
|
+
if (typeof raw['runId'] !== 'string' || !raw['runId'])
|
|
26
|
+
throw new UnknownAgentEventError('accepted requires runId');
|
|
27
|
+
payload = { type: 'AdvisorAcked', adapter: 'omp:SIMULATED' };
|
|
28
|
+
eventType = 'AdvisorAcked';
|
|
29
|
+
status = 'accepted';
|
|
30
|
+
actor = { role: 'advisor', adapter: 'omp' };
|
|
31
|
+
break;
|
|
32
|
+
case 'partial-stream':
|
|
33
|
+
case 'tool-finish':
|
|
34
|
+
case 'turn-finish':
|
|
35
|
+
if (type === 'partial-stream' && typeof raw['text'] !== 'string')
|
|
36
|
+
throw new UnknownAgentEventError('partial-stream requires text');
|
|
37
|
+
// Output and tool/turn completion do not assert task-level completion.
|
|
38
|
+
payload = { type: 'AdvisorUnknownOutcome', reason: 'adapter-fault', note: `${type}${typeof raw['text'] === 'string' ? `:${raw['text']}` : ''}` };
|
|
39
|
+
eventType = 'AdvisorUnknownOutcome';
|
|
40
|
+
status = type;
|
|
41
|
+
actor = { role: 'advisor', adapter: 'omp' };
|
|
42
|
+
break;
|
|
43
|
+
case 'permission-request':
|
|
44
|
+
if (typeof raw['requestId'] !== 'string' || !raw['requestId'])
|
|
45
|
+
throw new UnknownAgentEventError('permission-request requires requestId');
|
|
46
|
+
payload = { type: 'AdvisorUnknownOutcome', reason: 'adapter-fault', note: `permission-request:${raw['requestId']}` };
|
|
47
|
+
eventType = 'AdvisorUnknownOutcome';
|
|
48
|
+
status = 'waiting_input';
|
|
49
|
+
actor = { role: 'advisor', adapter: 'omp' };
|
|
50
|
+
break;
|
|
51
|
+
case 'run-finish':
|
|
52
|
+
if (raw['outcome'] !== 'success' && raw['outcome'] !== 'failed')
|
|
53
|
+
throw new UnknownAgentEventError('run-finish requires explicit success or failed outcome');
|
|
54
|
+
payload = raw['outcome'] === 'success' ? { type: 'AdvisorCompleted', resultRef: 'artifact-ompresult01' } : { type: 'AdvisorUnknownOutcome', reason: 'adapter-fault', note: 'explicit run failed' };
|
|
55
|
+
eventType = String(payload['type']);
|
|
56
|
+
status = raw['outcome'];
|
|
57
|
+
actor = { role: 'advisor', adapter: 'omp' };
|
|
58
|
+
break;
|
|
59
|
+
default: throw new UnknownAgentEventError(`unknown OMP event type ${JSON.stringify(type)}`);
|
|
60
|
+
}
|
|
61
|
+
const seq = Math.max(1, sequence);
|
|
62
|
+
try {
|
|
63
|
+
return validateEnvelope({ schemaVersion: EVENT_SCHEMA_VERSION, seq, sessionSequence: seq, sessionId: context.sessionId, taskId: context.taskId, projectId: context.projectId, runId: context.runId, at, sourceAt: at, causality: null,
|
|
64
|
+
eventId: `event-omp-${String(seq).padStart(6, '0')}`, parentEventId: null, causationId: null, attemptId: null, traceId: 'trace-omp000001', spanId: `span-omp-${String(seq).padStart(6, '0')}`,
|
|
65
|
+
actor, provenance: { source: 'simulated' }, adapter: 'omp', adapterVersion: '1', eventType, status, reasonCode: null, artifactRefs: [], decisionId: null, requirementIds: [],
|
|
66
|
+
ckitVersion: '0.0.0', policyVersion: '1', promptTemplateVersion: '1', redactedConfigHash: 'simulated-omp', payload });
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new UnknownAgentEventError(`OMP event cannot be normalized: ${error instanceof Error ? error.message : String(error)}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function replayOmpTranscript(transcript, context) {
|
|
73
|
+
if (!isRecord(transcript) || transcript.label !== 'SIMULATED' || transcript.version !== 1 || !Array.isArray(transcript.events))
|
|
74
|
+
throw new UnknownAgentEventError('unsupported transcript version/shape');
|
|
75
|
+
return Object.freeze(transcript.events.map((event, index) => normalizeOmpEvent(event, context, index + 1)));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AgentPort, AgentRequest } from '../../ports/agent.js';
|
|
2
|
+
import type { LaunchProfile } from '../launch/profile.js';
|
|
3
|
+
import { classifyAgentError } from './errors.js';
|
|
4
|
+
export type AgentLifecycleState = 'enqueued' | 'accepted' | 'running' | 'waiting_input' | 'finished' | 'failed' | 'unknown_delivery';
|
|
5
|
+
export interface TransportReceipt {
|
|
6
|
+
readonly requestId: string;
|
|
7
|
+
readonly state: AgentLifecycleState;
|
|
8
|
+
readonly runId: string | null;
|
|
9
|
+
readonly waitingRequestId: string | null;
|
|
10
|
+
readonly reconcileState: 'UNKNOWN_DELIVERY' | null;
|
|
11
|
+
}
|
|
12
|
+
export interface TransitionResult {
|
|
13
|
+
readonly receipt: TransportReceipt;
|
|
14
|
+
readonly dispatched: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface TransitionOptions {
|
|
17
|
+
readonly runId?: string;
|
|
18
|
+
readonly requestId?: string;
|
|
19
|
+
readonly cause?: 'explicit-run-completion' | 'explicit-failure' | 'ack-lost' | 'input-resolved';
|
|
20
|
+
}
|
|
21
|
+
export interface TransportLifecycle {
|
|
22
|
+
receipt(): TransportReceipt;
|
|
23
|
+
transition(next: AgentLifecycleState, options?: TransitionOptions): TransitionResult;
|
|
24
|
+
}
|
|
25
|
+
export declare function createTransportLifecycle(requestId: string): TransportLifecycle;
|
|
26
|
+
/** Contract boundary consumed by offline and future live adapters; does not launch a process. */
|
|
27
|
+
export interface AgentTransportContract {
|
|
28
|
+
readonly profile: LaunchProfile;
|
|
29
|
+
readonly port: AgentPort;
|
|
30
|
+
dispatch(request: AgentRequest): AsyncIterable<ReturnType<typeof classifyAgentError> | {
|
|
31
|
+
readonly kind: 'observation';
|
|
32
|
+
readonly value: Awaited<ReturnType<AgentPort['dispatch']> extends AsyncIterable<infer T> ? T : never>;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export declare function classifyPreDispatchFailure(error: unknown): import("./errors.js").ClassifiedAgentError;
|