Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

67 lines
2.0 KiB
TypeScript

import { useMemo } from "react";
import type {
AgentGUIInteractionReadiness,
AgentGUIInteractionReadinessIdentity,
AgentGUIInteractionReadinessSource
} from "../../../types";
import { useEngineSelector } from "../../../shared/engine/useEngineSelector";
const SYNCHRONIZING: AgentGUIInteractionReadiness = {
status: "blocked",
reason: "synchronizing"
};
/** Reads one exact Host projection; a supplied-but-incomplete source fails closed. */
export function readAgentGUIInteractionReadiness(input: {
identity: AgentGUIInteractionReadinessIdentity;
source?: AgentGUIInteractionReadinessSource | null;
}): AgentGUIInteractionReadiness | null {
if (!input.source) return null;
return input.source.getInteractionReadiness(input.identity) ?? SYNCHRONIZING;
}
export function useAgentGUIInteractionReadiness(input: {
identity: AgentGUIInteractionReadinessIdentity | null;
required?: boolean;
source?: AgentGUIInteractionReadinessSource | null;
}): AgentGUIInteractionReadiness | null {
const binding = useMemo(
() => ({
getSnapshot: () =>
input.identity
? readAgentGUIInteractionReadiness({
identity: input.identity,
source: input.source
})
: input.required && input.source
? SYNCHRONIZING
: null,
subscribe: (listener: () => void) =>
input.source?.subscribe(listener) ?? (() => undefined)
}),
[input.identity, input.required, input.source]
);
return useEngineSelector(
binding,
identityInteractionReadiness,
interactionReadinessEqual
);
}
function identityInteractionReadiness(
readiness: AgentGUIInteractionReadiness | null
): AgentGUIInteractionReadiness | null {
return readiness;
}
function interactionReadinessEqual(
left: AgentGUIInteractionReadiness | null,
right: AgentGUIInteractionReadiness | null
): boolean {
return (
left?.status === right?.status &&
(left?.status !== "blocked" ||
(right?.status === "blocked" && left.reason === right.reason))
);
}