@tomradex/plugin-sdk 0.0.0-stage → 0.2.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.
package/README.md CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # @tomradex/plugin-sdk
2
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.
3
+ The contract a Tomrade plugin is written against. `definePlugin` hands `apply()` a `PluginContext`: every call returns a Promise, every function you give it may be async, and every id you register carries your plugin's namespace.
4
+
5
+ ```sh
6
+ npx @tomradex/plugin-cli init my-plugin --id you/my-plugin
7
+ cd my-plugin && npm install && npm run dev
8
+ ```
9
+
10
+ ```ts
11
+ import { z } from "zod";
12
+ import { definePlugin, defineTool, requireProjectId } from "@tomradex/plugin-sdk";
13
+
14
+ export default definePlugin({
15
+ inject: ["items", "tools", "contributions"],
16
+ async apply(ctx) {
17
+ await ctx.tools.register(
18
+ defineTool({
19
+ name: "my_plugin_count_open", // starts with the namespace
20
+ title: "Count open issues",
21
+ description: "How many issues in the project are not done yet.",
22
+ input: z.object({ projectId: z.string().optional() }),
23
+ execute: async ({ projectId }, inv) =>
24
+ (await ctx.items.list({ projectId: requireProjectId("my_plugin_count_open", projectId, inv) })).filter((i) => i.status !== "done").length
25
+ })
26
+ );
27
+ await ctx.contributions.statusItem({ id: "my_plugin", text: async ({ projectId }) => (projectId ? `${(await ctx.items.list({ projectId })).length} issues` : null) });
28
+ }
29
+ });
30
+ ```
31
+
32
+ ## What the context offers
33
+
34
+ | Member | |
35
+ |---|---|
36
+ | `items` | `list`, `query`, `get`, `getByKey`, `create`, `update`, `delete`, `addRelation`, `removeRelation`, `labels` — writes take no author; Tomrade records who wrote |
37
+ | `fields`, `boards`, `views`, `projects` | the project's fields (and `create`, `update`, `remove`, `addOption`), workstreams, saved views, projects |
38
+ | `db` | `migrate(steps, { tables })` for `plugin_<namespace>_*`; `all`, `get`, `run`, `batch` against a project id or `"hub"` |
39
+ | `settings` | `register({ title, schema, defaults })`, `get`, `set` |
40
+ | `tools` | `register`, `list`, `call`, `gate` |
41
+ | `contributions` | `command`, `badge`, `statusItem`, `section`, `graph` |
42
+ | `agent` | `playbook({ id, title, when, body })` |
43
+ | `surfaces` | `open({ id, document })` — a document inside your package |
44
+ | `on`, `when`, `has`, `effect`, `interval` | events, optional services, cleanup, timers |
45
+
46
+ ## The manifest
47
+
48
+ `tomrade-plugin.json` beside `package.json`:
49
+
50
+ ```json
51
+ {
52
+ "id": "you/my-plugin",
53
+ "version": "0.1.0",
54
+ "title": "My plugin",
55
+ "description": "What it does, in one sentence.",
56
+ "license": "MIT",
57
+ "repository": "https://github.com/you/tomrade-plugin-my-plugin",
58
+ "engines": { "sdk": "^0.2.0" },
59
+ "permissions": { "network": [], "fs": "none", "exec": false }
60
+ }
61
+ ```
62
+
63
+ Declare what your code does beyond the SDK — the hosts it talks to, whether it touches the disk, whether it starts programs. The store's review compares it with the code. Community lists open-source plugins only, built from your public GitHub repository and reviewed before they are listed.
@@ -0,0 +1,341 @@
1
+ import type { z } from "zod";
2
+ import type { Author, Board, CreateItemInput, FieldDef, FieldOption, FieldType, FilterClause, Item, ListItemsFilter, OplogEntity, OplogEntry, OplogOp, Patch, Project, SortKey, View } from "@tomradex/domain";
3
+ /**
4
+ * The plugin contract. Everything a plugin reaches returns a Promise, and every
5
+ * function it hands the host may return one: the same code runs in the app's
6
+ * process today and behind a process boundary later. Values that cross are
7
+ * plain data — never a live object of the host's.
8
+ */
9
+ export type Disposer = () => void;
10
+ /** The services a plugin names in `inject` (required) or `optional`. */
11
+ export type ServiceName = "items" | "fields" | "boards" | "views" | "projects" | "db" | "settings" | "tools" | "contributions" | "agent" | "surfaces" | "oplog";
12
+ export interface Logger {
13
+ debug(...args: unknown[]): void;
14
+ info(...args: unknown[]): void;
15
+ warn(...args: unknown[]): void;
16
+ error(...args: unknown[]): void;
17
+ }
18
+ export interface ItemQuery {
19
+ projectId: string;
20
+ filter?: FilterClause[];
21
+ sortBy?: SortKey[];
22
+ search?: string;
23
+ limit?: number;
24
+ widen?: boolean;
25
+ }
26
+ /** Writes never take an author: the host says who wrote — a person, the agent run it serves, or the plugin itself. */
27
+ export interface ItemsApi {
28
+ list(filter?: ListItemsFilter): Promise<Item[]>;
29
+ query(q: ItemQuery): Promise<Item[]>;
30
+ get(projectId: string, id: string): Promise<Item | null>;
31
+ getByKey(projectId: string, key: string): Promise<Item | null>;
32
+ create(input: Omit<CreateItemInput, "by">): Promise<Item>;
33
+ update(projectId: string, id: string, patch: Patch, opts?: {
34
+ baseVersion?: number;
35
+ }): Promise<Item>;
36
+ delete(projectId: string, id: string): Promise<void>;
37
+ addRelation(projectId: string, id: string, blockedId: string): Promise<void>;
38
+ removeRelation(projectId: string, id: string, blockedId: string): Promise<void>;
39
+ labels(projectId: string): Promise<string[]>;
40
+ }
41
+ export interface FieldsApi {
42
+ list(projectId: string): Promise<FieldDef[]>;
43
+ get(projectId: string, id: string): Promise<FieldDef | null>;
44
+ create(input: {
45
+ projectId: string;
46
+ name: string;
47
+ type: FieldType;
48
+ options?: {
49
+ name: string;
50
+ description?: string | null;
51
+ }[];
52
+ }): Promise<FieldDef>;
53
+ update(projectId: string, id: string, patch: {
54
+ name?: string;
55
+ rank?: number;
56
+ }): Promise<FieldDef>;
57
+ remove(projectId: string, id: string): Promise<void>;
58
+ addOption(projectId: string, fieldId: string, input: {
59
+ name: string;
60
+ description?: string | null;
61
+ }): Promise<FieldOption>;
62
+ }
63
+ export interface BoardsApi {
64
+ list(projectId: string): Promise<Board[]>;
65
+ get(projectId: string, id: string): Promise<Board | null>;
66
+ defaultFor(projectId: string): Promise<Board>;
67
+ }
68
+ export interface ViewsApi {
69
+ list(projectId: string): Promise<View[]>;
70
+ get(projectId: string, id: string): Promise<View | null>;
71
+ }
72
+ export interface ProjectsApi {
73
+ list(): Promise<Project[]>;
74
+ get(id: string): Promise<Project | null>;
75
+ }
76
+ /** `"hub"` addresses the Hub's own database, for tables migrated with `scope: "hub"`. */
77
+ export type DbTarget = string;
78
+ export type SqlParams = unknown[] | Record<string, unknown>;
79
+ export interface TableSpec {
80
+ /** Project-scope tables: the column holding the project id, or a chain through another table. */
81
+ project?: string | {
82
+ via: string;
83
+ table: string;
84
+ };
85
+ /** Exported tables travel in the project's folder; `false` keeps them on this machine. */
86
+ export: {
87
+ order: string;
88
+ appendOnly?: boolean;
89
+ always?: boolean;
90
+ } | false;
91
+ }
92
+ /**
93
+ * Plain SQL against the caches. The namespace is the plugin's own: tables are
94
+ * `plugin_<namespace>_*`. Reads of the app's tables are allowed; writing them
95
+ * goes around history and undo, and review says so.
96
+ */
97
+ export interface DbApi {
98
+ migrate(steps: {
99
+ version: number;
100
+ up: string;
101
+ }[], opts: {
102
+ scope?: "project" | "hub";
103
+ tables: Record<string, TableSpec>;
104
+ }): Promise<void>;
105
+ all<T = Record<string, unknown>>(target: DbTarget, sql: string, params?: SqlParams): Promise<T[]>;
106
+ get<T = Record<string, unknown>>(target: DbTarget, sql: string, params?: SqlParams): Promise<T | undefined>;
107
+ run(target: DbTarget, sql: string, params?: SqlParams): Promise<{
108
+ changes: number;
109
+ lastInsertRowid: number;
110
+ }>;
111
+ /** One transaction: every statement lands, or none does. */
112
+ batch(target: DbTarget, statements: {
113
+ sql: string;
114
+ params?: SqlParams;
115
+ }[]): Promise<{
116
+ changes: number;
117
+ }[]>;
118
+ isOpen(projectId: string): Promise<boolean>;
119
+ }
120
+ export interface SettingsSectionSpec<T> {
121
+ /** Defaults to the namespace; otherwise it must start with it. */
122
+ id?: string;
123
+ title: string;
124
+ description?: string;
125
+ schema: z.ZodType<T>;
126
+ defaults: T;
127
+ scope?: "machine" | "user";
128
+ }
129
+ export interface SettingsApi {
130
+ register<T>(section: SettingsSectionSpec<T>): Promise<void>;
131
+ get<T = unknown>(id?: string): Promise<T>;
132
+ set<T = unknown>(value: T, id?: string): Promise<void>;
133
+ }
134
+ export interface ToolInvocation {
135
+ projectId?: string;
136
+ /** Present when an agent run made the call. */
137
+ runId?: string;
138
+ author: Author;
139
+ }
140
+ export interface ToolSpec<S extends z.ZodObject = z.ZodObject> {
141
+ /** Must start with the plugin's namespace. */
142
+ name: string;
143
+ title: string;
144
+ description: string;
145
+ input: S;
146
+ execute(args: z.output<S>, invocation: ToolInvocation): unknown | Promise<unknown>;
147
+ }
148
+ export interface ToolCallInfo {
149
+ name: string;
150
+ args: unknown;
151
+ author: Author;
152
+ projectId?: string;
153
+ runId?: string;
154
+ }
155
+ export interface ToolsApi {
156
+ register<S extends z.ZodObject>(tool: ToolSpec<S>): Promise<Disposer>;
157
+ list(): Promise<{
158
+ name: string;
159
+ title: string;
160
+ description: string;
161
+ inputSchema: Record<string, unknown>;
162
+ }[]>;
163
+ call(name: string, args: unknown, opts?: {
164
+ projectId?: string;
165
+ }): Promise<unknown>;
166
+ /** A policy over every tool call: throw to refuse it. */
167
+ gate(check: (call: ToolCallInfo) => void | Promise<void>): Promise<Disposer>;
168
+ }
169
+ export type BadgeTone = "faint" | "neutral" | "strong";
170
+ export interface Badge {
171
+ id: string;
172
+ label: string;
173
+ tone?: BadgeTone;
174
+ title?: string;
175
+ }
176
+ export interface CommandScope {
177
+ projectId?: string;
178
+ boardId?: string;
179
+ viewId?: string;
180
+ itemId?: string | null;
181
+ }
182
+ export type SectionState = "live" | "waiting" | "idle" | "ended" | "lost" | "ok" | "warn";
183
+ export interface SectionRow {
184
+ label: string;
185
+ value: string;
186
+ icon?: string;
187
+ mono?: boolean;
188
+ state?: SectionState;
189
+ href?: string;
190
+ command?: string;
191
+ }
192
+ export interface GraphEdge {
193
+ from: string;
194
+ to: string;
195
+ tone?: BadgeTone | "danger";
196
+ title?: string;
197
+ }
198
+ type Maybe<T> = T | Promise<T>;
199
+ /** Ids must equal the namespace or start with it followed by `.`, `-` or `_`. */
200
+ export interface ContributionsApi {
201
+ command(def: {
202
+ id: string;
203
+ title: string;
204
+ group?: string;
205
+ shortcut?: string;
206
+ run(scope: CommandScope): Maybe<{
207
+ toast?: string;
208
+ } | void>;
209
+ }): Promise<Disposer>;
210
+ badge(def: {
211
+ id: string;
212
+ compute(items: Item[], scope: {
213
+ projectId: string;
214
+ }): Maybe<Record<string, Badge[]>>;
215
+ }): Promise<Disposer>;
216
+ statusItem(def: {
217
+ id: string;
218
+ text(scope: {
219
+ projectId?: string;
220
+ }): Maybe<string | null>;
221
+ }): Promise<Disposer>;
222
+ section(def: {
223
+ id: string;
224
+ title: string;
225
+ render(item: Item): Maybe<{
226
+ rows?: SectionRow[];
227
+ text?: string;
228
+ } | null>;
229
+ }): Promise<Disposer>;
230
+ graph(def: {
231
+ id: string;
232
+ title: string;
233
+ icon?: string;
234
+ edits?: "blocks";
235
+ compute(items: Item[], scope: {
236
+ projectId: string;
237
+ }): Maybe<GraphEdge[]>;
238
+ }): Promise<Disposer>;
239
+ }
240
+ export interface PlaybookSpec {
241
+ /** Must start with the namespace. */
242
+ id: string;
243
+ title: string;
244
+ /** One line the agent reads to decide when to open it. */
245
+ when: string;
246
+ body: string;
247
+ tools?: string[];
248
+ }
249
+ export interface AgentApi {
250
+ playbook(spec: PlaybookSpec): Promise<Disposer>;
251
+ }
252
+ export interface SurfaceSpec {
253
+ id: string;
254
+ title: string;
255
+ /** A document inside the plugin's package, relative to its root. Remote pages are refused. */
256
+ document: string;
257
+ width: number;
258
+ height: number;
259
+ transparent?: boolean;
260
+ alwaysOnTop?: boolean;
261
+ clickThrough?: boolean;
262
+ initialState?: unknown;
263
+ /** Messages the document sends; a person is driving, so writes made here are theirs. */
264
+ onMessage?(message: unknown): Maybe<void>;
265
+ }
266
+ export interface SurfaceHandle {
267
+ readonly id: string;
268
+ setState(state: unknown): Promise<void>;
269
+ setPosition(x: number, y: number): Promise<void>;
270
+ bounds(): Promise<{
271
+ x: number;
272
+ y: number;
273
+ width: number;
274
+ height: number;
275
+ }>;
276
+ workArea(): Promise<{
277
+ x: number;
278
+ y: number;
279
+ width: number;
280
+ height: number;
281
+ }>;
282
+ close(): Promise<void>;
283
+ }
284
+ export interface SurfacesApi {
285
+ open(spec: SurfaceSpec): Promise<SurfaceHandle>;
286
+ }
287
+ export interface OplogApi {
288
+ recent(projectId: string, limit?: number): Promise<OplogEntry[]>;
289
+ history(projectId: string, entity: OplogEntity, id: string, limit?: number): Promise<OplogEntry[]>;
290
+ }
291
+ /** What landed, as the host tells every listener after the commit. */
292
+ export interface WriteEvent {
293
+ projectId: string;
294
+ entity: OplogEntity;
295
+ op: OplogOp;
296
+ id: string;
297
+ by: Author;
298
+ via: string | null;
299
+ runId: string | null;
300
+ }
301
+ export interface Events {
302
+ write: (event: WriteEvent) => Maybe<void>;
303
+ "tool.result": (call: ToolCallInfo, outcome: {
304
+ ok: boolean;
305
+ error?: string;
306
+ }) => Maybe<void>;
307
+ "project.opened": (projectId: string) => Maybe<void>;
308
+ "project.closed": (projectId: string) => Maybe<void>;
309
+ "settings.changed": () => Maybe<void>;
310
+ }
311
+ export interface PluginContext {
312
+ /** `publisher/name` for an extension; the row id for a built-in. */
313
+ readonly id: string;
314
+ readonly namespace: string;
315
+ readonly logger: Logger;
316
+ /** A directory only this plugin writes to, kept across updates; null for a built-in. */
317
+ readonly dataDir: string | null;
318
+ readonly items: ItemsApi;
319
+ readonly fields: FieldsApi;
320
+ readonly boards: BoardsApi;
321
+ readonly views: ViewsApi;
322
+ readonly projects: ProjectsApi;
323
+ readonly db: DbApi;
324
+ readonly settings: SettingsApi;
325
+ readonly tools: ToolsApi;
326
+ readonly contributions: ContributionsApi;
327
+ readonly agent: AgentApi;
328
+ readonly surfaces: SurfacesApi;
329
+ readonly oplog: OplogApi;
330
+ on<K extends keyof Events>(event: K, listener: Events[K]): Disposer;
331
+ /** Runs `fn` while an optional service is present; what it returns is disposed when the service goes. */
332
+ when(name: ServiceName, fn: (ctx: PluginContext) => Maybe<Disposer | void>): Disposer;
333
+ /** Whether a service is present right now. */
334
+ has(name: ServiceName): boolean;
335
+ /** Cleanup that runs when the plugin unloads. */
336
+ effect(fn: () => Maybe<Disposer>): void;
337
+ /** A timer cleared with the plugin. */
338
+ interval(fn: () => Maybe<void>, ms: number): Disposer;
339
+ }
340
+ export {};
341
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1,27 @@
1
+ import type { z } from "zod";
2
+ import type { PluginContext, ServiceName, ToolSpec } from "./contract.js";
3
+ /** Shared by every copy of the SDK, so a plugin that bundled one is still recognised. */
4
+ export declare const SDK_PLUGIN: unique symbol;
5
+ export interface PluginSpec<C = undefined> {
6
+ /** Loaded when every one is present; unloaded when one goes. */
7
+ inject?: ServiceName[];
8
+ /** Reached through `ctx.when` / `ctx.has`. */
9
+ optional?: ServiceName[];
10
+ /** Validates the row's config before `apply` runs. */
11
+ config?: z.ZodType<C>;
12
+ apply(ctx: PluginContext, config: C): void | Promise<void>;
13
+ }
14
+ export interface SdkPlugin<C = undefined> extends PluginSpec<C> {
15
+ readonly [SDK_PLUGIN]: 1;
16
+ }
17
+ export declare const definePlugin: <C = undefined>(spec: PluginSpec<C>) => SdkPlugin<C>;
18
+ export declare const isSdkPlugin: (value: unknown) => value is SdkPlugin<unknown>;
19
+ export declare const defineTool: <S extends z.ZodObject>(tool: ToolSpec<S>) => ToolSpec<S>;
20
+ export declare class ToolInputError extends Error {
21
+ name: string;
22
+ }
23
+ /** Tools scope to the caller's project; without one there is nothing safe to default to. */
24
+ export declare function requireProjectId(tool: string, given: string | undefined, invocation: {
25
+ projectId?: string;
26
+ }): string;
27
+ //# sourceMappingURL=define.d.ts.map
package/dist/define.js ADDED
@@ -0,0 +1,16 @@
1
+ /** Shared by every copy of the SDK, so a plugin that bundled one is still recognised. */
2
+ export const SDK_PLUGIN = Symbol.for("tomrade.sdk-plugin");
3
+ export const definePlugin = (spec) => Object.freeze({ ...spec, [SDK_PLUGIN]: 1 });
4
+ export const isSdkPlugin = (value) => typeof value === "object" && value !== null && value[SDK_PLUGIN] === 1 && typeof value.apply === "function";
5
+ export const defineTool = (tool) => tool;
6
+ export class ToolInputError extends Error {
7
+ name = "ToolInputError";
8
+ }
9
+ /** Tools scope to the caller's project; without one there is nothing safe to default to. */
10
+ export function requireProjectId(tool, given, invocation) {
11
+ const id = given ?? invocation.projectId;
12
+ if (!id)
13
+ throw new ToolInputError(`${tool}: projectId is required here — call list_projects and pass one`);
14
+ return id;
15
+ }
16
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1,6 @@
1
+ export * from "./contract.js";
2
+ export { SDK_PLUGIN, ToolInputError, definePlugin, defineTool, isSdkPlugin, requireProjectId, type PluginSpec, type SdkPlugin } from "./define.js";
3
+ export * from "./manifest.js";
4
+ export { compareVersions, isVersion, parseVersion, satisfies } from "./semver.js";
5
+ export type { Author, Board, CreateItemInput, FieldDef, FieldOption, FieldType, FieldValue, FilterClause, Item, ItemKind, ItemStatus, ListItemsFilter, OplogEntity, OplogEntry, OplogOp, Patch, Priority, Project, SortKey, View, WorkType } from "@tomradex/domain";
6
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./contract.js";
2
+ export { SDK_PLUGIN, ToolInputError, definePlugin, defineTool, isSdkPlugin, requireProjectId } from "./define.js";
3
+ export * from "./manifest.js";
4
+ export { compareVersions, isVersion, parseVersion, satisfies } from "./semver.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,134 @@
1
+ import { z } from "zod";
2
+ /** The contract this SDK describes. A plugin's `engines.sdk` range is checked against the host's. */
3
+ export declare const SDK_CONTRACT = "0.2.0";
4
+ export declare const PLUGIN_ID: RegExp;
5
+ export declare const NAMESPACE: RegExp;
6
+ /** The app's own names, and the official publisher's. */
7
+ export declare const RESERVED_NAMESPACES: Set<string>;
8
+ export declare const OFFICIAL_PUBLISHER = "tomrade";
9
+ export declare const PermissionsSchema: z.ZodDefault<z.ZodObject<{
10
+ network: z.ZodDefault<z.ZodArray<z.ZodString>>;
11
+ fs: z.ZodDefault<z.ZodEnum<{
12
+ project: "project";
13
+ plugin: "plugin";
14
+ any: "any";
15
+ none: "none";
16
+ }>>;
17
+ exec: z.ZodDefault<z.ZodBoolean>;
18
+ }, z.core.$strip>>;
19
+ export declare const ContributesSchema: z.ZodObject<{
20
+ tools: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
21
+ commands: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
22
+ badges: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
23
+ statusItems: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
24
+ sections: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
25
+ graphs: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
26
+ playbooks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
27
+ settings: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
28
+ surfaces: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
29
+ tables: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
30
+ }, z.core.$strip>;
31
+ export declare const ManifestSchema: z.ZodObject<{
32
+ id: z.ZodString;
33
+ namespace: z.ZodOptional<z.ZodString>;
34
+ version: z.ZodString;
35
+ title: z.ZodString;
36
+ description: z.ZodDefault<z.ZodString>;
37
+ license: z.ZodString;
38
+ repository: z.ZodOptional<z.ZodURL>;
39
+ homepage: z.ZodOptional<z.ZodURL>;
40
+ author: z.ZodOptional<z.ZodObject<{
41
+ name: z.ZodString;
42
+ url: z.ZodOptional<z.ZodURL>;
43
+ }, z.core.$strip>>;
44
+ engines: z.ZodObject<{
45
+ sdk: z.ZodString;
46
+ }, z.core.$strip>;
47
+ main: z.ZodDefault<z.ZodString>;
48
+ icon: z.ZodOptional<z.ZodString>;
49
+ permissions: z.ZodDefault<z.ZodObject<{
50
+ network: z.ZodDefault<z.ZodArray<z.ZodString>>;
51
+ fs: z.ZodDefault<z.ZodEnum<{
52
+ project: "project";
53
+ plugin: "plugin";
54
+ any: "any";
55
+ none: "none";
56
+ }>>;
57
+ exec: z.ZodDefault<z.ZodBoolean>;
58
+ }, z.core.$strip>>;
59
+ inject: z.ZodDefault<z.ZodArray<z.ZodEnum<{
60
+ items: "items";
61
+ fields: "fields";
62
+ boards: "boards";
63
+ views: "views";
64
+ projects: "projects";
65
+ db: "db";
66
+ settings: "settings";
67
+ tools: "tools";
68
+ contributions: "contributions";
69
+ agent: "agent";
70
+ surfaces: "surfaces";
71
+ oplog: "oplog";
72
+ }>>>;
73
+ optional: z.ZodDefault<z.ZodArray<z.ZodEnum<{
74
+ items: "items";
75
+ fields: "fields";
76
+ boards: "boards";
77
+ views: "views";
78
+ projects: "projects";
79
+ db: "db";
80
+ settings: "settings";
81
+ tools: "tools";
82
+ contributions: "contributions";
83
+ agent: "agent";
84
+ surfaces: "surfaces";
85
+ oplog: "oplog";
86
+ }>>>;
87
+ contributes: z.ZodDefault<z.ZodObject<{
88
+ tools: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
89
+ commands: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
90
+ badges: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
91
+ statusItems: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
92
+ sections: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
93
+ graphs: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
94
+ playbooks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
95
+ settings: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
96
+ surfaces: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
97
+ tables: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
98
+ }, z.core.$strip>>;
99
+ authoredBy: z.ZodDefault<z.ZodEnum<{
100
+ agent: "agent";
101
+ human: "human";
102
+ mixed: "mixed";
103
+ }>>;
104
+ forkOf: z.ZodOptional<z.ZodObject<{
105
+ id: z.ZodString;
106
+ version: z.ZodString;
107
+ }, z.core.$strip>>;
108
+ }, z.core.$strip>;
109
+ export type Manifest = z.output<typeof ManifestSchema>;
110
+ export type ManifestInput = z.input<typeof ManifestSchema>;
111
+ export type Permissions = z.output<typeof PermissionsSchema>;
112
+ export declare const MANIFEST_FILE = "tomrade-plugin.json";
113
+ export declare function parseManifest(raw: unknown): Manifest;
114
+ export declare const publisherOf: (id: string) => string;
115
+ export declare const nameOf: (id: string) => string;
116
+ /** The prefix every id the plugin registers carries, and the name of its tables. */
117
+ export declare const namespaceOf: (manifest: Pick<Manifest, "id" | "namespace">) => string;
118
+ export declare const ownsId: (namespace: string, id: string) => boolean;
119
+ export declare function assertOwned(namespace: string, id: string, kind: string): void;
120
+ export type RiskLevel = "low" | "elevated" | "high";
121
+ export interface Risk {
122
+ level: RiskLevel;
123
+ /** Stable keys the UI words: `exec`, `fs-any`, `network-any`, `network`, `fs-project`, `db`. */
124
+ reasons: string[];
125
+ }
126
+ /**
127
+ * High risk is labelled, not refused: running programs, reading anywhere on
128
+ * disk, or talking to any host. Elevated is what a person should still see.
129
+ */
130
+ export declare function riskOf(manifest: Pick<Manifest, "permissions" | "inject" | "optional">): Risk;
131
+ /** OSI-approved licenses the store accepts without a second look. */
132
+ export declare const OSI_LICENSES: Set<string>;
133
+ export declare const isOpenSource: (license: string) => boolean;
134
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ import { isRange, isVersion } from "./semver.js";
3
+ /** The contract this SDK describes. A plugin's `engines.sdk` range is checked against the host's. */
4
+ export const SDK_CONTRACT = "0.2.0";
5
+ export const PLUGIN_ID = /^[a-z0-9][a-z0-9-]{0,38}\/[a-z0-9][a-z0-9-]{0,63}$/;
6
+ export const NAMESPACE = /^[a-z][a-z0-9_]{1,31}$/;
7
+ /** The app's own names, and the official publisher's. */
8
+ export const RESERVED_NAMESPACES = new Set([
9
+ "agent", "archify", "boards", "code_link", "contributions", "core", "db", "deps", "deps_graph", "fields", "files", "hub", "ipc", "items",
10
+ "llm", "mcp", "oplog", "pet", "plugin", "plugins", "projects", "repos", "settings", "storage", "surfaces", "system", "tomrade", "tools", "views", "write"
11
+ ]);
12
+ export const OFFICIAL_PUBLISHER = "tomrade";
13
+ const SERVICE = z.enum(["items", "fields", "boards", "views", "projects", "db", "settings", "tools", "contributions", "agent", "surfaces", "oplog"]);
14
+ export const PermissionsSchema = z
15
+ .object({
16
+ /** Hosts the plugin talks to; `*` means any. */
17
+ network: z.array(z.string().min(1)).default([]),
18
+ /** `plugin`: its own data directory. `project`: the project folders. `any`: anywhere on disk. */
19
+ fs: z.enum(["none", "plugin", "project", "any"]).default("none"),
20
+ /** Starts other programs. */
21
+ exec: z.boolean().default(false)
22
+ })
23
+ .default({ network: [], fs: "none", exec: false });
24
+ export const ContributesSchema = z
25
+ .object({
26
+ tools: z.array(z.string()).default([]),
27
+ commands: z.array(z.string()).default([]),
28
+ badges: z.array(z.string()).default([]),
29
+ statusItems: z.array(z.string()).default([]),
30
+ sections: z.array(z.string()).default([]),
31
+ graphs: z.array(z.string()).default([]),
32
+ playbooks: z.array(z.string()).default([]),
33
+ settings: z.array(z.string()).default([]),
34
+ surfaces: z.array(z.string()).default([]),
35
+ tables: z.array(z.string()).default([])
36
+ })
37
+ .partial();
38
+ export const ManifestSchema = z.object({
39
+ id: z.string().regex(PLUGIN_ID, "publisher/name, lowercase letters, digits and dashes"),
40
+ namespace: z.string().regex(NAMESPACE, "lowercase letters, digits and underscores, 2–32 long, starting with a letter").optional(),
41
+ version: z.string().refine(isVersion, "a semantic version such as 1.2.0"),
42
+ title: z.string().min(1).max(60),
43
+ description: z.string().max(500).default(""),
44
+ /** An SPDX identifier of an OSI-approved license. */
45
+ license: z.string().min(1),
46
+ repository: z.url().optional(),
47
+ homepage: z.url().optional(),
48
+ author: z.object({ name: z.string().min(1), url: z.url().optional() }).optional(),
49
+ engines: z.object({ sdk: z.string().refine(isRange, "a version range such as ^0.2.0") }),
50
+ main: z.string().default("dist/index.js"),
51
+ icon: z.string().optional(),
52
+ permissions: PermissionsSchema,
53
+ /** Stamped by `tomrade-plugin build` from the exported plugin. */
54
+ inject: z.array(SERVICE).default([]),
55
+ optional: z.array(SERVICE).default([]),
56
+ contributes: ContributesSchema.default({}),
57
+ authoredBy: z.enum(["human", "agent", "mixed"]).default("human"),
58
+ /** A fork names what it came from; the store credits the original. */
59
+ forkOf: z.object({ id: z.string().regex(PLUGIN_ID), version: z.string() }).optional()
60
+ });
61
+ export const MANIFEST_FILE = "tomrade-plugin.json";
62
+ export function parseManifest(raw) {
63
+ const manifest = ManifestSchema.parse(raw);
64
+ const ns = namespaceOf(manifest);
65
+ if (!NAMESPACE.test(ns))
66
+ throw new Error(`${manifest.id}: the name part does not make a valid namespace ("${ns}"); set "namespace" in ${MANIFEST_FILE}`);
67
+ if (RESERVED_NAMESPACES.has(ns) && publisherOf(manifest.id) !== OFFICIAL_PUBLISHER)
68
+ throw new Error(`${manifest.id}: namespace "${ns}" is reserved`);
69
+ return manifest;
70
+ }
71
+ export const publisherOf = (id) => id.split("/")[0];
72
+ export const nameOf = (id) => id.split("/")[1] ?? id;
73
+ /** The prefix every id the plugin registers carries, and the name of its tables. */
74
+ export const namespaceOf = (manifest) => manifest.namespace ?? nameOf(manifest.id).replace(/-/g, "_");
75
+ export const ownsId = (namespace, id) => id === namespace || [".", "-", "_"].some((sep) => id.startsWith(namespace + sep));
76
+ export function assertOwned(namespace, id, kind) {
77
+ if (!ownsId(namespace, id))
78
+ throw new Error(`${kind} "${id}" must be named "${namespace}" or start with "${namespace}." "${namespace}-" or "${namespace}_"`);
79
+ }
80
+ /**
81
+ * High risk is labelled, not refused: running programs, reading anywhere on
82
+ * disk, or talking to any host. Elevated is what a person should still see.
83
+ */
84
+ export function riskOf(manifest) {
85
+ const p = manifest.permissions;
86
+ const high = [p.exec && "exec", p.fs === "any" && "fs-any", p.network.includes("*") && "network-any"].filter(Boolean);
87
+ const elevated = [
88
+ p.network.length && !p.network.includes("*") && "network",
89
+ p.fs === "project" && "fs-project",
90
+ [...manifest.inject, ...manifest.optional].includes("db") && "db"
91
+ ].filter(Boolean);
92
+ return { level: high.length ? "high" : elevated.length ? "elevated" : "low", reasons: [...high, ...elevated] };
93
+ }
94
+ /** OSI-approved licenses the store accepts without a second look. */
95
+ export const OSI_LICENSES = new Set([
96
+ "0BSD", "AGPL-3.0", "AGPL-3.0-only", "AGPL-3.0-or-later", "Apache-2.0", "Artistic-2.0", "BSD-2-Clause", "BSD-3-Clause", "BSL-1.0", "CDDL-1.0", "EPL-1.0", "EPL-2.0",
97
+ "EUPL-1.2", "GPL-2.0", "GPL-2.0-only", "GPL-2.0-or-later", "GPL-3.0", "GPL-3.0-only", "GPL-3.0-or-later", "ISC", "LGPL-2.1", "LGPL-2.1-only", "LGPL-2.1-or-later",
98
+ "LGPL-3.0", "LGPL-3.0-only", "LGPL-3.0-or-later", "MIT", "MIT-0", "MPL-2.0", "MS-PL", "MulanPSL-2.0", "NCSA", "OSL-3.0", "PostgreSQL", "Unlicense", "UPL-1.0", "Zlib"
99
+ ]);
100
+ export const isOpenSource = (license) => license.split(/\s+OR\s+/i).some((l) => OSI_LICENSES.has(l.replace(/[()]/g, "").trim()));
101
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1,9 @@
1
+ type Version = [number, number, number];
2
+ export declare function parseVersion(text: string): Version | null;
3
+ export declare const isVersion: (text: string) => boolean;
4
+ export declare function compareVersions(a: string, b: string): number;
5
+ /** The subset of npm ranges plugins need: `^`, `~`, comparisons, `*`, spaces for AND and `||` for OR. */
6
+ export declare function satisfies(version: string, range: string): boolean;
7
+ export declare const isRange: (range: string) => boolean;
8
+ export {};
9
+ //# sourceMappingURL=semver.d.ts.map
package/dist/semver.js ADDED
@@ -0,0 +1,67 @@
1
+ const VERSION = /^(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
2
+ export function parseVersion(text) {
3
+ const m = VERSION.exec(text.trim());
4
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
5
+ }
6
+ export const isVersion = (text) => parseVersion(text) !== null;
7
+ export function compareVersions(a, b) {
8
+ const x = parseVersion(a);
9
+ const y = parseVersion(b);
10
+ if (!x || !y)
11
+ throw new Error(`not a version: ${!x ? a : b}`);
12
+ for (let i = 0; i < 3; i++)
13
+ if (x[i] !== y[i])
14
+ return x[i] - y[i];
15
+ return 0;
16
+ }
17
+ function comparator(version, token) {
18
+ const cmp = (v) => {
19
+ for (let i = 0; i < 3; i++)
20
+ if (version[i] !== v[i])
21
+ return version[i] - v[i];
22
+ return 0;
23
+ };
24
+ if (token === "*" || token === "x")
25
+ return true;
26
+ const op = /^(\^|~|>=|<=|>|<|=)?(.+)$/.exec(token);
27
+ if (!op)
28
+ return false;
29
+ const base = parseVersion(op[2]);
30
+ if (!base)
31
+ return false;
32
+ switch (op[1]) {
33
+ case "^": {
34
+ if (cmp(base) < 0)
35
+ return false;
36
+ if (base[0] > 0)
37
+ return version[0] === base[0];
38
+ if (base[1] > 0)
39
+ return version[0] === 0 && version[1] === base[1];
40
+ return version[0] === 0 && version[1] === 0 && version[2] === base[2];
41
+ }
42
+ case "~":
43
+ return cmp(base) >= 0 && version[0] === base[0] && version[1] === base[1];
44
+ case ">=":
45
+ return cmp(base) >= 0;
46
+ case "<=":
47
+ return cmp(base) <= 0;
48
+ case ">":
49
+ return cmp(base) > 0;
50
+ case "<":
51
+ return cmp(base) < 0;
52
+ default:
53
+ return cmp(base) === 0;
54
+ }
55
+ }
56
+ /** The subset of npm ranges plugins need: `^`, `~`, comparisons, `*`, spaces for AND and `||` for OR. */
57
+ export function satisfies(version, range) {
58
+ const v = parseVersion(version);
59
+ if (!v)
60
+ return false;
61
+ return range.split("||").some((part) => {
62
+ const tokens = part.trim().split(/\s+/).filter(Boolean);
63
+ return tokens.length > 0 && tokens.every((token) => comparator(v, token));
64
+ });
65
+ }
66
+ export const isRange = (range) => range.split("||").every((part) => part.trim().split(/\s+/).filter(Boolean).every((t) => t === "*" || t === "x" || /^(\^|~|>=|<=|>|<|=)?\d+\.\d+\.\d+/.test(t)));
67
+ //# sourceMappingURL=semver.js.map
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@tomradex/plugin-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.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": "The Tomrade plugin contract: definePlugin, the async PluginContext every extension receives, and the manifest schema",
14
+ "keywords": [
15
+ "tomrade",
16
+ "tomrade-plugin",
17
+ "plugin",
18
+ "sdk"
19
+ ],
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "dependencies": {
32
+ "@tomradex/domain": "0.2.0",
33
+ "zod": "^4.4.3"
34
+ }
35
+ }