@huaweidevtools/aishell-dsh-deploy 0.0.0-stage → 0.0.1-beta.4
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 +164 -2
- package/cordis.patch.yml +15 -0
- package/lib/data/permission-registry.json +1 -0
- package/lib/data/terraform-examples.zip +0 -0
- package/lib/index.js +4796 -0
- package/lib/types/auth-http.d.ts +44 -0
- package/lib/types/auth-obs-signer.d.ts +46 -0
- package/lib/types/auth-signer.d.ts +46 -0
- package/lib/types/bridge.d.ts +70 -0
- package/lib/types/credentials.d.ts +105 -0
- package/lib/types/data-paths.d.ts +70 -0
- package/lib/types/deployment-state.d.ts +69 -0
- package/lib/types/gates/cost_gate.d.ts +24 -0
- package/lib/types/gates/credential_gate.d.ts +21 -0
- package/lib/types/gates/mirror.d.ts +27 -0
- package/lib/types/gates/networking_gate.d.ts +9 -0
- package/lib/types/gates/terraform_env.d.ts +26 -0
- package/lib/types/index.d.ts +96 -0
- package/lib/types/permission/gate.d.ts +87 -0
- package/lib/types/permission/mode.d.ts +69 -0
- package/lib/types/permission/registry.d.ts +109 -0
- package/lib/types/permission-context.d.ts +84 -0
- package/lib/types/permission-route.d.ts +78 -0
- package/lib/types/permission.d.ts +37 -0
- package/lib/types/prompt.d.ts +59 -0
- package/lib/types/schemas/cost.d.ts +108 -0
- package/lib/types/schemas/networking.d.ts +115 -0
- package/lib/types/security-groups.d.ts +43 -0
- package/lib/types/tools/annotations.d.ts +94 -0
- package/lib/types/tools/balance_summary.d.ts +69 -0
- package/lib/types/tools/cost.d.ts +16 -0
- package/lib/types/tools/deployment.d.ts +14 -0
- package/lib/types/tools/errors.d.ts +40 -0
- package/lib/types/tools/examples.d.ts +4 -0
- package/lib/types/tools/existing_resources.d.ts +29 -0
- package/lib/types/tools/index.d.ts +32 -0
- package/lib/types/tools/networking.d.ts +13 -0
- package/lib/types/tools/openapi.d.ts +113 -0
- package/lib/types/tools/provider_schema.d.ts +19 -0
- package/lib/types/tools/terraform.d.ts +32 -0
- package/lib/types/types.d.ts +84 -0
- package/lib/types/utils/hash.d.ts +11 -0
- package/lib/types/utils/tar.d.ts +29 -0
- package/lib/types/version.d.ts +18 -0
- package/package.json +59 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* networking.json zod schema.
|
|
3
|
+
*
|
|
4
|
+
* Three layers: topology (infra), network_objects (eips/nat/lb),
|
|
5
|
+
* components (resource identity + optional network attach).
|
|
6
|
+
*
|
|
7
|
+
* Validation tiers (§6):
|
|
8
|
+
* A (server hard-validates): reference consistency, uniqueness, CIDR
|
|
9
|
+
* B (structural): enums, required, port ranges
|
|
10
|
+
* C (loose): ports syntax, source CIDR, description — non-empty only
|
|
11
|
+
*
|
|
12
|
+
* Validation reads its contract from this in-code schema, NOT
|
|
13
|
+
* from the file's $schema field. $schema is just a label; the file is a
|
|
14
|
+
* request body, not a persistent contract — server upgrades don't
|
|
15
|
+
* promise to accept old files (re-run update_networking).
|
|
16
|
+
*/
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
export declare const NetworkingSchema: z.ZodObject<{
|
|
19
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
20
|
+
topology: z.ZodObject<{
|
|
21
|
+
vpc: z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
cidr: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
subnets: z.ZodArray<z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
cidr: z.ZodString;
|
|
28
|
+
az: z.ZodString;
|
|
29
|
+
route_table: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
route_tables: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
34
|
+
destination: z.ZodString;
|
|
35
|
+
next_hop_type: z.ZodEnum<{
|
|
36
|
+
nat: "nat";
|
|
37
|
+
vpn: "vpn";
|
|
38
|
+
peering: "peering";
|
|
39
|
+
internet: "internet";
|
|
40
|
+
}>;
|
|
41
|
+
next_hop: z.ZodString;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
}, z.core.$strip>>>;
|
|
44
|
+
security_groups: z.ZodArray<z.ZodObject<{
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
rules: z.ZodArray<z.ZodObject<{
|
|
47
|
+
direction: z.ZodEnum<{
|
|
48
|
+
ingress: "ingress";
|
|
49
|
+
egress: "egress";
|
|
50
|
+
}>;
|
|
51
|
+
protocol: z.ZodEnum<{
|
|
52
|
+
any: "any";
|
|
53
|
+
tcp: "tcp";
|
|
54
|
+
udp: "udp";
|
|
55
|
+
icmp: "icmp";
|
|
56
|
+
icmpv6: "icmpv6";
|
|
57
|
+
}>;
|
|
58
|
+
ports: z.ZodString;
|
|
59
|
+
source: z.ZodOptional<z.ZodString>;
|
|
60
|
+
destination: z.ZodOptional<z.ZodString>;
|
|
61
|
+
description: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
network_objects: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
eips: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
bandwidth: z.ZodString;
|
|
69
|
+
attached_to: z.ZodObject<{
|
|
70
|
+
kind: z.ZodEnum<{
|
|
71
|
+
nat: "nat";
|
|
72
|
+
instance: "instance";
|
|
73
|
+
port: "port";
|
|
74
|
+
}>;
|
|
75
|
+
target: z.ZodString;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
}, z.core.$strip>>>;
|
|
78
|
+
nat_gateways: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
79
|
+
id: z.ZodString;
|
|
80
|
+
subnet: z.ZodString;
|
|
81
|
+
snat_eip: z.ZodString;
|
|
82
|
+
snat_source_cidr: z.ZodString;
|
|
83
|
+
}, z.core.$strip>>>;
|
|
84
|
+
loadbalancers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
subnet: z.ZodString;
|
|
87
|
+
vip_type: z.ZodEnum<{
|
|
88
|
+
external: "external";
|
|
89
|
+
internal: "internal";
|
|
90
|
+
}>;
|
|
91
|
+
listeners: z.ZodArray<z.ZodObject<{
|
|
92
|
+
port: z.ZodNumber;
|
|
93
|
+
protocol: z.ZodEnum<{
|
|
94
|
+
tcp: "tcp";
|
|
95
|
+
udp: "udp";
|
|
96
|
+
http: "http";
|
|
97
|
+
https: "https";
|
|
98
|
+
}>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
members: z.ZodArray<z.ZodObject<{
|
|
101
|
+
target: z.ZodString;
|
|
102
|
+
port: z.ZodNumber;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
}, z.core.$strip>>>;
|
|
105
|
+
}, z.core.$strip>>;
|
|
106
|
+
components: z.ZodArray<z.ZodObject<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
type: z.ZodString;
|
|
109
|
+
subnet: z.ZodOptional<z.ZodString>;
|
|
110
|
+
security_groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
111
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
export type Networking = z.infer<typeof NetworkingSchema>;
|
|
115
|
+
//# sourceMappingURL=networking.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security-group rule extraction from plan/state JSON (§6.4).
|
|
3
|
+
*
|
|
4
|
+
* After terraform_plan / terraform_state, the tool extracts all
|
|
5
|
+
* secgroup rules from the structured JSON output and surfaces them as a
|
|
6
|
+
* flat list — pulling rules buried deep in the plan to the top for human
|
|
7
|
+
* review. No "reasonableness" judgment (that needs AI); just formatting.
|
|
8
|
+
*
|
|
9
|
+
* Provider has two port-field shapes (§6.4 fix):
|
|
10
|
+
* - `ports` (string, e.g. "80,443") — networking_secgroup_rule
|
|
11
|
+
* - `port_range_min`/`port_range_max` (numbers) — vpc_secgroup_rule
|
|
12
|
+
* Extraction prefers `ports`, falls back to the range.
|
|
13
|
+
*/
|
|
14
|
+
export interface SecgroupRuleView {
|
|
15
|
+
address: string;
|
|
16
|
+
rule_local_name: string;
|
|
17
|
+
direction: string;
|
|
18
|
+
protocol: string;
|
|
19
|
+
ports: string;
|
|
20
|
+
source: string;
|
|
21
|
+
}
|
|
22
|
+
interface PlanResource {
|
|
23
|
+
address: string;
|
|
24
|
+
type: string;
|
|
25
|
+
/** Field values — present in both planned_values (plan) and values (state). */
|
|
26
|
+
values?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
interface PlanJson {
|
|
29
|
+
planned_values?: {
|
|
30
|
+
root_module?: {
|
|
31
|
+
resources?: PlanResource[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
values?: {
|
|
35
|
+
root_module?: {
|
|
36
|
+
resources?: PlanResource[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Extract secgroup rules from a `terraform show -json` plan or state output. */
|
|
41
|
+
export declare function extractSecurityGroups(planOrStateJson: PlanJson): SecgroupRuleView[];
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=security-groups.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool risk declarations — what each tool is allowed to do to the account.
|
|
3
|
+
*
|
|
4
|
+
* ## These are HINTS, not a security boundary
|
|
5
|
+
*
|
|
6
|
+
* They do not change what any tool does: every tool still runs through its
|
|
7
|
+
* gates (`denyTerraformMutation`, `denyHttp`, the credential scanner, the
|
|
8
|
+
* cost/tf_hash gate). A declaration only lets a surface describe a call before
|
|
9
|
+
* it runs — "this one may destroy". A wrong `readOnlyHint: true` is therefore
|
|
10
|
+
* the dangerous direction: it invites an unconfirmed call to something that
|
|
11
|
+
* mutates.
|
|
12
|
+
*
|
|
13
|
+
* Nothing enforces these, so a wrong hint is not caught by anything — which is
|
|
14
|
+
* why they are reviewed tool by tool rather than applied in bulk.
|
|
15
|
+
*
|
|
16
|
+
* ## Defaults (why an unset field is the *safe* default)
|
|
17
|
+
*
|
|
18
|
+
* readOnlyHint defaults false → "assume it can modify things"
|
|
19
|
+
* destructiveHint defaults true → "assume it may destroy"
|
|
20
|
+
* idempotentHint defaults false → "assume a retry has an effect"
|
|
21
|
+
* openWorldHint defaults true → "assume it touches the outside world"
|
|
22
|
+
*
|
|
23
|
+
* Every field is still set explicitly: an implicit default and a deliberate
|
|
24
|
+
* choice look identical to a reader, and this file is where the deliberate
|
|
25
|
+
* choice is recorded.
|
|
26
|
+
*
|
|
27
|
+
* ## Semantics used here
|
|
28
|
+
*
|
|
29
|
+
* `readOnlyHint` = "does not modify **cloud** resources". This project's
|
|
30
|
+
* meaningful line is whether a tool can create/change/delete a billable cloud
|
|
31
|
+
* resource, not whether it writes a local file or syncs tfstate. So
|
|
32
|
+
* `terraform_plan` / `terraform_refresh` / `terraform_import` are marked
|
|
33
|
+
* read-only even though they write state — none of them touch cloud resources.
|
|
34
|
+
* `openapi_request` is the exception that proves the rule: it can issue DELETE,
|
|
35
|
+
* so it is NOT read-only. (`terraform_plan` writing state is a known grey area —
|
|
36
|
+
* see the per-tool note.)
|
|
37
|
+
*
|
|
38
|
+
* `openWorldHint` = "interacts with an external system" (HuaweiCloud APIs, a
|
|
39
|
+
* provider download). Pure local-filesystem tools are false.
|
|
40
|
+
*
|
|
41
|
+
* `destructiveHint` is only meaningful when `readOnlyHint` is false; it says
|
|
42
|
+
* "may destroy/replace". Set alongside for each writable tool.
|
|
43
|
+
*/
|
|
44
|
+
import type { ToolAnnotations } from "../types.js";
|
|
45
|
+
/**
|
|
46
|
+
* Reads HuaweiCloud / the local filesystem, changes nothing.
|
|
47
|
+
* e.g. apiexplorer, list_existing_resources.
|
|
48
|
+
*/
|
|
49
|
+
export declare const READ_ONLY_CLOUD: ToolAnnotations;
|
|
50
|
+
/**
|
|
51
|
+
* Reads only local state, no external system, changes nothing.
|
|
52
|
+
* e.g. provider_schema, terraform_state.
|
|
53
|
+
*/
|
|
54
|
+
export declare const READ_ONLY_LOCAL: ToolAnnotations;
|
|
55
|
+
/**
|
|
56
|
+
* Writes files inside the deployment workspace only; creates nothing, destroys
|
|
57
|
+
* nothing, no external system. Re-running with the same input converges.
|
|
58
|
+
* e.g. create_deployment, update_networking, update_cost.
|
|
59
|
+
*/
|
|
60
|
+
export declare const LOCAL_WRITE: ToolAnnotations;
|
|
61
|
+
/**
|
|
62
|
+
* Removes local data and cannot be undone (delete_deployment `rm -rf`).
|
|
63
|
+
* Re-running is safe (a second delete finds nothing) but the first is final.
|
|
64
|
+
*/
|
|
65
|
+
export declare const LOCAL_DESTRUCTIVE: ToolAnnotations;
|
|
66
|
+
/**
|
|
67
|
+
* Writes remote state / downloads artifacts; does not create or destroy cloud
|
|
68
|
+
* resources. e.g. terraform_init, terraform_install.
|
|
69
|
+
*/
|
|
70
|
+
export declare const CLOUD_WRITE: ToolAnnotations;
|
|
71
|
+
/**
|
|
72
|
+
* Creates, changes, or destroys cloud resources, and *converges* — a retry
|
|
73
|
+
* with the same input is a no-op. e.g. terraform_apply (re-apply converges),
|
|
74
|
+
* terraform_destroy (re-destroy finds nothing).
|
|
75
|
+
*/
|
|
76
|
+
export declare const CLOUD_DESTRUCTIVE: ToolAnnotations;
|
|
77
|
+
/**
|
|
78
|
+
* A raw API call whose effect depends on the argument: `openapi_request` is
|
|
79
|
+
* safe as a GET and destructive as a DELETE.
|
|
80
|
+
*
|
|
81
|
+
* Tool-level annotations cannot vary by argument, so **every** field reflects
|
|
82
|
+
* the worst case:
|
|
83
|
+
* - readOnlyHint false — it can DELETE. Marking it read-only would let a
|
|
84
|
+
* client skip confirmation for a call that destroys a resource, the exact
|
|
85
|
+
* failure this file exists to avoid.
|
|
86
|
+
* - idempotentHint false — it can POST, and a retried POST may create a
|
|
87
|
+
* second resource. (Not idempotent even though GET/HEAD are.)
|
|
88
|
+
* - destructiveHint true — a DELETE is never recoverable.
|
|
89
|
+
*
|
|
90
|
+
* The per-argument nuance cannot live in the annotation; it belongs in the
|
|
91
|
+
* tool description and the gates above.
|
|
92
|
+
*/
|
|
93
|
+
export declare const CLOUD_MUTABLE_API: ToolAnnotations;
|
|
94
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSS account-balance + coupon queries for the balance_summary field
|
|
3
|
+
* returned by list_existing_resources (§3.2 + cost review §7 step 9).
|
|
4
|
+
*
|
|
5
|
+
* Why these are aggregated into list_existing_resources instead of a
|
|
6
|
+
* separate tool: the deployment flow calls list_existing_resources at the
|
|
7
|
+
* reuse-decision point (step 5), and balance/coupon info is the same
|
|
8
|
+
* cost-decision context. One call gives the full cost picture at the
|
|
9
|
+
* reuse/budget decision point.
|
|
10
|
+
*
|
|
11
|
+
* Both APIs accept AK/SK signing (the swagger marks X-Auth-Token, but
|
|
12
|
+
* BSS accepts SDK-HMAC-SHA256 too — verified end-to-end: 200 responses
|
|
13
|
+
* from IAM, BSS balances, and BSS coupons). The shared signed HTTP
|
|
14
|
+
* client is in auth/http.ts.
|
|
15
|
+
*/
|
|
16
|
+
export interface BalanceSummary {
|
|
17
|
+
/** Account balances by type. */
|
|
18
|
+
balances: Array<{
|
|
19
|
+
account_type: number;
|
|
20
|
+
/** 1=余额 2=信用 5=奖励金 7=保证金 */
|
|
21
|
+
account_type_name: string;
|
|
22
|
+
amount: number;
|
|
23
|
+
currency: string;
|
|
24
|
+
/** Only for credit accounts (account_type=2). */
|
|
25
|
+
credit_amount?: number;
|
|
26
|
+
/** Reserved/special-purpose balance. */
|
|
27
|
+
designated_amount?: number;
|
|
28
|
+
}>;
|
|
29
|
+
/** Coupon list (代金券). */
|
|
30
|
+
coupons: {
|
|
31
|
+
count: number;
|
|
32
|
+
/** Total remaining balance across all coupons, null if any unparseable. */
|
|
33
|
+
total_balance: number | null;
|
|
34
|
+
/** Per-coupon details — each has expire_time, the LLM judges urgency. */
|
|
35
|
+
items: CouponDetail[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Per-coupon summary — the fields the LLM needs to advise the user. */
|
|
39
|
+
export interface CouponDetail {
|
|
40
|
+
coupon_id: string;
|
|
41
|
+
/** 1=代金券 2=折扣券 3=产品券 4=现金券 */
|
|
42
|
+
coupon_type: number | null;
|
|
43
|
+
/** 代金券/折扣券/产品券/现金券 (derived from coupon_type) */
|
|
44
|
+
coupon_type_name: string | null;
|
|
45
|
+
/** Remaining balance (元). Null for legacy coupons (coupon_version=1). */
|
|
46
|
+
balance: number | null;
|
|
47
|
+
/** Face value (元). */
|
|
48
|
+
face_value: number | null;
|
|
49
|
+
/** Usage description (e.g. "ECS 通用"). */
|
|
50
|
+
coupon_usage: string | null;
|
|
51
|
+
/** Promotion plan name. */
|
|
52
|
+
plan_name: string | null;
|
|
53
|
+
/** Expire time (ISO 8601 UTC). */
|
|
54
|
+
expire_time: string | null;
|
|
55
|
+
/** 1=legacy (one-time use) 2=new (reusable). */
|
|
56
|
+
coupon_version: number | null;
|
|
57
|
+
/** 0=not frozen 1=frozen. */
|
|
58
|
+
is_frozen: number | null;
|
|
59
|
+
}
|
|
60
|
+
export declare function queryAccountBalances(): Promise<BalanceSummary["balances"]>;
|
|
61
|
+
/**
|
|
62
|
+
* Query coupons (ListSubCustomerCoupons).
|
|
63
|
+
* GET /v2/promotions/benefits/coupons — no params.
|
|
64
|
+
* Response: { count, user_coupons: [{ coupon_id, status, balance, effective_time, expire_time, ... }] }
|
|
65
|
+
*/
|
|
66
|
+
export declare function queryCoupons(): Promise<BalanceSummary["coupons"]>;
|
|
67
|
+
/** Query both balances and coupons, return the combined summary. */
|
|
68
|
+
export declare function queryBalanceSummary(): Promise<BalanceSummary>;
|
|
69
|
+
//# sourceMappingURL=balance_summary.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* update_cost.
|
|
4
|
+
*
|
|
5
|
+
* inputSchema uses CostSchema directly — the zod-to-JSON-Schema conversion
|
|
6
|
+
* preserves the full structure (currency/items/charging), so the model sees
|
|
7
|
+
* exactly what fields to pass. superRefine (reuse→existing_id check) is
|
|
8
|
+
* runtime validation only; it does NOT block the JSON Schema export.
|
|
9
|
+
*
|
|
10
|
+
* Cross-file reference check (§5.2 A-layer): items[].resource must reference
|
|
11
|
+
* a component id in networking.json. This CANNOT be done in the zod schema
|
|
12
|
+
* (it validates one file; the reference target is another file). It's done
|
|
13
|
+
* in the handler after schema parse succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerCostTool(registrar: ToolRegistrar): void;
|
|
16
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* create_deployment + delete_deployment (§3.2).
|
|
4
|
+
*
|
|
5
|
+
* create: create or reuse a deployment workspace directory, writing
|
|
6
|
+
* .deployment.json (state snapshot). If the dir exists and is a deployment,
|
|
7
|
+
* return existing info + status. If it exists but is non-empty and not a
|
|
8
|
+
* deployment, refuse.
|
|
9
|
+
*
|
|
10
|
+
* delete: refuse if the deployment still has live cloud resources (check
|
|
11
|
+
* terraform.tfstate); if clean, remove the directory.
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerDeploymentTools(registrar: ToolRegistrar): void;
|
|
14
|
+
//# sourceMappingURL=deployment.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CallToolResult, ToolContext } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tool handler context — the harness adapter's, re-exported here because every
|
|
4
|
+
* tool module already imports it from this file.
|
|
5
|
+
*
|
|
6
|
+
* Empty today; see `../types.ts` for why it is kept.
|
|
7
|
+
*/
|
|
8
|
+
export type ToolCtx = ToolContext;
|
|
9
|
+
/** What a tool handler may return. */
|
|
10
|
+
export type ToolResult = CallToolResult;
|
|
11
|
+
/**
|
|
12
|
+
* A successful tool result: text content (and optional structured content).
|
|
13
|
+
*
|
|
14
|
+
* Tools return `content` arrays. `isError` is omitted
|
|
15
|
+
* (defaults to false) on success.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ok(text: string, structured?: Record<string, unknown>): CallToolResult;
|
|
18
|
+
/**
|
|
19
|
+
* A failed tool result: `isError: true` + text content.
|
|
20
|
+
*
|
|
21
|
+
* All tool failures return this shape. The model
|
|
22
|
+
* checks `isError`, reads `content[0].text` for the diagnostic.
|
|
23
|
+
*/
|
|
24
|
+
export declare function fail(message: string): CallToolResult;
|
|
25
|
+
/**
|
|
26
|
+
* Wrap an async tool handler so thrown errors become `fail()` results
|
|
27
|
+
* instead of propagating as JSON-RPC internal errors.
|
|
28
|
+
*
|
|
29
|
+
* Tool handlers throw for unexpected failures (network, filesystem, bugs).
|
|
30
|
+
* The message belongs in `content[0].text`, where the model reads and acts on
|
|
31
|
+
* it — a thrown stack trace that never reaches the result tells the model
|
|
32
|
+
* nothing it can use.
|
|
33
|
+
*
|
|
34
|
+
* The read-only gate runs first, before the handler body: a refused call must
|
|
35
|
+
* not reach any part of its implementation, including argument validation that
|
|
36
|
+
* might touch the filesystem. A tool declared in `CLOUD_MUTATING_TOOLS` is
|
|
37
|
+
* refused here in read-only mode and never starts.
|
|
38
|
+
*/
|
|
39
|
+
export declare function guard<TArgs extends Record<string, unknown> | undefined>(fn: (args: TArgs, ctx: ToolCtx) => Promise<ToolResult>, toolName?: string): (args: TArgs, ctx: ToolCtx) => Promise<ToolResult>;
|
|
40
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* list_existing_resources (§3.2).
|
|
4
|
+
*
|
|
5
|
+
* Lists HuaweiCloud resources the user already owns, for reuse in a deployment.
|
|
6
|
+
* Two-stage query against RMS (Resource Management Service) — the unified
|
|
7
|
+
* inventory API that covers ALL services (ECS, RDS, EIP, VPC, ELB, ...):
|
|
8
|
+
*
|
|
9
|
+
* Stage 1 (default, no service/region/detail args): CollectAllResourcesSummary.
|
|
10
|
+
* Returns a lightweight grouped count: provider → type → region → count.
|
|
11
|
+
* Cross-region by default — the user sees where resources live before
|
|
12
|
+
* drilling in. Cheap call, small response, ideal for the "what do I have?"
|
|
13
|
+
* first question.
|
|
14
|
+
*
|
|
15
|
+
* Stage 2 (service, region, or detail=true): ListAllResources. Returns the
|
|
16
|
+
* actual resource list (id/name/provider/type/region/status/properties).
|
|
17
|
+
* Service + region narrow the query. Use after the summary tells you which
|
|
18
|
+
* service/region to drill into — avoids pulling a large list blindly.
|
|
19
|
+
*
|
|
20
|
+
* Also returns balance_summary (BSS balances + coupons) for the full cost
|
|
21
|
+
* context at the reuse/budget decision point. Balance is best-effort.
|
|
22
|
+
*
|
|
23
|
+
* Verified: both RMS APIs accept AK/SK signing (despite swagger
|
|
24
|
+
* marking PkiTokenAuth) and return 200. domain_id in the path IS the
|
|
25
|
+
* account_id (resolved at auth, stored alongside credentials). RMS host is
|
|
26
|
+
* global (rms.myhuaweicloud.com, no region prefix).
|
|
27
|
+
*/
|
|
28
|
+
export declare function registerExistingResourcesTool(registrar: ToolRegistrar): void;
|
|
29
|
+
//# sourceMappingURL=existing_resources.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Register this plugin's tools on the DSH tool registry.
|
|
5
|
+
*
|
|
6
|
+
* Tool count: 17.
|
|
7
|
+
*
|
|
8
|
+
* 部署目录 2 + 状态文件 2 + 华为云能力 4 + terraform 9 = 17
|
|
9
|
+
*
|
|
10
|
+
* `auth` is not among them: it lives in `aishell-credentials`, which owns the
|
|
11
|
+
* credential lifecycle and the form that collects AK/SK. A verify tool here
|
|
12
|
+
* would mean two tools answering "is this account authenticated", one of them
|
|
13
|
+
* depending on a store it does not own.
|
|
14
|
+
*
|
|
15
|
+
* The six long-running terraform tools (install/init/plan/apply/destroy/
|
|
16
|
+
* refresh) run synchronously. Each call is bounded by the tool's own timeout,
|
|
17
|
+
* not by any progress mechanism.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerAllTools(registrar: ToolRegistrar): void;
|
|
20
|
+
/**
|
|
21
|
+
* Shared zod string schema for the `deployment` parameter — an absolute or
|
|
22
|
+
* relative path to the deployment workspace directory. Used by every tool
|
|
23
|
+
* that operates on a deployment.
|
|
24
|
+
*/
|
|
25
|
+
export declare const deploymentParam: z.ZodString;
|
|
26
|
+
/**
|
|
27
|
+
* Shared zod string schema for `dest` — the reference-data extraction
|
|
28
|
+
* target, distinct from the deployment workspace (§3.2: "distinct from
|
|
29
|
+
* the deployment workspace — this is where reference data is extracted").
|
|
30
|
+
*/
|
|
31
|
+
export declare const destParam: z.ZodString;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* update_networking.
|
|
4
|
+
*
|
|
5
|
+
* inputSchema uses NetworkingSchema directly — the zod-to-JSON-Schema
|
|
6
|
+
* conversion preserves the full structure (topology/components/network_objects),
|
|
7
|
+
* so the model sees exactly what fields to pass. superRefine (A-layer
|
|
8
|
+
* reference consistency) is runtime validation only; it does NOT block the
|
|
9
|
+
* JSON Schema export (verified: z.toJSONSchema emits the object shape
|
|
10
|
+
* regardless of superRefine).
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerNetworkingTool(registrar: ToolRegistrar): void;
|
|
13
|
+
//# sourceMappingURL=networking.d.ts.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* apiexplorer + openapi_request (§3.2).
|
|
4
|
+
*
|
|
5
|
+
* apiexplorer wraps HuaweiCloud APIExplorer (the "API of APIs") — a dedicated
|
|
6
|
+
* tool, NOT just openapi_request, because:
|
|
7
|
+
* - ListApis is paginated (a service can have 100+ APIs); this tool handles
|
|
8
|
+
* limit/offset + has_more so the LLM doesn't hand-compute pagination.
|
|
9
|
+
* - ShowApi returns a large swagger with metadata the LLM doesn't need; the
|
|
10
|
+
* server strips to paths/parameters/definitions.
|
|
11
|
+
*
|
|
12
|
+
* Five recursive levels (APIExplorer is a global service, one unified host):
|
|
13
|
+
* 1. No args → ListProductsV4: all cloud services (productshort + api_count).
|
|
14
|
+
* The LLM learns productshort values here.
|
|
15
|
+
* 2. productshort (no api_name) → ListApis: that service's APIs. Paginated.
|
|
16
|
+
* 3. productshort + api_name → ShowApi: the API's swagger — the parameter
|
|
17
|
+
* contract the LLM needs to call openapi_request correctly.
|
|
18
|
+
* 4. regions=true → ListRegionsV4: regions where the service/API is available
|
|
19
|
+
* (region_id + project_id). Use before openapi_request to confirm region
|
|
20
|
+
* support and get the project_id for region-scoped endpoints.
|
|
21
|
+
* 5. endpoints=true → ListGroups: per-region endpoint hosts (domain_url) for
|
|
22
|
+
* the service. Use to construct the full API URL for openapi_request.
|
|
23
|
+
*
|
|
24
|
+
* APIExplorer is itself a HuaweiCloud API — signedHttp signs it like any other
|
|
25
|
+
* (RMS, BSS).
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerOpenApiTools(registrar: ToolRegistrar): void;
|
|
28
|
+
export interface ShowApiResponse {
|
|
29
|
+
name: string;
|
|
30
|
+
summary?: string;
|
|
31
|
+
host?: string;
|
|
32
|
+
base_path?: string;
|
|
33
|
+
schemes?: unknown;
|
|
34
|
+
paths?: Record<string, Record<string, unknown>>;
|
|
35
|
+
parameters?: Record<string, SwaggerParameter>;
|
|
36
|
+
definitions?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
interface SwaggerParameter {
|
|
39
|
+
name?: string;
|
|
40
|
+
in?: string;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
type?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
schema?: {
|
|
45
|
+
$ref?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
type?: string;
|
|
48
|
+
};
|
|
49
|
+
$ref?: string;
|
|
50
|
+
}
|
|
51
|
+
interface CompactParam {
|
|
52
|
+
name: string;
|
|
53
|
+
in: string;
|
|
54
|
+
type: string;
|
|
55
|
+
required: boolean;
|
|
56
|
+
description: string;
|
|
57
|
+
/** Body params only: flat field paths (e.g. "product_infos[].cloud_service_type"). */
|
|
58
|
+
fields?: BodyField[];
|
|
59
|
+
}
|
|
60
|
+
interface CompactOperation {
|
|
61
|
+
method: string;
|
|
62
|
+
path: string;
|
|
63
|
+
required_params: CompactParam[];
|
|
64
|
+
optional_params: CompactParam[];
|
|
65
|
+
}
|
|
66
|
+
interface CompactContract {
|
|
67
|
+
name: string;
|
|
68
|
+
summary: string;
|
|
69
|
+
host: string;
|
|
70
|
+
host_note: string;
|
|
71
|
+
base_path: string;
|
|
72
|
+
operations: CompactOperation[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Extract a minimal API contract from a swagger 2.0 ShowApi response.
|
|
76
|
+
*
|
|
77
|
+
* For each path+method, collect the operation's parameters split into
|
|
78
|
+
* required/optional groups. Each parameter carries name/in/type/description —
|
|
79
|
+
* everything the LLM needs to construct the request. definitions/responses are
|
|
80
|
+
* dropped (use compact=false if body schema detail is needed).
|
|
81
|
+
*
|
|
82
|
+
* $ref parameters ("#/parameters/Foo") are resolved from the top-level
|
|
83
|
+
* `parameters` map. body parameters (in: "body") keep their description but
|
|
84
|
+
* don't expand the schema — that would re-introduce the large JSON compact
|
|
85
|
+
* is meant to avoid.
|
|
86
|
+
*/
|
|
87
|
+
export declare function extractCompactContract(data: ShowApiResponse): CompactContract;
|
|
88
|
+
/** A flat field path in the body schema. */
|
|
89
|
+
interface BodyField {
|
|
90
|
+
path: string;
|
|
91
|
+
type: string;
|
|
92
|
+
required: boolean;
|
|
93
|
+
description: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Extract fields from a JSON string using JSONPath (RFC 9535). Returns
|
|
97
|
+
* undefined if the body is not valid JSON (caller falls back to returning
|
|
98
|
+
* the raw body). Each path is evaluated via jsonpath-plus; a missing path
|
|
99
|
+
* yields null, a single-match path yields the bare value (backward compat
|
|
100
|
+
* with the old dot-path behavior), and a multi-match path (wildcards [*],
|
|
101
|
+
* indices [N], recursive descent ..) yields an array of matches.
|
|
102
|
+
*
|
|
103
|
+
* Upgraded from a hand-rolled dot-path walker that could not descend into
|
|
104
|
+
* arrays — HuaweiCloud APIs return arrays (resource lists, bill details),
|
|
105
|
+
* so account_balances[*].amount must work. jsonpath-plus is the RFC 9535
|
|
106
|
+
* reference implementation for JS.
|
|
107
|
+
*/
|
|
108
|
+
export declare function extractFields(jsonBody: string, fields: string[]): Array<{
|
|
109
|
+
path: string;
|
|
110
|
+
value: unknown;
|
|
111
|
+
}> | undefined;
|
|
112
|
+
export {};
|
|
113
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* provider_schema (§3.2).
|
|
4
|
+
*
|
|
5
|
+
* Runs `terraform providers schema -json` and extracts the huaweicloud
|
|
6
|
+
* provider's schema. The full output is ~6MB (thousands of resource and
|
|
7
|
+
* data-source schemas) — returning it whole would blow the LLM context. So:
|
|
8
|
+
* - With resource_type: return that single type's full schema (block,
|
|
9
|
+
* attributes, nested blocks) — small, focused.
|
|
10
|
+
* - Without resource_type: return only the type-name lists (resource_types
|
|
11
|
+
* + data_source_types), so the LLM can discover what exists and then
|
|
12
|
+
* drill in with a resource_type arg.
|
|
13
|
+
*
|
|
14
|
+
* The provider_schemas key is the full registry address
|
|
15
|
+
* "registry.terraform.io/huaweicloud/huaweicloud", NOT the short name
|
|
16
|
+
* "huaweicloud" (verified against terraform providers schema -json output).
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerProviderSchemaTool(registrar: ToolRegistrar): void;
|
|
19
|
+
//# sourceMappingURL=provider_schema.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ToolRegistrar } from "../types.js";
|
|
2
|
+
/** Shared terraform runner: resolve env, then spawn. */
|
|
3
|
+
export interface TerraformResult {
|
|
4
|
+
exitCode: number;
|
|
5
|
+
stdout: string;
|
|
6
|
+
stderr: string;
|
|
7
|
+
/** True if stdout was truncated at MAX_OUTPUT_BYTES (output incomplete). */
|
|
8
|
+
stdoutTruncated?: boolean;
|
|
9
|
+
/** True if stderr was truncated at MAX_OUTPUT_BYTES. */
|
|
10
|
+
stderrTruncated?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function runTerraform(cwd: string, args: string[], extraEnv?: string[]): Promise<TerraformResult>;
|
|
13
|
+
/** Register all 9 terraform tools. */
|
|
14
|
+
export declare function registerTerraformTools(registrar: ToolRegistrar): void;
|
|
15
|
+
/**
|
|
16
|
+
* Derive create/change/destroy counts from `terraform show -json <plan>`
|
|
17
|
+
* resource_changes — the authoritative, version-independent source.
|
|
18
|
+
*
|
|
19
|
+
* terraform 1.9+ changed the `plan -json` stdout summary line to
|
|
20
|
+
* type:"change_summary" (from type:"summary"), so parsePlanSummary returns 0.
|
|
21
|
+
* The show -json output's resource_changes[].change.actions is stable across
|
|
22
|
+
* versions: actions is an array like ["create"], ["update"], ["delete"],
|
|
23
|
+
* ["no-op"], or composite like ["create","delete"] (replace). We take the
|
|
24
|
+
* first action as the primary — same mapping convention as terraform's own
|
|
25
|
+
* tfjson (planFromJSON actionFromTFJSON).
|
|
26
|
+
*/
|
|
27
|
+
export declare function summaryFromPlanJson(planJson: unknown): {
|
|
28
|
+
create: number;
|
|
29
|
+
change: number;
|
|
30
|
+
destroy: number;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=terraform.d.ts.map
|