@hcmai/sdk 0.3.3 → 0.3.5

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/dist/index.d.ts CHANGED
@@ -275,8 +275,24 @@ declare enum CliErrorCode {
275
275
  IDENTITY_ALREADY_EXISTS = "IDENTITY_ALREADY_EXISTS",
276
276
  IDENTITY_NOT_IN_ENV = "IDENTITY_NOT_IN_ENV",
277
277
  TOKEN_EXPIRED = "TOKEN_EXPIRED",
278
- NO_ACTIVE_ENV = "NO_ACTIVE_ENV"
278
+ NO_ACTIVE_ENV = "NO_ACTIVE_ENV",
279
+ /** 同一个 id 在 CLI 自带与睿戎目录里同时存在。确定性拒绝,不静默取其一。 */
280
+ SKILL_ID_CONFLICT = "SKILL_ID_CONFLICT",
281
+ /** 装在这份 CLI 里的技能资源读不到(dist/skills 缺失或损坏)。安装损坏,硬失败。 */
282
+ SKILL_SOURCE_UNREACHABLE = "SKILL_SOURCE_UNREACHABLE",
283
+ /** `skills sync` 的锁文件此刻只记得下睿戎来源的出处;自带技能没有它要的三个字段。 */
284
+ SYNC_SOURCE_UNSUPPORTED = "SYNC_SOURCE_UNSUPPORTED"
279
285
  }
286
+ /**
287
+ * 🔴 **兜底不是防御性编程,是防「静默退 0」**。
288
+ *
289
+ * `CODE_TO_EXIT` 是 `Record<CliErrorCode, ExitCode>`,编译期漏一条会红,
290
+ * 所以这一句在类型正确的构建里永远走不到。它防的是**构建不同步**:
291
+ * CLI 的 dist 认识一个新错误码、而 sdk 的 dist 还是旧的时候,
292
+ * 这里会取到 `undefined` ⇒ `process.exit(undefined)` ⇒ **报了错却退 0**。
293
+ * 实测撞到过一次(只跑了 `npm run build -w @hcmai/cli`,没重建 sdk):
294
+ * 终端上明明打印了 Error,脚本里 `$?` 是 0——上游调用方会当成成功。
295
+ */
280
296
  declare function exitCodeFor(code: CliErrorCode): ExitCode;
281
297
 
