import { ComponentGenBackend } from "@huaqiu/component-gen-server"; import { Context } from "@deepseek-ai/cordis"; import { HuaqiuAuthService } from "@huaqiu/dsh-auth"; import { HuaqiuArtifacts } from "@huaqiu/dsh-artifacts"; //#region src/protocol.d.ts /** Command types the componentV2 backend understands. */ declare const commandTypes: { /** image → schematic symbol. */ readonly PARSE_SYMBOL: "agent.image.parse_symbol"; /** image → package dimensions (the pre-HIL extraction step). */ readonly FOOTPRINT_DIMENSIONS: "agent.footprint.dimensions.generate"; /** dimensions → footprint (the post-HIL generation step). */ readonly FOOTPRINT_GENERATE: "agent.footprint.generate"; }; /** AGENT-frame actions this plugin awaits. */ declare const agentActions: { readonly FOOTPRINT_DIMENSIONS: "footprint_dimensions"; readonly SYMBOL_BUTTON: "symbol_button"; readonly FOOTPRINT_BUTTON: "footprint_button"; /** The backend's "I don't know this package type" answer. */ readonly PKG_TYPE_NOT_FOUND: "pkgTypeNotFound"; }; /** The package types the backend's footprint extractor supports. */ declare const packageTypes: readonly ["bga", "dip", "plcc", "qfn", "son", "qfp", "sop", "sot23"]; /** Shape the socket factory can supply (Node 22+ global `WebSocket`). */ interface SocketLike { onopen: ((ev: unknown) => void) | null; onmessage: ((ev: { data: unknown; }) => void) | null; onerror: ((ev: { message?: string; }) => void) | null; onclose: (() => void) | null; send(data: string): void; close(): void; } //#endregion //#region src/hitl-i18n.d.ts /** * Locale pack for the NODE-side human-in-the-loop (HITL) prompts. * * Why this is not `client/i18n.ts`: that module imports React and subscribes * to the host locale store via `useLocale()`, so it can only run in the * browser half. The HITL helpers in `dimensions.ts` run in the node half — * they build the `userQuestions.ask()` payload, i.e. the text the human * actually reads — and they were hardcoded to English. * * The node half cannot see `` (no DOM), so the locale is a * DEPLOYMENT setting, not a detected one: `SymbolFootprintConfig.hitlLanguage` * / `HQ_EDA_HITL_LANGUAGE`. The default is zh to match the rest of the * package — `client/theme.ts` falls back to zh ("this is a Chinese-first * app") and `client/i18n.ts` pins `defaultT` to zh — so the dialog and the * card now speak the same language instead of the card being zh while the * dialog stayed en. * * Same typed-dictionary guard as `client/i18n.ts`: `ZH` is the source of * truth, `EN` is typed `Record`, so a key added to one * pack and not the other is a compile error rather than a silent fallback. * * @module @huaqiu/dsh-tool-symbol-footprint */ type HitlLocale = 'zh' | 'en'; //#endregion //#region src/dimensions.d.ts /** Minimal structural shape of the `userQuestions.ask()` result we consume. */ interface UserQuestionAnswer { answers?: Array<{ selected?: string[]; custom?: string; }>; } interface UserQuestionsLike { ask(options: Record): Promise; } interface ExecutionLike { agent?: unknown; signal?: AbortSignal; /** * UI language for the human-in-the-loop prompt copy. Accepts a locale id or * a BCP-47 tag (`zh-CN`, `en-US`); anything unresolved falls back to the * package default (zh) — see `hitl-i18n.ts`. */ locale?: HitlLocale | string; } //#endregion //#region src/tools.d.ts interface SymbolFootprintDeps { processEnv?: Record; fetchImpl?: typeof fetch; socketFactory?: (url: string) => SocketLike; random?: () => number; } interface SymbolFootprintEnv { /** `huaqiuAuth` node service — token capability. */ auth: HuaqiuAuthService['auth']; /** `huaqiuArtifacts` node service — preview-artifact store. */ artifacts: HuaqiuArtifacts; deps?: SymbolFootprintDeps; /** * UI language for the HIL prompt copy. Deployment-level (the node half has * no DOM to read the host locale from); see `SymbolFootprintConfig`. */ hitlLanguage?: HitlLocale; /** Opportunistic HIL seam — resolved per call, not injected. */ getUserQuestions?: () => UserQuestionsLike | undefined; } /** `generate_symbol_from_image` body. */ declare function runGenerateSymbol(args: Record, exec: ExecutionLike | undefined, env: SymbolFootprintEnv): Promise>; /** `generate_footprint_from_dimensions` body (the post-confirmation half). */ declare function runGenerateFootprintFromDimensions(args: Record, exec: ExecutionLike | undefined, env: SymbolFootprintEnv): Promise>; /** * `generate_footprint_from_image` body — the full flow with the * human-in-the-loop step in the middle. * * The one invariant that must not be broken: a footprint is generated ONLY from * dimensions a human has seen. The web client renders the dimension editor card * and the result returns `needs_confirmation` so the model calls * `generate_footprint_from_dimensions` with the confirmed values. */ declare function runGenerateFootprintFromImage(args: Record, exec: ExecutionLike | undefined, env: SymbolFootprintEnv): Promise>; //#endregion //#region src/index.d.ts /** Plugin id — matches package.json. */ declare const name = "@huaqiu/dsh-tool-symbol-footprint"; /** Cordis services this half depends on. `userQuestions` is deliberately NOT * injected — see the HIL note in the file header. `webServer` hosts the * component-gen API routes (jobs/SSE/history) that the browser workspace * drives. */ declare const inject: readonly ["tools", "huaqiuAuth", "huaqiuArtifacts", "webServer"]; interface SymbolFootprintConfig { /** Endpoint override, env-backed (`HQ_EDA_COMPONENT_WS_URL`); still * whitelist-checked. */ endpoint?: string; /** * UI language for the human-in-the-loop prompt (the accept/decline question * shown through the `userQuestions` seam). The node half has no DOM, so it * cannot read `` the way the browser card does — this is the * deployment-side equivalent. Accepts `zh` / `en` (or a BCP-47 tag such as * `zh-CN`); falls back to the package default, which is zh to match the * card copy. Also settable via `HQ_EDA_HITL_LANGUAGE`. */ hitlLanguage?: string; } /** * Host plugin body — register the three generation tools. * * @param ctx - real cordis context (node side). * @returns disposer — unregisters all three tools on plugin dispose. */ declare function apply(ctx: Context, config?: SymbolFootprintConfig): () => void; /** * Build the component-gen HTTP backend over the plugin's existing generation * functions. Shared by the DSH integration (this plugin) and the standalone * server (`@huaqiu/component-gen-server/standalone`). * * @param env - `SymbolFootprintEnv`; set `getUserQuestions: () => undefined` * to make the workspace the single HIL driver (no native accept/decline * popup). */ declare function createComponentGenBackend(env: SymbolFootprintEnv): ComponentGenBackend; //#endregion export { SymbolFootprintConfig, type SymbolFootprintDeps, type SymbolFootprintEnv, agentActions, apply, commandTypes, createComponentGenBackend, inject, name, packageTypes, runGenerateFootprintFromDimensions, runGenerateFootprintFromImage, runGenerateSymbol };