@sparkelf/dsh-plus 0.2.0-rc.9 → 0.2.1-alpha.10
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/cordis.patch.yml +74 -36
- package/lib/bin.js +866 -21
- package/lib/types/standalone-capabilities.d.ts +139 -0
- package/lib/types/standalone-capabilities.js +688 -0
- package/lib/types/standalone-cli.js +300 -18
- package/lib/types/standalone-profile.d.ts +45 -1
- package/lib/types/standalone-profile.js +84 -5
- package/package.json +118 -80
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The optional capabilities a Plus installation can enable, and the interview that
|
|
3
|
+
* decides which ones to set up.
|
|
4
|
+
*
|
|
5
|
+
* A standalone installation works without any of them: the agent runs, the shell
|
|
6
|
+
* runs, and files are read and written. Each entry here adds a capability whose
|
|
7
|
+
* backing service lives outside npm — a search provider that needs a key, a PDF
|
|
8
|
+
* parser that needs a local server, an Office toolchain that needs a runtime — so
|
|
9
|
+
* the choice is offered once, at install time, rather than left to a user who has
|
|
10
|
+
* no way to know what the deployment is missing.
|
|
11
|
+
*
|
|
12
|
+
* Every capability is selected by default. A user who wants the plain harness
|
|
13
|
+
* deselects them; a user who accepts the defaults ends up with a deployment whose
|
|
14
|
+
* features work, which is the state the interactive question exists to reach.
|
|
15
|
+
*
|
|
16
|
+
* Enabling a capability has to mean the feature works, so each entry carries both
|
|
17
|
+
* halves of that: the profile row that mounts it and the service it needs. A
|
|
18
|
+
* capability that only asked a question and then dropped the answer would report
|
|
19
|
+
* success while the deployment stayed exactly as it was.
|
|
20
|
+
*
|
|
21
|
+
* @module @sparkelf/dsh-plus/standalone-capabilities
|
|
22
|
+
*/
|
|
23
|
+
/** One optional capability a deployment can enable. */
|
|
24
|
+
export interface Capability {
|
|
25
|
+
/** Stable key used on the command line and in the profile. */
|
|
26
|
+
readonly id: string;
|
|
27
|
+
/** One-line name shown in the interview. */
|
|
28
|
+
readonly title: string;
|
|
29
|
+
/** What the deployment gains, shown beside the name. */
|
|
30
|
+
readonly detail: string;
|
|
31
|
+
/** Whether the backing service needs an address the user must supply. */
|
|
32
|
+
readonly needsEndpoint: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Capabilities offered at install time, in interview order. */
|
|
35
|
+
export declare const CAPABILITIES: readonly Capability[];
|
|
36
|
+
/** The answers one interview produced. */
|
|
37
|
+
export interface CapabilityAnswers {
|
|
38
|
+
/** Capability ids the user kept selected. */
|
|
39
|
+
readonly enabled: readonly string[];
|
|
40
|
+
/** Exa API key when web search was enabled and the user supplied one. */
|
|
41
|
+
readonly exaApiKey?: string;
|
|
42
|
+
/** MinerU endpoint to write; defaults to the local service this command starts. */
|
|
43
|
+
readonly mineruEndpoint?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Where this command starts MinerU when the capability is enabled. */
|
|
46
|
+
export declare const DEFAULT_MINERU_ENDPOINT = "http://127.0.0.1:8000/file_parse";
|
|
47
|
+
/** File under the deployment home recording which capabilities were enabled. */
|
|
48
|
+
export declare const CAPABILITY_RECORD = "capabilities.json";
|
|
49
|
+
/** Deployment env file the launcher reads as its `user-env` layer. */
|
|
50
|
+
export declare const CAPABILITY_ENV_FILE = ".env";
|
|
51
|
+
/** Comment that identifies a profile layer this interview wrote. */
|
|
52
|
+
export declare const CAPABILITY_MARKER = "Written by dsh-plus start from the capability interview.";
|
|
53
|
+
/**
|
|
54
|
+
* Interview the user about the optional capabilities.
|
|
55
|
+
*
|
|
56
|
+
* Each is offered on its own line and defaults to enabled, so pressing Enter
|
|
57
|
+
* through the interview produces a deployment whose features work. The answers are
|
|
58
|
+
* returned rather than applied, so a caller can report what it will do before it
|
|
59
|
+
* touches the profile.
|
|
60
|
+
*
|
|
61
|
+
* @param interactive - when false, every capability is enabled without asking.
|
|
62
|
+
* @returns the ids to enable and the values the enabled ones need.
|
|
63
|
+
*/
|
|
64
|
+
export declare function interviewCapabilities(interactive: boolean): Promise<CapabilityAnswers>;
|
|
65
|
+
/**
|
|
66
|
+
* The deployment env file, with one assignment per enabled capability that reaches
|
|
67
|
+
* its service through the launch environment.
|
|
68
|
+
*
|
|
69
|
+
* Exa reads its key from the launch environment, so a capability the user selected is enabled here
|
|
70
|
+
* as well as in the profile layer. Only the names this interview owns are rewritten: a
|
|
71
|
+
* deployment that keeps its own assignments in the same file keeps them, and
|
|
72
|
+
* deselecting a capability removes the assignment that turned it on.
|
|
73
|
+
*
|
|
74
|
+
* @param answers - the interview's answers.
|
|
75
|
+
* @param existing - the file's current text, when it already exists.
|
|
76
|
+
* @returns the environment file's text.
|
|
77
|
+
*/
|
|
78
|
+
export declare function capabilityEnvironment(answers: CapabilityAnswers, existing?: string): string;
|
|
79
|
+
export declare function capabilityPatchLayer(answers: CapabilityAnswers, existing?: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* The capability record a previous configured run wrote, or `undefined` when none exists.
|
|
82
|
+
*
|
|
83
|
+
* The record is what lets a later run report the deployment's answers instead of asking
|
|
84
|
+
* again. A malformed or unreadable file is treated as absent rather than fatal: it is a
|
|
85
|
+
* convenience cache, and refusing to boot over it would strand a deployment whose record
|
|
86
|
+
* was corrupted by an interrupted write.
|
|
87
|
+
*
|
|
88
|
+
* @param home - the deployment home holding the record.
|
|
89
|
+
* @returns the enabled ids, and the MinerU endpoint when the record carries one.
|
|
90
|
+
*/
|
|
91
|
+
export declare function readCapabilityRecord(home: string): CapabilityAnswers | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The capabilities a deployment actually has mounted, read from the files the loader and
|
|
94
|
+
* the launch environment consume.
|
|
95
|
+
*
|
|
96
|
+
* A record is a cache of an earlier answer and can drift from the deployment — a profile
|
|
97
|
+
* layer edited by hand, a record deleted, a plugin removed from the distribution. What a
|
|
98
|
+
* capability is *doing* is decided by the profile patch rows and the env file, so that is
|
|
99
|
+
* what a report reads.
|
|
100
|
+
*
|
|
101
|
+
* @param profilePatchText - the profile layer's YAML text.
|
|
102
|
+
* @param envText - the deployment env file's text.
|
|
103
|
+
* @returns the ids found in the profile layer and the env names present.
|
|
104
|
+
*/
|
|
105
|
+
export declare function detectEnabledCapabilities(profilePatchText: string, envText: string): {
|
|
106
|
+
readonly mounted: readonly string[];
|
|
107
|
+
readonly env: readonly string[];
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* One capability's effect, added to or removed from an existing profile layer without
|
|
111
|
+
* disturbing the rest of the file.
|
|
112
|
+
*
|
|
113
|
+
* `dsh-plus start` owns the whole layer and rewrites it from the interview's answers, which
|
|
114
|
+
* is correct for an install that answered once and never edits afterwards. A deployment
|
|
115
|
+
* that maintains its own rows in that same layer cannot be served that way: replacing the
|
|
116
|
+
* file drops every row the operator wrote. This edits the rows this module owns and leaves
|
|
117
|
+
* every other entry, comment, and blank line exactly where it was.
|
|
118
|
+
*
|
|
119
|
+
* @param existing - the layer's current YAML text.
|
|
120
|
+
* @param id - the capability to add or remove.
|
|
121
|
+
* @param enable - whether to add the capability.
|
|
122
|
+
* @param mineruEndpoint - the endpoint to write when enabling MinerU.
|
|
123
|
+
* @returns the layer's new text.
|
|
124
|
+
*/
|
|
125
|
+
export declare function editCapabilityPatchLayer(existing: string, id: string, enable: boolean, mineruEndpoint?: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* Install and start the backing services the selected capabilities need.
|
|
128
|
+
*
|
|
129
|
+
* Enabling a capability means the deployment expects its service to answer, so the
|
|
130
|
+
* command that offers the choice is also the command that provides it. Each step
|
|
131
|
+
* reports what it is doing and, on failure, the command a user can run by hand —
|
|
132
|
+
* a missing runtime is a fact about the host, not a reason to abandon the install.
|
|
133
|
+
*
|
|
134
|
+
* @param answers - the interview's answers.
|
|
135
|
+
* @param home - the deployment home, where generated service units are recorded.
|
|
136
|
+
* @returns the ids whose service is ready.
|
|
137
|
+
*/
|
|
138
|
+
export declare function installCapabilityServices(answers: CapabilityAnswers, home: string): Promise<readonly string[]>;
|
|
139
|
+
//# sourceMappingURL=standalone-capabilities.d.ts.map
|