@vornrun/connector-sdk 0.7.0-beta.8 → 0.7.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/README.md +268 -3
- package/dist/check-62s2GvcO.d.ts +1137 -0
- package/dist/chunk-ZKHXHE3O.js +3511 -0
- package/dist/cli.d.ts +9 -2
- package/dist/cli.js +83 -13
- package/dist/index.d.ts +180 -121
- package/dist/index.js +86 -34
- package/package.json +2 -2
- package/dist/chunk-NXZBUV63.js +0 -922
- package/dist/pack-C3ZJx9d4.d.ts +0 -340
package/dist/pack-C3ZJx9d4.d.ts
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Author-facing types for Vorn connectors.
|
|
3
|
-
*
|
|
4
|
-
* A connector written with this SDK runs as an ordinary MCP stdio server, so
|
|
5
|
-
* it is shared as a normal npm package and installed by pointing a Vorn
|
|
6
|
-
* connection at `npx -y <package>`. Nothing about the host app has to change
|
|
7
|
-
* to accept a new connector.
|
|
8
|
-
*/
|
|
9
|
-
/** A raw item as the author's code returns it. Only id and title are required. */
|
|
10
|
-
interface ConnectorItem {
|
|
11
|
-
/** Stable upstream identity. Vorn dedupes on this, so it must not change. */
|
|
12
|
-
externalId: string | number;
|
|
13
|
-
title: string;
|
|
14
|
-
url?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
/** Raw upstream status (`open`, `Active`, `In Progress`, …). */
|
|
17
|
-
status?: string;
|
|
18
|
-
labels?: string[];
|
|
19
|
-
assignee?: string;
|
|
20
|
-
/**
|
|
21
|
-
* When the item last changed. Vorn advances its poll cursor from this field,
|
|
22
|
-
* so it must be monotonic per item and comparable as an ISO 8601 string.
|
|
23
|
-
* Defaults to poll time when omitted.
|
|
24
|
-
*/
|
|
25
|
-
updatedAt?: string | Date;
|
|
26
|
-
/** Extra fields to expose to workflow templates as `{{trigger.item.<key>}}`. */
|
|
27
|
-
data?: Record<string, unknown>;
|
|
28
|
-
}
|
|
29
|
-
/** A connector item after normalization. This is the exact JSON Vorn sees. */
|
|
30
|
-
interface NormalizedItem extends Record<string, unknown> {
|
|
31
|
-
externalId: string;
|
|
32
|
-
title: string;
|
|
33
|
-
url: string;
|
|
34
|
-
description: string;
|
|
35
|
-
status: string;
|
|
36
|
-
labels: string[];
|
|
37
|
-
updatedAt: string;
|
|
38
|
-
assignee?: string;
|
|
39
|
-
}
|
|
40
|
-
/** Declares a value the connector needs at runtime, read from the environment. */
|
|
41
|
-
interface ConnectorConfigField {
|
|
42
|
-
key: string;
|
|
43
|
-
label: string;
|
|
44
|
-
/** Environment variable the value is read from. Defaults to CONSTANT_CASE(key). */
|
|
45
|
-
env?: string;
|
|
46
|
-
required?: boolean;
|
|
47
|
-
/** Secrets are stored encrypted by Vorn and never printed by the CLI. */
|
|
48
|
-
secret?: boolean;
|
|
49
|
-
description?: string;
|
|
50
|
-
default?: string;
|
|
51
|
-
}
|
|
52
|
-
type ConnectorConfig = Record<string, string | undefined>;
|
|
53
|
-
interface PollContext {
|
|
54
|
-
config: ConnectorConfig;
|
|
55
|
-
/**
|
|
56
|
-
* Lower bound the host asked for, when it was able to supply one. Treat it
|
|
57
|
-
* as a hint: returning older items is safe because Vorn dedupes, but
|
|
58
|
-
* returning fewer than everything after `since` loses events.
|
|
59
|
-
*/
|
|
60
|
-
since?: string;
|
|
61
|
-
/** Opaque cursor previously returned by this trigger, when supplied. */
|
|
62
|
-
cursor?: string;
|
|
63
|
-
/** Upper bound on items to return in one page. */
|
|
64
|
-
limit?: number;
|
|
65
|
-
/** Injectable clock so tests are deterministic. */
|
|
66
|
-
now(): string;
|
|
67
|
-
}
|
|
68
|
-
interface PollOutcome {
|
|
69
|
-
items: ConnectorItem[];
|
|
70
|
-
nextCursor?: string;
|
|
71
|
-
hasMore?: boolean;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* How the SDK decides which fetched items are new.
|
|
75
|
-
*
|
|
76
|
-
* - `timestamp` — for sources that expose a reliable "last changed" field and
|
|
77
|
-
* can filter on it. Handles the boundary case where several items share the
|
|
78
|
-
* newest timestamp, which is the classic source of both duplicates and
|
|
79
|
-
* silently dropped items.
|
|
80
|
-
* - `lastItem` — for feeds that return newest-first with no dependable
|
|
81
|
-
* timestamp. The cursor is the newest id already delivered.
|
|
82
|
-
*/
|
|
83
|
-
type DedupeStrategy = 'timestamp' | 'lastItem';
|
|
84
|
-
/**
|
|
85
|
-
* What a declarative trigger's `fetch` receives. Deliberately smaller than
|
|
86
|
-
* {@link PollContext}: cursor encoding, ordering, windowing and de-duplication
|
|
87
|
-
* are the SDK's job, so the author only has to answer "what is there now?".
|
|
88
|
-
*/
|
|
89
|
-
interface FetchContext {
|
|
90
|
-
config: ConnectorConfig;
|
|
91
|
-
/**
|
|
92
|
-
* With `dedupe: 'timestamp'`, everything changed at or after this instant is
|
|
93
|
-
* worth returning. Absent on the very first poll. Returning a little too
|
|
94
|
-
* much is safe — the SDK drops what was already delivered.
|
|
95
|
-
*/
|
|
96
|
-
since?: string;
|
|
97
|
-
/**
|
|
98
|
-
* With `dedupe: 'lastItem'`, the newest id already delivered. Absent on the
|
|
99
|
-
* very first poll. Return the feed newest-first and the SDK will stop there.
|
|
100
|
-
*/
|
|
101
|
-
lastItemId?: string;
|
|
102
|
-
/** Upper bound on items worth returning in one call. */
|
|
103
|
-
limit?: number;
|
|
104
|
-
/** Injectable clock so tests are deterministic. */
|
|
105
|
-
now(): string;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* What an upstream state should become when an item is imported as a task.
|
|
109
|
-
*
|
|
110
|
-
* A suggestion, not a rule: it seeds the connection form, and the person
|
|
111
|
-
* setting it up can change it. Without any, everything a connector imports
|
|
112
|
-
* lands as `todo` regardless of whether it was closed a year ago.
|
|
113
|
-
*/
|
|
114
|
-
interface StatusSuggestion {
|
|
115
|
-
/** The value the connector reports in `ConnectorItem.status`. */
|
|
116
|
-
upstream: string;
|
|
117
|
-
suggestedLocal: 'todo' | 'in_progress' | 'in_review' | 'done' | 'cancelled';
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* The workflow to create when a connection is made.
|
|
121
|
-
*
|
|
122
|
-
* A connector that fires on a schedule is useless until something polls it, and
|
|
123
|
-
* expecting every person to build that workflow by hand is how a connection
|
|
124
|
-
* ends up configured and silent. Seeded workflows are ordinary, visible and
|
|
125
|
-
* editable — the schedule is a starting point, not a fixed rule.
|
|
126
|
-
*/
|
|
127
|
-
interface DefaultWorkflow {
|
|
128
|
-
name: string;
|
|
129
|
-
defaultCronFromMinutes: number;
|
|
130
|
-
}
|
|
131
|
-
interface TriggerBase {
|
|
132
|
-
/** Event key, e.g. `workItemCreated`. Becomes the `poll_<type>` MCP tool. */
|
|
133
|
-
type: string;
|
|
134
|
-
label: string;
|
|
135
|
-
description?: string;
|
|
136
|
-
/** Seeds the connection's status mapping; the person setting it up owns it. */
|
|
137
|
-
statusMapping?: StatusSuggestion[];
|
|
138
|
-
/** Seeds a polling workflow when a connection is created. */
|
|
139
|
-
defaultWorkflow?: DefaultWorkflow;
|
|
140
|
-
/**
|
|
141
|
-
* Representative items. `vorn-connector check` replays these through the
|
|
142
|
-
* real dedupe pipeline, so a connector can be verified before anyone has
|
|
143
|
-
* credentials for it.
|
|
144
|
-
*/
|
|
145
|
-
sample?: ConnectorItem[];
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* A trigger is either declarative or hand-written, never both — expressed as a
|
|
149
|
-
* union so the invalid combinations are a type error at authoring time rather
|
|
150
|
-
* than a throw when the connector is first loaded.
|
|
151
|
-
*/
|
|
152
|
-
type TriggerDefinition = TriggerBase & ({
|
|
153
|
-
/**
|
|
154
|
-
* Declarative polling: return what the source has and let the SDK
|
|
155
|
-
* handle cursors and de-duplication.
|
|
156
|
-
*/
|
|
157
|
-
dedupe: DedupeStrategy;
|
|
158
|
-
fetch(context: FetchContext): Promise<ConnectorItem[]> | ConnectorItem[];
|
|
159
|
-
poll?: never;
|
|
160
|
-
} | {
|
|
161
|
-
/**
|
|
162
|
-
* Full control over cursors and paging. Use only when the source's
|
|
163
|
-
* paging cannot be expressed as "give me everything since X".
|
|
164
|
-
*/
|
|
165
|
-
poll(context: PollContext): Promise<PollOutcome> | PollOutcome;
|
|
166
|
-
dedupe?: never;
|
|
167
|
-
fetch?: never;
|
|
168
|
-
});
|
|
169
|
-
interface ActionInputField {
|
|
170
|
-
key: string;
|
|
171
|
-
label: string;
|
|
172
|
-
type?: 'string' | 'number' | 'boolean';
|
|
173
|
-
required?: boolean;
|
|
174
|
-
description?: string;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* A field the action is known to return. Declaring these is optional — extra
|
|
178
|
-
* keys always pass through — but declared fields show up in Vorn's variable
|
|
179
|
-
* autocomplete as `{{steps.<action>.<key>}}`.
|
|
180
|
-
*/
|
|
181
|
-
interface ActionOutputField {
|
|
182
|
-
key: string;
|
|
183
|
-
type?: 'string' | 'number' | 'boolean';
|
|
184
|
-
description?: string;
|
|
185
|
-
}
|
|
186
|
-
interface ActionContext {
|
|
187
|
-
config: ConnectorConfig;
|
|
188
|
-
now(): string;
|
|
189
|
-
}
|
|
190
|
-
interface ActionDefinition {
|
|
191
|
-
/** Action key, e.g. `closeWorkItem`. Becomes an MCP tool of the same name. */
|
|
192
|
-
type: string;
|
|
193
|
-
label: string;
|
|
194
|
-
description?: string;
|
|
195
|
-
/**
|
|
196
|
-
* Whether repeating the call with the same arguments is safe. Surfaced in
|
|
197
|
-
* the MCP tool description, because an agent retrying a failed step has no
|
|
198
|
-
* other way to know whether it is about to create a second issue.
|
|
199
|
-
*/
|
|
200
|
-
idempotent?: boolean;
|
|
201
|
-
inputs?: ActionInputField[];
|
|
202
|
-
outputs?: ActionOutputField[];
|
|
203
|
-
run(args: Record<string, unknown>, context: ActionContext): Promise<Record<string, unknown> | void> | Record<string, unknown> | void;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* A connector's own glyph, so an installed connector is recognizable in a list
|
|
207
|
-
* rather than sharing one generic icon with every other one.
|
|
208
|
-
*
|
|
209
|
-
* Path data only — deliberately not markup. Vorn draws these itself as
|
|
210
|
-
* `<path d="...">` inside an `<svg>` it owns, so a connector cannot inject
|
|
211
|
-
* elements, scripts or external references into the app rendering it.
|
|
212
|
-
*/
|
|
213
|
-
interface ConnectorIcon {
|
|
214
|
-
/** Defaults to `0 0 24 24`. */
|
|
215
|
-
viewBox?: string;
|
|
216
|
-
/** SVG path `d` data, drawn with `fill="currentColor"` so it inherits color. */
|
|
217
|
-
paths: string[];
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* What a connector reports about its own readiness.
|
|
221
|
-
*
|
|
222
|
-
* `message` is shown to the user verbatim, so it should say what to do rather
|
|
223
|
-
* than what went wrong — "run `gh auth login`" beats "not authenticated".
|
|
224
|
-
*/
|
|
225
|
-
interface PreflightResult {
|
|
226
|
-
ok: boolean;
|
|
227
|
-
message?: string;
|
|
228
|
-
}
|
|
229
|
-
interface ConnectorDefinition {
|
|
230
|
-
/** Stable connector id, e.g. `azure-devops`. */
|
|
231
|
-
id: string;
|
|
232
|
-
name: string;
|
|
233
|
-
version?: string;
|
|
234
|
-
description?: string;
|
|
235
|
-
icon?: ConnectorIcon;
|
|
236
|
-
config?: ConnectorConfigField[];
|
|
237
|
-
triggers?: TriggerDefinition[];
|
|
238
|
-
actions?: ActionDefinition[];
|
|
239
|
-
/**
|
|
240
|
-
* Whether this connector could work right now, asked before anyone waits on
|
|
241
|
-
* a poll.
|
|
242
|
-
*
|
|
243
|
-
* A connector whose credentials come from config fields does not need this:
|
|
244
|
-
* a missing field is already a visible, nameable error. One that borrows an
|
|
245
|
-
* external tool's login — `gh auth login`, `az login` — has no field to be
|
|
246
|
-
* missing, so without this the first sign that the tool is absent or signed
|
|
247
|
-
* out is a poll failing some minutes after the connection was saved.
|
|
248
|
-
*
|
|
249
|
-
* Answer `ok: false` with a message saying what to do about it. Throwing is
|
|
250
|
-
* equivalent — the server catches it and reports the same shape with the
|
|
251
|
-
* error's message — so there is one result for a caller to read and no
|
|
252
|
-
* behaviour riding on which you choose. Prefer returning when the state is
|
|
253
|
-
* one you recognise, because then you get to write the sentence.
|
|
254
|
-
*
|
|
255
|
-
* Absent means there is nothing to check, which is not the same answer as a
|
|
256
|
-
* check that passed.
|
|
257
|
-
*/
|
|
258
|
-
preflight?(): Promise<PreflightResult> | PreflightResult;
|
|
259
|
-
}
|
|
260
|
-
/** A validated definition. Every accessor below is guaranteed non-null. */
|
|
261
|
-
interface Connector extends ConnectorDefinition {
|
|
262
|
-
readonly version: string;
|
|
263
|
-
readonly config: ConnectorConfigField[];
|
|
264
|
-
readonly triggers: TriggerDefinition[];
|
|
265
|
-
readonly actions: ActionDefinition[];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
interface CheckFinding {
|
|
269
|
-
/** `error` means the connector will misbehave in Vorn; `warn` is advisory. */
|
|
270
|
-
level: 'error' | 'warn';
|
|
271
|
-
code: string;
|
|
272
|
-
/** Which part of the connector the finding is about. */
|
|
273
|
-
target: string;
|
|
274
|
-
message: string;
|
|
275
|
-
}
|
|
276
|
-
interface CheckOptions {
|
|
277
|
-
/**
|
|
278
|
-
* Poll every trigger against the real source. Off by default, so a check
|
|
279
|
-
* runs on declared `sample` items and the definition alone.
|
|
280
|
-
*/
|
|
281
|
-
live?: boolean;
|
|
282
|
-
/** Credentials, required by `live`. */
|
|
283
|
-
config?: ConnectorConfig;
|
|
284
|
-
now?: () => string;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Check a connector against the contract Vorn relies on.
|
|
288
|
-
*
|
|
289
|
-
* The point is a feedback loop: a connector — hand-written or generated — can
|
|
290
|
-
* be verified before it is ever installed, catching the failures that are
|
|
291
|
-
* otherwise invisible until duplicate tasks show up in someone's inbox days
|
|
292
|
-
* later.
|
|
293
|
-
*/
|
|
294
|
-
declare function checkConnector(connector: Connector, options?: CheckOptions): Promise<CheckFinding[]>;
|
|
295
|
-
/** Render findings for a terminal. Returns an empty string when all clear. */
|
|
296
|
-
declare function formatFindings(findings: CheckFinding[]): string;
|
|
297
|
-
|
|
298
|
-
/** Largest pack Vorn will install, matched by the server's own verification. */
|
|
299
|
-
declare const MAX_PACK_BYTES: number;
|
|
300
|
-
interface PackOptions {
|
|
301
|
-
/** Module specifier the connector was loaded from, bundled as the pack entry. */
|
|
302
|
-
entry: string;
|
|
303
|
-
/** Directory the `.vorn.tgz` is written to; defaults to the working directory. */
|
|
304
|
-
outDir?: string;
|
|
305
|
-
/** Directory module specifiers resolve from; defaults to the working directory. */
|
|
306
|
-
resolveDir?: string;
|
|
307
|
-
/** SDK specifier the generated stdio entry imports; overridden in tests. */
|
|
308
|
-
sdkModule?: string;
|
|
309
|
-
/** Size ceiling for the written archive; defaults to `MAX_PACK_BYTES`. */
|
|
310
|
-
maxBytes?: number;
|
|
311
|
-
/** Replaced in tests so packing does not shell out to a bundler. */
|
|
312
|
-
bundle?(request: BundleRequest): Promise<BundleOutput>;
|
|
313
|
-
}
|
|
314
|
-
interface BundleRequest {
|
|
315
|
-
contents: string;
|
|
316
|
-
resolveDir: string;
|
|
317
|
-
}
|
|
318
|
-
interface BundleOutput {
|
|
319
|
-
code: string;
|
|
320
|
-
/** Specifiers the bundler left for the runtime to resolve. */
|
|
321
|
-
external: string[];
|
|
322
|
-
}
|
|
323
|
-
interface PackResult {
|
|
324
|
-
findings: CheckFinding[];
|
|
325
|
-
/** Absolute path of the written pack; absent when a gate failed. */
|
|
326
|
-
file?: string;
|
|
327
|
-
bytes?: number;
|
|
328
|
-
}
|
|
329
|
-
/** Reject a source package whose install would run code on the user's machine. */
|
|
330
|
-
declare function lifecycleScriptFindings(pkg: unknown): CheckFinding[];
|
|
331
|
-
/** Specifiers left outside a bundle, which would need a registry at launch. */
|
|
332
|
-
declare function bundleDependencyFindings(external: string[]): CheckFinding[];
|
|
333
|
-
/** Nearest package.json at or above a directory, or undefined when there is none. */
|
|
334
|
-
declare function readNearestPackageJson(fromDir: string): Record<string, unknown> | undefined;
|
|
335
|
-
/** File name Vorn recognizes as a connector pack. */
|
|
336
|
-
declare function packFileName(connector: Connector): string;
|
|
337
|
-
/** The entry is generated, not the author's bin, so every pack launches alike. */
|
|
338
|
-
declare function packConnector(connector: Connector, options: PackOptions): Promise<PackResult>;
|
|
339
|
-
|
|
340
|
-
export { type ActionContext as A, type BundleRequest as B, type ConnectorDefinition as C, type DefaultWorkflow as D, type FetchContext as F, MAX_PACK_BYTES as M, type NormalizedItem as N, type PollContext as P, type StatusSuggestion as S, type TriggerDefinition as T, type BundleOutput as a, type Connector as b, type ConnectorConfig as c, type PollOutcome as d, type ConnectorItem as e, type ConnectorIcon as f, type ActionDefinition as g, type ActionInputField as h, type CheckFinding as i, type CheckOptions as j, type ConnectorConfigField as k, type DedupeStrategy as l, type PackOptions as m, type PackResult as n, type PreflightResult as o, bundleDependencyFindings as p, checkConnector as q, formatFindings as r, lifecycleScriptFindings as s, packConnector as t, packFileName as u, readNearestPackageJson as v };
|