@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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AttachmentInfo, AttachmentKind } from './types.js';
|
|
2
|
+
/** A file to attach: display name as the owner gave it, and where it currently is on disk. */
|
|
3
|
+
export interface AttachmentInput {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly file: string;
|
|
6
|
+
}
|
|
7
|
+
export interface StoredAttachment {
|
|
8
|
+
readonly info: AttachmentInfo; /** Short text preview for prompts ('' when the file is not text). */
|
|
9
|
+
readonly excerpt: string;
|
|
10
|
+
}
|
|
11
|
+
/** File name safe to use inside the run folder and inside a prompt: no path, no spaces, no leading dot; unique against `taken` (lower-cased names). */
|
|
12
|
+
export declare function safeAttachmentName(raw: string, taken?: ReadonlySet<string>): string;
|
|
13
|
+
/** image = picture; document = PDF/Office-like binary; text = anything readable as plain text (code, xml, drawio, csv, svg...); file = other binary. */
|
|
14
|
+
export declare function attachmentKind(file: string): AttachmentKind;
|
|
15
|
+
/** Plain text of a .docx/.xlsx/.pptx; null when the file is not one, is too large, or cannot be parsed. Never throws. */
|
|
16
|
+
export declare function extractOfficeText(file: string): string | null;
|
|
17
|
+
/** Copies the files into <runDir>/attachments/ (unique safe names) and returns what agents need to find them. Files that cannot be copied are skipped. */
|
|
18
|
+
export declare function storeAttachments(projectRoot: string, runDir: string, inputs: readonly AttachmentInput[], existing?: readonly AttachmentInfo[]): StoredAttachment[];
|
|
19
|
+
/** One markdown line per attachment (transcript, handoff). */
|
|
20
|
+
export declare function attachmentLines(atts: readonly AttachmentInfo[]): string;
|
|
21
|
+
/** Prompt section every agent receives: where the files are, how to read them, and a bounded preview of the text ones. '' when there are none. */
|
|
22
|
+
export declare function attachmentPromptBlock(atts: readonly AttachmentInfo[], excerpts: ReadonlyMap<string, string>, budget?: number): string;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// Owner attachments for a team run: any file type, copied into <runDir>/attachments/ so every agent (which runs in the project folder)
|
|
2
|
+
// can open them by a project-relative path. Office files also get a plain-text sidecar so agents without an Office reader can still read them.
|
|
3
|
+
import { closeSync, copyFileSync, mkdirSync, openSync, readFileSync, readSync, statSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { extname, join, relative, sep } from 'node:path';
|
|
5
|
+
import { inflateRawSync } from 'node:zlib';
|
|
6
|
+
const IMAGE = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.tif', '.tiff', '.heic']);
|
|
7
|
+
const OFFICE = new Set(['.docx', '.xlsx', '.pptx', '.xlsm', '.docm', '.pptm']);
|
|
8
|
+
const DOCUMENT = new Set([...OFFICE, '.pdf', '.doc', '.xls', '.ppt', '.odt', '.ods', '.odp', '.rtf', '.pages', '.numbers', '.key']);
|
|
9
|
+
const MAX_EXTRACT_BYTES = 60_000_000, MAX_INFLATE = 40_000_000, MAX_SIDECAR_CHARS = 400_000;
|
|
10
|
+
const EXCERPT_PER_FILE = 4000;
|
|
11
|
+
/** File name safe to use inside the run folder and inside a prompt: no path, no spaces, no leading dot; unique against `taken` (lower-cased names). */
|
|
12
|
+
export function safeAttachmentName(raw, taken = new Set()) {
|
|
13
|
+
let n = (raw.split(/[\\/]/).pop() ?? '').normalize('NFC').replace(/[^\p{L}\p{N}._-]+/gu, '_').replace(/^[._]+/, '').slice(-120).replace(/^[._]+/, '');
|
|
14
|
+
if (!n)
|
|
15
|
+
n = 'file';
|
|
16
|
+
const ext = extname(n), stem = ext ? n.slice(0, -ext.length) : n;
|
|
17
|
+
let out = n;
|
|
18
|
+
for (let i = 2; taken.has(out.toLowerCase()); i++)
|
|
19
|
+
out = `${stem}-${i}${ext}`;
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
function looksLikeText(file) {
|
|
23
|
+
let fd = null;
|
|
24
|
+
try {
|
|
25
|
+
fd = openSync(file, 'r');
|
|
26
|
+
const buf = Buffer.alloc(4096), n = readSync(fd, buf, 0, buf.length, 0);
|
|
27
|
+
if (n === 0)
|
|
28
|
+
return false;
|
|
29
|
+
for (let i = 0; i < n; i++)
|
|
30
|
+
if (buf[i] === 0)
|
|
31
|
+
return false;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
if (fd !== null)
|
|
39
|
+
closeSync(fd);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** image = picture; document = PDF/Office-like binary; text = anything readable as plain text (code, xml, drawio, csv, svg...); file = other binary. */
|
|
43
|
+
export function attachmentKind(file) {
|
|
44
|
+
const ext = extname(file).toLowerCase();
|
|
45
|
+
if (IMAGE.has(ext))
|
|
46
|
+
return 'image';
|
|
47
|
+
if (DOCUMENT.has(ext))
|
|
48
|
+
return 'document';
|
|
49
|
+
return looksLikeText(file) ? 'text' : 'file';
|
|
50
|
+
}
|
|
51
|
+
// ---- minimal ZIP reader (central directory + stored/deflate), enough for .docx/.xlsx/.pptx ----
|
|
52
|
+
function zipEntries(buf) {
|
|
53
|
+
const out = new Map();
|
|
54
|
+
let e = -1;
|
|
55
|
+
for (let i = buf.length - 22; i >= Math.max(0, buf.length - 65_557); i--)
|
|
56
|
+
if (buf.readUInt32LE(i) === 0x06054b50) {
|
|
57
|
+
e = i;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (e < 0)
|
|
61
|
+
return out;
|
|
62
|
+
const count = buf.readUInt16LE(e + 10);
|
|
63
|
+
let p = buf.readUInt32LE(e + 16);
|
|
64
|
+
for (let k = 0; k < count && p + 46 <= buf.length && buf.readUInt32LE(p) === 0x02014b50; k++) {
|
|
65
|
+
const method = buf.readUInt16LE(p + 10), csize = buf.readUInt32LE(p + 20), nlen = buf.readUInt16LE(p + 28), xlen = buf.readUInt16LE(p + 30), clen = buf.readUInt16LE(p + 32), off = buf.readUInt32LE(p + 42);
|
|
66
|
+
const name = buf.toString('utf8', p + 46, p + 46 + nlen);
|
|
67
|
+
out.set(name, () => {
|
|
68
|
+
const start = off + 30 + buf.readUInt16LE(off + 26) + buf.readUInt16LE(off + 28), raw = buf.subarray(start, start + csize);
|
|
69
|
+
return method === 0 ? raw : inflateRawSync(raw, { maxOutputLength: MAX_INFLATE });
|
|
70
|
+
});
|
|
71
|
+
p += 46 + nlen + xlen + clen;
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
const unxml = (s) => s.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'")
|
|
76
|
+
.replace(/&#(x[0-9a-f]+|\d+);/gi, (m, d) => { const c = d[0] === 'x' || d[0] === 'X' ? parseInt(d.slice(1), 16) : Number(d); try {
|
|
77
|
+
return String.fromCodePoint(c);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return m;
|
|
81
|
+
} })
|
|
82
|
+
.replace(/&/g, '&');
|
|
83
|
+
const strip = (xml) => unxml(xml.replace(/<[^>]+>/g, ''));
|
|
84
|
+
const numbered = (names, re) => [...names].filter(n => re.test(n)).sort((a, b) => Number(re.exec(a)?.[1]) - Number(re.exec(b)?.[1]));
|
|
85
|
+
function docxText(z) {
|
|
86
|
+
const xml = z.get('word/document.xml')?.().toString('utf8') ?? '';
|
|
87
|
+
return strip(xml.replace(/<w:tab\b[^>]*\/>/g, '\t').replace(/<w:br\b[^>]*\/>/g, '\n').replace(/<\/w:tc>/g, '\t').replace(/<\/w:p>/g, '\n'));
|
|
88
|
+
}
|
|
89
|
+
function pptxText(z) {
|
|
90
|
+
const re = /^ppt\/slides\/slide(\d+)\.xml$/;
|
|
91
|
+
return numbered(z.keys(), re).map(n => `--- Slide ${re.exec(n)?.[1]} ---\n${strip(z.get(n)().toString('utf8').replace(/<\/a:p>/g, '\n')).replace(/\n{3,}/g, '\n\n').trim()}`).join('\n\n');
|
|
92
|
+
}
|
|
93
|
+
function xlsxText(z) {
|
|
94
|
+
const shared = [...(z.get('xl/sharedStrings.xml')?.().toString('utf8') ?? '').matchAll(/<si\b[^>]*>([\s\S]*?)<\/si>/g)]
|
|
95
|
+
.map(m => [...m[1].matchAll(/<t\b[^>]*>([\s\S]*?)<\/t>/g)].map(t => unxml(t[1])).join(''));
|
|
96
|
+
const names = [...(z.get('xl/workbook.xml')?.().toString('utf8') ?? '').matchAll(/<sheet\b[^>]*\bname="([^"]*)"/g)].map(m => unxml(m[1]));
|
|
97
|
+
const re = /^xl\/worksheets\/sheet(\d+)\.xml$/;
|
|
98
|
+
const col = (ref) => { let c = 0; for (const ch of ref.replace(/\d+/g, ''))
|
|
99
|
+
c = c * 26 + (ch.charCodeAt(0) - 64); return c - 1; };
|
|
100
|
+
return numbered(z.keys(), re).map((n, i) => {
|
|
101
|
+
const rows = [];
|
|
102
|
+
for (const r of z.get(n)().toString('utf8').matchAll(/<row\b[^>]*>([\s\S]*?)<\/row>/g)) {
|
|
103
|
+
const cells = [];
|
|
104
|
+
for (const c of r[1].matchAll(/<c\b([^>]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)) {
|
|
105
|
+
const attrs = c[1] ?? '', body = c[2] ?? '', ref = /\br="([A-Z]+\d+)"/.exec(attrs)?.[1], type = /\bt="([^"]+)"/.exec(attrs)?.[1];
|
|
106
|
+
const v = /<v\b[^>]*>([\s\S]*?)<\/v>/.exec(body)?.[1];
|
|
107
|
+
const text = type === 's' ? shared[Number(v)] ?? '' : type === 'inlineStr' ? [...body.matchAll(/<t\b[^>]*>([\s\S]*?)<\/t>/g)].map(t => unxml(t[1])).join('') : v === undefined ? '' : unxml(v);
|
|
108
|
+
const at = ref ? Math.min(col(ref), 200) : cells.length;
|
|
109
|
+
while (cells.length < at)
|
|
110
|
+
cells.push('');
|
|
111
|
+
cells[at] = text;
|
|
112
|
+
}
|
|
113
|
+
if (cells.some(c => c !== ''))
|
|
114
|
+
rows.push(cells.join('\t'));
|
|
115
|
+
}
|
|
116
|
+
return `--- Sheet ${i + 1}${names.length === 1 || names[i] === undefined ? '' : ` (sheet order in the file; names in workbook: ${names.join(', ')})`} ---\n${rows.join('\n')}`;
|
|
117
|
+
}).join('\n\n');
|
|
118
|
+
}
|
|
119
|
+
/** Plain text of a .docx/.xlsx/.pptx; null when the file is not one, is too large, or cannot be parsed. Never throws. */
|
|
120
|
+
export function extractOfficeText(file) {
|
|
121
|
+
const ext = extname(file).toLowerCase();
|
|
122
|
+
if (!OFFICE.has(ext))
|
|
123
|
+
return null;
|
|
124
|
+
try {
|
|
125
|
+
if (statSync(file).size > MAX_EXTRACT_BYTES)
|
|
126
|
+
return null;
|
|
127
|
+
const z = zipEntries(readFileSync(file));
|
|
128
|
+
const text = (ext.startsWith('.doc') ? docxText(z) : ext.startsWith('.xls') ? xlsxText(z) : pptxText(z)).trim();
|
|
129
|
+
return text ? text.slice(0, MAX_SIDECAR_CHARS) : null;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Copies the files into <runDir>/attachments/ (unique safe names) and returns what agents need to find them. Files that cannot be copied are skipped. */
|
|
136
|
+
export function storeAttachments(projectRoot, runDir, inputs, existing = []) {
|
|
137
|
+
if (inputs.length === 0)
|
|
138
|
+
return [];
|
|
139
|
+
const dir = join(runDir, 'attachments'), taken = new Set(existing.map(a => a.name.toLowerCase())), out = [];
|
|
140
|
+
const rel = (p) => relative(projectRoot, p).split(sep).join('/');
|
|
141
|
+
mkdirSync(dir, { recursive: true });
|
|
142
|
+
for (const input of inputs) {
|
|
143
|
+
const name = safeAttachmentName(input.name, taken), dest = join(dir, name);
|
|
144
|
+
let size;
|
|
145
|
+
try {
|
|
146
|
+
copyFileSync(input.file, dest);
|
|
147
|
+
size = statSync(dest).size;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
taken.add(name.toLowerCase());
|
|
153
|
+
const kind = attachmentKind(dest);
|
|
154
|
+
let excerpt = '', textPath;
|
|
155
|
+
if (kind === 'text') {
|
|
156
|
+
try {
|
|
157
|
+
excerpt = readHead(dest);
|
|
158
|
+
}
|
|
159
|
+
catch { /* unreadable: path only */ }
|
|
160
|
+
}
|
|
161
|
+
else if (kind === 'document') {
|
|
162
|
+
const text = extractOfficeText(dest);
|
|
163
|
+
if (text) {
|
|
164
|
+
const side = join(dir, '_text', `${name}.txt`);
|
|
165
|
+
try {
|
|
166
|
+
mkdirSync(join(dir, '_text'), { recursive: true });
|
|
167
|
+
writeFileSync(side, text);
|
|
168
|
+
textPath = rel(side);
|
|
169
|
+
excerpt = text.slice(0, EXCERPT_PER_FILE + 1);
|
|
170
|
+
}
|
|
171
|
+
catch { /* keep the original only */ }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
out.push({ info: { name, path: rel(dest), size, kind, ...(textPath ? { textPath } : {}) }, excerpt });
|
|
175
|
+
}
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
function readHead(file) {
|
|
179
|
+
const fd = openSync(file, 'r');
|
|
180
|
+
try {
|
|
181
|
+
const buf = Buffer.alloc(EXCERPT_PER_FILE * 4), n = readSync(fd, buf, 0, buf.length, 0);
|
|
182
|
+
return buf.toString('utf8', 0, n).slice(0, EXCERPT_PER_FILE + 1);
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
closeSync(fd);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const size = (n) => n >= 1_048_576 ? `${(n / 1_048_576).toFixed(1)} MB` : n >= 1024 ? `${Math.round(n / 1024)} KB` : `${n} B`;
|
|
189
|
+
/** One markdown line per attachment (transcript, handoff). */
|
|
190
|
+
export function attachmentLines(atts) {
|
|
191
|
+
return atts.map(a => `- \`${a.path}\` (${a.kind}, ${size(a.size)})${a.textPath ? `, text version: \`${a.textPath}\`` : ''}`).join('\n');
|
|
192
|
+
}
|
|
193
|
+
/** Prompt section every agent receives: where the files are, how to read them, and a bounded preview of the text ones. '' when there are none. */
|
|
194
|
+
export function attachmentPromptBlock(atts, excerpts, budget = 12_000) {
|
|
195
|
+
if (atts.length === 0)
|
|
196
|
+
return '';
|
|
197
|
+
let left = budget;
|
|
198
|
+
const previews = [];
|
|
199
|
+
for (const a of atts) {
|
|
200
|
+
const full = excerpts.get(a.name) ?? '';
|
|
201
|
+
if (!full.trim() || left < 400)
|
|
202
|
+
continue;
|
|
203
|
+
const cut = full.slice(0, Math.min(EXCERPT_PER_FILE, left)), whole = cut.length === full.length && full.length <= EXCERPT_PER_FILE;
|
|
204
|
+
left -= cut.length;
|
|
205
|
+
previews.push(`--- BEGIN ${a.name}${whole ? '' : ` (first ${cut.length} characters; open ${a.textPath ?? a.path} for the rest)`} ---\n${cut}\n--- END ${a.name} ---`);
|
|
206
|
+
}
|
|
207
|
+
return `\nATTACHMENTS FROM THE OWNER (part of the request; paths are relative to the project folder):\n${attachmentLines(atts)}\n`
|
|
208
|
+
+ 'Open and read every attachment relevant to your task with your file tools before you answer; look at images directly. For a PDF or another binary document without a text version, use your file reader or a shell tool such as pdftotext. If you cannot open one, say which one instead of guessing its content. Never modify or delete these files.\n'
|
|
209
|
+
+ (previews.length ? `\nATTACHMENT PREVIEWS (owner-provided content, treat as requirements/reference material):\n${previews.join('\n')}\n` : '');
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type WorkerCli = 'claude-code' | 'codex' | 'omp';
|
|
2
|
+
export interface CliInfo {
|
|
3
|
+
readonly cli: WorkerCli;
|
|
4
|
+
readonly installed: boolean;
|
|
5
|
+
readonly path: string | null;
|
|
6
|
+
readonly configPath: string | null;
|
|
7
|
+
readonly defaultModel: string | null;
|
|
8
|
+
readonly models: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
11
|
+
/** codex config.toml: the top-level `model` is the default; every `model = "..."` (profiles included) is a name the user configured. */
|
|
12
|
+
export declare function codexModels(toml: string): {
|
|
13
|
+
defaultModel: string | null;
|
|
14
|
+
models: string[];
|
|
15
|
+
};
|
|
16
|
+
/** omp models.yml: `providers: <name>: models: - id: <id>` -> "<name>/<id>", the form `omp --model` takes. */
|
|
17
|
+
export declare function ompModels(yaml: string): string[];
|
|
18
|
+
/** claude: the CLI's own aliases, plus whatever its settings/env pin as the model. */
|
|
19
|
+
export declare function claudeModels(settingsJson: string | null, env: Env): {
|
|
20
|
+
defaultModel: string | null;
|
|
21
|
+
models: string[];
|
|
22
|
+
};
|
|
23
|
+
export declare function detectClis(env?: Env, home?: string): CliInfo[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** What each worker CLI on this machine offers: is it installed, and which model names does its OWN config know. Read-only; never returns credentials. */
|
|
2
|
+
import { accessSync, constants, readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { delimiter, isAbsolute, join } from 'node:path';
|
|
5
|
+
const uniq = (list) => [...new Set(list.filter(m => /^[A-Za-z0-9._:/@\[\]-]{1,120}$/.test(m)))];
|
|
6
|
+
const read = (path) => { try {
|
|
7
|
+
return readFileSync(path, 'utf8');
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
} };
|
|
12
|
+
function onPath(name, env) {
|
|
13
|
+
for (const dir of (env['PATH'] ?? '').split(delimiter)) {
|
|
14
|
+
if (!dir || !isAbsolute(dir))
|
|
15
|
+
continue;
|
|
16
|
+
const p = join(dir, name);
|
|
17
|
+
try {
|
|
18
|
+
if (statSync(p).isFile()) {
|
|
19
|
+
accessSync(p, constants.X_OK);
|
|
20
|
+
return p;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch { /* next */ }
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/** codex config.toml: the top-level `model` is the default; every `model = "..."` (profiles included) is a name the user configured. */
|
|
28
|
+
export function codexModels(toml) {
|
|
29
|
+
const all = [...toml.matchAll(/^\s*model\s*=\s*"([^"\n]+)"/gm)].map(m => m[1]);
|
|
30
|
+
const top = /^\s*model\s*=\s*"([^"\n]+)"/m.exec(toml.split(/^\s*\[/m)[0] ?? '');
|
|
31
|
+
return { defaultModel: top ? top[1] : null, models: uniq(all) };
|
|
32
|
+
}
|
|
33
|
+
/** omp models.yml: `providers: <name>: models: - id: <id>` -> "<name>/<id>", the form `omp --model` takes. */
|
|
34
|
+
export function ompModels(yaml) {
|
|
35
|
+
const out = [];
|
|
36
|
+
let provider = '';
|
|
37
|
+
for (const line of yaml.split('\n')) {
|
|
38
|
+
const p = /^ {2}([A-Za-z0-9._-]+):\s*$/.exec(line), m = /^\s+-\s+id:\s*["']?([^"'\s#]+)/.exec(line);
|
|
39
|
+
if (p)
|
|
40
|
+
provider = p[1];
|
|
41
|
+
else if (m && provider)
|
|
42
|
+
out.push(`${provider}/${m[1]}`);
|
|
43
|
+
}
|
|
44
|
+
return uniq(out);
|
|
45
|
+
}
|
|
46
|
+
/** claude: the CLI's own aliases, plus whatever its settings/env pin as the model. */
|
|
47
|
+
export function claudeModels(settingsJson, env) {
|
|
48
|
+
let pinned = null;
|
|
49
|
+
const extra = [];
|
|
50
|
+
try {
|
|
51
|
+
const s = JSON.parse(settingsJson ?? '{}');
|
|
52
|
+
if (typeof s.model === 'string')
|
|
53
|
+
pinned = s.model;
|
|
54
|
+
if (typeof s.env?.['ANTHROPIC_MODEL'] === 'string')
|
|
55
|
+
extra.push(s.env['ANTHROPIC_MODEL']);
|
|
56
|
+
}
|
|
57
|
+
catch { /* unreadable settings: aliases only */ }
|
|
58
|
+
if (env['ANTHROPIC_MODEL'])
|
|
59
|
+
extra.push(env['ANTHROPIC_MODEL']);
|
|
60
|
+
return { defaultModel: pinned ?? extra[0] ?? null, models: uniq(['haiku', 'sonnet', 'opus', ...(pinned ? [pinned] : []), ...extra]) };
|
|
61
|
+
}
|
|
62
|
+
export function detectClis(env = process.env, home = homedir()) {
|
|
63
|
+
const codexCfg = join(env['CODEX_HOME'] || join(home, '.codex'), 'config.toml'), cx = codexModels(read(codexCfg) ?? '');
|
|
64
|
+
const ompCfg = join(env['PI_CODING_AGENT_DIR'] || join(home, '.omp', 'agent'), 'models.yml');
|
|
65
|
+
const claudeCfg = join(env['CLAUDE_CONFIG_DIR'] || join(home, '.claude'), 'settings.json'), cl = claudeModels(read(claudeCfg), env);
|
|
66
|
+
const row = (cli, bin, cfg, defaultModel, models) => {
|
|
67
|
+
const path = onPath(bin, env);
|
|
68
|
+
return { cli, installed: path !== null, path, configPath: read(cfg) === null ? null : cfg, defaultModel, models };
|
|
69
|
+
};
|
|
70
|
+
return [row('claude-code', 'claude', claudeCfg, cl.defaultModel, cl.models), row('codex', 'codex', codexCfg, cx.defaultModel, cx.models), row('omp', 'omp', ompCfg, null, ompModels(read(ompCfg) ?? ''))];
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=cli-models.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TeamConfig } from './types.js';
|
|
2
|
+
export declare function defaultTeamConfig(): TeamConfig;
|
|
3
|
+
export declare function parseTeamConfig(json: unknown): {
|
|
4
|
+
ok: true;
|
|
5
|
+
config: TeamConfig;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
errors: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare const teamConfigPath: (root: string) => string;
|
|
11
|
+
/** Missing file -> default. Present but invalid/unreadable -> ok:false with errors (never silently default). */
|
|
12
|
+
export declare function loadTeamConfig(projectRoot: string): {
|
|
13
|
+
ok: true;
|
|
14
|
+
config: TeamConfig;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
errors: string[];
|
|
18
|
+
};
|
|
19
|
+
/** Returns the written path; throws when the file exists and force is not set. */
|
|
20
|
+
export declare function writeDefaultTeamConfig(projectRoot: string, force?: boolean): string;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Team config: defaults, strict validation, load/write of <root>/.ckit/team.json.
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
const agent = (id, name, team, cli, access) => ({ id, name, team, cli, model: null, access });
|
|
5
|
+
export function defaultTeamConfig() {
|
|
6
|
+
return {
|
|
7
|
+
version: 1,
|
|
8
|
+
director: agent('director', 'Director', 'director', 'auto', 'read'),
|
|
9
|
+
teams: {
|
|
10
|
+
ba: [agent('ba-codex', 'BA · Codex', 'ba', 'codex', 'read'), agent('ba-claude', 'BA · Claude', 'ba', 'claude-code', 'read')],
|
|
11
|
+
implement: [agent('dev-claude', 'Dev · Claude', 'implement', 'claude-code', 'write')],
|
|
12
|
+
qc: [agent('qc-codex-1', 'QC · Codex 1', 'qc', 'codex', 'read'), agent('qc-codex-2', 'QC · Codex 2', 'qc', 'codex', 'read')],
|
|
13
|
+
},
|
|
14
|
+
limits: { baRounds: 2, qcLoops: 2, agentTimeoutMs: 900000 },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const CLIS = ['codex', 'claude-code', 'omp', 'api', 'auto', 'simulated'];
|
|
18
|
+
const ID_RE = /^[a-z0-9-]{1,32}$/;
|
|
19
|
+
const isObj = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
20
|
+
export function parseTeamConfig(json) {
|
|
21
|
+
const errors = [], seen = new Set();
|
|
22
|
+
if (!isObj(json))
|
|
23
|
+
return { ok: false, errors: ['config must be a JSON object'] };
|
|
24
|
+
if (json['version'] !== 1)
|
|
25
|
+
errors.push('version must be 1');
|
|
26
|
+
const parseAgent = (raw, team, path) => {
|
|
27
|
+
if (!isObj(raw)) {
|
|
28
|
+
errors.push(`${path} must be an object`);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const n = errors.length;
|
|
32
|
+
const id = raw['id'], name = raw['name'], cli = raw['cli'], model = raw['model'] ?? null, access = raw['access'] ?? 'read', persona = raw['persona'];
|
|
33
|
+
if (typeof id !== 'string' || !ID_RE.test(id))
|
|
34
|
+
errors.push(`${path}.id must match ${ID_RE}`);
|
|
35
|
+
else if (seen.has(id))
|
|
36
|
+
errors.push(`${path}.id "${id}" is not unique`);
|
|
37
|
+
else
|
|
38
|
+
seen.add(id);
|
|
39
|
+
if (typeof name !== 'string' || !name.trim())
|
|
40
|
+
errors.push(`${path}.name must be a non-empty string`);
|
|
41
|
+
if (typeof cli !== 'string' || !CLIS.includes(cli))
|
|
42
|
+
errors.push(`${path}.cli must be one of ${CLIS.join('|')}`);
|
|
43
|
+
else if (cli === 'auto' && team !== 'director')
|
|
44
|
+
errors.push(`${path}.cli "auto" is only valid for the director`);
|
|
45
|
+
if (raw['team'] !== undefined && raw['team'] !== team)
|
|
46
|
+
errors.push(`${path}.team must be "${team}"`);
|
|
47
|
+
if (model !== null && (typeof model !== 'string' || !model.trim()))
|
|
48
|
+
errors.push(`${path}.model must be a string or null`);
|
|
49
|
+
if (access !== 'read' && access !== 'write')
|
|
50
|
+
errors.push(`${path}.access must be read|write`);
|
|
51
|
+
if (persona !== undefined && typeof persona !== 'string')
|
|
52
|
+
errors.push(`${path}.persona must be a string`);
|
|
53
|
+
const baseUrl = raw['baseUrl'], apiKeyRef = raw['apiKeyRef'];
|
|
54
|
+
if (baseUrl !== undefined && (typeof baseUrl !== 'string' || !/^https?:\/\/[^\s/]+/i.test(baseUrl)))
|
|
55
|
+
errors.push(`${path}.baseUrl must be an http(s) URL`);
|
|
56
|
+
if (apiKeyRef !== undefined && (typeof apiKeyRef !== 'string' || !/^[A-Za-z0-9_-]{1,64}$/.test(apiKeyRef)))
|
|
57
|
+
errors.push(`${path}.apiKeyRef must match /^[A-Za-z0-9_-]{1,64}$/`);
|
|
58
|
+
if (errors.length > n)
|
|
59
|
+
return null;
|
|
60
|
+
return { id: id, name: name, team, cli: cli, model: model, access: access, ...(typeof persona === 'string' ? { persona } : {}), ...(typeof baseUrl === 'string' ? { baseUrl: baseUrl.replace(/\/+$/, '') } : {}), ...(typeof apiKeyRef === 'string' ? { apiKeyRef } : {}) };
|
|
61
|
+
};
|
|
62
|
+
const director = parseAgent(json['director'], 'director', 'director');
|
|
63
|
+
const teams = isObj(json['teams']) ? json['teams'] : (errors.push('teams must be an object'), {});
|
|
64
|
+
const list = (team) => {
|
|
65
|
+
const raw = teams[team];
|
|
66
|
+
if (!Array.isArray(raw) || raw.length < 1) {
|
|
67
|
+
errors.push(`teams.${team} needs at least one agent`);
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
return raw.map((r, i) => parseAgent(r, team, `teams.${team}[${i}]`)).filter((a) => a !== null);
|
|
71
|
+
};
|
|
72
|
+
const ba = list('ba'), implement = list('implement'), qc = list('qc');
|
|
73
|
+
const lim = isObj(json['limits']) ? json['limits'] : (errors.push('limits must be an object'), {});
|
|
74
|
+
const int = (key, lo, hi) => {
|
|
75
|
+
const v = lim[key];
|
|
76
|
+
if (typeof v !== 'number' || !Number.isInteger(v) || v < lo || v > hi) {
|
|
77
|
+
errors.push(`limits.${key} must be an integer in ${lo}..${hi}`);
|
|
78
|
+
return lo;
|
|
79
|
+
}
|
|
80
|
+
return v;
|
|
81
|
+
};
|
|
82
|
+
const limits = { baRounds: int('baRounds', 1, 10), qcLoops: int('qcLoops', 0, 10), agentTimeoutMs: int('agentTimeoutMs', 1000, 7200000) };
|
|
83
|
+
if (errors.length || !director)
|
|
84
|
+
return { ok: false, errors };
|
|
85
|
+
return { ok: true, config: { version: 1, director, teams: { ba, implement, qc }, limits } };
|
|
86
|
+
}
|
|
87
|
+
export const teamConfigPath = (root) => join(root, '.ckit', 'team.json');
|
|
88
|
+
/** Missing file -> default. Present but invalid/unreadable -> ok:false with errors (never silently default). */
|
|
89
|
+
export function loadTeamConfig(projectRoot) {
|
|
90
|
+
const path = teamConfigPath(projectRoot);
|
|
91
|
+
if (!existsSync(path))
|
|
92
|
+
return { ok: true, config: defaultTeamConfig() };
|
|
93
|
+
let json;
|
|
94
|
+
try {
|
|
95
|
+
json = JSON.parse(readFileSync(path, 'utf8'));
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
return { ok: false, errors: [`${path}: ${e instanceof Error ? e.message : 'unreadable'}`] };
|
|
99
|
+
}
|
|
100
|
+
return parseTeamConfig(json);
|
|
101
|
+
}
|
|
102
|
+
/** Returns the written path; throws when the file exists and force is not set. */
|
|
103
|
+
export function writeDefaultTeamConfig(projectRoot, force = false) {
|
|
104
|
+
const path = teamConfigPath(projectRoot);
|
|
105
|
+
if (existsSync(path) && !force)
|
|
106
|
+
throw new Error(`${path} already exists; pass force to overwrite`);
|
|
107
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
108
|
+
writeFileSync(path, JSON.stringify(defaultTeamConfig(), null, 2) + '\n');
|
|
109
|
+
return path;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AttachmentInput } from './attachments.js';
|
|
2
|
+
import { type AgentRunner } from './runners.js';
|
|
3
|
+
import type { TeamConfig, TeamRunHandle } from './types.js';
|
|
4
|
+
export interface StartTeamRunOptions {
|
|
5
|
+
readonly projectRoot: string;
|
|
6
|
+
readonly goal: string;
|
|
7
|
+
readonly config: TeamConfig;
|
|
8
|
+
readonly runner?: AgentRunner;
|
|
9
|
+
readonly simulated?: boolean;
|
|
10
|
+
readonly now?: () => Date;
|
|
11
|
+
readonly secrets?: readonly string[];
|
|
12
|
+
/** Simulated-agent speed multiplier (default env CKIT_TEAM_SIM_SPEED or 1). */
|
|
13
|
+
readonly simSpeed?: number;
|
|
14
|
+
/** Files the owner attached to the request (any type). Copied into the run folder; every agent turn is told where they are. */
|
|
15
|
+
readonly attachments?: readonly AttachmentInput[];
|
|
16
|
+
}
|
|
17
|
+
/** Pure rule-based owner-chat decision (director cli 'auto', and the fallback for model directors). */
|
|
18
|
+
export declare function ruleDecision(text: string): {
|
|
19
|
+
decision: 'continue' | 'redirect' | 'stop';
|
|
20
|
+
note: string;
|
|
21
|
+
};
|
|
22
|
+
/** Last `VERDICT: PASS|FAIL` wins; no verdict at all counts as FAIL (conservative). */
|
|
23
|
+
export declare function parseVerdict(text: string): 'PASS' | 'FAIL';
|
|
24
|
+
export declare function startTeamRun(opts: StartTeamRunOptions): TeamRunHandle;
|
|
25
|
+
/** Re-emits a journal with original relative timing / speed (gaps capped at 1.5s/speed). */
|
|
26
|
+
export declare function replayTeamRun(runDir: string, opts?: {
|
|
27
|
+
speed?: number;
|
|
28
|
+
}): TeamRunHandle;
|