Files
hose-use/src/cli/commands/assist-platform/common.ts
T
gitea ed9fa979e0 feat(assist-platform): add assist platform automation and tenant onboarding
- Add SSO QR status poller and assist platform HTTP client
- Add assist-platform session store with 0600 secure permissions
- Implement domains/assist-platform (api, services, types) for corporation search, detail, tickets, staff query and passwordless token generation
- Implement cli/commands/assist-platform with aliases assist-center and ap
- Support seamless --save --switch --elevate pipeline to import tenant and extract persistent OpenAPI credentials
- Update embedded skill documentation, reference guide, and test suites
2026-10-21 10:33:27 +08:00

28 lines
1000 B
TypeScript

import { loadAssistPlatformSession } from "../../../core/auth/assist-platform-store.js";
import { createAssistPlatformClient } from "../../../core/http/assist-platform-client.js";
import { stringOption } from "../../parser.js";
import type { CliParsedArgs, CliRuntime } from "../../types.js";
import { AuthenticationError } from "../../../core/errors.js";
import type { KyInstance } from "ky";
export function resolveAssistClient(
parsed: CliParsedArgs,
_runtime: CliRuntime
): KyInstance {
const explicitToken = stringOption(parsed.options, ["token", "t"]);
const session = loadAssistPlatformSession();
const token = explicitToken || session?.token;
if (!token || !token.trim()) {
throw new AuthenticationError(
"未检测到协助平台登录凭证。请先运行: hose-use assist-platform login --token <TOKEN>"
);
}
return createAssistPlatformClient({
token: token.trim(),
hoseAccessToken: session?.hoseAccessToken,
baseUrl: session?.baseUrl,
});
}