@tomradex/plugins 0.0.0-stage → 0.19.0

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 ADDED
@@ -0,0 +1,204 @@
1
+ Copyright 2026 Haoyuan Tang
2
+
3
+
4
+ Apache License
5
+ Version 2.0, January 2004
6
+ http://www.apache.org/licenses/
7
+
8
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
9
+
10
+ 1. Definitions.
11
+
12
+ "License" shall mean the terms and conditions for use, reproduction,
13
+ and distribution as defined by Sections 1 through 9 of this document.
14
+
15
+ "Licensor" shall mean the copyright owner or entity authorized by
16
+ the copyright owner that is granting the License.
17
+
18
+ "Legal Entity" shall mean the union of the acting entity and all
19
+ other entities that control, are controlled by, or are under common
20
+ control with that entity. For the purposes of this definition,
21
+ "control" means (i) the power, direct or indirect, to cause the
22
+ direction or management of such entity, whether by contract or
23
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
24
+ outstanding shares, or (iii) beneficial ownership of such entity.
25
+
26
+ "You" (or "Your") shall mean an individual or Legal Entity
27
+ exercising permissions granted by this License.
28
+
29
+ "Source" form shall mean the preferred form for making modifications,
30
+ including but not limited to software source code, documentation
31
+ source, and configuration files.
32
+
33
+ "Object" form shall mean any form resulting from mechanical
34
+ transformation or translation of a Source form, including but
35
+ not limited to compiled object code, generated documentation,
36
+ and conversions to other media types.
37
+
38
+ "Work" shall mean the work of authorship, whether in Source or
39
+ Object form, made available under the License, as indicated by a
40
+ copyright notice that is included in or attached to the work
41
+ (an example is provided in the Appendix below).
42
+
43
+ "Derivative Works" shall mean any work, whether in Source or Object
44
+ form, that is based on (or derived from) the Work and for which the
45
+ editorial revisions, annotations, elaborations, or other modifications
46
+ represent, as a whole, an original work of authorship. For the purposes
47
+ of this License, Derivative Works shall not include works that remain
48
+ separable from, or merely link (or bind by name) to the interfaces of,
49
+ the Work and Derivative Works thereof.
50
+
51
+ "Contribution" shall mean any work of authorship, including
52
+ the original version of the Work and any modifications or additions
53
+ to that Work or Derivative Works thereof, that is intentionally
54
+ submitted to Licensor for inclusion in the Work by the copyright owner
55
+ or by an individual or Legal Entity authorized to submit on behalf of
56
+ the copyright owner. For the purposes of this definition, "submitted"
57
+ means any form of electronic, verbal, or written communication sent
58
+ to the Licensor or its representatives, including but not limited to
59
+ communication on electronic mailing lists, source code control systems,
60
+ and issue tracking systems that are managed by, or on behalf of, the
61
+ Licensor for the purpose of discussing and improving the Work, but
62
+ excluding communication that is conspicuously marked or otherwise
63
+ designated in writing by the copyright owner as "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity
66
+ on behalf of whom a Contribution has been received by Licensor and
67
+ subsequently incorporated within the Work.
68
+
69
+ 2. Grant of Copyright License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ copyright license to reproduce, prepare Derivative Works of,
73
+ publicly display, publicly perform, sublicense, and distribute the
74
+ Work and such Derivative Works in Source or Object form.
75
+
76
+ 3. Grant of Patent License. Subject to the terms and conditions of
77
+ this License, each Contributor hereby grants to You a perpetual,
78
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79
+ (except as stated in this section) patent license to make, have made,
80
+ use, offer to sell, sell, import, and otherwise transfer the Work,
81
+ where such license applies only to those patent claims licensable
82
+ by such Contributor that are necessarily infringed by their
83
+ Contribution(s) alone or by combination of their Contribution(s)
84
+ with the Work to which such Contribution(s) was submitted. If You
85
+ institute patent litigation against any entity (including a
86
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
87
+ or a Contribution incorporated within the Work constitutes direct
88
+ or contributory patent infringement, then any patent licenses
89
+ granted to You under this License for that Work shall terminate
90
+ as of the date such litigation is filed.
91
+
92
+ 4. Redistribution. You may reproduce and distribute copies of the
93
+ Work or Derivative Works thereof in any medium, with or without
94
+ modifications, and in Source or Object form, provided that You
95
+ meet the following conditions:
96
+
97
+ (a) You must give any other recipients of the Work or
98
+ Derivative Works a copy of this License; and
99
+
100
+ (b) You must cause any modified files to carry prominent notices
101
+ stating that You changed the files; and
102
+
103
+ (c) You must retain, in the Source form of any Derivative Works
104
+ that You distribute, all copyright, patent, trademark, and
105
+ attribution notices from the Source form of the Work,
106
+ excluding those notices that do not pertain to any part of
107
+ the Derivative Works; and
108
+
109
+ (d) If the Work includes a "NOTICE" text file as part of its
110
+ distribution, then any Derivative Works that You distribute must
111
+ include a readable copy of the attribution notices contained
112
+ within such NOTICE file, excluding those notices that do not
113
+ pertain to any part of the Derivative Works, in at least one
114
+ of the following places: within a NOTICE text file distributed
115
+ as part of the Derivative Works; within the Source form or
116
+ documentation, if provided along with the Derivative Works; or,
117
+ within a display generated by the Derivative Works, if and
118
+ wherever such third-party notices normally appear. The contents
119
+ of the NOTICE file are for informational purposes only and
120
+ do not modify the License. You may add Your own attribution
121
+ notices within Derivative Works that You distribute, alongside
122
+ or as an addendum to the NOTICE text from the Work, provided
123
+ that such additional attribution notices cannot be construed
124
+ as modifying the License.
125
+
126
+ You may add Your own copyright statement to Your modifications and
127
+ may provide additional or different license terms and conditions
128
+ for use, reproduction, or distribution of Your modifications, or
129
+ for any such Derivative Works as a whole, provided Your use,
130
+ reproduction, and distribution of the Work otherwise complies with
131
+ the conditions stated in this License.
132
+
133
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
134
+ any Contribution intentionally submitted for inclusion in the Work
135
+ by You to the Licensor shall be under the terms and conditions of
136
+ this License, without any additional terms or conditions.
137
+ Notwithstanding the above, nothing herein shall supersede or modify
138
+ the terms of any separate license agreement you may have executed
139
+ with Licensor regarding such Contributions.
140
+
141
+ 6. Trademarks. This License does not grant permission to use the trade
142
+ names, trademarks, service marks, or product names of the Licensor,
143
+ except as required for reasonable and customary use in describing the
144
+ origin of the Work and reproducing the content of the NOTICE file.
145
+
146
+ 7. Disclaimer of Warranty. Unless required by applicable law or
147
+ agreed to in writing, Licensor provides the Work (and each
148
+ Contributor provides its Contributions) on an "AS IS" BASIS,
149
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150
+ implied, including, without limitation, any warranties or conditions
151
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152
+ PARTICULAR PURPOSE. You are solely responsible for determining the
153
+ appropriateness of using or redistributing the Work and assume any
154
+ risks associated with Your exercise of permissions under this License.
155
+
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor be
160
+ liable to You for damages, including any direct, indirect, special,
161
+ incidental, or consequential damages of any character arising as a
162
+ result of this License or out of the use or inability to use the
163
+ Work (including but not limited to damages for loss of goodwill,
164
+ work stoppage, computer failure or malfunction, or any and all
165
+ other commercial damages or losses), even if such Contributor
166
+ has been advised of the possibility of such damages.
167
+
168
+ 9. Accepting Warranty or Additional Liability. While redistributing
169
+ the Work or Derivative Works thereof, You may choose to offer,
170
+ and charge a fee for, acceptance of support, warranty, indemnity,
171
+ or other liability obligations and/or rights consistent with this
172
+ License. However, in accepting such obligations, You may act only
173
+ on Your own behalf and on Your sole responsibility, not on behalf
174
+ of any other Contributor, and only if You agree to indemnify,
175
+ defend, and hold each Contributor harmless for any liability
176
+ incurred by, or claims asserted against, such Contributor by reason
177
+ of your accepting any such warranty or additional liability.
178
+
179
+ END OF TERMS AND CONDITIONS
180
+
181
+ APPENDIX: How to apply the Apache License to your work.
182
+
183
+ To apply the Apache License to your work, attach the following
184
+ boilerplate notice, with the fields enclosed by brackets "[]"
185
+ replaced with your own identifying information. (Don't include
186
+ the brackets!) The text should be enclosed in the appropriate
187
+ comment syntax for the file format. We also recommend that a
188
+ file or class name and description of purpose be included on the
189
+ same "printed page" as the copyright notice for easier
190
+ identification within third-party archives.
191
+
192
+ Copyright [yyyy] [name of copyright owner]
193
+
194
+ Licensed under the Apache License, Version 2.0 (the "License");
195
+ you may not use this file except in compliance with the License.
196
+ You may obtain a copy of the License at
197
+
198
+ http://www.apache.org/licenses/LICENSE-2.0
199
+
200
+ Unless required by applicable law or agreed to in writing, software
201
+ distributed under the License is distributed on an "AS IS" BASIS,
202
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
203
+ See the License for the specific language governing permissions and
204
+ limitations under the License.
@@ -0,0 +1,194 @@
1
+ import type { Plugin } from "cordis";
2
+ import { type Manifest, type Risk } from "@tomradex/plugin-sdk";
3
+ import { type Analysis, type Attestation, type LockEntry, type TrustTier } from "@tomradex/plugin-kit";
4
+ import { type RowPatch } from "./types.js";
5
+ export interface ExtensionStoreConfig {
6
+ /** `~/Tomrade/plugins`: installed versions and each plugin's data. */
7
+ root: string;
8
+ lockFile: string;
9
+ /** keyId → public key PEM: whose attestations this build believes. */
10
+ trustedKeys: Record<string, string>;
11
+ /** The host's own `import()`, so a plugin's bare imports resolve the host's way. */
12
+ importer(url: string): Promise<unknown>;
13
+ /** This Tomrade's version, held to a full-mode plugin's `engines.tomrade`. Absent in a checkout, which checks no range. */
14
+ appVersion?: string | null;
15
+ }
16
+ /** What one row of a full-mode extension does to Tomrade's composition. */
17
+ export interface RowChange {
18
+ id: string;
19
+ change: "adds" | "replaces" | "switches-off" | "configures";
20
+ /** Other extensions whose rows change the same row; the one installed last is laid on last. */
21
+ alsoBy: string[];
22
+ /** Why it is not applied, when it is not. */
23
+ refused?: string;
24
+ }
25
+ export interface FullModeInfo {
26
+ /** The Tomrade versions it says it works with. */
27
+ tomrade: string;
28
+ rows: RowChange[];
29
+ /** Its rows are not the ones this start applied: they change with the next start. */
30
+ restart: boolean;
31
+ }
32
+ /**
33
+ * A version range the plugin's manifest names that this Tomrade is outside:
34
+ * `tomrade` for a full-mode plugin's `engines.tomrade`, `sdk` for `engines.sdk`.
35
+ * `granted`: the person let this exact plugin version run on this exact version anyway.
36
+ */
37
+ export interface RangeMiss {
38
+ kind: "tomrade" | "sdk";
39
+ range: string;
40
+ version: string;
41
+ granted: boolean;
42
+ }
43
+ export declare const COMPATIBILITY_FILE = "compatibility.json";
44
+ /** What the manager shows for a row that is an extension. */
45
+ export interface ExtensionInfo {
46
+ id: string;
47
+ namespace: string;
48
+ version: string;
49
+ title: string;
50
+ description: string;
51
+ license: string;
52
+ repository?: string;
53
+ source: LockEntry["source"];
54
+ tier: TrustTier;
55
+ risk: Risk;
56
+ permissions: Manifest["permissions"];
57
+ inject: string[];
58
+ authoredBy: Manifest["authoredBy"];
59
+ dir: string;
60
+ modified: boolean;
61
+ autoUpdate: boolean;
62
+ previousVersion: string | null;
63
+ /** A studio build nobody has confirmed yet: its digest and what the analyzer found in it. */
64
+ pending: {
65
+ digest: string;
66
+ analysis: Analysis;
67
+ } | null;
68
+ attestation: Attestation | null;
69
+ /** Runs with Tomrade's whole Context rather than the SDK's facade. */
70
+ full: FullModeInfo | null;
71
+ /** The CLI agent hook events it hears, as its build recorded them. */
72
+ agentHooks: string[];
73
+ /** The ranges it names that this Tomrade is outside, each granted or not. */
74
+ outOfRange: RangeMiss[];
75
+ }
76
+ export declare class ExtensionRefused extends Error {
77
+ name: string;
78
+ }
79
+ /**
80
+ * The installed extensions and the rules for loading one: the files must be
81
+ * the ones installed, the code must be an SDK plugin the host's contract
82
+ * satisfies, and an agent's build loads only at a digest a person confirmed.
83
+ */
84
+ export declare class ExtensionStore {
85
+ private readonly config;
86
+ private lock;
87
+ private readonly watchers;
88
+ private readonly pendingAnalysis;
89
+ /** The app's own row ids, which a full-mode extension's rows may change; known once the composition asks for rows. */
90
+ private appRows;
91
+ /** Each full-mode extension's rows as this start applied them, to tell when the next start would differ. */
92
+ private readonly applied;
93
+ onChange: (id: string) => void;
94
+ private grants;
95
+ /** What could not be read from `compatibility.json`; while the file itself cannot be parsed it is never overwritten. */
96
+ compatibilityProblems: string[];
97
+ private compatibilityReadOnly;
98
+ constructor(config: ExtensionStoreConfig);
99
+ private get compatibilityFile();
100
+ /** Every record that reads as a grant applies; the rest are reported, never fatal. */
101
+ private readGrants;
102
+ private writeGrants;
103
+ /** The ranges a manifest names that this Tomrade is outside, and whether this exact pair was let in. */
104
+ private misses;
105
+ /**
106
+ * Lets this exact version of the plugin run on this exact Tomrade, outside the ranges it names. The
107
+ * person has been told it may crash Tomrade or lose data; neither a new plugin version nor a new
108
+ * Tomrade inherits it.
109
+ */
110
+ allowVersion(id: string): LockEntry;
111
+ /** Takes back what `allowVersion` let in for this plugin version, on any Tomrade. */
112
+ withdrawVersion(id: string): LockEntry;
113
+ /** Installed first, laid on first: an update or a switch does not move a plugin in this order. */
114
+ private inOrder;
115
+ /** A full-mode extension's manifest, when it is one that may run here; null for an SDK plugin. */
116
+ private full;
117
+ /** Why this Tomrade does not run the plugin for its ranges, or null when it does: in range, or let in for this exact pair. */
118
+ private outOfRange;
119
+ /** Each of an extension's rows as this start would lay it on, checked against the app's own rows. */
120
+ private plan;
121
+ /** The rows an extension lays on now: none while it is off, unconfirmed, or outside its Tomrade range. */
122
+ private active;
123
+ /**
124
+ * The rows full-mode extensions lay over the app's, one list per extension in
125
+ * the order they were installed, for the composition to apply after the
126
+ * app's rows and before the person's own patch file. What it returns is what
127
+ * this start applies.
128
+ */
129
+ patches(appRows: Iterable<string>): {
130
+ from: string;
131
+ rows: RowPatch[];
132
+ }[];
133
+ /** A plugin one of an extension's rows loads is that extension's code: its writes carry the namespace too. */
134
+ claim(plugin: object, from: string): void;
135
+ /** What an extension's rows do, and which other extensions' rows change the same ones. */
136
+ private fullInfo;
137
+ get root(): string;
138
+ entries(): LockEntry[];
139
+ has(id: string): boolean;
140
+ entry(id: string): LockEntry;
141
+ /** One composition row per installed extension. A studio build waiting for a person stays off. */
142
+ rows(): {
143
+ id: string;
144
+ name: string;
145
+ disabled: boolean;
146
+ }[];
147
+ private confirmed;
148
+ private currentDigest;
149
+ private save;
150
+ private put;
151
+ info(id: string): ExtensionInfo;
152
+ /**
153
+ * Turns an installed entry into a row cordis can load, refusing what the
154
+ * rules say may not run. Files that changed since install still load — they
155
+ * are on this person's machine — but the plugin loses its store standing.
156
+ */
157
+ load(id: string): Promise<Plugin>;
158
+ /** A full-mode plugin is loaded as it is, like a row of the app's own; only what it writes is marked as its. */
159
+ private fullPlugin;
160
+ /**
161
+ * A `.tomrade-plugin` file: from the store, which lists the digest its
162
+ * contents must have (and, for Tomrade's own plugins, an attestation), or
163
+ * handed over by a person.
164
+ */
165
+ installFile(file: string, opts?: {
166
+ source?: "store" | "file";
167
+ digest?: string;
168
+ attestation?: unknown;
169
+ vet?: (manifest: Manifest) => void;
170
+ disabled?: boolean;
171
+ }): Promise<LockEntry>;
172
+ /** A person's own directory, loaded as it stands and reloaded when its build changes. */
173
+ addFolder(dir: string, source?: "folder" | "studio", vet?: (manifest: Manifest) => void): LockEntry;
174
+ /** Two extensions sharing a namespace would share tables and ids. */
175
+ private refuseClash;
176
+ confirm(id: string, digest: string): LockEntry;
177
+ setDisabled(id: string, disabled: boolean): void;
178
+ setAutoUpdate(id: string, autoUpdate: boolean): void;
179
+ /** Whether this build believes an attestation for a digest, before anything is downloaded. */
180
+ verify(raw: unknown, digest: string): Attestation | null;
181
+ /** Tomrade signed the installed build as official after it was installed. */
182
+ setAttestation(id: string, raw: unknown): Attestation | null;
183
+ /** Back to the version before the last update; the newer one is removed. */
184
+ rollback(id: string): LockEntry;
185
+ uninstall(id: string, opts?: {
186
+ removeData?: boolean;
187
+ }): void;
188
+ /** Watch every development folder; a rebuilt bundle reloads the row. */
189
+ watchAll(): void;
190
+ private watch;
191
+ private unwatch;
192
+ close(): void;
193
+ }
194
+ //# sourceMappingURL=extensions.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { Plugins, Plugins as default } from "./manager.js";
2
+ export { PROTECTED_ROWS, RequiredModuleError, type ContractSpec, type ModuleSpec, type ModuleView, type PluginRow, type PluginState, type PluginView, type PluginsConfig, type PluginsSnapshot, type RowPatch } from "./types.js";
3
+ export { COMPATIBILITY_FILE, ExtensionRefused, ExtensionStore, type ExtensionInfo, type ExtensionStoreConfig, type FullModeInfo, type RangeMiss, type RowChange } from "./extensions.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,137 @@
1
+ import { Context, Service } from "cordis";
2
+ import { type ModuleView, type PluginRow, type PluginView, type PluginsConfig, type PluginsSnapshot } from "./types.js";
3
+ declare module "cordis" {
4
+ interface Context {
5
+ plugins: Plugins;
6
+ }
7
+ }
8
+ declare module "@tomradex/ipc" {
9
+ interface Channels {
10
+ "plugins.list": () => PluginsSnapshot;
11
+ "plugins.setEnabled": (id: string, enabled: boolean) => PluginsSnapshot;
12
+ /** A `.tomrade-plugin` file a person picked. */
13
+ "plugins.installFile": (file: string) => PluginsSnapshot;
14
+ /** A plugin's own folder, loaded as it stands and reloaded when its build changes. */
15
+ "plugins.addFolder": (dir: string) => PluginsSnapshot;
16
+ "plugins.uninstall": (id: string, removeData: boolean) => PluginsSnapshot;
17
+ "plugins.rollback": (id: string) => PluginsSnapshot;
18
+ "plugins.reload": (id: string) => PluginsSnapshot;
19
+ /** Allow a development build to load at exactly this digest. */
20
+ "plugins.confirm": (id: string, digest: string) => PluginsSnapshot;
21
+ "plugins.setAutoUpdate": (id: string, on: boolean) => PluginsSnapshot;
22
+ /** Run this exact plugin version on this exact Tomrade anyway, outside the ranges it names; the person accepted the risk. */
23
+ "plugins.allowVersion": (id: string) => PluginsSnapshot;
24
+ "plugins.withdrawVersion": (id: string) => PluginsSnapshot;
25
+ }
26
+ interface Broadcasts {
27
+ "plugins.changed": () => void;
28
+ }
29
+ }
30
+ /**
31
+ * The loader, and the thing the user manages it with. It owns every row's
32
+ * fiber, so it can say what is running, switch a row off, and put it back —
33
+ * except when that would leave a required module with nothing providing it.
34
+ *
35
+ * It is not a row itself: you cannot switch off the thing that does the switching.
36
+ */
37
+ export declare class Plugins extends Service {
38
+ readonly config: PluginsConfig;
39
+ static provide: string;
40
+ private fibers;
41
+ private errors;
42
+ /** Full-mode extensions whose rows this start took back, and the required modules those rows left empty. */
43
+ private rowsRefused;
44
+ private notify;
45
+ private queue;
46
+ /**
47
+ * Inside a service method `this.ctx` is the *caller's* context, and a row
48
+ * loaded from one would belong to whoever asked for it — the IPC handler, on
49
+ * a switch thrown in the UI. Every row hangs off this one instead.
50
+ */
51
+ private readonly home;
52
+ constructor(ctx: Context, config: PluginsConfig);
53
+ get extensions(): import("./extensions.js").ExtensionStore | undefined;
54
+ [Service.init](): Promise<void>;
55
+ rows(): PluginRow[];
56
+ /** Whether a row is switched off, a row the app no longer ships included: the person's switch for it outlives the row. */
57
+ switchedOff(id: string): boolean;
58
+ snapshot(): PluginsSnapshot;
59
+ list(): PluginView[];
60
+ modules(): ModuleView[];
61
+ /**
62
+ * Switching a row on loads it; switching one off disposes its fiber, and
63
+ * everything that injected what it provided unloads with it. Both survive a
64
+ * restart through `persist`.
65
+ *
66
+ * Switches run one at a time. Two of them interleaved would read a half
67
+ * torn-down context and guard against the wrong answer — and two windows, or
68
+ * one impatient click, are enough to do it.
69
+ */
70
+ setEnabled(id: string, enabled: boolean): Promise<PluginsSnapshot>;
71
+ /** Serialised with the switches, for the same reason they are. */
72
+ private queued;
73
+ private store;
74
+ /** A row that joins after boot: an extension installed, or a folder loaded. */
75
+ add(row: PluginRow): Promise<PluginsSnapshot>;
76
+ /** Unload a row and forget it. Held modules are guarded as for a switch. */
77
+ remove(id: string): Promise<PluginsSnapshot>;
78
+ /** Load a row again from its current files; a switched-off row stays off. */
79
+ reload(id: string): Promise<PluginsSnapshot>;
80
+ private restart;
81
+ /** `disabled`: a first install goes on switched off; an update keeps the switch it had. */
82
+ installFile(file: string, opts?: {
83
+ source?: "store" | "file";
84
+ digest?: string;
85
+ attestation?: unknown;
86
+ disabled?: boolean;
87
+ }): Promise<PluginsSnapshot>;
88
+ addFolder(dir: string, source?: "folder" | "studio"): Promise<PluginsSnapshot>;
89
+ confirm(id: string, digest: string): Promise<PluginsSnapshot>;
90
+ allowVersion(id: string): Promise<PluginsSnapshot>;
91
+ withdrawVersion(id: string): Promise<PluginsSnapshot>;
92
+ rollback(id: string): Promise<PluginsSnapshot>;
93
+ uninstall(id: string, opts?: {
94
+ removeData?: boolean;
95
+ }): Promise<PluginsSnapshot>;
96
+ private apply;
97
+ private disable;
98
+ /**
99
+ * A full-mode extension whose rows switch off the last provider of a required
100
+ * module is refused as it is installed. A row that replaces one is judged when
101
+ * its rows are laid on, at the next start.
102
+ */
103
+ private vetRows;
104
+ /**
105
+ * Rows of full-mode extensions that left a required module empty are taken
106
+ * back, the extension laid on last first, and each one taken back is told
107
+ * which modules its rows emptied. One whose rows were not the cause is put back.
108
+ */
109
+ private keepRequired;
110
+ /** Bring the composition's own rows to `next`: a changed row restarts, a row gone stops, a new row starts. Extensions' rows stay. */
111
+ private lay;
112
+ private start;
113
+ /**
114
+ * A fiber whose dependencies arrive later starts loading after the notify
115
+ * that brings them, so settle until no fiber is mid-flight.
116
+ */
117
+ private settle;
118
+ private describe;
119
+ /**
120
+ * Which row puts each live service on the context. Read from the context
121
+ * rather than from a declaration, so a row that loads further plugins — and
122
+ * every row here may — is credited with what they provide.
123
+ */
124
+ private providers;
125
+ /**
126
+ * Declared on the row, because a switched-off row registers nothing — and a
127
+ * disabled engine is the one someone opens this pane to find. A running row
128
+ * is also credited with every registry its effects are labelled with.
129
+ */
130
+ private contractsOf;
131
+ /** Walk out of nested fibers until one of them is a row of the composition. */
132
+ private ownerOf;
133
+ /** Plugin id → the required modules it is the last one holding up. */
134
+ private soleProviders;
135
+ private viewsOf;
136
+ }
137
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ throw new Error("@tomradex/plugins is Tomrade's own code: a full-mode plugin gets the running app's copy, so load the plugin in Tomrade");
@@ -0,0 +1,116 @@
1
+ import type { Plugin } from "cordis";
2
+ import type { ExtensionInfo, ExtensionStore } from "./extensions.js";
3
+ /** One row of the composition: exactly what a line of tomrade.yml carries. */
4
+ export interface PluginRow {
5
+ id: string;
6
+ name: string;
7
+ /** What to call the row where the plugin cannot say itself — switched off, it registers no title. */
8
+ title?: string;
9
+ config?: unknown;
10
+ disabled?: boolean;
11
+ /** Contract ids this row fills, for when it is switched off and registers nothing to observe. */
12
+ implements?: string[];
13
+ /** The full-mode extension whose rows put this row's plugin here: its writes carry that extension's namespace. */
14
+ from?: string;
15
+ }
16
+ /** A row as a patch file or a full-mode extension writes it: the fields it changes on the row with its id. */
17
+ export type RowPatch = Partial<PluginRow> & {
18
+ id: string;
19
+ };
20
+ /**
21
+ * Rows no extension's rows may change: the renderer's channels, through which a
22
+ * plugin is switched off and removed, and the catalog that verifies and revokes
23
+ * plugins. Protecting Tomrade itself is the one limit full mode has.
24
+ */
25
+ export declare const PROTECTED_ROWS: ReadonlySet<string>;
26
+ /**
27
+ * A module is a capability, named by the service key that carries it. A
28
+ * required module may never be left without a plugin providing it — that is
29
+ * the one thing the manager refuses.
30
+ */
31
+ export interface ModuleSpec {
32
+ id: string;
33
+ title: string;
34
+ required?: boolean;
35
+ }
36
+ /**
37
+ * A contract is a registry plugins plug into, named by the call that does it —
38
+ * `agent.engine`, `storage.register`. Its members are interchangeable, which
39
+ * is what the Plugins pane groups them by.
40
+ */
41
+ export interface ContractSpec {
42
+ id: string;
43
+ title: string;
44
+ /** The registering call. Its effects on a running row are how membership is observed. */
45
+ registry: string;
46
+ }
47
+ export type PluginState = "active" | "failed" | "pending" | "disabled";
48
+ /** What the renderer, and `--dump-config`, get for one row. */
49
+ export interface PluginView {
50
+ id: string;
51
+ name: string;
52
+ title?: string;
53
+ config?: unknown;
54
+ state: PluginState;
55
+ error?: string;
56
+ /** For a pending row: the services it is still waiting for. */
57
+ waitingFor?: string[];
58
+ /** Service keys this row puts on the context — observed, not declared. */
59
+ provides: string[];
60
+ /** Service keys it named in `inject`. Empty until it has loaded once. */
61
+ injects: string[];
62
+ /** Required modules it is the only provider of, which is why it cannot be switched off. */
63
+ holds: string[];
64
+ /** Contracts it fills: declared on its row, plus any it was seen registering into. */
65
+ implements: string[];
66
+ /** Present when the row is an installed extension rather than part of the app. */
67
+ extension?: ExtensionInfo;
68
+ /** A full-mode extension's rows taken back this start, and the required modules they left with no plugin. */
69
+ rowsRefused?: string[];
70
+ }
71
+ export interface ModuleView {
72
+ id: string;
73
+ title: string;
74
+ required: boolean;
75
+ /** Plugin ids currently providing it. Empty means the module is unfilled. */
76
+ providers: string[];
77
+ }
78
+ export interface PluginsSnapshot {
79
+ modules: ModuleView[];
80
+ contracts: ContractSpec[];
81
+ plugins: PluginView[];
82
+ /** Records of compatibility.json that could not be read, which no exemption comes from. */
83
+ compatibilityProblems?: string[];
84
+ }
85
+ export interface PluginsConfig {
86
+ rows: PluginRow[];
87
+ modules?: ModuleSpec[];
88
+ contracts?: ContractSpec[];
89
+ /**
90
+ * Turning a name into a plugin belongs to the host: Node resolves a bare
91
+ * package specifier against the file that asks for it, and the application
92
+ * is what depends on the plugins.
93
+ */
94
+ resolve(row: PluginRow): Promise<Plugin>;
95
+ /** Installed extensions; their rows join the composition's. */
96
+ extensions?: ExtensionStore;
97
+ /** Called after a row is switched, so the choice survives a restart. */
98
+ persist?(id: string, disabled: boolean): void | Promise<void>;
99
+ /**
100
+ * The composition again, without the rows of the full-mode extensions named:
101
+ * how a start takes back rows that left a required module empty.
102
+ */
103
+ recompose?(without: ReadonlySet<string>): PluginRow[];
104
+ /** The full-mode extensions whose rows this start applied, in the order they were laid on. */
105
+ rowsFrom?: string[];
106
+ /** The person's switches for rows the composition no longer has, by row id: what a plugin taking such a row's place starts as. */
107
+ leftSwitches?: Record<string, boolean>;
108
+ }
109
+ /** Refusing to empty a required module is the guard; it reads as one sentence. */
110
+ export declare class RequiredModuleError extends Error {
111
+ readonly pluginId: string;
112
+ readonly modules: ModuleView[];
113
+ name: string;
114
+ constructor(pluginId: string, modules: ModuleView[]);
115
+ }
116
+ //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@tomradex/plugins",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.19.0",
4
+ "type": "module",
5
+ "author": "Haoyuan Tang",
6
+ "engines": {
7
+ "node": ">=22"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "license": "Apache-2.0",
13
+ "description": "ctx.plugins — what is installed, what each row actually provides, and the modules a composition may not be left without — declarations for full-mode plugins; Tomrade provides the code at run time",
14
+ "keywords": [
15
+ "tomrade",
16
+ "tomrade-plugin",
17
+ "types"
18
+ ],
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/runtime.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "dependencies": {
30
+ "@tomradex/contracts": "0.19.0",
31
+ "@tomradex/extensions": "0.19.0",
32
+ "@tomradex/ipc": "0.19.0",
33
+ "@tomradex/plugin-kit": "0.19.0",
34
+ "@tomradex/plugin-sdk": "0.2.28",
35
+ "cordis": "4.0.0-rc.8"
36
+ }
37
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.