282
298
  interface CliErrorInit {
@@ -1879,4 +1895,262 @@ declare function resetSettingItem(http: AxiosInstance, domain: string, namespace
1879
1895
  */
1880
1896
  declare function parseSettingAssignment(raw: string): SettingWrite;
1881
1897
 
1882
- export { type ActionHttpMethod, type ActionInput, type ActionMeta, type ActionResult, type ActionScope, type AdminResetPasswordRequest, type AdminResetPasswordResult, type AnyStreamEvent, type ApprovalConfirmPayload, type ApprovalRejectPayload, type AttachmentMeta, type AuthScheme, type BootstrapReconcileResult, type BootstrapTenantRequest, type BootstrapTenantResult, type CacheClearResult, type CacheStats, type ChangePasswordInput, type ChironCategory, type ChironManifest, type ChironSkill, type ChironSkillFile, type ChironStage, type ClearMetaCacheOpts, CliError, CliErrorCode, type CliErrorInit, type ClientAuthContext, type ClientCredentialsInput, type ConnectionMessage, type ControlChannelEnvelope, type ConversationListItem, type ConversationListResult, type ConversationState, type CreateResult, type CreatedConversation, DEFAULT_AGENT_ID, DEFAULT_SESSION_TTL_SECONDS, type DescribeOpts, type EnvConfig, ExitCode, type FieldMeta, type Fixture, type FormatOptions, type GlobalConfig, HcmClient, type HcmClientOpts, type HttpClientOptions, type IdentityMeta, type ImportClient, type ImportOptions, type ImportResult, type InteractionAnswerPayload, type InteractionRequest, type InteractionResolved, type ListTenantMetaOpts, type LoginOutcome, MINI_CONTEXT_FILE, MINI_CONTEXT_KIND, MINI_CONTEXT_VERSION, MINI_PULL_MANIFEST_FILE, MINI_REMOTE_ROOT, MINI_STATE_DIR, type MessageClass, type MessageCreatePayload, type MessageStreamHandle, type MigrationSummary, type MiniFileSnapshot, type MiniInitArgs, type MiniLocalFile, type MiniLocalStatus, type MiniPreviewTarget, type MiniProjectContext, type MiniPullArgs, type MiniPullManifest, type MiniPullResult, type MiniPushArgs, type MiniPushConflict, type MiniPushOperation, type MiniPushPlanItem, type MiniPushResult, type MiniSmokeCheckArgs, type MiniSmokeFetch, type MiniSmokeFetchResponse, type MiniSmokeResult, type MiniSmokeTargetKind, type MiniSmokeTargetResult, type MiniStatusEntry, type MiniSurface, type MiniTemplateArgs, type MiniTemplateKind, type MiniValidationResult, type MiniVerifyAgentReport, type MiniVerifyBrowserAcceptance, type MiniVerifyChangedFile, type MiniVerifyNextAction, type MiniVerifyPlan, type MiniVerifyPreviewUrl, type MiniVerifyReport, type MiniVerifySummary, type MiniWritableTemplateConfig, type ModelDescription, type ModelQueryDsl, type OneShotOpts, type OneShotResult, type OneShotToolCall, type OutputFormat, PASSWORD_CHANGE_REQUIRED, PROACTIVE_REFRESH_MARGIN_SECONDS, type PairingLoginInput, type ParsedPlaceholder, type PasswordChangeChallenge, type PasswordLoginInput, type PatLoginInput, type Principal, type ProfileConfig, type QueryResult, RefStore, type RefreshInput, type RelationMeta, type RemoveResult, type ResponseCompletedPayload, type ResponseFailedPayload, type ResponsePartDeltaPayload, type ResponseStartedPayload, type ResumeSummary, type ResumeTurn, type RowResult, type RowStatus, SDK_VERSION, type SaveMetaResult, type SendMessageOpts, type SettingItem, type SettingWrite, type StreamCancelPayload, type StreamCommand, type StreamCommandEnvelope, type StreamCommandType, type StreamEventEnvelope, type StreamEventType, type TaskProgressPayload, type TenantMetaEntry, type TimelineItemLite, type TokenRecord, TokenStore, type ToolCallFailedPayload, type ToolCallResultPayload, type ToolCallStartedPayload, type V4RenderSink, type V4StreamEventType, type WorkspaceFileContent, type WorkspaceFileItem, type WorkspaceFileListResult, WsClient, type WsClientOpts, absoluteDownloadUrl, adminResetPassword, archiveDir, assertSafeReferencePath, assertSafeSkillFilePath, assertSafeSkillId, bootstrapTenant, buildAnswer, buildConfirm, buildInterrupt, buildMiniAppTemplateFiles, buildMiniPreviewTargets, buildMiniVerifyAgentReport, buildReject, buildResumeSummary, buildSteer, camelizeKeys, changePassword, classifyMessage, clearMetaCache, clearModelCache, conversationStateFile, create, createConversation, createHttpClient, createV4Reducer, createWorkspaceFile, credentialsFile, defaultDownloadDir, defaultMiniRequiredScopes, deleteEnv, deleteIdentity, deleteTenantMeta, deleteWorkspaceFile, deriveNamelessToolLabel, describePrincipal, detectDelegationPause, detectDirectInteractionPending, detectPasswordChangeChallenge, displayWidth, downloadDocument, ensureSessionFresh, envDir, envFile, envsDir, exitCodeFor, extractNextSteps, fetchConversationTimeline, fetchConversationTimelineStrict, fetchRecentConversations, fetchSkillCatalog, fetchSkillFile, fetchSkillMarkdown, fetchSkillReference, filterByStage, findLastAssistantSeq, flattenSkills, formatMiniVerifyReport, formatObject, formatRows, fromAxiosError, getCacheStats, getMiniStatus, getSettingDomain, getTenantMeta, globalConfigFile, guessMimeType, hcmConfigDir, identitiesDir, identityDir, identityMetaFile, inferEnvName, inferMiniWritableTemplateOptionsFromModel, initMiniAppProject, isDelegationToolName, isServerSlidingSession, listEnvs, listIdentities, listProfiles, listTenantMeta, listWorkspaceFiles, loadConversationState, loadEnv, loadGlobalConfig, loadIdentity, loadProfile, loadWorkspaceFileContent, loginClientCredentials, loginPairing, loginPassword, loginPat, matchSkills, migrateLegacyProfiles, needsRefresh, normalizeReferences, oneShot, parseConfirmToolName, parseFixture, parseInteractionRequest, parseInteractionResolved, parsePlaceholder, parseSettingAssignment, parseSkillFrontmatter, parseSkillRequirements, patchSettingDomain, profileDir, profileFile, pullMiniAppProject, pushMiniAppProject, readMiniContext, readPullManifest, refreshToken, remove, replHistoryFile, resetSettingItem, resolveActiveEnv, resolveActiveIdentity, resolveActiveProfile, resolveAllSkillsInstallOrder, resolveChironBase, resolveRefs, resolveSkillInstallOrder, runImport, runMiniSmokeChecks, saveConversationState, saveEnv, saveGlobalConfig, saveIdentity, saveProfile, saveTenantMeta, saveWorkspaceFileContent, sendMessageAndStream, snakeToCamel, toJson, toOrigin, toPrincipal, toTable, toYaml, truncateDisplay, update, uploadDocument, validateMiniProject };
1898
+ /**
1899
+ * sourceKey 实测形如 `ws:poc-cnpc`;冒号等字符不能直接进路径。
1900
+ *
1901
+ * 🔴 纯字符替换做不到单射(`ws:alice` 与 `ws_alice` 会撞进同一个目录),而不同 sourceKey
1902
+ * 的产物不可互换——撞目录不是「挤在一起」,是后跑的 FDE 静默覆盖前一个 FDE 的
1903
+ * models.json / meta/*.json。所以在可读 slug 后面缀上**原始键**的短摘要:
1904
+ * slug 用来给人看,后缀用来保证身份。
1905
+ */
1906
+ declare function safeSegment(value: string): string;
1907
+ /**
1908
+ * 租户段的归一。
1909
+ *
1910
+ * 🔴 **它就是 `safeSegment`,不是另一个归一函数。** 保留独立函数名只为让调用点读起来
1911
+ * 有语义(也给命令层一个公开入口,两端才不会各自拼路径),实现必须**原样委派**,
1912
+ * 绝不允许两个归一算法并存。
1913
+ *
1914
+ * ⚠️ 不要改成「校验 tenantId 字符集、非法即拒」:那会在某个 tenantId 真含特殊字符的
1915
+ * 环境上**硬拒一个合法环境**,把可用性押在我们对 tenantId 取值范围的猜测上。
1916
+ * 摘要后缀不拒绝任何输入,且无条件单射。
1917
+ */
1918
+ declare function tenantSegment(value: string): string;
1919
+ declare class ReconLayout {
1920
+ readonly root: string;
1921
+ readonly tenantId: string;
1922
+ readonly sourceKey: string;
1923
+ readonly dir: string;
1924
+ constructor(root: string, tenantId: string, sourceKey: string);
1925
+ /**
1926
+ * 把相对路径解析成绝对路径,并过两道**互相印证**的遏制闸。
1927
+ *
1928
+ * 🔴 `rel` 里会嵌入**现爬的 modelKey**:`meta/<k>.model.json`、`valuedomain/<k>.json`、
1929
+ * `mapping/<k>.json`。服务端说什么,这里就拼什么。
1930
+ *
1931
+ * 实测分档(沿用 Python 侧 2026-08-16 的实跑结论):
1932
+ * `../evil` → 规范化后**仍在产物根内**,写成 `<产物根>/evil.json`。第二道闸**拦不住**。
1933
+ * `../models` → 同上,**顶掉 recon 自己的模型名册**,写入方拿到「成功」,产物里没有留痕。
1934
+ * `../../evil` → 真的逃出产物根 ⇒ 第二道闸拦得住。
1935
+ * `/etc/passwd` → 前导 `/` 被路径规范化吃掉,落在 `valuedomain/etc/passwd.json`。
1936
+ * ⇒ 真正的危害不是「逃出产物根」(那一档本来就拦得住),是「**逃出预期子目录、
1937
+ * 静默顶掉同级产物**」——`models.json` / `fingerprint.json` / `gates.json` 全在射程内。
1938
+ *
1939
+ * ⚠️ 拒绝而不是消毒:消毒会让 `meta/<modelKey>.json` 不再能按 modelKey grep 回去。
1940
+ */
1941
+ resolvePath(rel: string, createParents?: boolean): string;
1942
+ writeJson(rel: string, obj: unknown): string;
1943
+ writeJsonl(rel: string, rows: Iterable<unknown>): string;
1944
+ writeText(rel: string, text: string): string;
1945
+ /**
1946
+ * 逐行读一份 JSONL 产物。
1947
+ *
1948
+ * 🔴 与 `readJson` 同走那两道越界闸——同一个收口点不能一半有闸一半没有。
1949
+ * 🔴 **跳过空行**(末尾换行是 `writeJsonl` 必然产生的),但**不跳过坏行**:
1950
+ * 坏行原样抛,因为「这一行读不出来」和「这个产物没有这一行」是两件事。
1951
+ */
1952
+ readJsonlRows(rel: string): unknown[];
1953
+ readJson(rel: string): unknown;
1954
+ }
1955
+ /**
1956
+ * 路径遏制被触发。
1957
+ *
1958
+ * 独立于 `CliError`:它是**内部不变量**被破坏,不是顾问能修的用法错误。
1959
+ * 命令层负责把它翻成一句人话 + 退出码,见 `packages/cli/src/commands/delivery-doctor.ts`。
1960
+ */
1961
+ declare class LayoutContainmentError extends Error {
1962
+ constructor(message: string);
1963
+ }
1964
+
1965
+ /**
1966
+ * 侦察层对 HTTP 的**窄端口**与**响应分类**。
1967
+ *
1968
+ * 🔴 为什么是端口而不是搬一份客户端过来(ADR-319 刀 6b 明令):
1969
+ * CLI 已经有认证 / endpoint 解析 / token 刷新 / 拦截器这一整条管道
1970
+ * (`packages/core/src/client.ts` + `src/http/`)。侦察层再造一份,就是
1971
+ * 「集成 reference path 必复用 helper」那条铁律的反面。
1972
+ *
1973
+ * 但**响应分类**不在那条管道里,而它是侦察层的命根子:顾问打的是一个陌生环境,
1974
+ * 「没权限」「没这个端点」「网关吐了 HTML」「连不上」的下一步完全不同。
1975
+ * 把它们压成一个布尔,产物里就再也分不出来了。所以这一层必须自己有。
1976
+ *
1977
+ * ⚠️ `error` 用字符串而不是布尔:要区分的不是「成没成」,而是「没成是哪一种」。
1978
+ * 判成功一律写 `error === 'ok'`,别写 `!error`。
1979
+ */
1980
+
1981
+ /** 响应分类的完整取值域。 */
1982
+ type OutcomeError = 'ok' | 'unauthorized' | 'forbidden' | 'not-found' | 'server-error' | 'bad-response' | 'network';
1983
+ interface Outcome {
1984
+ /** 网络层没走通时是 `-1`——它不是 HTTP 状态,别拿去和 4xx 比。 */
1985
+ status: number;
1986
+ /** 🔴 是 unknown 不是对象:服务端完全可能返回 array / string / number。 */
1987
+ body: unknown;
1988
+ error: OutcomeError;
1989
+ /**
1990
+ * 本次响应的头,键一律小写。
1991
+ *
1992
+ * 🔴 挂在 Outcome 上而不是客户端实例上(Python 侧是 `client.last_headers`):
1993
+ * 那种可变字段有「串味」风险——上一次成功的头留到这一次失败时被读到,
1994
+ * 而 `probeExtensionSource` 恰恰是紧跟每次 GET 读头。挂在返回值上让串味**结构上不可能**,
1995
+ * 契约里那几条「last_headers 必须清空」于是从「要测的行为」变成「构造上成立」。
1996
+ */
1997
+ headers: Record<string, string>;
1998
+ }
1999
+ interface ReconProbe {
2000
+ get(path: string, params?: Record<string, unknown>): Promise<Outcome>;
2001
+ post?(path: string, body: unknown): Promise<Outcome>;
2002
+ getMany?(paths: string[]): Promise<Record<string, Outcome>>;
2003
+ postMany?(jobs: Array<{
2004
+ path: string;
2005
+ body: unknown;
2006
+ }>): Promise<Record<string, Outcome>>;
2007
+ /** 爬取时声明的 capability 串——它是**爬法**属性,不是环境属性。 */
2008
+ readonly capabilities: string;
2009
+ }
2010
+ /** 把既有 axios 管道(已带认证与刷新)适配成侦察层的窄端口。 */
2011
+ declare function httpProbe(http: AxiosInstance, capabilities: string): Required<ReconProbe>;
2012
+
2013
+ /** 🔴 只有这三个分量作门。backendVersion 仅记录——实测它在 on-prem 恒返 "unknown"。 */
2014
+ declare const GATE_COMPONENTS: readonly ["tenantMetaManifestDigest", "extensionSource", "modelListHash"];
2015
+ declare const BLIND_SPOTS: string;
2016
+ declare const MODELS_PATH = "/api/system/models";
2017
+ declare const MANIFEST_PATH = "/api/tenant-meta/list";
2018
+ declare const VERSION_PATH = "/api/version/backend";
2019
+ declare const META_PATH = "/api/models/{model}/meta";
2020
+ declare const EXTENSION_SOURCE_HEADER = "x-hcm-extension-source";
2021
+ /**
2022
+ * 探针上限。取不到就取不到,**不许**为了拿到一个值把 761 个模型全试一遍——
2023
+ * 那会让 doctor 从「几秒」变成「几分钟」,而 doctor 存在的意义就是**快速**告诉顾问他站在哪儿。
2024
+ *
2025
+ * 🔴 为什么是 50 而不是 20:「20 够不够」这个问题,原工位实测第 1 个 key 就命中,
2026
+ * 但**这不能证明任何别的环境**;若某环境排序靠前的 key 恰好全是隐藏型(实测有 19 个),
2027
+ * 探针会空手而归并阻断门,而 key 21 可能就带着这个头。
2028
+ * ⇒ 正确的应对**不是**把 20 换成另一个同样证明不了的数字,而是:
2029
+ * ① 放宽到显然够用又不至于拖慢 doctor(命中即停,坏情况 50 × ~50ms ≈ 2.5s);
2030
+ * ② 把失败讲清楚(见 attempted/answered)。判据从「猜一个够用的数」换成「失败时说得出为什么」。
2031
+ */
2032
+ declare const MAX_SOURCE_PROBES = 50;
2033
+ /**
2034
+ * 本模块的全部前提是「打一个不认识的环境」。一个把 totalPages 报成 2**31 的
2035
+ * 服务端会让顾问的笔记本原地转圈。200 页 × 200 行 = 4 万行,远超真实 workspace。
2036
+ */
2037
+ declare const MAX_MANIFEST_PAGES = 200;
2038
+ interface ModelEntry {
2039
+ modelKey?: string;
2040
+ type?: string;
2041
+ [k: string]: unknown;
2042
+ }
2043
+ /**
2044
+ * `/api/system/models` 的响应体 → **可用的**模型条目。
2045
+ *
2046
+ * 🔴 **这是唯一一道门**。原先 doctor / computeFingerprint / 布局解析三个点各写各的过滤,
2047
+ * 第三个漏了——而它跑在**最前面**,客户网关一改清单形状,recon 就在第一步崩掉,
2048
+ * 而 FDE 手上没有源码、没有安装包、也没有第二份基线可对照。
2049
+ *
2050
+ * 两种敌意形状都在这里挡掉,调用方不必(也不许)自己判:
2051
+ * ① `body` 整体不是对象——服务端**声明**返 object,但网关扒掉 envelope 直接返数组是真会发生的;
2052
+ * ② `models[]` 里混进非对象元素——部分序列化失败 / 拼接出错。
2053
+ *
2054
+ * ⚠️ **降级不是静默**:这里只负责「不崩」,「有没有掉东西」由调用方各自留痕。
2055
+ */
2056
+ declare function modelEntries(body: unknown): ModelEntry[];
2057
+ /**
2058
+ * `/api/system/models` 的响应体 → 探针用的 modelKey 列表(去空串 + 排序)。
2059
+ *
2060
+ * 🔴 空串过滤不能省:一条缺 `modelKey` 的记录会让第一发打到 `/api/models//meta`,
2061
+ * 白烧一发**有限的**探针配额。
2062
+ * 🔴 排序 = 探针确定性:同一个环境两次 recon 必须探同一个模型,否则 `extensionSourceProbe`
2063
+ * 会无端漂移,看上去像环境变了。
2064
+ */
2065
+ declare function modelKeys(body: unknown): string[];
2066
+ interface ProbeResult {
2067
+ sourceKey: string;
2068
+ probeModelKey: string;
2069
+ attempted: number;
2070
+ answered: number;
2071
+ }
2072
+ /**
2073
+ * 探 `X-HCM-Extension-Source`。
2074
+ *
2075
+ * 🔴 **这个头只挂在 `GET /api/models/{model}/meta` 上,`/api/system/models` 上没有**。
2076
+ * 读错端点的后果不是「偶尔取不到」,是**每一个真实环境上恒为 unknown**:三个门分量残掉
2077
+ * 一个 ⇒ `compareFingerprint` 恒返 `incomplete:` ⇒ 门被 `--force-stale` 常态化绕过。
2078
+ *
2079
+ * 🔴 `answered` 不是凑数的统计量,它是「unknown 到底是哪种 unknown」的唯一判据。
2080
+ * 只返回 `(sourceKey, probeModelKey)` 时,「一个模型都没答应」与「答应了但没回这个头」
2081
+ * **都**返回空串、**都**写同一条失败条目——顾问看到 `unknown` 照样不知道该查连通/权限还是查反代。
2082
+ * **一个自己都分辨不了的分辨承诺比不承诺更糟**,它让人以为这件事已经处理了。
2083
+ */
2084
+ declare function probeExtensionSource(probe: ReconProbe, keys: string[]): Promise<ProbeResult>;
2085
+ interface Fingerprint {
2086
+ tenantMetaManifestDigest: string;
2087
+ manifestEntryCount: number;
2088
+ extensionSource: string;
2089
+ extensionSourceProbe: string;
2090
+ extensionSourceProbeAttempted: number;
2091
+ extensionSourceProbeAnswered: number;
2092
+ modelListHash: string;
2093
+ modelCount: number;
2094
+ backendVersion: unknown;
2095
+ capabilities: string;
2096
+ createdAt: string;
2097
+ ttlDays: number;
2098
+ coverageNotes: {
2099
+ gateComponents: string[];
2100
+ blindSpots: string;
2101
+ fetchFailures: string[];
2102
+ };
2103
+ }
2104
+ declare function computeFingerprint(probe: ReconProbe, opts?: {
2105
+ ttlDays?: number;
2106
+ now?: () => Date;
2107
+ }): Promise<Fingerprint>;
2108
+ /**
2109
+ * 比对两份四元组,回**差异清单**(空 = 同源)。
2110
+ *
2111
+ * 🔴 某个分量没爬到时,它和「爬到了而且相等」在值上同形。两边都没爬到 → 三个分量全等
2112
+ * → 门放行一份根本没验过的基线。所以残缺本身也要进差异清单。
2113
+ */
2114
+ declare function compareFingerprint(recorded: Record<string, unknown>, current: Record<string, unknown>): string[];
2115
+
2116
+ type DoctorAnchor = 'connectivity' | 'identity' | 'config-admin' | 'layer';
2117
+ /** 四条锚点的顺序是固定的:连通 → 我是谁 → 有没有权限 → 站在哪一层。 */
2118
+ declare const DOCTOR_ANCHORS: readonly DoctorAnchor[];
2119
+ interface DoctorCheck {
2120
+ anchor: DoctorAnchor;
2121
+ ok: boolean;
2122
+ detail: string;
2123
+ }
2124
+ interface DoctorReport {
2125
+ ok: boolean;
2126
+ checks: DoctorCheck[];
2127
+ }
2128
+ /**
2129
+ * 登录身份。`null` 表示**本工具没有经手登录**——那与「登录了但服务端没给 user」
2130
+ * 是两种状态,处置不同,不许合并。
2131
+ */
2132
+ interface ReconIdentity {
2133
+ /** token 实际归属的租户(服务端登录响应里的 `user.tenantId`)。 */
2134
+ tenantId?: string;
2135
+ /** 顾问**要的**租户(命令行给的)。 */
2136
+ requestedTenantId?: string;
2137
+ username?: string;
2138
+ roles?: string[];
2139
+ }
2140
+ declare function runDoctor(probe: ReconProbe, identity: ReconIdentity | null): Promise<DoctorReport>;
2141
+ /** `GET /api/auth/info` —— 服务端认定的 token 归属从这里来。 */
2142
+ declare const AUTH_INFO_PATH = "/api/auth/info";
2143
+ /**
2144
+ * 现打一次 `/api/auth/info`,拼出 identity 锚点要的那一对身份。
2145
+ *
2146
+ * 🔴 **复用 `toPrincipal`,不另写解析**:那个 helper 已经处理了两个来源
2147
+ * (`POST /api/auth/login` 的 `user` 与 `GET /api/auth/info` 本体)字段名一致但容器
2148
+ * 不同、以及 tenantId 可能是 number 也可能是 UUID 这两件事。再写一份就是第二套口径。
2149
+ *
2150
+ * 🔴 取不到时回 `null` 而不是空对象:**核不了 ≠ 核过了没问题**。
2151
+ * 空对象会落进「服务端没给 user.tenantId」那一档,把一次「问都没问成」
2152
+ * 说成「问了,服务端没答」——两者的下一步不同。
2153
+ */
2154
+ declare function fetchReconIdentity(probe: ReconProbe, requestedTenantId: string): Promise<ReconIdentity | null>;
2155
+
2156
+ export { AUTH_INFO_PATH, type ActionHttpMethod, type ActionInput, type ActionMeta, type ActionResult, type ActionScope, type AdminResetPasswordRequest, type AdminResetPasswordResult, type AnyStreamEvent, type ApprovalConfirmPayload, type ApprovalRejectPayload, type AttachmentMeta, type AuthScheme, BLIND_SPOTS, type BootstrapReconcileResult, type BootstrapTenantRequest, type BootstrapTenantResult, type CacheClearResult, type CacheStats, type ChangePasswordInput, type ChironCategory, type ChironManifest, type ChironSkill, type ChironSkillFile, type ChironStage, type ClearMetaCacheOpts, CliError, CliErrorCode, type CliErrorInit, type ClientAuthContext, type ClientCredentialsInput, type ConnectionMessage, type ControlChannelEnvelope, type ConversationListItem, type ConversationListResult, type ConversationState, type CreateResult, type CreatedConversation, DEFAULT_AGENT_ID, DEFAULT_SESSION_TTL_SECONDS, DOCTOR_ANCHORS, type DescribeOpts, type DoctorAnchor, type DoctorCheck, type DoctorReport, EXTENSION_SOURCE_HEADER, type EnvConfig, ExitCode, type FieldMeta, type Fingerprint, type Fixture, type FormatOptions, GATE_COMPONENTS, type GlobalConfig, HcmClient, type HcmClientOpts, type HttpClientOptions, type IdentityMeta, type ImportClient, type ImportOptions, type ImportResult, type InteractionAnswerPayload, type InteractionRequest, type InteractionResolved, LayoutContainmentError, type ListTenantMetaOpts, type LoginOutcome, MANIFEST_PATH, MAX_MANIFEST_PAGES, MAX_SOURCE_PROBES, META_PATH, MINI_CONTEXT_FILE, MINI_CONTEXT_KIND, MINI_CONTEXT_VERSION, MINI_PULL_MANIFEST_FILE, MINI_REMOTE_ROOT, MINI_STATE_DIR, MODELS_PATH, type MessageClass, type MessageCreatePayload, type MessageStreamHandle, type MigrationSummary, type MiniFileSnapshot, type MiniInitArgs, type MiniLocalFile, type MiniLocalStatus, type MiniPreviewTarget, type MiniProjectContext, type MiniPullArgs, type MiniPullManifest, type MiniPullResult, type MiniPushArgs, type MiniPushConflict, type MiniPushOperation, type MiniPushPlanItem, type MiniPushResult, type MiniSmokeCheckArgs, type MiniSmokeFetch, type MiniSmokeFetchResponse, type MiniSmokeResult, type MiniSmokeTargetKind, type MiniSmokeTargetResult, type MiniStatusEntry, type MiniSurface, type MiniTemplateArgs, type MiniTemplateKind, type MiniValidationResult, type MiniVerifyAgentReport, type MiniVerifyBrowserAcceptance, type MiniVerifyChangedFile, type MiniVerifyNextAction, type MiniVerifyPlan, type MiniVerifyPreviewUrl, type MiniVerifyReport, type MiniVerifySummary, type MiniWritableTemplateConfig, type ModelDescription, type ModelQueryDsl, type OneShotOpts, type OneShotResult, type OneShotToolCall, type Outcome, type OutputFormat, PASSWORD_CHANGE_REQUIRED, PROACTIVE_REFRESH_MARGIN_SECONDS, type PairingLoginInput, type ParsedPlaceholder, type PasswordChangeChallenge, type PasswordLoginInput, type PatLoginInput, type Principal, type ProfileConfig, type QueryResult, type ReconIdentity, ReconLayout, type ReconProbe, RefStore, type RefreshInput, type RelationMeta, type RemoveResult, type ResponseCompletedPayload, type ResponseFailedPayload, type ResponsePartDeltaPayload, type ResponseStartedPayload, type ResumeSummary, type ResumeTurn, type RowResult, type RowStatus, SDK_VERSION, type SaveMetaResult, type SendMessageOpts, type SettingItem, type SettingWrite, type StreamCancelPayload, type StreamCommand, type StreamCommandEnvelope, type StreamCommandType, type StreamEventEnvelope, type StreamEventType, type TaskProgressPayload, type TenantMetaEntry, type TimelineItemLite, type TokenRecord, TokenStore, type ToolCallFailedPayload, type ToolCallResultPayload, type ToolCallStartedPayload, type V4RenderSink, type V4StreamEventType, VERSION_PATH, type WorkspaceFileContent, type WorkspaceFileItem, type WorkspaceFileListResult, WsClient, type WsClientOpts, absoluteDownloadUrl, adminResetPassword, archiveDir, assertSafeReferencePath, assertSafeSkillFilePath, assertSafeSkillId, bootstrapTenant, buildAnswer, buildConfirm, buildInterrupt, buildMiniAppTemplateFiles, buildMiniPreviewTargets, buildMiniVerifyAgentReport, buildReject, buildResumeSummary, buildSteer, camelizeKeys, changePassword, classifyMessage, clearMetaCache, clearModelCache, compareFingerprint, computeFingerprint, conversationStateFile, create, createConversation, createHttpClient, createV4Reducer, createWorkspaceFile, credentialsFile, defaultDownloadDir, defaultMiniRequiredScopes, deleteEnv, deleteIdentity, deleteTenantMeta, deleteWorkspaceFile, deriveNamelessToolLabel, describePrincipal, detectDelegationPause, detectDirectInteractionPending, detectPasswordChangeChallenge, displayWidth, downloadDocument, ensureSessionFresh, envDir, envFile, envsDir, exitCodeFor, extractNextSteps, fetchConversationTimeline, fetchConversationTimelineStrict, fetchRecentConversations, fetchReconIdentity, fetchSkillCatalog, fetchSkillFile, fetchSkillMarkdown, fetchSkillReference, filterByStage, findLastAssistantSeq, flattenSkills, formatMiniVerifyReport, formatObject, formatRows, fromAxiosError, getCacheStats, getMiniStatus, getSettingDomain, getTenantMeta, globalConfigFile, guessMimeType, hcmConfigDir, httpProbe, identitiesDir, identityDir, identityMetaFile, inferEnvName, inferMiniWritableTemplateOptionsFromModel, initMiniAppProject, isDelegationToolName, isServerSlidingSession, listEnvs, listIdentities, listProfiles, listTenantMeta, listWorkspaceFiles, loadConversationState, loadEnv, loadGlobalConfig, loadIdentity, loadProfile, loadWorkspaceFileContent, loginClientCredentials, loginPairing, loginPassword, loginPat, matchSkills, migrateLegacyProfiles, modelEntries, modelKeys, needsRefresh, normalizeReferences, oneShot, parseConfirmToolName, parseFixture, parseInteractionRequest, parseInteractionResolved, parsePlaceholder, parseSettingAssignment, parseSkillFrontmatter, parseSkillRequirements, patchSettingDomain, probeExtensionSource, profileDir, profileFile, pullMiniAppProject, pushMiniAppProject, readMiniContext, readPullManifest, refreshToken, remove, replHistoryFile, resetSettingItem, resolveActiveEnv, resolveActiveIdentity, resolveActiveProfile, resolveAllSkillsInstallOrder, resolveChironBase, resolveRefs, resolveSkillInstallOrder, runDoctor, runImport, runMiniSmokeChecks, safeSegment, saveConversationState, saveEnv, saveGlobalConfig, saveIdentity, saveProfile, saveTenantMeta, saveWorkspaceFileContent, sendMessageAndStream, snakeToCamel, tenantSegment, toJson, toOrigin, toPrincipal, toTable, toYaml, truncateDisplay, update, uploadDocument, validateMiniProject };