akanjs 3.2.0-rc.12 → 3.2.0-rc.13
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/ARCHITECTURE.md +17 -17
- package/CHANGELOG.md +18 -0
- package/client/csrTypes.ts +2 -0
- package/client/index.ts +1 -0
- package/client/route/RouteDefinition.ts +24 -7
- package/client/route/routeArgs.ts +7 -0
- package/client/router.ts +12 -2
- package/package.json +1 -1
- package/server/akanApp.ts +103 -1270
- package/server/akanServer.ts +1 -1
- package/server/gateway/childSupervisor.ts +325 -0
- package/server/gateway/devHostChannel.ts +40 -0
- package/server/gateway/gatewayChildren.ts +135 -0
- package/server/gateway/gatewayConfig.ts +182 -0
- package/server/gateway/gatewayHttpProxy.ts +231 -0
- package/server/gateway/gatewayLogging.ts +111 -0
- package/server/gateway/gatewayRooms.ts +134 -0
- package/server/gateway/gatewayStatus.ts +116 -0
- package/server/gateway/gatewayStatusPage.ts +54 -0
- package/server/gateway/gatewayWebSocketRelay.ts +149 -0
- package/server/mcp/McpDispatcher.ts +6 -24
- package/signal/SignalFailure.ts +21 -0
- package/signal/agentTurnStream.ts +5 -2
- package/types/client/csrTypes.d.ts +2 -0
- package/types/client/index.d.ts +1 -1
- package/types/client/route/RouteDefinition.d.ts +2 -2
- package/types/client/route/routeArgs.d.ts +6 -0
- package/types/client/router.d.ts +2 -1
- package/types/server/akanApp.d.ts +2 -20
- package/types/server/gateway/childSupervisor.d.ts +33 -0
- package/types/server/gateway/devHostChannel.d.ts +13 -0
- package/types/server/gateway/gatewayChildren.d.ts +47 -0
- package/types/server/gateway/gatewayConfig.d.ts +82 -0
- package/types/server/gateway/gatewayHttpProxy.d.ts +22 -0
- package/types/server/gateway/gatewayLogging.d.ts +16 -0
- package/types/server/gateway/gatewayRooms.d.ts +22 -0
- package/types/server/gateway/gatewayStatus.d.ts +62 -0
- package/types/server/gateway/gatewayStatusPage.d.ts +9 -0
- package/types/server/gateway/gatewayWebSocketRelay.d.ts +17 -0
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/signal/SignalFailure.d.ts +1 -0
- package/types/signal/agentTurnStream.d.ts +1 -0
- package/types/ui/Agent/Chat.d.ts +5 -2
- package/types/ui/Agent/ChatHeader.d.ts +13 -0
- package/types/ui/Agent/ChatPendingCards.d.ts +23 -0
- package/types/ui/overlayLayer.d.ts +6 -1
- package/types/vendor/@akanjs/native/packages/cli/src/lib/project.d.ts +4 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/relaunch.d.ts +1 -0
- package/types/vendor/@akanjs/native/plugins/external-view/src/index.d.ts +14 -10
- package/types/vendor/use-agentic/failureCode.d.ts +4 -0
- package/types/vendor/use-agentic/types.d.ts +6 -0
- package/types/webkit/CsrGuards.d.ts +2 -0
- package/ui/Agent/Chat.tsx +96 -116
- package/ui/Agent/ChatHeader.tsx +59 -0
- package/ui/Agent/ChatPendingCards.tsx +49 -0
- package/ui/Agent/fetchRunner.ts +8 -1
- package/ui/BottomSheet.tsx +1 -1
- package/ui/Dialog/LegacyModal.tsx +1 -1
- package/ui/Dialog/Modal.tsx +1 -1
- package/ui/Popconfirm.tsx +1 -1
- package/ui/overlayLayer.ts +22 -1
- package/vendor/@akanjs/native/CHANGELOG.md +6 -1
- package/vendor/@akanjs/native/native/desktop/src/external.rs +213 -111
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +12 -4
- package/vendor/@akanjs/native/native/desktop/src/linux/external.rs +275 -0
- package/vendor/@akanjs/native/native/desktop/src/linux/mod.rs +1 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/native-plugins.ts +5 -3
- package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +25 -1
- package/vendor/@akanjs/native/packages/desktop/src/deeplinks.ts +2 -2
- package/vendor/@akanjs/native/packages/desktop/src/host.ts +2 -2
- package/vendor/@akanjs/native/packages/desktop/src/relaunch.ts +8 -3
- package/vendor/@akanjs/native/plugins/app/src/desktop.ts +2 -2
- package/vendor/@akanjs/native/plugins/autostart/src/desktop.ts +2 -1
- package/vendor/@akanjs/native/plugins/external-view/native-plugin.json +4 -1
- package/vendor/@akanjs/native/plugins/external-view/src/index.ts +14 -10
- package/vendor/use-agentic/AgentSession.ts +11 -11
- package/vendor/use-agentic/CHANGELOG.md +6 -0
- package/vendor/use-agentic/Compaction.ts +2 -1
- package/vendor/use-agentic/ToolRunner.ts +3 -15
- package/vendor/use-agentic/Transcript.ts +6 -3
- package/vendor/use-agentic/WIRE.md +12 -1
- package/vendor/use-agentic/failureCode.ts +44 -0
- package/vendor/use-agentic/httpRunner.ts +14 -3
- package/vendor/use-agentic/types.ts +6 -0
- package/webkit/CsrGuards.ts +7 -2
- package/webkit/useLocation.ts +3 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePage } from "akanjs/client";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { AiOutlineClear, AiOutlineClose } from "react-icons/ai";
|
|
5
|
+
import { tokenCount } from "./tokenCount";
|
|
6
|
+
|
|
7
|
+
export interface ChatHeaderProps {
|
|
8
|
+
title?: ReactNode;
|
|
9
|
+
running: boolean;
|
|
10
|
+
context: { used: number; compactAt?: number };
|
|
11
|
+
controls?: ReactNode;
|
|
12
|
+
onClear?: () => void;
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ChatHeader = ({ title, running, context, controls, onClear, onClose }: ChatHeaderProps) => {
|
|
17
|
+
const { l } = usePage();
|
|
18
|
+
return (
|
|
19
|
+
<header className="flex items-center gap-2 border-border border-b px-4 py-3" data-slot="agent-header">
|
|
20
|
+
<span className="font-semibold text-sm" data-slot="agent-title">
|
|
21
|
+
{title ?? l("base.agent")}
|
|
22
|
+
</span>
|
|
23
|
+
{running ? <span className="size-2 animate-pulse rounded-full bg-primary" data-slot="agent-running" /> : null}
|
|
24
|
+
{context.used ? (
|
|
25
|
+
<span
|
|
26
|
+
className="shrink-0 whitespace-nowrap text-[10px] text-foreground/40"
|
|
27
|
+
title={context.compactAt ? l("base.agentCompactsAt", { limit: tokenCount(context.compactAt) }) : undefined}
|
|
28
|
+
>
|
|
29
|
+
{context.compactAt
|
|
30
|
+
? l("base.agentTokensOf", { count: tokenCount(context.used), limit: tokenCount(context.compactAt) })
|
|
31
|
+
: l("base.agentTokens", { count: tokenCount(context.used) })}
|
|
32
|
+
</span>
|
|
33
|
+
) : null}
|
|
34
|
+
<span className="ml-auto flex items-center gap-2">
|
|
35
|
+
{controls}
|
|
36
|
+
{onClear ? (
|
|
37
|
+
<button
|
|
38
|
+
aria-label={l("base.agentClear")}
|
|
39
|
+
className="text-foreground/50 hover:text-foreground"
|
|
40
|
+
onClick={onClear}
|
|
41
|
+
type="button"
|
|
42
|
+
>
|
|
43
|
+
<AiOutlineClear />
|
|
44
|
+
</button>
|
|
45
|
+
) : null}
|
|
46
|
+
{onClose ? (
|
|
47
|
+
<button
|
|
48
|
+
aria-label={l("base.cancel")}
|
|
49
|
+
className="text-foreground/50 hover:text-foreground"
|
|
50
|
+
onClick={onClose}
|
|
51
|
+
type="button"
|
|
52
|
+
>
|
|
53
|
+
<AiOutlineClose />
|
|
54
|
+
</button>
|
|
55
|
+
) : null}
|
|
56
|
+
</span>
|
|
57
|
+
</header>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import type { AgentSession } from "../../vendor/use-agentic";
|
|
4
|
+
import { OverlayPortalProvider, overlayZ, useHoldsScrim } from "../overlayLayer";
|
|
5
|
+
import Approval from "./Approval";
|
|
6
|
+
import Question from "./Question";
|
|
7
|
+
import ToolCard from "./ToolCard";
|
|
8
|
+
|
|
9
|
+
export const isAsking = (session: AgentSession) =>
|
|
10
|
+
!!(session.pendingApproval || session.pendingCard || session.pendingQuestion);
|
|
11
|
+
|
|
12
|
+
export const ChatPendingCards = ({ session, portal }: { session: AgentSession; portal: HTMLElement | null }) => (
|
|
13
|
+
<OverlayPortalProvider value={portal}>
|
|
14
|
+
{session.pendingApproval ? <Approval approval={session.pendingApproval} /> : null}
|
|
15
|
+
{session.pendingCard ? <ToolCard card={session.pendingCard} key={session.pendingCard.callId} /> : null}
|
|
16
|
+
{session.pendingQuestion ? (
|
|
17
|
+
<Question key={session.pendingQuestion.callId} question={session.pendingQuestion} />
|
|
18
|
+
) : null}
|
|
19
|
+
</OverlayPortalProvider>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const host = "fixed top-0 left-0 size-0";
|
|
23
|
+
|
|
24
|
+
export const usePanelOverlays = () => {
|
|
25
|
+
const [layer, onLayer] = useState<HTMLElement | null>(null);
|
|
26
|
+
const [cardLayer, onCardLayer] = useState<HTMLElement | null>(null);
|
|
27
|
+
return { layer, cardLayer, hosts: { layer, onLayer, onCardLayer } };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
interface PanelOverlayHostsProps {
|
|
31
|
+
asking: boolean;
|
|
32
|
+
layer: HTMLElement | null;
|
|
33
|
+
onLayer: (layer: HTMLElement | null) => void;
|
|
34
|
+
onCardLayer: (layer: HTMLElement | null) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const PanelOverlayHosts = ({ asking, layer, onLayer, onCardLayer }: PanelOverlayHostsProps) => {
|
|
38
|
+
const sunk = useHoldsScrim(layer) && asking;
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<div
|
|
42
|
+
className={host}
|
|
43
|
+
ref={onLayer}
|
|
44
|
+
style={{ zIndex: sunk ? overlayZ.agentPanelOverlaySunk : overlayZ.agentPanelOverlay }}
|
|
45
|
+
/>
|
|
46
|
+
<div className={host} ref={onCardLayer} style={{ zIndex: overlayZ.agentPanelCardOverlay }} />
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
};
|
package/ui/Agent/fetchRunner.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getEnv } from "akanjs/base";
|
|
2
2
|
import { fetch, Translator } from "akanjs/client";
|
|
3
|
+
import { FailureCode } from "akanjs/common";
|
|
3
4
|
import { type AgentRunner, httpRunner, type RunnerEvent } from "../../vendor/use-agentic";
|
|
4
5
|
|
|
5
6
|
const errorKey = /^[a-zA-Z][A-Za-z0-9]*\.error\.[A-Za-z0-9_]+$/;
|
|
@@ -8,7 +9,13 @@ const readable = (event: RunnerEvent): RunnerEvent => {
|
|
|
8
9
|
if (event.type !== "error" || !errorKey.test(event.message)) return event;
|
|
9
10
|
const text = Translator.translateByLocale(Translator.getActiveLocale() ?? "en", event.message, event.data);
|
|
10
11
|
if (text === event.message) return event;
|
|
11
|
-
|
|
12
|
+
const code = event.code ?? (FailureCode.isKey(event.message) ? event.message : undefined);
|
|
13
|
+
return {
|
|
14
|
+
type: "error",
|
|
15
|
+
message: text,
|
|
16
|
+
...(code ? { code } : {}),
|
|
17
|
+
...(event.overflow ? { overflow: event.overflow } : {}),
|
|
18
|
+
};
|
|
12
19
|
};
|
|
13
20
|
|
|
14
21
|
/** Runs each turn against `<serverHttpUri>/runAgentTurn` (service signals mount unprefixed) through `httpRunner`. */
|
package/ui/BottomSheet.tsx
CHANGED
|
@@ -55,7 +55,7 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
55
55
|
const ref = useRef<HTMLDivElement>(null);
|
|
56
56
|
const shown = useRef(false);
|
|
57
57
|
const portal = useOverlayPortal();
|
|
58
|
-
const overlayLayerProps = useOverlayLayerProps();
|
|
58
|
+
const overlayLayerProps = useOverlayLayerProps(true);
|
|
59
59
|
|
|
60
60
|
const isCurrentPage = usePageActivity() === "current";
|
|
61
61
|
const [root, setRoot] = useState<HTMLDivElement | null>(null);
|
|
@@ -37,7 +37,7 @@ export const LegacyModal = ({ className, bodyClassName, confirmClose, children,
|
|
|
37
37
|
const focusedElementRef = useRef<HTMLElement | null>(null);
|
|
38
38
|
const titleId = useId();
|
|
39
39
|
const contentId = useId();
|
|
40
|
-
const overlayLayerProps = useOverlayLayerProps();
|
|
40
|
+
const overlayLayerProps = useOverlayLayerProps(true);
|
|
41
41
|
const [{ translate }, api] = useSpring(() => ({ translate: 1 }));
|
|
42
42
|
const portalElement = useOverlayPortal();
|
|
43
43
|
const isCurrentPage = usePageActivity() === "current";
|
package/ui/Dialog/Modal.tsx
CHANGED
|
@@ -39,7 +39,7 @@ export const Modal = ({
|
|
|
39
39
|
const focusedElementRef = useRef<HTMLElement | null>(null);
|
|
40
40
|
const titleId = useId();
|
|
41
41
|
const contentId = useId();
|
|
42
|
-
const overlayLayerProps = useOverlayLayerProps();
|
|
42
|
+
const overlayLayerProps = useOverlayLayerProps(true);
|
|
43
43
|
const portalElement = useOverlayPortal();
|
|
44
44
|
|
|
45
45
|
const isCurrentPage = usePageActivity() === "current";
|
package/ui/Popconfirm.tsx
CHANGED
|
@@ -54,7 +54,7 @@ export const DefaultPopconfirm = ({
|
|
|
54
54
|
const portal = useOverlayPortal();
|
|
55
55
|
const triggerRef = useRef<HTMLDivElement>(null);
|
|
56
56
|
const panelRef = useRef<HTMLDivElement>(null);
|
|
57
|
-
const overlayLayerProps = useOverlayLayerProps();
|
|
57
|
+
const overlayLayerProps = useOverlayLayerProps(true);
|
|
58
58
|
const position = useOverlayPosition({
|
|
59
59
|
opened: isConfirming,
|
|
60
60
|
triggerRef,
|
package/ui/overlayLayer.ts
CHANGED
|
@@ -14,10 +14,28 @@ export const overlayZ = {
|
|
|
14
14
|
modal: 120,
|
|
15
15
|
approval: 130,
|
|
16
16
|
toast: 140,
|
|
17
|
+
agentPanelOverlaySunk: 145,
|
|
17
18
|
agentPanel: 150,
|
|
19
|
+
agentPanelOverlay: 160,
|
|
20
|
+
agentPanelCardOverlay: 170,
|
|
18
21
|
reconnect: 200,
|
|
19
22
|
} as const;
|
|
20
23
|
|
|
24
|
+
const OVERLAY_SCRIM_ATTR = "data-akan-scrim";
|
|
25
|
+
|
|
26
|
+
export const useHoldsScrim = (layer: HTMLElement | null) => {
|
|
27
|
+
const [holds, setHolds] = useState(false);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!layer) return;
|
|
30
|
+
const read = () => setHolds(!!layer.querySelector(`[${OVERLAY_SCRIM_ATTR}]`));
|
|
31
|
+
read();
|
|
32
|
+
const observer = new MutationObserver(read);
|
|
33
|
+
observer.observe(layer, { childList: true, subtree: true });
|
|
34
|
+
return () => observer.disconnect();
|
|
35
|
+
}, [layer]);
|
|
36
|
+
return holds;
|
|
37
|
+
};
|
|
38
|
+
|
|
21
39
|
const OverlayOwnerContext = sharedContext("overlayOwner", "");
|
|
22
40
|
|
|
23
41
|
/** Takes the scope from {@link useOverlayScope}. */
|
|
@@ -30,7 +48,10 @@ export const useOverlayScope = (id: string) => {
|
|
|
30
48
|
};
|
|
31
49
|
|
|
32
50
|
/** Spread onto every root an overlay portals out of its own tree. */
|
|
33
|
-
export const useOverlayLayerProps = () => ({
|
|
51
|
+
export const useOverlayLayerProps = (scrim = false) => ({
|
|
52
|
+
[OVERLAY_LAYER_ATTR]: useContext(OverlayOwnerContext),
|
|
53
|
+
...(scrim ? { [OVERLAY_SCRIM_ATTR]: "" } : null),
|
|
54
|
+
});
|
|
34
55
|
|
|
35
56
|
/** True when the click landed in an overlay `scope`, or a scope nested in it, rendered; any other is outside. */
|
|
36
57
|
export const isOwnOverlayClick = (target: EventTarget | null, scope: string) => {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# @akanjs/native
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b602e5e: The `external-view` plugin now works on Linux, on Wayland as well as X11. A view lies over the window's page at its bounds, with a browser profile of its own; its top level stays on the origins it was opened for while its frames load web content from anywhere, and its init script runs in the top document only. A failed load off those origins shows no error page there, a page's `window.close()` leaves the view in place, a hidden view stays hidden when the window is shown again, and an unattended app's views open no file chooser or print dialog. `capture` returns a PNG of the view's content, and `setMuted`, `clearData`, `loadFailed` (`http<status>`, `cannotConnect`, `hostNameNotResolved`, `timeout`, `certificate`, …) and `gone` (`crashed`, `killed` or `oom`; the view loads its page again by itself) work as on Windows. Linux has no `sendKey`: the visible view shown last holds the keyboard focus inside its window — on open, when shown, after a navigation, a reload or a restart, and when the window is focused again — and the page takes it back when the view is hidden or closed. Linux sends no `consoleMessage`: the `console` option is accepted and does nothing there. A plugin's `desktop` entry can now leave methods out of one desktop OS with `"unsupported": { "linux": [...] }`, so `isSupported()` answers per OS: `external-view` now reports `sendKey` unsupported on Linux, and `sendKey`, `setMuted` and `capture` unsupported on macOS, where the shell already refused them.
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
11
|
+
- 66e6074: `app.relaunch()` and the desktop recovery's relaunch now start an AppImage again from its own file (`$APPIMAGE`) instead of the mount it ran from, which is gone once the app exits, so the app no longer quits without coming back. The relaunched app no longer inherits the old mount's `APPDIR`, `APPIMAGE`, `ARGV0` and `OWD`; its AppImage runtime sets them anew. An app that another AppImage started (an AppImage editor or launcher, say) inherits that AppImage's `APPIMAGE`; relaunch, the deep-link handler and the autostart entry now use `$APPIMAGE` only when the app runs from that AppImage's own mount, so such an app no longer registers the other AppImage in its place.
|
|
7
12
|
- e3de9ef: Native and desktop builds now ship tighter defaults for page content, external links, temporary files and installed updates.
|
|
8
13
|
|
|
9
14
|
- **A content security policy by default.** An Akan app's native build puts a Content-Security-Policy in its `index.html`: scripts from `'self'` only (inline ones by hash), connections to `'self'` and any `https:` or `wss:` origin, `https:` images, media, fonts, stylesheets and frames, inline styles, and the plain-`http:` origins the build knows of (an `http:` `AKAN_PUBLIC_SERVER_URL`, `http://localhost:*` in local mode, the carried server's loopback port). The policy also sets `form-action 'self'`, `base-uri 'self'` and `object-src 'none'`, so a form that posts to another origin (an outside payment page, say) no longer submits, and `<object>`/`<embed>` content does not load; add the origin in a map (`{ "form-action": ["https://pay.example.com"] }`). A directive map in `native.csp` adds sources to that policy (`{ "script-src": ["https://cdn.example.com"] }`), a string replaces it, and `native.csp: false` ships no policy, as before; `native.csp: ""` is a build error. In a map, directive names ignore case, a `default-src` entry is added to every fetch directive of the policy but `object-src`, and a directive the policy lacks starts from the one CSP falls back to (`script-src-elem` from `script-src`, `manifest-src` from `default-src`). akan-native hashes inline scripts and styles into `script-src-elem` and `style-src-elem` too when a policy has them.
|