@aui.io/apollo 0.1.9 → 0.1.11
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/node_modules/@aui.io/apollo-cli/bin/apollo.js +8 -5
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/operate.js +3 -10
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/operate.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/package.json +3 -3
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.d.ts +13 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.js +17 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.d.ts +17 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.js +27 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/package.json +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/ActionPalette.d.ts +13 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/ActionPalette.js +47 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/ActionPalette.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/registry.d.ts +28 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/registry.js +219 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/registry.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivityDrawer.d.ts +8 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivityDrawer.js +43 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivityDrawer.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivitySummary.d.ts +5 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivitySummary.js +26 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivitySummary.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/operationStore.d.ts +67 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/operationStore.js +138 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/operationStore.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/AuthorHome.d.ts +27 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/AuthorHome.js +92 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/AuthorHome.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/DiffView.d.ts +46 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/DiffView.js +87 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/DiffView.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/SessionPane.d.ts +15 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/SessionPane.js +38 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/SessionPane.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/ValidationView.d.ts +11 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/ValidationView.js +34 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/ValidationView.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/VersionsView.d.ts +9 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/VersionsView.js +31 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/VersionsView.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/claudeCode.d.ts +23 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/claudeCode.js +293 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/claudeCode.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/index.d.ts +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/index.js +13 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/sessions.d.ts +3 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/sessions.js +36 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/sessions.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/types.d.ts +85 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/types.js +11 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/backend/types.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/data.d.ts +78 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/data.js +279 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/data.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/session.d.ts +64 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/session.js +319 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/session.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/tree.d.ts +25 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/tree.js +69 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/tree.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/context/ContextSwitcher.d.ts +23 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/context/ContextSwitcher.js +60 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/context/ContextSwitcher.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/index.d.ts +17 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/index.js +22 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/index.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/keyprobe.d.ts +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/keyprobe.js +51 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/keyprobe.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/actions.d.ts +25 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/actions.js +143 -19
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/actions.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/clipboard.d.ts +7 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/clipboard.js +33 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/clipboard.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.d.ts +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.js +53 -10
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/ide.d.ts +16 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/ide.js +39 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/ide.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/keydiag.d.ts +17 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/keydiag.js +76 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/keydiag.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/keys.d.ts +64 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/keys.js +105 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/keys.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/modes.d.ts +18 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/modes.js +24 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/modes.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/place.d.ts +7 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/place.js +17 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/place.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.d.ts +25 -6
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.js +108 -17
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/sheet.d.ts +3 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/sheet.js +2 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/sheet.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/opentui-app.js +1802 -245
- package/node_modules/@aui.io/apollo-tui/dist/src/opentui-app.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/Breadcrumb.d.ts +15 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/Breadcrumb.js +22 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/Breadcrumb.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/FooterHints.d.ts +8 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/FooterHints.js +23 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/FooterHints.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/ModeNav.d.ts +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/ModeNav.js +7 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/ModeNav.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/Composer.d.ts +20 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/Composer.js +29 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/Composer.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/InspectorPane.d.ts +15 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/InspectorPane.js +27 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/InspectorPane.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/TalkView.d.ts +30 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/TalkView.js +60 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/TalkView.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/ThreadsPane.d.ts +17 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/ThreadsPane.js +61 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/ThreadsPane.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/data.d.ts +107 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/data.js +235 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/talk/data.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/theme/tokens.d.ts +8 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/theme/tokens.js +9 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/theme/tokens.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/ConfirmPane.d.ts +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/ConfirmPane.js +15 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/ConfirmPane.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/OutputPane.d.ts +5 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/OutputPane.js +16 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/OutputPane.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/PickerPane.d.ts +10 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/PickerPane.js +29 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/PickerPane.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/SheetPane.d.ts +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/SheetPane.js +22 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/SheetPane.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/package.json +2 -2
- package/package.json +4 -4
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/tabs.d.ts +0 -10
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/tabs.js +0 -19
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/tabs.js.map +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { AMBER, DIM, FAINT, FG, RED, TEAL, TEAL_DIM } from "../theme/tokens.js";
|
|
3
|
+
const TONE_COLOR = {
|
|
4
|
+
prompt: FG,
|
|
5
|
+
prose: DIM,
|
|
6
|
+
thinking: FAINT,
|
|
7
|
+
action: DIM,
|
|
8
|
+
"action-running": AMBER,
|
|
9
|
+
"action-error": RED,
|
|
10
|
+
body: FAINT,
|
|
11
|
+
"outcome-ok": TEAL,
|
|
12
|
+
"outcome-error": RED,
|
|
13
|
+
"outcome-cancelled": DIM,
|
|
14
|
+
hint: TEAL,
|
|
15
|
+
queued: FAINT,
|
|
16
|
+
spacer: FAINT,
|
|
17
|
+
};
|
|
18
|
+
export function SessionPane({ session, rows, cursor, scrollRef, }) {
|
|
19
|
+
return (_jsx("box", { title: ` ${session.backend} session · turn ${session.turn}${session.running ? " · running" : ""} `, style: {
|
|
20
|
+
border: true,
|
|
21
|
+
borderStyle: "rounded",
|
|
22
|
+
borderColor: session.running ? AMBER : TEAL_DIM,
|
|
23
|
+
flexDirection: "column",
|
|
24
|
+
// The transcript is the flexible region: flexBasis 0 keeps its
|
|
25
|
+
// content height from inflating the layout (the scrollbox clips).
|
|
26
|
+
flexGrow: 1,
|
|
27
|
+
flexShrink: 1,
|
|
28
|
+
flexBasis: 0,
|
|
29
|
+
minHeight: 4,
|
|
30
|
+
width: "100%",
|
|
31
|
+
paddingLeft: 1,
|
|
32
|
+
paddingRight: 1,
|
|
33
|
+
}, children: _jsx("scrollbox", { ref: scrollRef, style: { flexGrow: 1, flexShrink: 1, flexDirection: "column" }, children: rows.map((row, i) => {
|
|
34
|
+
const selected = row.isLabel && row.unit === cursor;
|
|
35
|
+
return (_jsx("text", { fg: selected ? FG : TONE_COLOR[row.tone], children: (selected ? "▸ " : " ") + (row.text || " ") }, i));
|
|
36
|
+
}) }) }));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=SessionPane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionPane.js","sourceRoot":"","sources":["../../../src/author/SessionPane.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEhF,MAAM,UAAU,GAA4B;IAC1C,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,GAAG;IACX,gBAAgB,EAAE,KAAK;IACvB,cAAc,EAAE,GAAG;IACnB,IAAI,EAAE,KAAK;IACX,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,GAAG;IACpB,mBAAmB,EAAE,GAAG;IACxB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,EAC1B,OAAO,EACP,IAAI,EACJ,MAAM,EACN,SAAS,GAMV;IACC,OAAO,CACL,cACE,KAAK,EAAE,IAAI,OAAO,CAAC,OAAO,mBAAmB,OAAO,CAAC,IAAI,GACvD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EACnC,GAAG,EACH,KAAK,EAAE;YACL,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;YAC/C,aAAa,EAAE,QAAQ;YACvB,+DAA+D;YAC/D,kEAAkE;YAClE,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,CAAC;YACZ,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;SAChB,YAED,oBACE,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,YAE7D,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;gBACnB,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC;gBACpD,OAAO,CACL,eAAc,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,YACnD,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IADpC,CAAC,CAEL,CACR,CAAC;YACJ,CAAC,CAAC,GACQ,GACR,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
3
|
+
import type { ValidationRecord } from "./data.js";
|
|
4
|
+
/**
|
|
5
|
+
* Structured validation results (TUI_DESIGN §8.4) — severity, location,
|
|
6
|
+
* message. Staleness is flagged when files changed after the run.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ValidationViewPane({ record, scrollRef, }: {
|
|
9
|
+
record?: ValidationRecord | undefined;
|
|
10
|
+
scrollRef?: RefObject<ScrollBoxRenderable | null> | undefined;
|
|
11
|
+
}): import("react").ReactNode;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { relativeTime } from "./data.js";
|
|
3
|
+
import { AMBER, DIM, FAINT, FG, RED, TEAL, TEAL_DIM } from "../theme/tokens.js";
|
|
4
|
+
/**
|
|
5
|
+
* Structured validation results (TUI_DESIGN §8.4) — severity, location,
|
|
6
|
+
* message. Staleness is flagged when files changed after the run.
|
|
7
|
+
*/
|
|
8
|
+
export function ValidationViewPane({ record, scrollRef, }) {
|
|
9
|
+
return (_jsx("box", { title: " validation ", style: {
|
|
10
|
+
border: true,
|
|
11
|
+
borderStyle: "rounded",
|
|
12
|
+
borderColor: TEAL_DIM,
|
|
13
|
+
flexDirection: "column",
|
|
14
|
+
flexGrow: 1,
|
|
15
|
+
minHeight: 0,
|
|
16
|
+
width: "100%",
|
|
17
|
+
paddingLeft: 1,
|
|
18
|
+
paddingRight: 1,
|
|
19
|
+
}, children: !record ? (_jsx("text", { fg: DIM, children: "Not run yet \u2014 press v to validate the local program." })) : (_jsxs(_Fragment, { children: [_jsx(ValidationHeader, { record: record }), _jsx("text", { children: " " }), record.result.findings.length === 0 ? (_jsx("text", { fg: DIM, children: "No findings." })) : (_jsx("scrollbox", { ref: scrollRef, style: {
|
|
20
|
+
flexGrow: 1,
|
|
21
|
+
flexShrink: 1,
|
|
22
|
+
flexBasis: 0,
|
|
23
|
+
minHeight: 2,
|
|
24
|
+
flexDirection: "column",
|
|
25
|
+
}, children: record.result.findings.map((finding, i) => (_jsxs("text", { children: [_jsx("span", { fg: finding.level === "warning" ? AMBER : RED, children: (finding.level ?? "error").toUpperCase().padEnd(8) }), _jsx("span", { fg: FAINT, children: finding.file || finding.code || finding.path }), " ", _jsx("span", { fg: FG, children: finding.message })] }, i))) })), _jsx("text", { fg: FAINT, style: { flexShrink: 0 }, children: "v re-run \u00B7 Esc back" })] })) }));
|
|
26
|
+
}
|
|
27
|
+
function ValidationHeader({ record }) {
|
|
28
|
+
const errors = record.result.findings.filter((f) => f.level !== "warning").length;
|
|
29
|
+
const warnings = record.result.findings.filter((f) => f.level === "warning").length;
|
|
30
|
+
const ok = record.result.valid && errors === 0;
|
|
31
|
+
const program = record.result.program;
|
|
32
|
+
return (_jsxs("text", { children: [_jsx("span", { fg: ok ? TEAL : RED, children: ok ? "✓ program valid" : `✕ ${errors} error(s)` }), warnings > 0 ? _jsxs("span", { fg: AMBER, children: [" \u00B7 ", warnings, " warning(s)"] }) : null, program?.id ? (_jsxs("span", { fg: DIM, children: [" ", "\u00B7 ", program.id, program.version ? `@${program.version}` : ""] })) : null, _jsxs("span", { fg: FAINT, children: [" \u00B7 ", relativeTime(record.at)] }), record.stale ? _jsx("span", { fg: AMBER, children: " \u00B7 stale \u2014 files changed since" }) : null] }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ValidationView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationView.js","sourceRoot":"","sources":["../../../src/author/ValidationView.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEhF;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,MAAM,EACN,SAAS,GAIV;IACC,OAAO,CACL,cACE,KAAK,EAAC,cAAc,EACpB,KAAK,EAAE;YACL,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,QAAQ;YACrB,aAAa,EAAE,QAAQ;YACvB,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;SAChB,YAEA,CAAC,MAAM,CAAC,CAAC,CAAC,CACT,eAAM,EAAE,EAAE,GAAG,0EAA6D,CAC3E,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,gBAAgB,IAAC,MAAM,EAAE,MAAM,GA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M,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;IACpF,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,KAAK,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IACtC,OAAO,CACL,2BACE,eAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,YACtB,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,MAAM,WAAW,GAC3C,EACN,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAM,EAAE,EAAE,KAAK,yBAAM,QAAQ,mBAAmB,CAAC,CAAC,CAAC,IAAI,EACtE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CACb,gBAAM,EAAE,EAAE,GAAG,aACV,GAAG,aACD,OAAO,CAAC,EAAE,EACZ,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IACxC,CACR,CAAC,CAAC,CAAC,IAAI,EACR,gBAAM,EAAE,EAAE,KAAK,yBAAM,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,IAAQ,EACnD,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,eAAM,EAAE,EAAE,KAAK,yDAAuC,CAAC,CAAC,CAAC,IAAI,IACxE,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import type { AgentVersion } from "@aui.io/apollo-core/api/management.js";
|
|
3
|
+
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
4
|
+
/** Version history subview — read-only; publish/archive live in ^K. */
|
|
5
|
+
export declare function VersionsViewPane({ versions, currentTag, scrollRef, }: {
|
|
6
|
+
versions: AgentVersion[];
|
|
7
|
+
currentTag: string;
|
|
8
|
+
scrollRef?: RefObject<ScrollBoxRenderable | null> | undefined;
|
|
9
|
+
}): import("react").ReactNode;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { AMBER, DIM, FAINT, FG, TEAL, TEAL_DIM } from "../theme/tokens.js";
|
|
3
|
+
const STATUS_COLOR = {
|
|
4
|
+
published: TEAL,
|
|
5
|
+
draft: AMBER,
|
|
6
|
+
archived: FAINT,
|
|
7
|
+
};
|
|
8
|
+
/** Version history subview — read-only; publish/archive live in ^K. */
|
|
9
|
+
export function VersionsViewPane({ versions, currentTag, scrollRef, }) {
|
|
10
|
+
return (_jsxs("box", { title: " versions ", style: {
|
|
11
|
+
border: true,
|
|
12
|
+
borderStyle: "rounded",
|
|
13
|
+
borderColor: TEAL_DIM,
|
|
14
|
+
flexDirection: "column",
|
|
15
|
+
flexGrow: 1,
|
|
16
|
+
minHeight: 0,
|
|
17
|
+
width: "100%",
|
|
18
|
+
paddingLeft: 1,
|
|
19
|
+
paddingRight: 1,
|
|
20
|
+
}, children: [versions.length === 0 ? (_jsx("text", { fg: DIM, children: "No versions yet \u2014 push to create the first draft." })) : (_jsx("scrollbox", { ref: scrollRef, style: {
|
|
21
|
+
flexGrow: 1,
|
|
22
|
+
flexShrink: 1,
|
|
23
|
+
flexBasis: 0,
|
|
24
|
+
minHeight: 2,
|
|
25
|
+
flexDirection: "column",
|
|
26
|
+
}, children: versions.map((version) => {
|
|
27
|
+
const bound = version.version_tag === currentTag;
|
|
28
|
+
return (_jsxs("text", { children: [_jsx("span", { fg: bound ? TEAL : FAINT, children: bound ? "● " : " " }), _jsx("span", { fg: bound ? FG : DIM, children: version.version_tag.padEnd(10) }), _jsx("span", { fg: STATUS_COLOR[version.status] ?? DIM, children: version.status.padEnd(11) }), _jsx("span", { fg: DIM, children: version.label ?? "" }), _jsx("span", { fg: FAINT, children: version.created_at ? ` ${version.created_at.slice(0, 10)}` : "" })] }, version.id));
|
|
29
|
+
}) })), _jsx("text", { fg: FAINT, style: { flexShrink: 0 }, children: "\u25CF bound tag \u00B7 publish/archive via ^K \u00B7 Esc back" })] }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=VersionsView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VersionsView.js","sourceRoot":"","sources":["../../../src/author/VersionsView.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,YAAY,GAA2B;IAC3C,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,SAAS,GAKV;IACC,OAAO,CACL,eACE,KAAK,EAAC,YAAY,EAClB,KAAK,EAAE;YACL,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,QAAQ;YACrB,aAAa,EAAE,QAAQ;YACvB,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;SAChB,aAEA,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CACvB,eAAM,EAAE,EAAE,GAAG,uEAA0D,CACxE,CAAC,CAAC,CAAC,CACF,oBACE,GAAG,EAAE,SAAS,EACd,KAAK,EAAE;oBACL,QAAQ,EAAE,CAAC;oBACX,UAAU,EAAE,CAAC;oBACb,SAAS,EAAE,CAAC;oBACZ,SAAS,EAAE,CAAC;oBACZ,aAAa,EAAE,QAAQ;iBACxB,YAEA,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;oBACxB,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,KAAK,UAAU,CAAC;oBACjD,OAAO,CACL,2BACE,eAAM,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,YAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAQ,EAC5D,eAAM,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,YACvB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,GAC1B,EACP,eAAM,EAAE,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,YAC1C,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,GACrB,EACP,eAAM,EAAE,EAAE,GAAG,YAAG,OAAO,CAAC,KAAK,IAAI,EAAE,GAAQ,EAC3C,eAAM,EAAE,EAAE,KAAK,YACZ,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAC5D,KAXE,OAAO,CAAC,EAAE,CAYd,CACR,CAAC;gBACJ,CAAC,CAAC,GACQ,CACb,EACD,eAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,+EAElC,IACH,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AuthorBackend, BackendEvent } from "./types.js";
|
|
2
|
+
/** File-work tools only — documented policy, revisit with Level 2 prompts. */
|
|
3
|
+
export declare const CLAUDE_ALLOWED_TOOLS: string[];
|
|
4
|
+
export declare function claudeArgs(text: string, sessionId?: string): string[];
|
|
5
|
+
export interface StreamParseState {
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Short human label for a tool call: "Edit — bundle/src/program.yaml". */
|
|
9
|
+
export declare function summarizeToolUse(name: string, input: Record<string, unknown> | undefined): {
|
|
10
|
+
label: string;
|
|
11
|
+
detail?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Map one stream-json line to normalized events. Tolerant: unknown or
|
|
15
|
+
* malformed lines yield nothing (vendor formats evolve).
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseClaudeLine(line: string, state: StreamParseState): BackendEvent[];
|
|
18
|
+
/**
|
|
19
|
+
* `claude --version` prints "2.1.220 (Claude Code)" — the UI already labels
|
|
20
|
+
* the backend, so the parenthetical would just repeat it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cleanVersionOutput(out: string): string | undefined;
|
|
23
|
+
export declare const claudeCodeBackend: AuthorBackend;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code adapter, Level 1 (TODO Phase 5) — headless CLI integration:
|
|
3
|
+
* `claude -p --output-format stream-json`, cwd pinned to the checkout,
|
|
4
|
+
* `--resume <id>` for per-checkout session continuity. Permission policy:
|
|
5
|
+
* `acceptEdits` + an explicit tool allowlist scoped to file work inside the
|
|
6
|
+
* checkout — no Bash, no network tools; in headless mode disallowed tools
|
|
7
|
+
* are simply unavailable to the agent (nothing can prompt).
|
|
8
|
+
*
|
|
9
|
+
* Everything the UI learns about file changes still comes from Apollo's own
|
|
10
|
+
* watcher/diff — backend-reported edits are rendered as activity, not truth.
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { createInterface } from "node:readline";
|
|
14
|
+
/** File-work tools only — documented policy, revisit with Level 2 prompts. */
|
|
15
|
+
export const CLAUDE_ALLOWED_TOOLS = [
|
|
16
|
+
"Read",
|
|
17
|
+
"Glob",
|
|
18
|
+
"Grep",
|
|
19
|
+
"LS",
|
|
20
|
+
"Edit",
|
|
21
|
+
"Write",
|
|
22
|
+
"MultiEdit",
|
|
23
|
+
"TodoWrite",
|
|
24
|
+
];
|
|
25
|
+
export function claudeArgs(text, sessionId) {
|
|
26
|
+
return [
|
|
27
|
+
"-p",
|
|
28
|
+
text,
|
|
29
|
+
"--output-format",
|
|
30
|
+
"stream-json",
|
|
31
|
+
"--verbose", // the CLI requires it for stream-json with -p
|
|
32
|
+
"--include-partial-messages", // token-level streaming (stream_event lines)
|
|
33
|
+
"--permission-mode",
|
|
34
|
+
"acceptEdits",
|
|
35
|
+
"--allowedTools",
|
|
36
|
+
CLAUDE_ALLOWED_TOOLS.join(","),
|
|
37
|
+
...(sessionId ? ["--resume", sessionId] : []),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
const INPUT_BODY_CAP = 30;
|
|
41
|
+
const RESULT_BODY_CAP = 60;
|
|
42
|
+
function capLines(lines, cap) {
|
|
43
|
+
if (lines.length <= cap)
|
|
44
|
+
return lines;
|
|
45
|
+
return [...lines.slice(0, cap), `… (${lines.length - cap} more lines)`];
|
|
46
|
+
}
|
|
47
|
+
/** Pretty tool input for the expandable unit body. */
|
|
48
|
+
function inputBody(input) {
|
|
49
|
+
if (!input || Object.keys(input).length === 0)
|
|
50
|
+
return [];
|
|
51
|
+
return capLines(JSON.stringify(input, null, 2).split("\n"), INPUT_BODY_CAP);
|
|
52
|
+
}
|
|
53
|
+
/** tool_result content arrives as a string or a list of text blocks. */
|
|
54
|
+
function resultBody(content) {
|
|
55
|
+
if (typeof content === "string") {
|
|
56
|
+
return capLines(content.split("\n"), RESULT_BODY_CAP);
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(content)) {
|
|
59
|
+
const lines = [];
|
|
60
|
+
for (const block of content) {
|
|
61
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
62
|
+
lines.push(...block.text.split("\n"));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return capLines(lines, RESULT_BODY_CAP);
|
|
66
|
+
}
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
/** Short human label for a tool call: "Edit — bundle/src/program.yaml". */
|
|
70
|
+
export function summarizeToolUse(name, input) {
|
|
71
|
+
const pick = (key) => {
|
|
72
|
+
const value = input?.[key];
|
|
73
|
+
return typeof value === "string" ? value : undefined;
|
|
74
|
+
};
|
|
75
|
+
const detail = pick("file_path") ??
|
|
76
|
+
pick("command") ??
|
|
77
|
+
pick("pattern") ??
|
|
78
|
+
pick("path") ??
|
|
79
|
+
pick("skill");
|
|
80
|
+
const short = detail && detail.length > 80 ? `${detail.slice(0, 77)}…` : detail;
|
|
81
|
+
return { label: name, ...(short ? { detail: short } : {}) };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Map one stream-json line to normalized events. Tolerant: unknown or
|
|
85
|
+
* malformed lines yield nothing (vendor formats evolve).
|
|
86
|
+
*/
|
|
87
|
+
export function parseClaudeLine(line, state) {
|
|
88
|
+
const trimmed = line.trim();
|
|
89
|
+
if (!trimmed.startsWith("{"))
|
|
90
|
+
return [];
|
|
91
|
+
let data;
|
|
92
|
+
try {
|
|
93
|
+
data = JSON.parse(trimmed);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
if (typeof data.session_id === "string")
|
|
99
|
+
state.sessionId = data.session_id;
|
|
100
|
+
// Partial-message stream (--include-partial-messages): Anthropic streaming
|
|
101
|
+
// events wrapped in stream_event lines. Deltas render live; the complete
|
|
102
|
+
// assistant message that follows is authoritative and replaces them.
|
|
103
|
+
if (data.type === "stream_event") {
|
|
104
|
+
const event = data.event;
|
|
105
|
+
if (event?.type === "content_block_start") {
|
|
106
|
+
const block = event.content_block;
|
|
107
|
+
if (block?.type === "tool_use" && block.name && block.id) {
|
|
108
|
+
return [{ type: "action-start", id: block.id, label: block.name }];
|
|
109
|
+
}
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
if (event?.type === "content_block_delta") {
|
|
113
|
+
const delta = event.delta;
|
|
114
|
+
if (delta?.type === "text_delta" && typeof delta.text === "string") {
|
|
115
|
+
return [{ type: "text-delta", text: delta.text }];
|
|
116
|
+
}
|
|
117
|
+
if (delta?.type === "thinking_delta" &&
|
|
118
|
+
typeof delta.thinking === "string") {
|
|
119
|
+
return [{ type: "thinking-delta", text: delta.thinking }];
|
|
120
|
+
}
|
|
121
|
+
return []; // input_json_delta etc. — the complete action carries the input
|
|
122
|
+
}
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
if (data.type === "assistant") {
|
|
126
|
+
const message = data.message;
|
|
127
|
+
const events = [];
|
|
128
|
+
for (const block of message?.content ?? []) {
|
|
129
|
+
if (block.type === "text" && block.text?.trim()) {
|
|
130
|
+
events.push({ type: "text", text: block.text });
|
|
131
|
+
}
|
|
132
|
+
else if (block.type === "tool_use" && block.name) {
|
|
133
|
+
const { label, detail } = summarizeToolUse(block.name, block.input);
|
|
134
|
+
const body = inputBody(block.input);
|
|
135
|
+
events.push({
|
|
136
|
+
type: "action",
|
|
137
|
+
label,
|
|
138
|
+
...(block.id ? { id: block.id } : {}),
|
|
139
|
+
...(detail ? { detail } : {}),
|
|
140
|
+
...(body.length > 0 ? { body } : {}),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return events;
|
|
145
|
+
}
|
|
146
|
+
// Tool results ride on user messages; they complete the matching action.
|
|
147
|
+
if (data.type === "user") {
|
|
148
|
+
const message = data.message;
|
|
149
|
+
const events = [];
|
|
150
|
+
for (const block of message?.content ?? []) {
|
|
151
|
+
if (block.type === "tool_result" && typeof block.tool_use_id === "string") {
|
|
152
|
+
events.push({
|
|
153
|
+
type: "action-result",
|
|
154
|
+
id: block.tool_use_id,
|
|
155
|
+
body: resultBody(block.content),
|
|
156
|
+
ok: block.is_error !== true,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return events;
|
|
161
|
+
}
|
|
162
|
+
if (data.type === "result") {
|
|
163
|
+
const isError = data.is_error === true ||
|
|
164
|
+
(typeof data.subtype === "string" && data.subtype !== "success");
|
|
165
|
+
if (isError) {
|
|
166
|
+
const message = (typeof data.result === "string" && data.result) ||
|
|
167
|
+
(typeof data.error === "string" && data.error) ||
|
|
168
|
+
`claude result: ${typeof data.subtype === "string" ? data.subtype : "error"}`;
|
|
169
|
+
return [{ type: "error", message }];
|
|
170
|
+
}
|
|
171
|
+
const parts = [];
|
|
172
|
+
if (typeof data.num_turns === "number")
|
|
173
|
+
parts.push(`${data.num_turns} turns`);
|
|
174
|
+
if (typeof data.duration_ms === "number") {
|
|
175
|
+
parts.push(`${Math.round(data.duration_ms / 1000)}s`);
|
|
176
|
+
}
|
|
177
|
+
if (typeof data.total_cost_usd === "number") {
|
|
178
|
+
parts.push(`$${data.total_cost_usd.toFixed(2)}`);
|
|
179
|
+
}
|
|
180
|
+
return [
|
|
181
|
+
{
|
|
182
|
+
type: "done",
|
|
183
|
+
...(state.sessionId ? { sessionId: state.sessionId } : {}),
|
|
184
|
+
...(parts.length > 0 ? { summary: parts.join(" · ") } : {}),
|
|
185
|
+
},
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
// system/init (session capture above), user/tool_result — no UI event.
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
const DETECT_TIMEOUT_MS = 4000;
|
|
192
|
+
/**
|
|
193
|
+
* `claude --version` prints "2.1.220 (Claude Code)" — the UI already labels
|
|
194
|
+
* the backend, so the parenthetical would just repeat it.
|
|
195
|
+
*/
|
|
196
|
+
export function cleanVersionOutput(out) {
|
|
197
|
+
const version = out.trim().replace(/\s*\(claude code\)\s*$/i, "");
|
|
198
|
+
return version || undefined;
|
|
199
|
+
}
|
|
200
|
+
export const claudeCodeBackend = {
|
|
201
|
+
id: "claude-code",
|
|
202
|
+
label: "Claude Code",
|
|
203
|
+
capabilities: {
|
|
204
|
+
streaming: true, // coarse (per message/tool event) but real
|
|
205
|
+
cancel: true, // SIGTERM the headless process
|
|
206
|
+
permissionPrompts: false, // Level 2 (agent SDK canUseTool)
|
|
207
|
+
sessionResume: true,
|
|
208
|
+
},
|
|
209
|
+
detect() {
|
|
210
|
+
return new Promise((resolve) => {
|
|
211
|
+
const child = spawn("claude", ["--version"], {
|
|
212
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
213
|
+
});
|
|
214
|
+
let out = "";
|
|
215
|
+
const timer = setTimeout(() => {
|
|
216
|
+
child.kill("SIGKILL");
|
|
217
|
+
resolve({ available: false, reason: "claude --version timed out" });
|
|
218
|
+
}, DETECT_TIMEOUT_MS);
|
|
219
|
+
child.stdout.on("data", (chunk) => (out += chunk.toString()));
|
|
220
|
+
child.on("error", (error) => {
|
|
221
|
+
clearTimeout(timer);
|
|
222
|
+
resolve({
|
|
223
|
+
available: false,
|
|
224
|
+
reason: error.code === "ENOENT"
|
|
225
|
+
? "claude CLI not found on PATH — install Claude Code (https://claude.com/claude-code)"
|
|
226
|
+
: error.message,
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
child.on("close", (code) => {
|
|
230
|
+
clearTimeout(timer);
|
|
231
|
+
if (code === 0) {
|
|
232
|
+
resolve({ available: true, version: cleanVersionOutput(out) });
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
resolve({ available: false, reason: `claude --version exited ${code ?? "?"}` });
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
startTurn({ checkoutDir, text, sessionId, onEvent }) {
|
|
241
|
+
const child = spawn("claude", claudeArgs(text, sessionId), {
|
|
242
|
+
cwd: checkoutDir,
|
|
243
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
244
|
+
});
|
|
245
|
+
const state = {};
|
|
246
|
+
let terminal = false;
|
|
247
|
+
let stderrTail = "";
|
|
248
|
+
const emit = (event) => {
|
|
249
|
+
if (terminal)
|
|
250
|
+
return;
|
|
251
|
+
if (event.type === "done" || event.type === "error")
|
|
252
|
+
terminal = true;
|
|
253
|
+
onEvent(event);
|
|
254
|
+
};
|
|
255
|
+
const lines = createInterface({ input: child.stdout });
|
|
256
|
+
lines.on("line", (line) => {
|
|
257
|
+
for (const event of parseClaudeLine(line, state))
|
|
258
|
+
emit(event);
|
|
259
|
+
});
|
|
260
|
+
child.stderr.on("data", (chunk) => {
|
|
261
|
+
stderrTail = (stderrTail + chunk.toString()).slice(-500);
|
|
262
|
+
});
|
|
263
|
+
child.on("error", (error) => {
|
|
264
|
+
emit({
|
|
265
|
+
type: "error",
|
|
266
|
+
message: error.code === "ENOENT"
|
|
267
|
+
? "claude CLI not found on PATH — install Claude Code (https://claude.com/claude-code)"
|
|
268
|
+
: error.message,
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
child.on("close", (code) => {
|
|
272
|
+
// If stream-json already delivered the terminal event this is a no-op.
|
|
273
|
+
if (code === 0) {
|
|
274
|
+
emit({
|
|
275
|
+
type: "done",
|
|
276
|
+
...(state.sessionId ? { sessionId: state.sessionId } : {}),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
emit({
|
|
281
|
+
type: "error",
|
|
282
|
+
message: `claude exited ${code ?? "by signal"}${stderrTail.trim() ? ` — ${stderrTail.trim()}` : ""}`,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
return {
|
|
287
|
+
cancel: () => {
|
|
288
|
+
child.kill("SIGTERM");
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
//# sourceMappingURL=claudeCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeCode.js","sourceRoot":"","sources":["../../../../src/author/backend/claudeCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM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AAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC3D,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC;oBACH,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,iBAAiB,IAAI,IAAI,WAAW,GAC3C,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAClD,EAAE;iBACH,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,MAAM,EAAE,GAAG,EAAE;gBACX,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACxB,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AuthorBackend } from "./types.js";
|
|
2
|
+
export declare const AUTHOR_BACKENDS: AuthorBackend[];
|
|
3
|
+
export declare function resolveAuthorBackend(id?: string | undefined): AuthorBackend;
|
|
4
|
+
export type { AuthorBackend, BackendCapabilities, BackendDetection, BackendEvent, TurnHandle, TurnOptions, } from "./types.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author backend registry. One entry today (Claude Code); the seam and the
|
|
3
|
+
* env override exist so adding Codex / Apollo Author API is additive.
|
|
4
|
+
* Config-file selection (`author.backend`) + a palette switch action are
|
|
5
|
+
* deferred until a second backend exists — a switcher over one option is
|
|
6
|
+
* noise.
|
|
7
|
+
*/
|
|
8
|
+
import { claudeCodeBackend } from "./claudeCode.js";
|
|
9
|
+
export const AUTHOR_BACKENDS = [claudeCodeBackend];
|
|
10
|
+
export function resolveAuthorBackend(id = process.env.APOLLO_AUTHOR_BACKEND) {
|
|
11
|
+
return AUTHOR_BACKENDS.find((b) => b.id === id) ?? claudeCodeBackend;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/author/backend/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,MAAM,CAAC,MAAM,eAAe,GAAoB,CAAC,iBAAiB,CAAC,CAAC;AAEpE,MAAM,UAAU,oBAAoB,CAClC,KAAyB,OAAO,CAAC,GAAG,CAAC,qBAAqB;IAE1D,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,iBAAiB,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-checkout author session identity (TODO Phase 5): checkout dir →
|
|
3
|
+
* backend session id, persisted under ~/.apollo so a TUI restart resumes
|
|
4
|
+
* the same conversation for the same checkout.
|
|
5
|
+
*/
|
|
6
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
export function defaultSessionsFile() {
|
|
10
|
+
return path.join(homedir(), ".apollo", "author-sessions.json");
|
|
11
|
+
}
|
|
12
|
+
export async function loadSessions(file = defaultSessionsFile()) {
|
|
13
|
+
try {
|
|
14
|
+
const raw = await readFile(file, "utf8");
|
|
15
|
+
const data = JSON.parse(raw);
|
|
16
|
+
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
17
|
+
const out = {};
|
|
18
|
+
for (const [key, value] of Object.entries(data)) {
|
|
19
|
+
if (typeof value === "string")
|
|
20
|
+
out[key] = value;
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Missing or corrupt file — start clean.
|
|
27
|
+
}
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
export async function saveSession(checkoutDir, sessionId, file = defaultSessionsFile()) {
|
|
31
|
+
const sessions = await loadSessions(file);
|
|
32
|
+
sessions[checkoutDir] = sessionId;
|
|
33
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
34
|
+
await writeFile(file, `${JSON.stringify(sessions, null, 2)}\n`, "utf8");
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../../src/author/backend/sessions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,sBAAsB,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAI,GAAG,mBAAmB,EAAE;IAE5B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACzC,MAAM,IAAI,GAAY,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7D,MAAM,GAAG,GAA2B,EAAE,CAAC;YACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChD,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAClD,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;IAC3C,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,WAAmB,EACnB,SAAiB,EACjB,IAAI,GAAG,mBAAmB,EAAE;IAE5B,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;IAClC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AuthorBackend seam (TUI_DESIGN §9, TODO Phase 5).
|
|
3
|
+
*
|
|
4
|
+
* The TUI talks only to this interface — never to a vendor CLI/SDK
|
|
5
|
+
* directly. Backends are replaceable by design (Claude Code today; Codex,
|
|
6
|
+
* Apollo Author API later): the UI renders only the normalized event
|
|
7
|
+
* vocabulary below, and capability gaps degrade honestly — a backend
|
|
8
|
+
* without streaming shows a pending state, never fake streaming.
|
|
9
|
+
*/
|
|
10
|
+
export interface BackendDetection {
|
|
11
|
+
available: boolean;
|
|
12
|
+
version?: string;
|
|
13
|
+
/** When unavailable: why, plus an install hint. */
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface BackendCapabilities {
|
|
17
|
+
/** Emits incremental events during a turn (may be coarse-grained). */
|
|
18
|
+
streaming: boolean;
|
|
19
|
+
cancel: boolean;
|
|
20
|
+
/** Can surface interactive permission prompts (Level 2). */
|
|
21
|
+
permissionPrompts: boolean;
|
|
22
|
+
sessionResume: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Normalized event vocabulary — everything the UI knows how to render.
|
|
26
|
+
* Adapters guarantee exactly one terminal event (`done` or `error`).
|
|
27
|
+
*
|
|
28
|
+
* `action` is one unit of backend work (a tool call: Bash, Edit, Skill, …);
|
|
29
|
+
* `id` correlates `action-start`/`action-result` to it, and `body` carries
|
|
30
|
+
* the expandable payload (tool input). Streaming backends additionally emit
|
|
31
|
+
* `text-delta`/`thinking-delta` fragments and `action-start` notices; the
|
|
32
|
+
* later complete `text`/`action` events are authoritative and replace the
|
|
33
|
+
* accumulated fragments (no duplicates). Backends without streaming or
|
|
34
|
+
* correlation ids degrade to complete-block, non-expandable units.
|
|
35
|
+
*/
|
|
36
|
+
export type BackendEvent = {
|
|
37
|
+
type: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "text-delta";
|
|
41
|
+
text: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: "thinking-delta";
|
|
44
|
+
text: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: "action-start";
|
|
47
|
+
id: string;
|
|
48
|
+
label: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: "action";
|
|
51
|
+
id?: string;
|
|
52
|
+
label: string;
|
|
53
|
+
detail?: string;
|
|
54
|
+
body?: string[];
|
|
55
|
+
} | {
|
|
56
|
+
type: "action-result";
|
|
57
|
+
id: string;
|
|
58
|
+
body: string[];
|
|
59
|
+
ok: boolean;
|
|
60
|
+
} | {
|
|
61
|
+
type: "error";
|
|
62
|
+
message: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "done";
|
|
65
|
+
sessionId?: string;
|
|
66
|
+
summary?: string;
|
|
67
|
+
};
|
|
68
|
+
export interface TurnOptions {
|
|
69
|
+
/** Agent checkout the backend may read and edit (its cwd). */
|
|
70
|
+
checkoutDir: string;
|
|
71
|
+
text: string;
|
|
72
|
+
/** Resume a previous per-checkout conversation when supported. */
|
|
73
|
+
sessionId?: string;
|
|
74
|
+
onEvent: (event: BackendEvent) => void;
|
|
75
|
+
}
|
|
76
|
+
export interface TurnHandle {
|
|
77
|
+
cancel(): void;
|
|
78
|
+
}
|
|
79
|
+
export interface AuthorBackend {
|
|
80
|
+
id: string;
|
|
81
|
+
label: string;
|
|
82
|
+
capabilities: BackendCapabilities;
|
|
83
|
+
detect(): Promise<BackendDetection>;
|
|
84
|
+
startTurn(options: TurnOptions): TurnHandle;
|
|
85
|
+
}
|