@crouter/api 0.3.386 → 0.3.388
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/api/__tests__/integration/client.test.js +97 -0
- package/dist/api/client.d.ts +7 -0
- package/dist/api/client.js +40 -21
- package/dist/core/asset-root.d.ts +7 -0
- package/dist/core/asset-root.js +18 -0
- package/dist/core/canvas/boot-id.d.ts +6 -0
- package/dist/core/canvas/boot-id.js +26 -0
- package/dist/core/canvas/paths.d.ts +72 -0
- package/dist/core/canvas/paths.js +163 -0
- package/dist/core/canvas/pid.d.ts +391 -0
- package/dist/core/canvas/pid.js +948 -0
- package/dist/core/command-plugins/bundle.d.ts +149 -0
- package/dist/core/command-plugins/bundle.js +588 -0
- package/dist/core/command-plugins/endpoint.d.ts +24 -0
- package/dist/core/command-plugins/endpoint.js +51 -0
- package/dist/core/config.d.ts +233 -0
- package/dist/core/config.js +1120 -0
- package/dist/core/env-name.d.ts +6 -0
- package/dist/core/env-name.js +9 -0
- package/dist/core/errors.d.ts +38 -0
- package/dist/core/errors.js +90 -0
- package/dist/core/events/emit.d.ts +6 -0
- package/dist/core/events/emit.js +42 -0
- package/dist/core/events/envelope.d.ts +2 -0
- package/dist/core/events/envelope.js +84 -0
- package/dist/core/events/errors.d.ts +4 -0
- package/dist/core/events/errors.js +69 -0
- package/dist/core/events/operation-id.d.ts +4 -0
- package/dist/core/events/operation-id.js +24 -0
- package/dist/core/events/serialize.d.ts +4 -0
- package/dist/core/events/serialize.js +199 -0
- package/dist/core/events/source.d.ts +16 -0
- package/dist/core/events/source.js +31 -0
- package/dist/core/events/types.d.ts +68 -0
- package/dist/core/events/types.js +11 -0
- package/dist/core/exclusive-lock.d.ts +34 -0
- package/dist/core/exclusive-lock.js +197 -0
- package/dist/core/fs-utils.d.ts +44 -0
- package/dist/core/fs-utils.js +208 -0
- package/dist/core/help.d.ts +309 -0
- package/dist/core/help.js +406 -0
- package/dist/core/human/page-catalog.d.ts +57 -0
- package/dist/core/human/page-catalog.js +172 -0
- package/dist/core/installed-plugins.d.ts +2 -0
- package/dist/core/installed-plugins.js +79 -0
- package/dist/core/io.d.ts +122 -0
- package/dist/core/io.js +373 -0
- package/dist/core/keybindings/attach-control.d.ts +49 -0
- package/dist/core/keybindings/attach-control.js +42 -0
- package/dist/core/keybindings/catalog.d.ts +18 -0
- package/dist/core/keybindings/catalog.js +257 -0
- package/dist/core/keybindings/types.d.ts +42 -0
- package/dist/core/keybindings/types.js +1 -0
- package/dist/core/layout.d.ts +26 -0
- package/dist/core/layout.js +94 -0
- package/dist/core/locked-file.d.ts +27 -0
- package/dist/core/locked-file.js +118 -0
- package/dist/core/log.d.ts +9 -0
- package/dist/core/log.js +89 -0
- package/dist/core/manifest.d.ts +5 -0
- package/dist/core/manifest.js +15 -0
- package/dist/core/plugin-env.d.ts +8 -0
- package/dist/core/plugin-env.js +31 -0
- package/dist/core/plugin-extensions.d.ts +29 -0
- package/dist/core/plugin-extensions.js +191 -0
- package/dist/core/plugin-swap-lock.d.ts +9 -0
- package/dist/core/plugin-swap-lock.js +31 -0
- package/dist/core/preview-result-path.d.ts +4 -0
- package/dist/core/preview-result-path.js +26 -0
- package/dist/core/profiles/env-store.d.ts +22 -0
- package/dist/core/profiles/env-store.js +163 -0
- package/dist/core/profiles/fuzzy-match.d.ts +19 -0
- package/dist/core/profiles/fuzzy-match.js +92 -0
- package/dist/core/profiles/manifest.d.ts +120 -0
- package/dist/core/profiles/manifest.js +529 -0
- package/dist/core/rate-limit-scope.d.ts +25 -0
- package/dist/core/rate-limit-scope.js +64 -0
- package/dist/core/render.d.ts +12 -0
- package/dist/core/render.js +138 -0
- package/dist/core/resolver.d.ts +14 -0
- package/dist/core/resolver.js +111 -0
- package/dist/core/runtime/branded-host.d.ts +25 -0
- package/dist/core/runtime/branded-host.js +264 -0
- package/dist/core/runtime/broker/daemon-ops.d.ts +65 -0
- package/dist/core/runtime/broker/daemon-ops.js +177 -0
- package/dist/core/runtime/broker/signal-stream.d.ts +30 -0
- package/dist/core/runtime/broker/signal-stream.js +149 -0
- package/dist/core/scope.d.ts +32 -0
- package/dist/core/scope.js +184 -0
- package/dist/core/scoped-state/db.d.ts +17 -0
- package/dist/core/scoped-state/db.js +247 -0
- package/dist/core/scoped-state/migrate.d.ts +8 -0
- package/dist/core/scoped-state/migrate.js +187 -0
- package/dist/core/scoped-state/paths.d.ts +9 -0
- package/dist/core/scoped-state/paths.js +27 -0
- package/dist/core/scoped-state/profiles.d.ts +27 -0
- package/dist/core/scoped-state/profiles.js +93 -0
- package/dist/core/scoped-state/providers.d.ts +24 -0
- package/dist/core/scoped-state/providers.js +19 -0
- package/dist/core/scoped-state/schema.d.ts +6 -0
- package/dist/core/scoped-state/schema.js +43 -0
- package/dist/core/scoped-state/settings.d.ts +28 -0
- package/dist/core/scoped-state/settings.js +83 -0
- package/dist/core/spaces/open-beneath.d.ts +71 -0
- package/dist/core/spaces/open-beneath.js +581 -0
- package/dist/core/sqlite-statements.d.ts +4 -0
- package/dist/core/sqlite-statements.js +17 -0
- package/dist/core/subscription-state.d.ts +121 -0
- package/dist/core/subscription-state.js +287 -0
- package/dist/core/user-settings.d.ts +377 -0
- package/dist/core/user-settings.js +458 -0
- package/dist/daemon/broker-signals/bus.d.ts +30 -0
- package/dist/daemon/broker-signals/bus.js +87 -0
- package/dist/daemon/manage.d.ts +176 -0
- package/dist/daemon/manage.js +664 -0
- package/dist/daemon/pidfile.d.ts +8 -0
- package/dist/daemon/pidfile.js +37 -0
- package/dist/daemon/startup-policy.d.ts +1 -0
- package/dist/daemon/startup-policy.js +1 -0
- package/dist/native/linux.d.ts +29 -0
- package/dist/native/linux.js +20 -0
- package/dist/shared/env.d.ts +116 -0
- package/dist/shared/env.js +271 -0
- package/dist/shared/inbox-entry-body.d.ts +22 -0
- package/dist/shared/inbox-entry-body.js +116 -0
- package/dist/shared/working-activity.d.ts +9 -0
- package/dist/shared/working-activity.js +27 -0
- package/dist/types.d.ts +562 -0
- package/dist/types.js +186 -0
- package/package.json +1 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { DeclaredOutputField } from '../api/command-manifest/result.js';
|
|
2
|
+
export type Field = DeclaredOutputField;
|
|
3
|
+
/** Positional argument. A repeatable positional consumes every remaining positional token. */
|
|
4
|
+
export interface PositionalParam {
|
|
5
|
+
kind: 'positional';
|
|
6
|
+
name: string;
|
|
7
|
+
/** Display hint only; always parsed as string. `file` names a
|
|
8
|
+
* capability-provider file argument, sent locally as the string typed. */
|
|
9
|
+
type?: 'string' | 'path' | 'file';
|
|
10
|
+
required: boolean;
|
|
11
|
+
constraint: string;
|
|
12
|
+
/** When true, every positional token is collected into an array in argv order. */
|
|
13
|
+
repeatable?: boolean;
|
|
14
|
+
/** Local-file materialization contract, valid only on a `path` param. The
|
|
15
|
+
* CLI-side value is a path to a local file; the invoker reads that file and
|
|
16
|
+
* sends its CONTENT as the mapped value — 'text' as UTF-8, 'base64' as the
|
|
17
|
+
* base64 of its raw bytes. The path string itself never crosses the wire. */
|
|
18
|
+
encoding?: FileEncoding;
|
|
19
|
+
/** Ambient default: when the caller omits this param and the named client
|
|
20
|
+
* environment variable is set and non-empty, that value is used and counts as
|
|
21
|
+
* supplied — see FlagParam.defaultFromEnv. */
|
|
22
|
+
defaultFromEnv?: string;
|
|
23
|
+
}
|
|
24
|
+
/** How a local file named by a `path` param is encoded into the request. */
|
|
25
|
+
export type FileEncoding = 'text' | 'base64';
|
|
26
|
+
/** Additional guidance for an uncommon flag whose safe selection, value
|
|
27
|
+
* grammar, dynamic choices, or effects do not fit in its compact leaf-schema
|
|
28
|
+
* row. The compact row routes the agent to `crtr <leaf> --<flag> -h`; that
|
|
29
|
+
* focused continuation renders only this parameter contract. */
|
|
30
|
+
export interface FocusedFlagHelp {
|
|
31
|
+
/** Concrete cases that justify overriding the default, plus when to omit. */
|
|
32
|
+
whenToUse: string;
|
|
33
|
+
/** Complete accepted-value grammar and default/inheritance behavior. */
|
|
34
|
+
value: string;
|
|
35
|
+
/** Flag-specific persistent or lifecycle effects and coupled interactions. */
|
|
36
|
+
effects?: string[];
|
|
37
|
+
/** Bounded dynamic choices owned by this flag, rendered only in focused help. */
|
|
38
|
+
dynamicState?: () => string | null;
|
|
39
|
+
}
|
|
40
|
+
/** Long-form flag (`--name`). */
|
|
41
|
+
export interface FlagParam {
|
|
42
|
+
kind: 'flag';
|
|
43
|
+
name: string;
|
|
44
|
+
/** 'bool' flags take no value — presence = true. 'file' names a
|
|
45
|
+
* capability-provider file argument, sent locally as the string typed. */
|
|
46
|
+
type: 'string' | 'int' | 'bool' | 'path' | 'enum' | 'file';
|
|
47
|
+
/** Required only when type is 'enum'. */
|
|
48
|
+
choices?: string[];
|
|
49
|
+
required: boolean;
|
|
50
|
+
/** Compact discovery contract. When focusedHelp is present, state what the
|
|
51
|
+
* flag changes and the condition that could justify it; the renderer adds
|
|
52
|
+
* the exact focused-help road sign automatically. */
|
|
53
|
+
constraint: string;
|
|
54
|
+
/** Opt into focused `--flag -h` guidance. Use only when omission is normal
|
|
55
|
+
* and the complete safe contract cannot fit in one compact row. */
|
|
56
|
+
focusedHelp?: FocusedFlagHelp;
|
|
57
|
+
default?: string | number | boolean;
|
|
58
|
+
/** When true, the flag may appear multiple times; values accumulate into an
|
|
59
|
+
* array (parseArgv collects them; body-placed REST params ship as a JSON array). */
|
|
60
|
+
repeatable?: boolean;
|
|
61
|
+
/** When true, the flag is PARSED normally but never rendered in `-h`. For a
|
|
62
|
+
* deliberately-undiscoverable confirmation gate the agent must be TOLD about
|
|
63
|
+
* in the command's own output (not by reading the schema), never advertised. */
|
|
64
|
+
hidden?: boolean;
|
|
65
|
+
/** The value is a secret. Parse errors for the leaf then withhold every stray
|
|
66
|
+
* argv value, since a mistyped invocation is how a secret lands in one. */
|
|
67
|
+
sensitive?: boolean;
|
|
68
|
+
/** Local-file materialization contract, valid only on a `path` flag — see
|
|
69
|
+
* PositionalParam.encoding. */
|
|
70
|
+
encoding?: FileEncoding;
|
|
71
|
+
/** Ambient default sourced from the CALLER's environment: when the param is
|
|
72
|
+
* not supplied on the command line and this environment variable is set and
|
|
73
|
+
* non-empty, its value fills the param and counts as explicitly supplied (it
|
|
74
|
+
* therefore satisfies `required` and ships like a typed value — unlike a
|
|
75
|
+
* static `default`, which is a display/parse convenience only). This is how a
|
|
76
|
+
* leaf picks up ambient identity a caller should not have to retype, e.g.
|
|
77
|
+
* CRTR_NODE_ID, which every broker exports into its node's environment. */
|
|
78
|
+
defaultFromEnv?: string;
|
|
79
|
+
}
|
|
80
|
+
/** Raw stdin content blob (piped text, not parsed as JSON). */
|
|
81
|
+
export interface StdinParam {
|
|
82
|
+
kind: 'stdin';
|
|
83
|
+
name: string;
|
|
84
|
+
required: boolean;
|
|
85
|
+
constraint: string;
|
|
86
|
+
/** Whether one positional token may supply stdin instead of a pipe. Defaults
|
|
87
|
+
* to true for existing stdin-body leaves; false requires actual stdin. */
|
|
88
|
+
allowPositional?: boolean;
|
|
89
|
+
/** Optional leaf-specific recovery when a positional stdin body collides with
|
|
90
|
+
* piped stdin. Return undefined to keep the generic collision error. */
|
|
91
|
+
positionalStdinConflict?: (input: Readonly<Record<string, unknown>>) => {
|
|
92
|
+
message: string;
|
|
93
|
+
field?: string;
|
|
94
|
+
next: string;
|
|
95
|
+
} | undefined;
|
|
96
|
+
}
|
|
97
|
+
/** --context-file PATH: reads and JSON-parses the file at PATH. */
|
|
98
|
+
export interface ContextFileParam {
|
|
99
|
+
kind: 'context-file';
|
|
100
|
+
name: string;
|
|
101
|
+
required: boolean;
|
|
102
|
+
constraint: string;
|
|
103
|
+
/** Optional description of the expected JSON shape. */
|
|
104
|
+
shape?: string;
|
|
105
|
+
}
|
|
106
|
+
export type InputParam = PositionalParam | FlagParam | StdinParam | ContextFileParam;
|
|
107
|
+
/** How prominently a subcommand surfaces in ancestor (parent / root) -h
|
|
108
|
+
* listings. Set per child in the parent branch's `help.children`. Default
|
|
109
|
+
* 'normal'.
|
|
110
|
+
* - hidden — never listed anywhere, not even in this branch's own -h.
|
|
111
|
+
* You must already know it exists to invoke it.
|
|
112
|
+
* - normal — listed in this branch's own -h only (the default).
|
|
113
|
+
* - common — ALSO promoted into the parent's -h, as a bare qualified name.
|
|
114
|
+
* - important — ALSO promoted into the parent's -h, name + shortform desc. */
|
|
115
|
+
export type SubTier = 'hidden' | 'normal' | 'common' | 'important';
|
|
116
|
+
/** A child's assembled parent-level listing entry — computed by defineBranch
|
|
117
|
+
* from each child def's own self-description (`description`/`whenToUse`/`tier`).
|
|
118
|
+
* renderBranch consumes this; it is never authored by hand and there is no
|
|
119
|
+
* parent-side copy of a child's description (principle 16: each node owns its
|
|
120
|
+
* representation one level up). */
|
|
121
|
+
export interface ListingChild {
|
|
122
|
+
name: string;
|
|
123
|
+
/** Plugin that contributed this child to an extensible core branch. */
|
|
124
|
+
plugin?: string;
|
|
125
|
+
/** Short description for this child's <subcommand> row. */
|
|
126
|
+
description: string;
|
|
127
|
+
/** Selection rubric — plainly states when to reach for this command. Expansive
|
|
128
|
+
* with a variety of examples for judgment-heavy commands; concise for
|
|
129
|
+
* genuinely single-purpose ones. Rendered verbatim (no prefix). */
|
|
130
|
+
whenToUse: string;
|
|
131
|
+
/** Visibility tier in ancestor listings (see SubTier). 'hidden' children are
|
|
132
|
+
* dropped from every listing. */
|
|
133
|
+
tier: SubTier;
|
|
134
|
+
/** Whether the child is a leaf or a branch. */
|
|
135
|
+
kind?: 'leaf' | 'branch';
|
|
136
|
+
/** How many non-hidden subcommands this child itself owns — drives the
|
|
137
|
+
* `subcommands="N"` attribute when a branch child is listed without
|
|
138
|
+
* expansion. Absent for leaves and childless branches. */
|
|
139
|
+
subCount?: number;
|
|
140
|
+
}
|
|
141
|
+
/** A subtree's self-description at the parent (root) level. Each subtree owns
|
|
142
|
+
* the content that represents it one level up: its vocabulary line, its
|
|
143
|
+
* selection rubric, and any bounded block it contributes to the parent's -h.
|
|
144
|
+
* defineRoot assembles the root help from these — root never hardcodes a
|
|
145
|
+
* subtree's representation. See cli-design "Each node owns its parent-level
|
|
146
|
+
* representation". */
|
|
147
|
+
export interface RootEntry {
|
|
148
|
+
/** One-line vocabulary desc — what this subtree is. Rendered first in the
|
|
149
|
+
* subtree's <name> block at root. */
|
|
150
|
+
concept: string;
|
|
151
|
+
/** Operations summary (verb list). Carried for completeness; the root block
|
|
152
|
+
* leads with concept + rubric, so this is available but not rendered. */
|
|
153
|
+
desc: string;
|
|
154
|
+
/** The selection rubric — `use when X` in the subtree's <name> block. */
|
|
155
|
+
useWhen: string;
|
|
156
|
+
/** Optional bounded block this subtree contributes to its <name> block at
|
|
157
|
+
* root. Returns a complete self-named state element (build it with
|
|
158
|
+
* stateBlock), e.g. `<kinds count="7">…</kinds>`. Aggregate, never an
|
|
159
|
+
* unbounded enumeration on a cold path. Soft-fails to omission on
|
|
160
|
+
* null/throw. */
|
|
161
|
+
dynamicState?: () => string | null;
|
|
162
|
+
}
|
|
163
|
+
export interface RootHelp {
|
|
164
|
+
tagline: string;
|
|
165
|
+
/** One entry per listed subtree. Each renders as its own <name> XML block at
|
|
166
|
+
* root, carrying the subtree's concept, selection rubric, and any nested
|
|
167
|
+
* runtime-state block. Assembled from subtrees' RootEntry by defineRoot;
|
|
168
|
+
* root hardcodes none of it. */
|
|
169
|
+
commands: RootCommand[];
|
|
170
|
+
globals: {
|
|
171
|
+
name: string;
|
|
172
|
+
desc: string;
|
|
173
|
+
}[];
|
|
174
|
+
}
|
|
175
|
+
/** A single command block at root. Most fields come from the subtree's
|
|
176
|
+
* RootEntry; `subcommands`/`otherSubcommandCount` are computed by defineRoot
|
|
177
|
+
* from the subtree's children tiers. */
|
|
178
|
+
export interface RootCommand {
|
|
179
|
+
name: string;
|
|
180
|
+
concept: string;
|
|
181
|
+
desc: string;
|
|
182
|
+
useWhen: string;
|
|
183
|
+
dynamicState?: () => string | null;
|
|
184
|
+
/** Promoted subcommands surfaced inline under this command at root, in
|
|
185
|
+
* declaration order. `desc` is present only for 'important' tier; 'common'
|
|
186
|
+
* tier carries the bare qualified path. */
|
|
187
|
+
subcommands?: {
|
|
188
|
+
path: string;
|
|
189
|
+
desc?: string;
|
|
190
|
+
}[];
|
|
191
|
+
/** How many of this command's other (non-hidden, not-promoted) direct
|
|
192
|
+
* subcommands are not shown. Drives the "[+N (other) subcommands]" line. */
|
|
193
|
+
otherSubcommandCount?: number;
|
|
194
|
+
}
|
|
195
|
+
export interface BranchHelp {
|
|
196
|
+
name: string;
|
|
197
|
+
/** The command's own description — rendered as the `description` attribute of
|
|
198
|
+
* its <command> card at its own -h. */
|
|
199
|
+
summary: string;
|
|
200
|
+
/** Local model prose orienting the agent to what the subtree contains and how
|
|
201
|
+
* the children differ as a group — never a per-child restatement (each
|
|
202
|
+
* child's purpose lives in its own listing row). */
|
|
203
|
+
model?: string;
|
|
204
|
+
/** Bounded runtime aggregate as a complete self-named state element (build
|
|
205
|
+
* it with stateBlock), e.g. `<kinds count="7">…</kinds>`. Renderer
|
|
206
|
+
* soft-fails to omission if this returns null or throws. */
|
|
207
|
+
dynamicState?: () => string | null;
|
|
208
|
+
/** Parent-level listing assembled by defineBranch from the actual child defs.
|
|
209
|
+
* renderBranch reads this; never author it by hand. */
|
|
210
|
+
listing?: ListingChild[];
|
|
211
|
+
/** A rejected repository fragment is visible only on its owning extensible branch. */
|
|
212
|
+
extensionIssue?: {
|
|
213
|
+
fragment: string;
|
|
214
|
+
message: string;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/** Viewer-only hint about how a leaf's result should preview in the attach
|
|
218
|
+
* viewer's chat — never part of `-h` output and never reaches agent-facing
|
|
219
|
+
* stdout (see renderLeafArgv / renderResult, neither of which read this
|
|
220
|
+
* field). Declared on the leaf that owns the behavior, so the attach viewer
|
|
221
|
+
* asks the command tree instead of guessing from rendered text. */
|
|
222
|
+
export interface PreviewMeta {
|
|
223
|
+
/** When true, the attach viewer collapses this leaf's successful result to
|
|
224
|
+
* a one-line status by default (still expandable with Ctrl+O). For a
|
|
225
|
+
* command whose result is a machine-readable dump meant for a browser/tool
|
|
226
|
+
* rather than a human glance (e.g. a snapshot leaf). Never suppresses a
|
|
227
|
+
* failed run — errors always show in full. */
|
|
228
|
+
suppressOutput?: boolean;
|
|
229
|
+
}
|
|
230
|
+
export interface LeafHelp {
|
|
231
|
+
name: string;
|
|
232
|
+
summary: string;
|
|
233
|
+
/** Optional long-form workflow prose rendered immediately after the summary
|
|
234
|
+
* line, before the schema. Carried only by leaves whose correct use needs
|
|
235
|
+
* prose beyond the schema (e.g. node new's prompt-writing guidance,
|
|
236
|
+
* node yield's pre-yield checklist). */
|
|
237
|
+
guide?: string;
|
|
238
|
+
params?: InputParam[];
|
|
239
|
+
/** Note appended when there is no input (replaces the Input block). */
|
|
240
|
+
inputNote?: string;
|
|
241
|
+
output: Field[];
|
|
242
|
+
outputKind: 'object' | 'jsonl';
|
|
243
|
+
/** Every persistent change the command makes to the world. For read-only
|
|
244
|
+
* leaves use exactly: ["None. Read-only."] */
|
|
245
|
+
effects: string[];
|
|
246
|
+
/** Bounded runtime aggregate as a complete self-named state element (build it
|
|
247
|
+
* with stateBlock), e.g. `<kinds count="7">…</kinds>`. Lazily evaluated at
|
|
248
|
+
* render time so it reflects the caller's cwd/project scope; appended after
|
|
249
|
+
* the schema. Renderer soft-fails to omission if it returns null or throws.
|
|
250
|
+
* Mirrors BranchHelp.dynamicState. */
|
|
251
|
+
dynamicState?: () => string | null;
|
|
252
|
+
/** Attach-viewer preview hint (see PreviewMeta). Optional; omit for the
|
|
253
|
+
* default preview behaviour. */
|
|
254
|
+
preview?: PreviewMeta;
|
|
255
|
+
}
|
|
256
|
+
/** Invocation-local help view for one hook-eligible core leaf. It shares every
|
|
257
|
+
* non-effects field with the frozen core help and owns a separately frozen
|
|
258
|
+
* effects list that describes the effective pipeline. */
|
|
259
|
+
export type EffectiveLeafHelp = Readonly<Omit<LeafHelp, 'effects'> & {
|
|
260
|
+
effects: readonly string[];
|
|
261
|
+
}>;
|
|
262
|
+
/** State elements a leaf reads asynchronously (e.g. from the daemon) when its
|
|
263
|
+
* help renders: `leaf` stands in for `dynamicState`, `flags` for a named
|
|
264
|
+
* flag's `focusedHelp.dynamicState`. */
|
|
265
|
+
export interface AsyncHelpState {
|
|
266
|
+
leaf?: () => Promise<string>;
|
|
267
|
+
flags?: Readonly<Record<string, () => Promise<string>>>;
|
|
268
|
+
}
|
|
269
|
+
/** `help` with the async state the render shows read once: the leaf's for
|
|
270
|
+
* ordinary help, only `focusedFlag`'s for focused help. A read that throws
|
|
271
|
+
* renders no element, the same soft failure `evalDynamic` gives a sync one. */
|
|
272
|
+
export declare function withAsyncHelpState(help: LeafHelp, state: AsyncHelpState, focusedFlag?: string): Promise<LeafHelp>;
|
|
273
|
+
/** Build a self-named runtime-state element: `<tag attr="v">body</tag>`. The
|
|
274
|
+
* subtree that owns the state authors it through this, so the tag name and any
|
|
275
|
+
* scalar metadata (e.g. a count) travel with the data and render identically
|
|
276
|
+
* at every level the block appears. The tag name carries the label, so the
|
|
277
|
+
* body never repeats it. Attribute values are controlled (counts, short
|
|
278
|
+
* tokens) and not escaped. */
|
|
279
|
+
export declare function stateBlock(tag: string, attrs: Record<string, string | number>, body: string): string;
|
|
280
|
+
export declare function renderRoot(h: RootHelp): string;
|
|
281
|
+
/** A branch with more visible children than this lists only its promoted
|
|
282
|
+
* (`common` / `important`) children in its own -h and counts the rest. A
|
|
283
|
+
* plugin that mounts one command per catalog entry (a provider with >1,000
|
|
284
|
+
* services) would otherwise print every one on each `-h`. Unlisted children
|
|
285
|
+
* still route, and their own `-h` still renders. */
|
|
286
|
+
export declare const WIDE_BRANCH_LISTING_LIMIT = 40;
|
|
287
|
+
/** Split a branch's non-hidden children into the ones its -h lists and the count
|
|
288
|
+
* it leaves out. A branch at or under the limit, or one with no promoted child
|
|
289
|
+
* to fall back on, lists everything. */
|
|
290
|
+
export declare function collapseWideChildren<T extends {
|
|
291
|
+
tier?: SubTier;
|
|
292
|
+
}>(visible: readonly T[]): {
|
|
293
|
+
listed: T[];
|
|
294
|
+
unlisted: number;
|
|
295
|
+
};
|
|
296
|
+
/** The children of a branch that its parent's (root) -h promotes inline: its
|
|
297
|
+
* `common` / `important` ones. On a wide branch only leaves are promoted, so a
|
|
298
|
+
* promoted service branch shows in the branch's own -h but does not widen the
|
|
299
|
+
* root listing every agent reads. */
|
|
300
|
+
export declare function rootPromotedChildren<T extends {
|
|
301
|
+
tier?: SubTier;
|
|
302
|
+
kind?: 'leaf' | 'branch';
|
|
303
|
+
}>(visible: readonly T[]): T[];
|
|
304
|
+
export declare function renderBranch(h: BranchHelp): string;
|
|
305
|
+
/** Render one leaf's ordinary contract, or the focused continuation for one
|
|
306
|
+
* uncommon flag selected through `--flag -h`. The caller reaches focused help
|
|
307
|
+
* from the ordinary row, so that view contains only leaf identity and the new
|
|
308
|
+
* parameter detail instead of repeating information already in context. */
|
|
309
|
+
export declare function renderLeafArgv(h: LeafHelp | EffectiveLeafHelp, focusedFlag?: string): string;
|