@huawei-iac-tools/landingzone-workbench 0.0.0-stage → 0.0.1
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/LICENSE +201 -0
- package/README.md +85 -2
- package/cordis.patch.yml +21 -0
- package/knowledge/account-qualification.md +128 -0
- package/knowledge/blueprints/_base/blueprint.json +481 -0
- package/knowledge/blueprints/_base/defaults.json +127 -0
- package/knowledge/blueprints/foundation-lz/blueprint.json +43 -0
- package/knowledge/blueprints/foundation-lz/defaults.json +47 -0
- package/knowledge/blueprints/full-lz/blueprint.json +11 -0
- package/knowledge/blueprints/full-lz/defaults.json +8 -0
- package/knowledge/config.json +43 -0
- package/knowledge/error-rules.json +14 -0
- package/knowledge/ic-policies.json +21 -0
- package/knowledge/modules/account-structure.md +101 -0
- package/knowledge/modules/compliance/config-rms.md +212 -0
- package/knowledge/modules/compliance/cts.md +179 -0
- package/knowledge/modules/compliance/obs-lts.md +155 -0
- package/knowledge/modules/ic-policies.json +21 -0
- package/knowledge/modules/identity-center.md +603 -0
- package/knowledge/modules/module-layers.md +169 -0
- package/knowledge/modules/network/er.md +222 -0
- package/knowledge/modules/network/nat-eip.md +123 -0
- package/knowledge/modules/network/ram-share.md +92 -0
- package/knowledge/modules/network/vpc-subnet.md +142 -0
- package/knowledge/modules/organization-security/scp.md +122 -0
- package/knowledge/modules/organizations.md +212 -0
- package/knowledge/modules/recommended-config.md +157 -0
- package/knowledge/modules/recommended-rules.json +175 -0
- package/knowledge/modules/scp-policies.json +111 -0
- package/knowledge/modules/security/aad.md +94 -0
- package/knowledge/modules/security/cfw.md +105 -0
- package/knowledge/modules/security/waf.md +110 -0
- package/knowledge/param-mappings.json +133 -0
- package/knowledge/prompts.md +83 -0
- package/knowledge/resource-types.json +1162 -0
- package/knowledge/scp-policies.json +111 -0
- package/knowledge/state-machine.md +33 -0
- package/lib/client.js +21 -0
- package/lib/index.js +28592 -0
- package/lib/types/account-role.d.ts +19 -0
- package/lib/types/account-scope.d.ts +10 -0
- package/lib/types/agency.d.ts +38 -0
- package/lib/types/client/DropdownSelect.d.ts +49 -0
- package/lib/types/client/LoginGate.d.ts +20 -0
- package/lib/types/client/PanelIcon.d.ts +11 -0
- package/lib/types/client/WorkbenchShell.d.ts +21 -0
- package/lib/types/client/account-role.d.ts +15 -0
- package/lib/types/client/credential-status.d.ts +15 -0
- package/lib/types/client/huawei-mark.d.ts +37 -0
- package/lib/types/client/index.d.ts +26 -0
- package/lib/types/client/layout-ref.d.ts +23 -0
- package/lib/types/client/pages/ConfigPage/AdviceCard.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/AuditBar.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/ChangeSummaryCard.d.ts +22 -0
- package/lib/types/client/pages/ConfigPage/ChangesCard.d.ts +27 -0
- package/lib/types/client/pages/ConfigPage/ComplianceDetail.d.ts +25 -0
- package/lib/types/client/pages/ConfigPage/ComplianceSummaryCard.d.ts +31 -0
- package/lib/types/client/pages/ConfigPage/FindingsCard.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/GlossaryDrawer.d.ts +17 -0
- package/lib/types/client/pages/ConfigPage/OrgComplianceDetail.d.ts +15 -0
- package/lib/types/client/pages/ConfigPage/Pager.d.ts +32 -0
- package/lib/types/client/pages/ConfigPage/ResourceDrawer.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/ResourcesTable.d.ts +35 -0
- package/lib/types/client/pages/ConfigPage/RollupPanel.d.ts +17 -0
- package/lib/types/client/pages/ConfigPage/RuleDetailDrawer.d.ts +23 -0
- package/lib/types/client/pages/ConfigPage/StatusCards.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/UncoveredDialog.d.ts +22 -0
- package/lib/types/client/pages/ConfigPage/config-api.d.ts +101 -0
- package/lib/types/client/pages/ConfigPage/config-store.d.ts +57 -0
- package/lib/types/client/pages/ConfigPage/index.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/paging.d.ts +46 -0
- package/lib/types/client/pages/ConfigPage/scope-options.d.ts +51 -0
- package/lib/types/client/pages/CostPage/AccountAllocation.d.ts +24 -0
- package/lib/types/client/pages/CostPage/AccountBars.d.ts +20 -0
- package/lib/types/client/pages/CostPage/AccountColumns.d.ts +24 -0
- package/lib/types/client/pages/CostPage/AccountDonut.d.ts +18 -0
- package/lib/types/client/pages/CostPage/AccountSwitcher.d.ts +25 -0
- package/lib/types/client/pages/CostPage/AdviceCard.d.ts +43 -0
- package/lib/types/client/pages/CostPage/AdviceFindings.d.ts +43 -0
- package/lib/types/client/pages/CostPage/BillingPanels.d.ts +23 -0
- package/lib/types/client/pages/CostPage/BudgetCard.d.ts +36 -0
- package/lib/types/client/pages/CostPage/GlossaryDrawer.d.ts +16 -0
- package/lib/types/client/pages/CostPage/KpiRow.d.ts +23 -0
- package/lib/types/client/pages/CostPage/MarkdownBlock.d.ts +16 -0
- package/lib/types/client/pages/CostPage/ReportView.d.ts +17 -0
- package/lib/types/client/pages/CostPage/ResourceColumns.d.ts +19 -0
- package/lib/types/client/pages/CostPage/ResourceDonut.d.ts +18 -0
- package/lib/types/client/pages/CostPage/ResourcesCard.d.ts +40 -0
- package/lib/types/client/pages/CostPage/RuleDetailDrawer.d.ts +23 -0
- package/lib/types/client/pages/CostPage/SavingView.d.ts +38 -0
- package/lib/types/client/pages/CostPage/ServiceDonut.d.ts +17 -0
- package/lib/types/client/pages/CostPage/TrendChart.d.ts +24 -0
- package/lib/types/client/pages/CostPage/budget-input.d.ts +30 -0
- package/lib/types/client/pages/CostPage/cost-api.d.ts +266 -0
- package/lib/types/client/pages/CostPage/cost-store.d.ts +25 -0
- package/lib/types/client/pages/CostPage/format.d.ts +37 -0
- package/lib/types/client/pages/CostPage/index.d.ts +34 -0
- package/lib/types/client/pages/CostPage/trend-fold.d.ts +32 -0
- package/lib/types/client/pages/CostPage/useEcharts.d.ts +70 -0
- package/lib/types/client/pages/OrgStructurePage/AccountStatsCard.d.ts +22 -0
- package/lib/types/client/pages/OrgStructurePage/CoreAccountsCard.d.ts +18 -0
- package/lib/types/client/pages/OrgStructurePage/CreateAccountDialog.d.ts +28 -0
- package/lib/types/client/pages/OrgStructurePage/ManageUsersDialog.d.ts +28 -0
- package/lib/types/client/pages/OrgStructurePage/MemberAccountsTable.d.ts +32 -0
- package/lib/types/client/pages/OrgStructurePage/MoveAccountDialog.d.ts +29 -0
- package/lib/types/client/pages/OrgStructurePage/OrgGlossaryDrawer.d.ts +13 -0
- package/lib/types/client/pages/OrgStructurePage/OrgTreeCard.d.ts +31 -0
- package/lib/types/client/pages/OrgStructurePage/index.d.ts +21 -0
- package/lib/types/client/pages/OrgStructurePage/org-api.d.ts +166 -0
- package/lib/types/client/pages/OverviewPage/AnchorRow.d.ts +24 -0
- package/lib/types/client/pages/OverviewPage/AttentionList.d.ts +29 -0
- package/lib/types/client/pages/OverviewPage/OverviewCharts.d.ts +79 -0
- package/lib/types/client/pages/OverviewPage/OverviewGlossaryDrawer.d.ts +15 -0
- package/lib/types/client/pages/OverviewPage/index.d.ts +22 -0
- package/lib/types/client/pages/OverviewPage/overview-api.d.ts +115 -0
- package/lib/types/client/pages/ResourcePage/AccountResourceList.d.ts +21 -0
- package/lib/types/client/pages/ResourcePage/components/GlossaryDrawer.d.ts +20 -0
- package/lib/types/client/pages/ResourcePage/components/MetricCards.d.ts +19 -0
- package/lib/types/client/pages/ResourcePage/components/MultiSelect.d.ts +27 -0
- package/lib/types/client/pages/ResourcePage/components/PanelPager.d.ts +26 -0
- package/lib/types/client/pages/ResourcePage/components/RankBars.d.ts +25 -0
- package/lib/types/client/pages/ResourcePage/components/ScopeSelect.d.ts +27 -0
- package/lib/types/client/pages/ResourcePage/components/SourceConfigModal.d.ts +21 -0
- package/lib/types/client/pages/ResourcePage/components/SyncControls.d.ts +18 -0
- package/lib/types/client/pages/ResourcePage/components/TrendChart.d.ts +14 -0
- package/lib/types/client/pages/ResourcePage/components/useColumnWidths.d.ts +12 -0
- package/lib/types/client/pages/ResourcePage/format.d.ts +9 -0
- package/lib/types/client/pages/ResourcePage/index.d.ts +20 -0
- package/lib/types/client/pages/ResourcePage/summary-api.d.ts +205 -0
- package/lib/types/client/pages/SetupPage/AskPanel.d.ts +21 -0
- package/lib/types/client/pages/SetupPage/ChatEmbed.d.ts +40 -0
- package/lib/types/client/pages/SetupPage/ChatTab.d.ts +17 -0
- package/lib/types/client/pages/SetupPage/FormTab.d.ts +12 -0
- package/lib/types/client/pages/SetupPage/FormTabV2.d.ts +14 -0
- package/lib/types/client/pages/SetupPage/ProgressTreeView.d.ts +15 -0
- package/lib/types/client/pages/SetupPage/StageFlow.d.ts +16 -0
- package/lib/types/client/pages/SetupPage/index.d.ts +10 -0
- package/lib/types/client/pages/SetupPage/progress-types.d.ts +36 -0
- package/lib/types/client/pages/SetupPage/session-binding.d.ts +38 -0
- package/lib/types/client/pages/SetupPage/session-store.d.ts +57 -0
- package/lib/types/client/pages/SetupPage/sessions-ref.d.ts +5 -0
- package/lib/types/client/pages/SetupPage/setup-replan.d.ts +13 -0
- package/lib/types/client/pages/SetupPage/wb-api.d.ts +192 -0
- package/lib/types/client/pages/list-preview.d.ts +36 -0
- package/lib/types/client/permission-mode.d.ts +53 -0
- package/lib/types/client/store.d.ts +22 -0
- package/lib/types/collect.d.ts +78 -0
- package/lib/types/config/account-scope.d.ts +61 -0
- package/lib/types/config/advice-findings.d.ts +31 -0
- package/lib/types/config/advice-prompt.d.ts +60 -0
- package/lib/types/config/advice.d.ts +116 -0
- package/lib/types/config/cts.d.ts +30 -0
- package/lib/types/config/evidence/rules.d.ts +31 -0
- package/lib/types/config/evidence/types.d.ts +103 -0
- package/lib/types/config/failure-note.d.ts +46 -0
- package/lib/types/config/fingerprint-cache.d.ts +45 -0
- package/lib/types/config/identity.d.ts +67 -0
- package/lib/types/config/query.d.ts +49 -0
- package/lib/types/config/rms.d.ts +412 -0
- package/lib/types/config/routes.d.ts +32 -0
- package/lib/types/config/types.d.ts +785 -0
- package/lib/types/config/views.d.ts +158 -0
- package/lib/types/cost/accounts.d.ts +29 -0
- package/lib/types/cost/advice-findings.d.ts +77 -0
- package/lib/types/cost/advice-model.d.ts +19 -0
- package/lib/types/cost/advice-prompt.d.ts +73 -0
- package/lib/types/cost/advice-subagent-types.d.ts +6 -0
- package/lib/types/cost/advice-subagent.d.ts +116 -0
- package/lib/types/cost/advice-types.d.ts +63 -0
- package/lib/types/cost/advice.d.ts +125 -0
- package/lib/types/cost/aggregate.d.ts +157 -0
- package/lib/types/cost/assume.d.ts +43 -0
- package/lib/types/cost/bss.d.ts +166 -0
- package/lib/types/cost/budget-overview.d.ts +38 -0
- package/lib/types/cost/budget.d.ts +56 -0
- package/lib/types/cost/cache.d.ts +58 -0
- package/lib/types/cost/caliber.d.ts +40 -0
- package/lib/types/cost/console-links.d.ts +27 -0
- package/lib/types/cost/credentials.d.ts +38 -0
- package/lib/types/cost/data-window.d.ts +38 -0
- package/lib/types/cost/evidence/catalog.d.ts +35 -0
- package/lib/types/cost/evidence/index.d.ts +70 -0
- package/lib/types/cost/evidence/inventory.d.ts +44 -0
- package/lib/types/cost/evidence/pricing.d.ts +72 -0
- package/lib/types/cost/evidence/projects.d.ts +18 -0
- package/lib/types/cost/evidence/rules.d.ts +66 -0
- package/lib/types/cost/evidence/state.d.ts +38 -0
- package/lib/types/cost/evidence/thresholds.d.ts +68 -0
- package/lib/types/cost/evidence/types.d.ts +288 -0
- package/lib/types/cost/evidence/utilization.d.ts +37 -0
- package/lib/types/cost/history.d.ts +36 -0
- package/lib/types/cost/ledger.d.ts +97 -0
- package/lib/types/cost/normalize.d.ts +37 -0
- package/lib/types/cost/period-projection.d.ts +57 -0
- package/lib/types/cost/plan-check.d.ts +102 -0
- package/lib/types/cost/plan-db.d.ts +73 -0
- package/lib/types/cost/plan-types.d.ts +183 -0
- package/lib/types/cost/plan.d.ts +63 -0
- package/lib/types/cost/quote.d.ts +45 -0
- package/lib/types/cost/report.d.ts +136 -0
- package/lib/types/cost/resources.d.ts +108 -0
- package/lib/types/cost/routes.d.ts +38 -0
- package/lib/types/cost/scope.d.ts +42 -0
- package/lib/types/cost/types.d.ts +335 -0
- package/lib/types/cost/unit-prices-derive.d.ts +19 -0
- package/lib/types/cost/unit-prices.d.ts +23 -0
- package/lib/types/db.d.ts +228 -0
- package/lib/types/host-log.d.ts +7 -0
- package/lib/types/http.d.ts +42 -0
- package/lib/types/index.d.ts +30 -0
- package/lib/types/inventory.d.ts +286 -0
- package/lib/types/obs.d.ts +16 -0
- package/lib/types/org/aggregate.d.ts +36 -0
- package/lib/types/org/churn.d.ts +10 -0
- package/lib/types/org/orgs.d.ts +258 -0
- package/lib/types/org/routes.d.ts +28 -0
- package/lib/types/org-types.d.ts +156 -0
- package/lib/types/per-service.d.ts +39 -0
- package/lib/types/setup/blueprint-loader.d.ts +81 -0
- package/lib/types/setup/caller.d.ts +105 -0
- package/lib/types/setup/engine.d.ts +41 -0
- package/lib/types/setup/form-store.d.ts +13 -0
- package/lib/types/setup/nodes/n1-check.d.ts +14 -0
- package/lib/types/setup/nodes/n10-governance.d.ts +6 -0
- package/lib/types/setup/nodes/n11-infra.d.ts +6 -0
- package/lib/types/setup/nodes/n12-reconcile.d.ts +6 -0
- package/lib/types/setup/nodes/n2-region.d.ts +6 -0
- package/lib/types/setup/nodes/n3-blueprint.d.ts +6 -0
- package/lib/types/setup/nodes/n4-modules.d.ts +6 -0
- package/lib/types/setup/nodes/n5-details.d.ts +6 -0
- package/lib/types/setup/nodes/n6-plan.d.ts +6 -0
- package/lib/types/setup/nodes/n7-verify.d.ts +6 -0
- package/lib/types/setup/nodes/n8-approve.d.ts +6 -0
- package/lib/types/setup/nodes/n9-buildmode.d.ts +6 -0
- package/lib/types/setup/plan-state.d.ts +10 -0
- package/lib/types/setup/prompt-loader.d.ts +16 -0
- package/lib/types/setup/routes.d.ts +22 -0
- package/lib/types/setup/session-notify.d.ts +30 -0
- package/lib/types/setup/tools.d.ts +19 -0
- package/lib/types/setup/types.d.ts +157 -0
- package/lib/types/sse-bus.d.ts +23 -0
- package/lib/types/tools/config-facts.d.ts +16 -0
- package/lib/types/tools/cost-facts.d.ts +10 -0
- package/lib/types/tools/register.d.ts +18 -0
- package/lib/types/wb-conventions.d.ts +140 -0
- package/package.json +77 -4
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { type ScopeDecision, type ScopeIdentity } from './account-scope.ts';
|
|
2
|
+
import { getMainAccount, type ConfigIdentity } from './identity.ts';
|
|
3
|
+
import { type RmsContext } from './rms.ts';
|
|
4
|
+
import { type ConfigAccountList, type ConfigCapability, type ConfigChangesView, type ConfigComplianceDetail, type ConfigComplianceRollup, type ConfigRuleDetail, type ConfigResourceDetail, type ConfigResourceRow, type ConfigScope, type ConfigSnapshot, type UncoveredReport, type ConfigChannel } from './types.ts';
|
|
5
|
+
/** 取数结果:快照 + 元信息;失败时给能力状态。 */
|
|
6
|
+
export interface SnapshotResult {
|
|
7
|
+
readonly snapshot: ConfigSnapshot | null;
|
|
8
|
+
readonly dataAsOf: string | null;
|
|
9
|
+
readonly source: 'live' | 'cache';
|
|
10
|
+
readonly capability?: ConfigCapability;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 清掉进程内缓存(刷新按钮 / 换账号)。
|
|
14
|
+
*
|
|
15
|
+
* 换凭据**不需要**调用它:身份与字典都按 AK 指纹分键,指纹一变天然未命中
|
|
16
|
+
* (见 `fingerprint-cache.ts`)。这个函数只服务"同一个身份下想重新问云上"。
|
|
17
|
+
*/
|
|
18
|
+
export declare function forgetConfig(accountId?: string): void;
|
|
19
|
+
/** 主账号的取法搬到了 `identity.ts`(身份与它同源);这里转出去只为兼容既有调用方。 */
|
|
20
|
+
export { getMainAccount };
|
|
21
|
+
/**
|
|
22
|
+
* 可切换的账号列表 + 主账号 + 通道判定。
|
|
23
|
+
*
|
|
24
|
+
* 成员身份下**不调组织名单接口**:必然 401/403,只会把一次失败写进 30 分钟的
|
|
25
|
+
* 名单缓存(资源页 2026-11-12 实测过这件事 —— 换回主账号后页面仍在报旧错误)。
|
|
26
|
+
* 名单因此只剩本账号自己,前端的视角初值由 `scope_default` 决定。
|
|
27
|
+
*/
|
|
28
|
+
export declare function computeAccountList(force?: boolean): Promise<ConfigAccountList | {
|
|
29
|
+
readonly unavailable: ConfigCapability;
|
|
30
|
+
}>;
|
|
31
|
+
/** 一次快照请求的参数。 */
|
|
32
|
+
export interface SnapshotOptions {
|
|
33
|
+
/** 页面传来的视角原文;空串 = 组织视角。**会**被 `decideScope` 按身份改写成生效视角。 */
|
|
34
|
+
readonly accountId: string;
|
|
35
|
+
readonly provider: string | null;
|
|
36
|
+
readonly region: string | null;
|
|
37
|
+
readonly force: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** 一次快照请求最终落在哪个视角、为什么。 */
|
|
40
|
+
export interface SnapshotResolution {
|
|
41
|
+
/** 组织域(主账号;成员身份下等于自己)。 */
|
|
42
|
+
readonly mainAccountId: string | null;
|
|
43
|
+
/** 生效的账号(空串 = 组织视角)。可能与 `SnapshotOptions.accountId` 不同。 */
|
|
44
|
+
readonly accountId: string;
|
|
45
|
+
readonly scope: ConfigScope;
|
|
46
|
+
/** 当前凭据身份(页面标注"当前是谁在看")。 */
|
|
47
|
+
readonly identity: {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly name: string;
|
|
50
|
+
} | null;
|
|
51
|
+
readonly channel: ConfigChannel;
|
|
52
|
+
/** 视角被改写/降级时的说明。 */
|
|
53
|
+
readonly note?: string;
|
|
54
|
+
}
|
|
55
|
+
/** 一次视角裁决:凭据是谁、请求的视角最后落在哪。 */
|
|
56
|
+
export interface ScopeResolution {
|
|
57
|
+
readonly identity: ConfigIdentity;
|
|
58
|
+
readonly ctx: RmsContext;
|
|
59
|
+
readonly decision: ScopeDecision;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 解析"当前凭据 + 请求的视角" → 生效视角。
|
|
63
|
+
*
|
|
64
|
+
* 路由里每个按账号取数的接口都要这一步(热点是同一个判定),抽出来是为了让
|
|
65
|
+
* "钳制"只在一处实现 —— 界面上的下拉、接口里的 `?account=`、AI 工具的参数
|
|
66
|
+
* 走的都是同一套规则。
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveScopeFor(requested: string, force?: boolean): Promise<({
|
|
69
|
+
readonly ok: true;
|
|
70
|
+
} & ScopeResolution) | {
|
|
71
|
+
readonly ok: false;
|
|
72
|
+
readonly capability: ConfigCapability;
|
|
73
|
+
}>;
|
|
74
|
+
export declare function computeSnapshot(options: SnapshotOptions): Promise<SnapshotResult & SnapshotResolution>;
|
|
75
|
+
/** 身份 → 视角决策的输入。 */
|
|
76
|
+
export declare function scopeIdentityOf(identity: ConfigIdentity): ScopeIdentity;
|
|
77
|
+
/** 单资源详情 + 时间线(只有账号视角取得到:跨 domain 读详情会 403)。 */
|
|
78
|
+
export declare function computeResourceDetail(accountId: string, resourceId: string, row: ConfigResourceRow | null): Promise<{
|
|
79
|
+
detail: ConfigResourceDetail | null;
|
|
80
|
+
capability?: ConfigCapability;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* 逐个问清楚"为什么这个账号在聚合结果里没有数据"。
|
|
84
|
+
*
|
|
85
|
+
* 判定只用两个事实,不做推断:
|
|
86
|
+
* 1. assume 能不能换成该账号的临时凭据(换不到 = 连看都看不到);
|
|
87
|
+
* 2. 换到之后 `tracker-config` 说什么 —— 实测未开记录器是
|
|
88
|
+
* `404 RMS.00010005 Tracker configuration does not exist in domain …`,
|
|
89
|
+
* 于是"没开资源记录器"这个结论是有出处的。
|
|
90
|
+
*/
|
|
91
|
+
export declare function computeUncovered(force?: boolean): Promise<{
|
|
92
|
+
report: UncoveredReport | null;
|
|
93
|
+
capability?: ConfigCapability;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* 只读缓存里的变更流**不触发取数**。
|
|
97
|
+
*
|
|
98
|
+
* 概览页要判断"是直接显示最近 3 条,还是给一个'扫描'按钮":组织视角扫一次要回看
|
|
99
|
+
* 20 个资源的时间线(几秒),不能因为打开页面就先跑一遍。所以先 peek。
|
|
100
|
+
*/
|
|
101
|
+
export declare function peekChanges(accountId: string, requested?: number): ConfigChangesView | null;
|
|
102
|
+
/**
|
|
103
|
+
* 变更事件流。
|
|
104
|
+
*
|
|
105
|
+
* 两种视角取"最近变更的资源"方式不同(都有实测依据):
|
|
106
|
+
* · 组织视角 → 聚合器 ResourceQL `order by updated desc limit N`(主账号凭据可以跑);
|
|
107
|
+
* · 账号视角 → 直接用已缓存的**全量清单**本地排序(assumed 凭据跑 ResourceQL 会 403
|
|
108
|
+
* `RMS.00010006 You are currently restricted`,所以不能走查询)。
|
|
109
|
+
*
|
|
110
|
+
* 然后逐个资源回看它自己的时间线,合并成一条流。这就是"没有跨资源变更 API"下
|
|
111
|
+
* 能做出来的最接近真事的形态 —— 数据里必须写明"这是最近 N 个资源的事件"。
|
|
112
|
+
*/
|
|
113
|
+
export declare function computeChanges(accountId: string, requested: number, force: boolean): Promise<{
|
|
114
|
+
view: ConfigChangesView | null;
|
|
115
|
+
capability?: ConfigCapability;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* 组织级合规汇总 —— **手动触发**。
|
|
119
|
+
*
|
|
120
|
+
* 为什么必须手动:聚合器不聚合合规(`/aggregators/{id}/policy-states` 实测 404),
|
|
121
|
+
* 只能逐账号 assume 读它自己的合规结果。5 个账号约 2 秒;缓存 6 小时。
|
|
122
|
+
*
|
|
123
|
+
* 一条硬规矩:**合计只算取数成功的账号**,失败的单独列出来。把失败的账号当 0
|
|
124
|
+
* 参与平均,会让"组织合规率"看起来比实际更好 —— 这是审计里最危险的一种错。
|
|
125
|
+
*/
|
|
126
|
+
export declare function computeComplianceRollup(force?: boolean): Promise<{
|
|
127
|
+
rollup: ConfigComplianceRollup | null;
|
|
128
|
+
capability?: ConfigCapability;
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* 一条合规规则的细则:assignment 详情 + 它的 policy-definition。
|
|
132
|
+
*
|
|
133
|
+
* 为什么要两次请求:assignment 给的是"这条规则在这个账号里怎么配的"(状态、参数、过滤),
|
|
134
|
+
* definition 给的才是"它到底在检查什么"(描述 + policy_rule 判定逻辑)。
|
|
135
|
+
* 前者拿不到 definition_id 时就只返回前者,不编造。
|
|
136
|
+
*
|
|
137
|
+
* @param accountId 拥有该规则的账号(组织视角下由汇总里挑一个)
|
|
138
|
+
* @param assignmentId 该账号里的规则 id
|
|
139
|
+
*/
|
|
140
|
+
export declare function computeRuleDetail(accountId: string, assignmentId: string): Promise<{
|
|
141
|
+
detail: ConfigRuleDetail | null;
|
|
142
|
+
capability?: ConfigCapability;
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* 合规明细:规则清单 + 不合规资源清单(可只取某条规则)。
|
|
146
|
+
*
|
|
147
|
+
* 为什么只有账号视角:驱动它的聚合器侧接口在云上未发布
|
|
148
|
+
* (`/aggregators/{id}/policy-states` → 404 APIGW.0101,实测)。
|
|
149
|
+
* 所以组织视角在这里不是"没做",而是**不可做** —— 返回能力状态而不是空表。
|
|
150
|
+
*
|
|
151
|
+
* @param accountId 目标账号(空串 = 组织视角 → 直接返回不可用)。
|
|
152
|
+
* @param ruleId 只看这条规则的不合规资源;null/空 = 全部规则。
|
|
153
|
+
*/
|
|
154
|
+
export declare function computeComplianceDetail(accountId: string, ruleId: string | null): Promise<{
|
|
155
|
+
detail: ConfigComplianceDetail | null;
|
|
156
|
+
capability?: ConfigCapability;
|
|
157
|
+
}>;
|
|
158
|
+
//# sourceMappingURL=views.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type BssContext } from './bss.ts';
|
|
2
|
+
/** 一个可切换的账号。 */
|
|
3
|
+
export interface CostAccount {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
/** active / suspended 等(原样返回,便于页面区分)。 */
|
|
7
|
+
readonly status: string;
|
|
8
|
+
/** created = 组织创建(自带委托);invited = 邀请加入。 */
|
|
9
|
+
readonly joinMethod: string;
|
|
10
|
+
}
|
|
11
|
+
/** 列表结果:带来源与能力状态。 */
|
|
12
|
+
export interface AccountList {
|
|
13
|
+
readonly accounts: readonly CostAccount[];
|
|
14
|
+
readonly source: 'organization' | 'cost-data' | 'none';
|
|
15
|
+
/** 组织接口不可用时的原因(此时回落到成本数据里的账号 ID)。 */
|
|
16
|
+
readonly organizationUnavailable?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function akFingerprint(ak: string): string;
|
|
19
|
+
/** 丢掉缓存(切换/刷新时用)。 */
|
|
20
|
+
export declare function forgetAccounts(): void;
|
|
21
|
+
/**
|
|
22
|
+
* 取组织账号列表。
|
|
23
|
+
*
|
|
24
|
+
* @param ctx 凭据上下文。
|
|
25
|
+
* @param fallbackIds 组织接口不可用时,用成本数据里出现过的账号兜底。
|
|
26
|
+
* @param force 忽略缓存。
|
|
27
|
+
*/
|
|
28
|
+
export declare function listAccounts(ctx: BssContext, fallbackIds?: readonly string[], force?: boolean): Promise<AccountList>;
|
|
29
|
+
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 发现 → 建议:把规则算好的东西喂给模型,并**守住数字**。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要单独一层(而不是继续让模型自己算):
|
|
5
|
+
* 上一版把"服务合计 + 占比"交给模型,它只能编比例("按 10% 降配"里的 10%
|
|
6
|
+
* 就是编的)。现在所有金额都由宿主按**资源的账单行**算好,模型只负责:
|
|
7
|
+
* ① 人话解释机制(为什么这台机器在浪费钱)
|
|
8
|
+
* ② 风险提示
|
|
9
|
+
* ③ 建议的执行顺序
|
|
10
|
+
* 模型输出里不出现任何金额字段可被采信 —— 它给的 `group_key` 才是它真正
|
|
11
|
+
* 表达的东西;金额一律由 `groupOf()` 回填。
|
|
12
|
+
*
|
|
13
|
+
* 另一条:**模型漏掉的分组必须补回来**。模型只会挑它认为重要的 3–5 条,
|
|
14
|
+
* 但"未挂载盘"这种小事漏掉没关系,"空闲 64C256G"漏掉是事故。所以
|
|
15
|
+
* `mergeAdvice()` 会把模型没提到的分组按模板补在末尾。
|
|
16
|
+
*
|
|
17
|
+
* @module @huaweidevtools/landingzone-workbench/cost/advice-findings
|
|
18
|
+
*/
|
|
19
|
+
import type { AdviceItem, AdviceStructured } from './advice-types.ts';
|
|
20
|
+
import type { Finding, FindingsGroup, FindingsResult } from './evidence/types.ts';
|
|
21
|
+
import { type CostType } from './types.ts';
|
|
22
|
+
/**
|
|
23
|
+
* 建议的优先级比较器。
|
|
24
|
+
*
|
|
25
|
+
* 排序由**宿主**决定,不交给模型:模型只会挑它觉得重要的几条,顺序还常常
|
|
26
|
+
* 跟着它写 prompt 的先后走。
|
|
27
|
+
*
|
|
28
|
+
* 规则:**风险高→低** → 层(确定性 → 规格过大 → 待观察 → 无法判定)→
|
|
29
|
+
* 账单金额降序 → 资源个数多优先。金额为 null 的组排在最后(它给不出钱)。
|
|
30
|
+
*
|
|
31
|
+
* 为什么风险排第一:用户要的是"先看哪几条"。风险决定了"能不能直接动手" ——
|
|
32
|
+
* 高风险的要走审批、要停机窗口,越早知道越好;低风险的多是"顺手关掉",
|
|
33
|
+
* 什么时候做都不吃亏。
|
|
34
|
+
*/
|
|
35
|
+
export declare function compareAdvice(a: AdviceItem, b: AdviceItem, groups: ReadonlyMap<string, FindingsGroup>): number;
|
|
36
|
+
/** 分组的稳定键(模型引用它,宿主据此换算金额)。 */
|
|
37
|
+
export declare function groupKey(group: Pick<FindingsGroup, 'layer' | 'kind'>): string;
|
|
38
|
+
/**
|
|
39
|
+
* 给模型看的事实快照。
|
|
40
|
+
*
|
|
41
|
+
* 只给"判定所必需"的字段,且**每条都带 group_key** —— 模型引用它即可,
|
|
42
|
+
* 不需要(也不允许)自己算钱。
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildFindingsFacts(result: FindingsResult, costType?: CostType): Record<string, unknown>;
|
|
45
|
+
/** 一个分组 → 一条模板建议(模型挂了也能看)。 */
|
|
46
|
+
export declare function templateItem(group: FindingsGroup): AdviceItem;
|
|
47
|
+
/** 纯模板版建议:不需要模型,`mergeAdvice()` 用它兜底与补漏。 */
|
|
48
|
+
export declare function templateAdvice(result: FindingsResult): AdviceStructured;
|
|
49
|
+
/**
|
|
50
|
+
* 脚注:**一行**说清"哪些没进合计"。
|
|
51
|
+
*
|
|
52
|
+
* 为什么由宿主拼、不让模型写:模型的脚注会把同一件事说三遍("watching 不计入
|
|
53
|
+
* 合计" + "观测不足只列清单" + "未用主账号顶替"),还会顺手编一句"本会话为只读
|
|
54
|
+
* 模式"——它不是这个系统里的事实来源。脚注只描述**数据口径**,而口径是宿主算的。
|
|
55
|
+
*/
|
|
56
|
+
export declare function footnoteOf(result: FindingsResult): string;
|
|
57
|
+
/**
|
|
58
|
+
* 把模型的条目与规则的分组合起来。
|
|
59
|
+
*
|
|
60
|
+
* 规则:
|
|
61
|
+
* · 模型每条必须带 `group_key`,且必须是真实存在的分组 —— 否则丢弃该条
|
|
62
|
+
* (避免它凭空造出"服务级"建议);
|
|
63
|
+
* · 金额、风险、证据一律由**分组**决定,模型的文本只占 `reason` /
|
|
64
|
+
* `risk_note` / `action` / `title`;
|
|
65
|
+
* · 模型没提到的分组按模板补在末尾 —— 不许因为模型"觉得不重要"就消失。
|
|
66
|
+
*/
|
|
67
|
+
export declare function mergeAdvice(model: AdviceStructured | null, result: FindingsResult): AdviceStructured;
|
|
68
|
+
/** 某分组里最该被点名的几个资源(卡片展开用)。 */
|
|
69
|
+
export declare function sampleFindings(group: FindingsGroup, limit?: number): readonly Finding[];
|
|
70
|
+
/**
|
|
71
|
+
* 模板正文(markdown 兜底)。
|
|
72
|
+
*
|
|
73
|
+
* 为什么还要 markdown:`writeAdvice` 拒绝空正文;而且存档里留一份人可读的
|
|
74
|
+
* 文本,日后 diff 起来比 JSON 直观。
|
|
75
|
+
*/
|
|
76
|
+
export declare function findingsMarkdown(result: FindingsResult): string;
|
|
77
|
+
//# sourceMappingURL=advice-findings.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** 解析结果。 */
|
|
2
|
+
export interface AdviceModelRoute {
|
|
3
|
+
readonly provider: string;
|
|
4
|
+
readonly model: string;
|
|
5
|
+
/** 从哪儿来的(排障用):env / profile:<名字> / none。 */
|
|
6
|
+
readonly source: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 列出候选模型路由(按优先级)。
|
|
10
|
+
*
|
|
11
|
+
* 为什么是"候选"而不是"唯一答案":本进程到底用哪个 profile,插件侧没有可靠信号,
|
|
12
|
+
* 而不同 profile 的默认模型可能不同(实测 web 用 hwcdeveloper,desktop 用
|
|
13
|
+
* hwc-equipment)。拿错 provider 会让子代理直接跑成 error,所以调用方按顺序试,
|
|
14
|
+
* 第一个跑通的就是对的那个。
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveAdviceModels(): readonly AdviceModelRoute[];
|
|
17
|
+
/** 解析子代理要用的模型路由(取第一个候选)。 */
|
|
18
|
+
export declare function resolveAdviceModel(preferProfile?: string): AdviceModelRoute | null;
|
|
19
|
+
//# sourceMappingURL=advice-model.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 成本建议的 prompt 与输出 schema(宿主侧)。
|
|
3
|
+
*
|
|
4
|
+
* 这一版的核心变化:**模型不再拥有任何金额**。
|
|
5
|
+
*
|
|
6
|
+
* 上一版把"服务合计 + 占比"塞给模型,并要求它"从上面的数字推出来" ——
|
|
7
|
+
* 实际上它推不出来,只能给服务总额乘一个自己发明的比例("按 10% 降配回收")。
|
|
8
|
+
* 现在宿主先用规则引擎把每条发现算到**具体资源的账单行**上(见
|
|
9
|
+
* `evidence/` 与 `advice-findings.ts`),模型改成只回答三件事:
|
|
10
|
+
* ① 这组资源为什么在浪费钱(机制)
|
|
11
|
+
* ② 动它有什么副作用(风险)
|
|
12
|
+
* ③ 几条建议的先后顺序
|
|
13
|
+
*
|
|
14
|
+
* 输出因此不再有 `saving_month`:模型给 `group_key`,金额由宿主回填。
|
|
15
|
+
* 这样即使模型胡写,卡片上的钱也是对的。
|
|
16
|
+
*
|
|
17
|
+
* @module @huaweidevtools/landingzone-workbench/cost/advice-prompt
|
|
18
|
+
*/
|
|
19
|
+
import { type CostType } from './types.ts';
|
|
20
|
+
/** 结构化输出的 JSON Schema(ObjectJsonSchema 子集)。 */
|
|
21
|
+
export declare const ADVICE_OUTPUT_SCHEMA: {
|
|
22
|
+
readonly type: "object";
|
|
23
|
+
readonly additionalProperties: false;
|
|
24
|
+
readonly required: readonly ["items"];
|
|
25
|
+
readonly properties: {
|
|
26
|
+
readonly items: {
|
|
27
|
+
readonly type: "array";
|
|
28
|
+
readonly items: {
|
|
29
|
+
readonly type: "object";
|
|
30
|
+
readonly additionalProperties: false;
|
|
31
|
+
readonly required: readonly ["title", "group_key", "risk", "action", "reason", "risk_note"];
|
|
32
|
+
readonly properties: {
|
|
33
|
+
/** 这一组的人话标题(不超过 24 字)。 */
|
|
34
|
+
readonly title: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
};
|
|
37
|
+
/** 必须原样取自 facts.groups[].group_key。 */
|
|
38
|
+
readonly group_key: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
};
|
|
41
|
+
readonly risk: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
readonly enum: readonly ["low", "medium", "high"];
|
|
44
|
+
};
|
|
45
|
+
/** 用户具体怎么做(可执行,含控制台路径)。 */
|
|
46
|
+
readonly action: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
};
|
|
49
|
+
/** 为什么这组在浪费钱(机制,不超过 60 字)。 */
|
|
50
|
+
readonly reason: {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
};
|
|
53
|
+
/** 副作用与要留意的点。 */
|
|
54
|
+
readonly risk_note: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/** 生成建议的 prompt。facts 是 `buildFindingsFacts()` 的产物。 */
|
|
63
|
+
export declare function buildAdvicePrompt(input: {
|
|
64
|
+
readonly cycle: string;
|
|
65
|
+
readonly accountId: string;
|
|
66
|
+
readonly accountName: string | null;
|
|
67
|
+
readonly facts: unknown;
|
|
68
|
+
/** 这份钱是按哪个成本口径算的(原始成本 / 摊销成本)。 */
|
|
69
|
+
readonly costType: CostType;
|
|
70
|
+
/** 可以挑的分组键(模型只能从这里选)。 */
|
|
71
|
+
readonly groupKeys: readonly string[];
|
|
72
|
+
}): string;
|
|
73
|
+
//# sourceMappingURL=advice-prompt.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用「一次性子代理」跑成本建议(宿主侧)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么不再往用户会话里 `prompt`:那会把用户正在进行的对话顶上去 —— 用户看得见
|
|
5
|
+
* 一轮陌生的问答,上下文也被污染。DSH 有专门的机制干这件事:
|
|
6
|
+
* `ctx.subagents.startActivation({ delivery: 'caller' })` —— 子代理独立建会话,
|
|
7
|
+
* 结果只回给调用方,**不通知父代理**,用户会话完全不受影响。
|
|
8
|
+
*
|
|
9
|
+
* 还顺带两个好处:`outputSchema` 让子代理直接返回结构化 JSON;子代理有自己的
|
|
10
|
+
* stopReason/diagnostic,失败原因比"等了 150 秒没等到"精确得多。
|
|
11
|
+
*
|
|
12
|
+
* 父 agent 的取法(实测顺序,很重要):
|
|
13
|
+
* 1. 调用方显式给的;
|
|
14
|
+
* 2. 宿主里**现成的 live agent**(`agents.list()`)—— 它带着用户配好的模型与组合;
|
|
15
|
+
* 3. 自建 root agent(兜底)。自建的必须给 `meta.cwd`,否则会话落到 sessions/_no-cwd;
|
|
16
|
+
* 而且可能**没有模型**,所以只当最后手段。
|
|
17
|
+
*
|
|
18
|
+
* @module @huaweidevtools/landingzone-workbench/cost/advice-subagent
|
|
19
|
+
*/
|
|
20
|
+
import type { Logger } from './advice-subagent-types.ts';
|
|
21
|
+
/** 一次运行的结果。 */
|
|
22
|
+
export interface SubagentRunResult {
|
|
23
|
+
readonly ok: boolean;
|
|
24
|
+
/** 结构化结果(请求了 outputSchema 且子代理按约定返回时)。 */
|
|
25
|
+
readonly structured?: unknown;
|
|
26
|
+
/** 最终 assistant 文本(没有结构化结果时的兜底)。 */
|
|
27
|
+
readonly text: string;
|
|
28
|
+
readonly stopReason: string;
|
|
29
|
+
readonly error?: string;
|
|
30
|
+
/** 子代理的会话 id(排障用)。 */
|
|
31
|
+
readonly childSessionId?: string;
|
|
32
|
+
/** 诊断:父 agent 的来源(caller / list / created)与宿主里 live agent 的数量。 */
|
|
33
|
+
readonly parentSource?: string;
|
|
34
|
+
readonly liveAgents?: number;
|
|
35
|
+
/** 诊断:父 agent 上可读到的键(用来判断能不能取到模型配置)。 */
|
|
36
|
+
readonly parentKeys?: readonly string[];
|
|
37
|
+
readonly parentOptionsKeys?: readonly string[];
|
|
38
|
+
/** 诊断:从父 agent 上读到的模型路由(provider/model)。 */
|
|
39
|
+
readonly parentModel?: string;
|
|
40
|
+
/** 诊断:最终被宿主接受的 spec 形状(新版扁平 / 旧版 request)。 */
|
|
41
|
+
readonly specShape?: 'flat' | 'legacy';
|
|
42
|
+
}
|
|
43
|
+
/** 从服务对象上找出可用的"启动"方法;找不到时给出可读的诊断。 */
|
|
44
|
+
export declare function resolveSubagentStarter(service: unknown): {
|
|
45
|
+
ok: true;
|
|
46
|
+
start: (spec: unknown) => Promise<unknown>;
|
|
47
|
+
} | {
|
|
48
|
+
ok: false;
|
|
49
|
+
error: string;
|
|
50
|
+
};
|
|
51
|
+
/** 宿主服务的**最小子集**(只声明用到的部分,避免把 dsh 内部类型带进来)。 */
|
|
52
|
+
export interface AdviceHostServices {
|
|
53
|
+
readonly agents: {
|
|
54
|
+
create: (options: unknown) => Promise<unknown>;
|
|
55
|
+
list?: () => readonly unknown[];
|
|
56
|
+
} | null;
|
|
57
|
+
readonly subagents: {
|
|
58
|
+
startActivation: (spec: unknown) => Promise<unknown>;
|
|
59
|
+
} | null;
|
|
60
|
+
readonly logger: Logger;
|
|
61
|
+
}
|
|
62
|
+
export interface AdviceRunInput {
|
|
63
|
+
readonly prompt: string;
|
|
64
|
+
readonly label: string;
|
|
65
|
+
/** 可选:让子代理直接返回结构化结果的 JSON Schema。 */
|
|
66
|
+
readonly outputSchema?: object;
|
|
67
|
+
/** 可选:显式指定父 agent。 */
|
|
68
|
+
readonly parentAgent?: unknown;
|
|
69
|
+
/** 可选:直接指定父会话 id(跳过 sessions.create,探针用)。 */
|
|
70
|
+
readonly sessionId?: string;
|
|
71
|
+
/** 父 agent 的工作目录;缺省会让会话落到 sessions/_no-cwd 且跑不起来。 */
|
|
72
|
+
readonly cwd?: string;
|
|
73
|
+
/** 超时(毫秒),默认 180 秒。 */
|
|
74
|
+
readonly timeoutMs?: number;
|
|
75
|
+
/** 结果投递方式:caller=只回调用方(默认);parent=同时通知父代理。 */
|
|
76
|
+
readonly delivery?: 'caller' | 'parent';
|
|
77
|
+
/** 子代理的模型路由(provider/model);缺省继承父 agent 的组合。 */
|
|
78
|
+
readonly agentOptions?: {
|
|
79
|
+
provider?: string;
|
|
80
|
+
model?: string;
|
|
81
|
+
reasoningEffort?: string;
|
|
82
|
+
maxTokens?: number;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** 一次性子代理的调用参数:同一份内容,按新旧两种宿主形状各拼一份。 */
|
|
86
|
+
export interface SubagentSpecs {
|
|
87
|
+
/** DSH 0.2.2-rc.5 起:parent / prompt / cwd / signal … 都在顶层。 */
|
|
88
|
+
readonly flat: Record<string, unknown>;
|
|
89
|
+
/** DSH ≤ 0.2.1-rc.x:整包塞在 `request` 里。 */
|
|
90
|
+
readonly legacy: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 按两种宿主形状拼 spec。
|
|
94
|
+
*
|
|
95
|
+
* 为什么要两份:DSH 在 0.2.2-rc.5 把 `SubagentActivationSpec` 拍平了 —— 旧版读
|
|
96
|
+
* `spec.request.parent`,新版读 `spec.parent.id`。只认一种形状,换一版宿主就变成
|
|
97
|
+
* `Cannot read properties of undefined (reading 'id')`(2026-11-23 实测:同一次点击
|
|
98
|
+
* 在 0.2.1-rc.2 上能跑、在 0.2.2-rc.5 上必失败,而且报错完全看不出是形状问题)。
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildSubagentSpecs(input: AdviceRunInput, parentAgent: unknown, signal: AbortSignal): SubagentSpecs;
|
|
101
|
+
/** 这条异常像不像"宿主读的 spec 形状和我们给的不一样"。 */
|
|
102
|
+
export declare function isSpecShapeMismatch(error: unknown): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* 先按新形状起,只有"看起来是形状不匹配"时才退回旧形状。
|
|
105
|
+
*
|
|
106
|
+
* 两次失败都把原因带上:只报最后一句,排查时看不出试过什么,也分不清是宿主
|
|
107
|
+
* 版本问题还是父 agent 没选对。
|
|
108
|
+
*/
|
|
109
|
+
export declare function startWithShapeFallback(start: (spec: unknown) => Promise<unknown>, specs: SubagentSpecs): Promise<{
|
|
110
|
+
activation: unknown;
|
|
111
|
+
shape: 'flat' | 'legacy';
|
|
112
|
+
flatError?: string;
|
|
113
|
+
}>;
|
|
114
|
+
/** 生成一次建议。 */
|
|
115
|
+
export declare function runAdviceSubagent(services: AdviceHostServices, input: AdviceRunInput): Promise<SubagentRunResult>;
|
|
116
|
+
//# sourceMappingURL=advice-subagent.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 建议的结构化形态(**纯类型 + 纯函数**,浏览器与宿主共用)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独一个文件:`advice.ts` 要 `node:fs` / `node:crypto`,客户端一旦 import
|
|
5
|
+
* 它的值,打包器就会把 node 内置模块拖进浏览器 bundle。所以卡片与解析只碰这个文件。
|
|
6
|
+
*
|
|
7
|
+
* @module @huaweidevtools/landingzone-workbench/cost/advice-types
|
|
8
|
+
*/
|
|
9
|
+
/** 一条建议。 */
|
|
10
|
+
export interface AdviceItem {
|
|
11
|
+
readonly title: string;
|
|
12
|
+
/** 预计月度节省(元);说不清时为 null —— 不编数字。 */
|
|
13
|
+
readonly saving_month: number | null;
|
|
14
|
+
readonly risk: 'low' | 'medium' | 'high' | 'unknown';
|
|
15
|
+
/**
|
|
16
|
+
* **为什么这样做能省钱**(机制:闲置 / 规格过剩 / 重复订购 / 计费模式不匹配…)。
|
|
17
|
+
*
|
|
18
|
+
* 这一条与 evidence 是两回事:evidence 是"数据凭什么这么说",
|
|
19
|
+
* reason 是"省下的钱从哪来"。老存档没有这个字段,所以允许为空串。
|
|
20
|
+
*/
|
|
21
|
+
readonly reason: string;
|
|
22
|
+
/** 这条建议主要在**排除什么风险**(例如"继续为空闲地址付费")。老存档为空串。 */
|
|
23
|
+
readonly risk_note: string;
|
|
24
|
+
/** 证据:必须引用工具返回的原值。 */
|
|
25
|
+
readonly evidence: string;
|
|
26
|
+
/** 怎么做:可执行的动作。 */
|
|
27
|
+
readonly action: string;
|
|
28
|
+
/**
|
|
29
|
+
* 这条建议对应哪一个**规则分组**(`layer:kind`)。
|
|
30
|
+
*
|
|
31
|
+
* 这是"数字归谁管"的分界线:模型只表达"我在说哪一组",金额、风险、证据
|
|
32
|
+
* 由宿主按该组的资源账单回填(见 `advice-findings.ts mergeAdvice`)。
|
|
33
|
+
* 老存档没有这个字段,所以允许为空。
|
|
34
|
+
*/
|
|
35
|
+
readonly group_key: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** 整份建议的结构化形态。 */
|
|
38
|
+
export interface AdviceStructured {
|
|
39
|
+
/** 合计月度节省(元);以逐项相加为准(见 normalizeStructured)。 */
|
|
40
|
+
readonly total_saving_month: number | null;
|
|
41
|
+
readonly items: readonly AdviceItem[];
|
|
42
|
+
readonly footnote: string;
|
|
43
|
+
}
|
|
44
|
+
/** 风险等级的人话。 */
|
|
45
|
+
export declare const RISK_LABEL: Readonly<Record<AdviceItem['risk'], string>>;
|
|
46
|
+
/**
|
|
47
|
+
* 把模型给的东西收敛成合法形态;不合法返回 null(卡片会退回显示原始 markdown)。
|
|
48
|
+
*
|
|
49
|
+
* 一个刻意的选择:**合计以逐项相加为准**。模型自己报的 `total_saving_month`
|
|
50
|
+
* 经常与条目之和差一点,而卡片上"合计 ¥6.1 万"就写在几条"¥1.8 万"上面,
|
|
51
|
+
* 用户会顺手加一下 —— 加不上就没人信这份建议了。
|
|
52
|
+
*/
|
|
53
|
+
export declare function normalizeStructured(value: unknown): AdviceStructured | null;
|
|
54
|
+
/**
|
|
55
|
+
* 从模型输出里抠出结构化建议。
|
|
56
|
+
*
|
|
57
|
+
* 模型只会被要求给一个 ```json 代码块,但它偶尔会加上一句"根据工具返回……",
|
|
58
|
+
* 所以这里不追求严格——先找 fenced block,再退一步找最外层的花括号。
|
|
59
|
+
*
|
|
60
|
+
* @returns 结构化结果;解析不出来为 null(调用方退回显示 markdown)。
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseAdviceOutput(text: string): AdviceStructured | null;
|
|
63
|
+
//# sourceMappingURL=advice-types.d.ts.map
|