@huaweidevtools/aishell-dsh-deploy 0.0.16 → 0.0.17

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.
@@ -42,11 +42,36 @@ export interface CallToolResult {
42
42
  /**
43
43
  * Per-call context handed to a handler.
44
44
  *
45
- * Empty. It exists so a handler that later needs the caller's session or signal
46
- * has one obvious place to take it from, rather than reaching into the harness
47
- * from a tool module.
45
+ * ## Why the session directory is here
46
+ *
47
+ * Every tool in this plugin takes a `deployment` path, and a caller may give it
48
+ * relatively — the model writes "huawei-topology" because that is the directory
49
+ * it just made. A relative path has to resolve against *something*, and the
50
+ * default Node and the harness differ on what:
51
+ *
52
+ * - Node resolves it against `process.cwd()`, the directory the host was
53
+ * launched from. That has nothing to do with the working directory the
54
+ * person picked for this session.
55
+ * - Every filesystem tool in the product resolves it against the session's
56
+ * working directory, which is what a person means by "here".
57
+ *
58
+ * Two tools disagreeing about what "huawei-topology" names is exactly the
59
+ * failure that produces a workspace nobody can find, so this plugin anchors at
60
+ * the session like everything else does.
61
+ *
62
+ * The field is optional because the service may not be mounted. Its absence is
63
+ * not permission to fall back to `process.cwd()`: a relative path then has no
64
+ * correct meaning, and the tool says so. `undefined` is a fact to report, not a
65
+ * default to invent.
48
66
  */
49
67
  export interface ToolContext {
68
+ /**
69
+ * The session's absolute working directory, when the host provides one.
70
+ *
71
+ * Absolute and already validated by the host — it restores the original
72
+ * directory when the one the person picked has been removed.
73
+ */
74
+ readonly sessionDirectory?: string;
50
75
  }
51
76
  /** The context type the tool modules name. */
52
77
  export type ToolCtx = ToolContext;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@huaweidevtools/aishell-dsh-deploy",
3
3
  "description": "Huawei Cloud infrastructure tools for DSH — Terraform, OpenAPI, resource inventory, cost estimates",
4
- "version": "0.0.16",
4
+ "version": "0.0.17",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -32,7 +32,7 @@
32
32
  "hcl2-parser": "^1.0.3",
33
33
  "jsonpath-plus": "^10.4.0",
34
34
  "zod": "^4.2.0",
35
- "@huaweidevtools/aishell-dsh-credentials-store": "0.0.16"
35
+ "@huaweidevtools/aishell-dsh-credentials-store": "0.0.17"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@deepseek-ai/cordis": "^4.0.4",
@@ -1,74 +0,0 @@
1
- /**
2
- * Drawing the topology: D2 source, then an SVG.
3
- *
4
- * ## Why D2 and not hand-built SVG
5
- *
6
- * A network topology is a nested graph with edges, and every hand-rolled
7
- * layout for one has to solve two things badly: where a box goes, and where
8
- * its edges land. D2 solves both, and it is the format's own vocabulary —
9
- * containers nest, arrows connect, `near:` pins an annotation panel.
10
- *
11
- * The cost is real and worth stating: the WASM build is ~21 MB packaged, and
12
- * the compile step instantiates it once per process (~1.1 s cold, then ~70 ms
13
- * per diagram). It runs inside a worker thread that D2 owns, so the
14
- * instantiation does not block this process's event loop; {@link closeD2}
15
- * terminates that worker, which is the only way to hand the ~600 MB of WASM
16
- * linear memory back.
17
- *
18
- * ## What D2 does and does not carry
19
- *
20
- * It carries the PICTURE. It does not carry data: custom `vars` are discarded,
21
- * an attribute written as a child (`cidr: "10.0.0.0/16"`) becomes a visible
22
- * second box, and a mistyped attribute or an edge to an undefined node are
23
- * accepted silently. So nothing here is read back out of D2 — the topology is
24
- * derived from HCL and D2 is only where it is drawn. That direction matters:
25
- * a generator is exact, a parser of pictures is not.
26
- *
27
- * ## Theme
28
- *
29
- * `render` is given both `themeID` and `darkThemeID`; D2 emits both palettes
30
- * into one SVG and selects between them with `@media
31
- * (prefers-color-scheme: dark)`. The result follows the viewer's setting with
32
- * no JavaScript.
33
- *
34
- * @module @huaweidevtools/aishell-dsh-deploy/d2-render
35
- */
36
- import type { Topology, TopologyEdge } from './topology.ts';
37
- /** One render in, one render out; the caller owns timing and disposal. */
38
- export interface RenderResult {
39
- /** The D2 source that was rendered, so a reader can see what was drawn. */
40
- readonly source: string;
41
- /** The SVG, with no XML declaration so it embeds directly in HTML. */
42
- readonly svg: string;
43
- }
44
- /**
45
- * Draw the topology.
46
- *
47
- * @param topology - the derived picture.
48
- * @param edges - the relationships to draw, from `<from-address>` to
49
- * `<to-address>`. Only addresses the topology knows are drawn.
50
- * @returns the D2 source and the SVG it renders to.
51
- * @throws when the generated D2 source does not compile. That is a defect in
52
- * this module rather than in the user's configuration — the generator is
53
- * what produced the text — so the message names the generated fragment.
54
- */
55
- export declare function renderTopology(topology: Topology, edges: readonly TopologyEdge[]): Promise<RenderResult>;
56
- /**
57
- * Generate the D2 source for one topology.
58
- *
59
- * The shape of the output is fixed by what D2 accepts, and every choice here
60
- * comes from something D2 refused:
61
- *
62
- * - Nothing is written as an attribute child. `cidr: "10.0.0.0/16"` inside a
63
- * node's block renders as its own box, which would put a stray rectangle
64
- * in every subnet. Facts go into the node's LABEL instead.
65
- * - Facts are separated by `·` rather than aligned into columns, because D2
66
- * treats a leading `|` as a block-string terminator.
67
- * - No `vars` block: D2 discards everything under it except `d2-config`.
68
- *
69
- * @param topology - the derived picture.
70
- * @param edges - the relationships to draw.
71
- * @returns D2 source text.
72
- */
73
- export declare function toD2(topology: Topology, edges: readonly TopologyEdge[]): string;
74
- //# sourceMappingURL=d2-render.d.ts.map