@vornrun/connector-sdk 0.6.1 → 0.7.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -2
- package/dist/chunk-XOP6JKBX.js +2220 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +89 -9
- package/dist/index.d.ts +103 -418
- package/dist/index.js +58 -34
- package/dist/packaging-DFTuP4fr.d.ts +882 -0
- package/package.json +3 -1
- package/dist/chunk-457KOZUU.js +0 -773
package/dist/index.d.ts
CHANGED
|
@@ -1,272 +1,7 @@
|
|
|
1
|
+
import { C as ConnectorDefinition, b as Connector, c as ConnectorConfig, T as TriggerDefinition, P as PollContext, d as PollOutcome, e as ConnectorItem, N as NormalizedItem, f as PostReceiveOp, A as ActionRequest, B as BundleRequest, a as BundleOutput, g as CheckFinding } from './packaging-DFTuP4fr.js';
|
|
2
|
+
export { h as ActionContext, i as ActionDefinition, j as ActionInputField, k as ActionInputOption, l as ActionInputType, m as ActionOutputField, n as AuthRung, o as CHECK_OWNERS, p as CheckCode, q as CheckOptions, r as ConformanceRun, s as ConnectionSetup, t as ConnectorAuth, u as ConnectorConfigField, v as ConnectorHarness, w as ConnectorIcon, x as ConnectorManifest, y as ConnectorVerification, D as DedupeStrategy, z as DefaultWorkflow, F as FetchContext, H as HarnessOptions, M as MANIFEST_TOOL, E as MAX_PACK_BYTES, G as MAX_POLL_PAGES, I as MockCall, J as MockRoute, K as MockRouteMissError, L as MockRun, O as OPTIONS_TOOL, Q as OptionsContext, R as OptionsLoader, S as PREFLIGHT_TOOL, U as PaginationStrategy, V as PollPage, W as PreflightResult, X as ResilientFetchOptions, Y as RetryPolicy, Z as RunActionOptions, _ as RunPollOptions, $ as StatusSuggestion, a0 as backoffMs, a1 as bundleDependencyFindings, a2 as checkConnector, a3 as connectionSetup, a4 as connectorManifest, a5 as createConnectorHarness, a6 as drainPoll, a7 as esbuildBundle, a8 as escapedMockHttp, a9 as formatFindings, aa as lifecycleScriptFindings, ab as pollToolName, ac as readNearestPackageJson, ad as resilientFetch, ae as retryAfterMs, af as runAction, ag as runConformance, ah as runOptions, ai as runPoll, aj as withMockHttp } from './packaging-DFTuP4fr.js';
|
|
1
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
4
|
|
|
3
|
-
/**
|
|
4
|
-
* Author-facing types for Vorn connectors.
|
|
5
|
-
*
|
|
6
|
-
* A connector written with this SDK runs as an ordinary MCP stdio server, so
|
|
7
|
-
* it is shared as a normal npm package and installed by pointing a Vorn
|
|
8
|
-
* connection at `npx -y <package>`. Nothing about the host app has to change
|
|
9
|
-
* to accept a new connector.
|
|
10
|
-
*/
|
|
11
|
-
/** A raw item as the author's code returns it. Only id and title are required. */
|
|
12
|
-
interface ConnectorItem {
|
|
13
|
-
/** Stable upstream identity. Vorn dedupes on this, so it must not change. */
|
|
14
|
-
externalId: string | number;
|
|
15
|
-
title: string;
|
|
16
|
-
url?: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
/** Raw upstream status (`open`, `Active`, `In Progress`, …). */
|
|
19
|
-
status?: string;
|
|
20
|
-
labels?: string[];
|
|
21
|
-
assignee?: string;
|
|
22
|
-
/**
|
|
23
|
-
* When the item last changed. Vorn advances its poll cursor from this field,
|
|
24
|
-
* so it must be monotonic per item and comparable as an ISO 8601 string.
|
|
25
|
-
* Defaults to poll time when omitted.
|
|
26
|
-
*/
|
|
27
|
-
updatedAt?: string | Date;
|
|
28
|
-
/** Extra fields to expose to workflow templates as `{{trigger.item.<key>}}`. */
|
|
29
|
-
data?: Record<string, unknown>;
|
|
30
|
-
}
|
|
31
|
-
/** A connector item after normalization. This is the exact JSON Vorn sees. */
|
|
32
|
-
interface NormalizedItem extends Record<string, unknown> {
|
|
33
|
-
externalId: string;
|
|
34
|
-
title: string;
|
|
35
|
-
url: string;
|
|
36
|
-
description: string;
|
|
37
|
-
status: string;
|
|
38
|
-
labels: string[];
|
|
39
|
-
updatedAt: string;
|
|
40
|
-
assignee?: string;
|
|
41
|
-
}
|
|
42
|
-
/** Declares a value the connector needs at runtime, read from the environment. */
|
|
43
|
-
interface ConnectorConfigField {
|
|
44
|
-
key: string;
|
|
45
|
-
label: string;
|
|
46
|
-
/** Environment variable the value is read from. Defaults to CONSTANT_CASE(key). */
|
|
47
|
-
env?: string;
|
|
48
|
-
required?: boolean;
|
|
49
|
-
/** Secrets are stored encrypted by Vorn and never printed by the CLI. */
|
|
50
|
-
secret?: boolean;
|
|
51
|
-
description?: string;
|
|
52
|
-
default?: string;
|
|
53
|
-
}
|
|
54
|
-
type ConnectorConfig = Record<string, string | undefined>;
|
|
55
|
-
interface PollContext {
|
|
56
|
-
config: ConnectorConfig;
|
|
57
|
-
/**
|
|
58
|
-
* Lower bound the host asked for, when it was able to supply one. Treat it
|
|
59
|
-
* as a hint: returning older items is safe because Vorn dedupes, but
|
|
60
|
-
* returning fewer than everything after `since` loses events.
|
|
61
|
-
*/
|
|
62
|
-
since?: string;
|
|
63
|
-
/** Opaque cursor previously returned by this trigger, when supplied. */
|
|
64
|
-
cursor?: string;
|
|
65
|
-
/** Upper bound on items to return in one page. */
|
|
66
|
-
limit?: number;
|
|
67
|
-
/** Injectable clock so tests are deterministic. */
|
|
68
|
-
now(): string;
|
|
69
|
-
}
|
|
70
|
-
interface PollOutcome {
|
|
71
|
-
items: ConnectorItem[];
|
|
72
|
-
nextCursor?: string;
|
|
73
|
-
hasMore?: boolean;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* How the SDK decides which fetched items are new.
|
|
77
|
-
*
|
|
78
|
-
* - `timestamp` — for sources that expose a reliable "last changed" field and
|
|
79
|
-
* can filter on it. Handles the boundary case where several items share the
|
|
80
|
-
* newest timestamp, which is the classic source of both duplicates and
|
|
81
|
-
* silently dropped items.
|
|
82
|
-
* - `lastItem` — for feeds that return newest-first with no dependable
|
|
83
|
-
* timestamp. The cursor is the newest id already delivered.
|
|
84
|
-
*/
|
|
85
|
-
type DedupeStrategy = 'timestamp' | 'lastItem';
|
|
86
|
-
/**
|
|
87
|
-
* What a declarative trigger's `fetch` receives. Deliberately smaller than
|
|
88
|
-
* {@link PollContext}: cursor encoding, ordering, windowing and de-duplication
|
|
89
|
-
* are the SDK's job, so the author only has to answer "what is there now?".
|
|
90
|
-
*/
|
|
91
|
-
interface FetchContext {
|
|
92
|
-
config: ConnectorConfig;
|
|
93
|
-
/**
|
|
94
|
-
* With `dedupe: 'timestamp'`, everything changed at or after this instant is
|
|
95
|
-
* worth returning. Absent on the very first poll. Returning a little too
|
|
96
|
-
* much is safe — the SDK drops what was already delivered.
|
|
97
|
-
*/
|
|
98
|
-
since?: string;
|
|
99
|
-
/**
|
|
100
|
-
* With `dedupe: 'lastItem'`, the newest id already delivered. Absent on the
|
|
101
|
-
* very first poll. Return the feed newest-first and the SDK will stop there.
|
|
102
|
-
*/
|
|
103
|
-
lastItemId?: string;
|
|
104
|
-
/** Upper bound on items worth returning in one call. */
|
|
105
|
-
limit?: number;
|
|
106
|
-
/** Injectable clock so tests are deterministic. */
|
|
107
|
-
now(): string;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* What an upstream state should become when an item is imported as a task.
|
|
111
|
-
*
|
|
112
|
-
* A suggestion, not a rule: it seeds the connection form, and the person
|
|
113
|
-
* setting it up can change it. Without any, everything a connector imports
|
|
114
|
-
* lands as `todo` regardless of whether it was closed a year ago.
|
|
115
|
-
*/
|
|
116
|
-
interface StatusSuggestion {
|
|
117
|
-
/** The value the connector reports in `ConnectorItem.status`. */
|
|
118
|
-
upstream: string;
|
|
119
|
-
suggestedLocal: 'todo' | 'in_progress' | 'in_review' | 'done' | 'cancelled';
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* The workflow to create when a connection is made.
|
|
123
|
-
*
|
|
124
|
-
* A connector that fires on a schedule is useless until something polls it, and
|
|
125
|
-
* expecting every person to build that workflow by hand is how a connection
|
|
126
|
-
* ends up configured and silent. Seeded workflows are ordinary, visible and
|
|
127
|
-
* editable — the schedule is a starting point, not a fixed rule.
|
|
128
|
-
*/
|
|
129
|
-
interface DefaultWorkflow {
|
|
130
|
-
name: string;
|
|
131
|
-
defaultCronFromMinutes: number;
|
|
132
|
-
}
|
|
133
|
-
interface TriggerBase {
|
|
134
|
-
/** Event key, e.g. `workItemCreated`. Becomes the `poll_<type>` MCP tool. */
|
|
135
|
-
type: string;
|
|
136
|
-
label: string;
|
|
137
|
-
description?: string;
|
|
138
|
-
/** Seeds the connection's status mapping; the person setting it up owns it. */
|
|
139
|
-
statusMapping?: StatusSuggestion[];
|
|
140
|
-
/** Seeds a polling workflow when a connection is created. */
|
|
141
|
-
defaultWorkflow?: DefaultWorkflow;
|
|
142
|
-
/**
|
|
143
|
-
* Representative items. `vorn-connector check` replays these through the
|
|
144
|
-
* real dedupe pipeline, so a connector can be verified before anyone has
|
|
145
|
-
* credentials for it.
|
|
146
|
-
*/
|
|
147
|
-
sample?: ConnectorItem[];
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* A trigger is either declarative or hand-written, never both — expressed as a
|
|
151
|
-
* union so the invalid combinations are a type error at authoring time rather
|
|
152
|
-
* than a throw when the connector is first loaded.
|
|
153
|
-
*/
|
|
154
|
-
type TriggerDefinition = TriggerBase & ({
|
|
155
|
-
/**
|
|
156
|
-
* Declarative polling: return what the source has and let the SDK
|
|
157
|
-
* handle cursors and de-duplication.
|
|
158
|
-
*/
|
|
159
|
-
dedupe: DedupeStrategy;
|
|
160
|
-
fetch(context: FetchContext): Promise<ConnectorItem[]> | ConnectorItem[];
|
|
161
|
-
poll?: never;
|
|
162
|
-
} | {
|
|
163
|
-
/**
|
|
164
|
-
* Full control over cursors and paging. Use only when the source's
|
|
165
|
-
* paging cannot be expressed as "give me everything since X".
|
|
166
|
-
*/
|
|
167
|
-
poll(context: PollContext): Promise<PollOutcome> | PollOutcome;
|
|
168
|
-
dedupe?: never;
|
|
169
|
-
fetch?: never;
|
|
170
|
-
});
|
|
171
|
-
interface ActionInputField {
|
|
172
|
-
key: string;
|
|
173
|
-
label: string;
|
|
174
|
-
type?: 'string' | 'number' | 'boolean';
|
|
175
|
-
required?: boolean;
|
|
176
|
-
description?: string;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* A field the action is known to return. Declaring these is optional — extra
|
|
180
|
-
* keys always pass through — but declared fields show up in Vorn's variable
|
|
181
|
-
* autocomplete as `{{steps.<action>.<key>}}`.
|
|
182
|
-
*/
|
|
183
|
-
interface ActionOutputField {
|
|
184
|
-
key: string;
|
|
185
|
-
type?: 'string' | 'number' | 'boolean';
|
|
186
|
-
description?: string;
|
|
187
|
-
}
|
|
188
|
-
interface ActionContext {
|
|
189
|
-
config: ConnectorConfig;
|
|
190
|
-
now(): string;
|
|
191
|
-
}
|
|
192
|
-
interface ActionDefinition {
|
|
193
|
-
/** Action key, e.g. `closeWorkItem`. Becomes an MCP tool of the same name. */
|
|
194
|
-
type: string;
|
|
195
|
-
label: string;
|
|
196
|
-
description?: string;
|
|
197
|
-
/**
|
|
198
|
-
* Whether repeating the call with the same arguments is safe. Surfaced in
|
|
199
|
-
* the MCP tool description, because an agent retrying a failed step has no
|
|
200
|
-
* other way to know whether it is about to create a second issue.
|
|
201
|
-
*/
|
|
202
|
-
idempotent?: boolean;
|
|
203
|
-
inputs?: ActionInputField[];
|
|
204
|
-
outputs?: ActionOutputField[];
|
|
205
|
-
run(args: Record<string, unknown>, context: ActionContext): Promise<Record<string, unknown> | void> | Record<string, unknown> | void;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* A connector's own glyph, so an installed connector is recognizable in a list
|
|
209
|
-
* rather than sharing one generic icon with every other one.
|
|
210
|
-
*
|
|
211
|
-
* Path data only — deliberately not markup. Vorn draws these itself as
|
|
212
|
-
* `<path d="...">` inside an `<svg>` it owns, so a connector cannot inject
|
|
213
|
-
* elements, scripts or external references into the app rendering it.
|
|
214
|
-
*/
|
|
215
|
-
interface ConnectorIcon {
|
|
216
|
-
/** Defaults to `0 0 24 24`. */
|
|
217
|
-
viewBox?: string;
|
|
218
|
-
/** SVG path `d` data, drawn with `fill="currentColor"` so it inherits color. */
|
|
219
|
-
paths: string[];
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* What a connector reports about its own readiness.
|
|
223
|
-
*
|
|
224
|
-
* `message` is shown to the user verbatim, so it should say what to do rather
|
|
225
|
-
* than what went wrong — "run `gh auth login`" beats "not authenticated".
|
|
226
|
-
*/
|
|
227
|
-
interface PreflightResult {
|
|
228
|
-
ok: boolean;
|
|
229
|
-
message?: string;
|
|
230
|
-
}
|
|
231
|
-
interface ConnectorDefinition {
|
|
232
|
-
/** Stable connector id, e.g. `azure-devops`. */
|
|
233
|
-
id: string;
|
|
234
|
-
name: string;
|
|
235
|
-
version?: string;
|
|
236
|
-
description?: string;
|
|
237
|
-
icon?: ConnectorIcon;
|
|
238
|
-
config?: ConnectorConfigField[];
|
|
239
|
-
triggers?: TriggerDefinition[];
|
|
240
|
-
actions?: ActionDefinition[];
|
|
241
|
-
/**
|
|
242
|
-
* Whether this connector could work right now, asked before anyone waits on
|
|
243
|
-
* a poll.
|
|
244
|
-
*
|
|
245
|
-
* A connector whose credentials come from config fields does not need this:
|
|
246
|
-
* a missing field is already a visible, nameable error. One that borrows an
|
|
247
|
-
* external tool's login — `gh auth login`, `az login` — has no field to be
|
|
248
|
-
* missing, so without this the first sign that the tool is absent or signed
|
|
249
|
-
* out is a poll failing some minutes after the connection was saved.
|
|
250
|
-
*
|
|
251
|
-
* Answer `ok: false` with a message saying what to do about it. Throwing is
|
|
252
|
-
* equivalent — the server catches it and reports the same shape with the
|
|
253
|
-
* error's message — so there is one result for a caller to read and no
|
|
254
|
-
* behaviour riding on which you choose. Prefer returning when the state is
|
|
255
|
-
* one you recognise, because then you get to write the sentence.
|
|
256
|
-
*
|
|
257
|
-
* Absent means there is nothing to check, which is not the same answer as a
|
|
258
|
-
* check that passed.
|
|
259
|
-
*/
|
|
260
|
-
preflight?(): Promise<PreflightResult> | PreflightResult;
|
|
261
|
-
}
|
|
262
|
-
/** A validated definition. Every accessor below is guaranteed non-null. */
|
|
263
|
-
interface Connector extends ConnectorDefinition {
|
|
264
|
-
readonly version: string;
|
|
265
|
-
readonly config: ConnectorConfigField[];
|
|
266
|
-
readonly triggers: TriggerDefinition[];
|
|
267
|
-
readonly actions: ActionDefinition[];
|
|
268
|
-
}
|
|
269
|
-
|
|
270
5
|
/** Environment variable a config field reads from, e.g. `apiToken` → `API_TOKEN`. */
|
|
271
6
|
declare function envNameFor(key: string, explicit?: string): string;
|
|
272
7
|
/**
|
|
@@ -285,36 +20,6 @@ declare function defineConnector(definition: ConnectorDefinition): Connector;
|
|
|
285
20
|
*/
|
|
286
21
|
declare function resolveConfig(connector: Connector, env?: NodeJS.ProcessEnv): ConnectorConfig;
|
|
287
22
|
|
|
288
|
-
interface CheckFinding {
|
|
289
|
-
/** `error` means the connector will misbehave in Vorn; `warn` is advisory. */
|
|
290
|
-
level: 'error' | 'warn';
|
|
291
|
-
code: string;
|
|
292
|
-
/** Which part of the connector the finding is about. */
|
|
293
|
-
target: string;
|
|
294
|
-
message: string;
|
|
295
|
-
}
|
|
296
|
-
interface CheckOptions {
|
|
297
|
-
/**
|
|
298
|
-
* Poll every trigger against the real source. Off by default, so a check
|
|
299
|
-
* runs on declared `sample` items and the definition alone.
|
|
300
|
-
*/
|
|
301
|
-
live?: boolean;
|
|
302
|
-
/** Credentials, required by `live`. */
|
|
303
|
-
config?: ConnectorConfig;
|
|
304
|
-
now?: () => string;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Check a connector against the contract Vorn relies on.
|
|
308
|
-
*
|
|
309
|
-
* The point is a feedback loop: a connector — hand-written or generated — can
|
|
310
|
-
* be verified before it is ever installed, catching the failures that are
|
|
311
|
-
* otherwise invisible until duplicate tasks show up in someone's inbox days
|
|
312
|
-
* later.
|
|
313
|
-
*/
|
|
314
|
-
declare function checkConnector(connector: Connector, options?: CheckOptions): Promise<CheckFinding[]>;
|
|
315
|
-
/** Render findings for a terminal. Returns an empty string when all clear. */
|
|
316
|
-
declare function formatFindings(findings: CheckFinding[]): string;
|
|
317
|
-
|
|
318
23
|
/**
|
|
319
24
|
* Run a declarative trigger: call the author's `fetch`, then apply the chosen
|
|
320
25
|
* dedupe strategy.
|
|
@@ -341,114 +46,88 @@ declare function normalizeItem(item: ConnectorItem, polledAt: string): Normalize
|
|
|
341
46
|
*/
|
|
342
47
|
declare function normalizeItems(items: ConnectorItem[], polledAt: string): NormalizedItem[];
|
|
343
48
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
interface
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
cursor?: string;
|
|
353
|
-
limit?: number;
|
|
354
|
-
now?: () => string;
|
|
49
|
+
/** The value at a dotted path, or undefined if any step is missing. */
|
|
50
|
+
declare function valueAt(value: unknown, path: string): unknown;
|
|
51
|
+
/** Run a response through the declared ops, left to right. */
|
|
52
|
+
declare function applyPostReceive(value: unknown, ops: PostReceiveOp[] | undefined): unknown;
|
|
53
|
+
|
|
54
|
+
interface RequestScope {
|
|
55
|
+
args: Record<string, unknown>;
|
|
56
|
+
config: ConnectorConfig;
|
|
355
57
|
}
|
|
356
|
-
/** Longest chain of pages `drainPoll` will follow before calling it a bug. */
|
|
357
|
-
declare const MAX_POLL_PAGES = 1000;
|
|
358
58
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
59
|
+
* How a substituted value is written into its surroundings.
|
|
60
|
+
*
|
|
61
|
+
* A value's meaning depends on where it lands: a path segment has to be
|
|
62
|
+
* escaped, a header has characters it may not contain at all. Passing that
|
|
63
|
+
* decision in means the substitution is made safe once, here, instead of by
|
|
64
|
+
* every author who interpolates an argument.
|
|
361
65
|
*/
|
|
362
|
-
|
|
66
|
+
type Substitution = (value: string, source: 'args' | 'config') => string;
|
|
363
67
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
68
|
+
* Resolve `{{args.x}}` and `{{config.y}}` inside a value.
|
|
69
|
+
*
|
|
70
|
+
* A whole-string placeholder keeps the referenced value's own type, so a body
|
|
71
|
+
* can carry a number or an object; a placeholder among other text is rendered
|
|
72
|
+
* into the string. An unset reference resolves to `undefined` on its own and to
|
|
73
|
+
* the empty string when it is part of a larger one, which is what lets an
|
|
74
|
+
* optional argument simply not appear.
|
|
75
|
+
*
|
|
76
|
+
* With a `substitute`, every resolved value passes through it — including a
|
|
77
|
+
* whole-string one, which then arrives as text rather than keeping its type,
|
|
78
|
+
* because a place that needs escaping is a place that holds a string.
|
|
367
79
|
*/
|
|
368
|
-
declare function
|
|
369
|
-
interface
|
|
370
|
-
|
|
371
|
-
|
|
80
|
+
declare function resolveTemplates(value: unknown, scope: RequestScope, substitute?: Substitution): unknown;
|
|
81
|
+
interface ResolvedRequest {
|
|
82
|
+
url: string;
|
|
83
|
+
method: string;
|
|
84
|
+
headers: Record<string, string>;
|
|
85
|
+
body?: string;
|
|
372
86
|
}
|
|
373
|
-
/**
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
*/
|
|
378
|
-
declare function runAction(connector: Connector, actionType: string, args: Record<string, unknown>, options?: RunActionOptions): Promise<Record<string, unknown>>;
|
|
379
|
-
|
|
380
|
-
/** MCP tool name a trigger is served under. */
|
|
381
|
-
declare function pollToolName(triggerType: string): string;
|
|
382
|
-
/** Tool that reports the connector's manifest and setup hints. */
|
|
383
|
-
declare const MANIFEST_TOOL = "vorn_connector_manifest";
|
|
384
|
-
/**
|
|
385
|
-
* Tool that reports whether the connector can run right now. Present only when
|
|
386
|
-
* the connector declares a `preflight`, so its absence means "nothing to
|
|
387
|
-
* check" rather than "check passed".
|
|
388
|
-
*/
|
|
389
|
-
declare const PREFLIGHT_TOOL = "vorn_connector_preflight";
|
|
390
|
-
interface ConnectionSetup {
|
|
391
|
-
connectorId: string;
|
|
392
|
-
triggerType: string;
|
|
393
|
-
/** Values to paste into Vorn's MCP connection form. */
|
|
394
|
-
filters: {
|
|
395
|
-
pollTool: string;
|
|
396
|
-
itemsPath: 'items';
|
|
397
|
-
idField: 'externalId';
|
|
398
|
-
timestampField: 'updatedAt';
|
|
399
|
-
titleField: 'title';
|
|
400
|
-
urlField: 'url';
|
|
401
|
-
cursorArg: 'cursor';
|
|
402
|
-
cursorPath: 'nextCursor';
|
|
403
|
-
};
|
|
404
|
-
/** Environment variable names the connector reads. */
|
|
405
|
-
env: Array<{
|
|
406
|
-
name: string;
|
|
407
|
-
required: boolean;
|
|
408
|
-
secret: boolean;
|
|
409
|
-
description?: string;
|
|
410
|
-
}>;
|
|
87
|
+
/** Build the exact call a declared request makes, with its templates resolved. */
|
|
88
|
+
declare function resolveRequest(request: ActionRequest, scope: RequestScope): ResolvedRequest;
|
|
89
|
+
interface SendOptions {
|
|
90
|
+
fetchImpl: typeof fetch;
|
|
411
91
|
}
|
|
412
92
|
/**
|
|
413
|
-
*
|
|
93
|
+
* The action's result, as Vorn stores it.
|
|
414
94
|
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
*/
|
|
421
|
-
declare
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
declare function connectorManifest(connector: Connector): ConnectorManifest;
|
|
95
|
+
* A step's output is a record, so a response that is a list becomes `items` —
|
|
96
|
+
* the name the rest of this SDK already uses for one — and any other bare
|
|
97
|
+
* value becomes `result`.
|
|
98
|
+
*/
|
|
99
|
+
declare function asOutput(value: unknown): Record<string, unknown>;
|
|
100
|
+
/** Longest chain of pages a declared request will follow before calling it a bug. */
|
|
101
|
+
declare const MAX_REQUEST_PAGES = 100;
|
|
102
|
+
/** The URL of the next page, as a paged HTTP API states it in its `Link` header. */
|
|
103
|
+
declare function nextLink(header: string | null): string | undefined;
|
|
104
|
+
/** Run a declared request end to end: resolve, send, follow its pages, reshape. */
|
|
105
|
+
declare function executeRequest(request: ActionRequest, postReceive: PostReceiveOp[] | undefined, scope: RequestScope, options: SendOptions): Promise<Record<string, unknown>>;
|
|
106
|
+
|
|
107
|
+
interface PackOptions {
|
|
108
|
+
/** Module specifier the connector was loaded from, bundled as the pack entry. */
|
|
109
|
+
entry: string;
|
|
110
|
+
/** Directory the `.vorn.tgz` is written to; defaults to the working directory. */
|
|
111
|
+
outDir?: string;
|
|
112
|
+
/** Directory module specifiers resolve from; defaults to the working directory. */
|
|
113
|
+
resolveDir?: string;
|
|
114
|
+
/** SDK specifier the generated stdio entry imports; overridden in tests. */
|
|
115
|
+
sdkModule?: string;
|
|
116
|
+
/** Size ceiling for the written archive; defaults to `MAX_PACK_BYTES`. */
|
|
117
|
+
maxBytes?: number;
|
|
118
|
+
/** Replaced in tests so packing does not shell out to a bundler. */
|
|
119
|
+
bundle?(request: BundleRequest): Promise<BundleOutput>;
|
|
120
|
+
}
|
|
121
|
+
interface PackResult {
|
|
122
|
+
findings: CheckFinding[];
|
|
123
|
+
/** Absolute path of the written pack; absent when a gate failed. */
|
|
124
|
+
file?: string;
|
|
125
|
+
bytes?: number;
|
|
126
|
+
}
|
|
127
|
+
/** File name Vorn recognizes as a connector pack. */
|
|
128
|
+
declare function packFileName(connector: Connector): string;
|
|
129
|
+
/** The entry is generated, not the author's bin, so every pack launches alike. */
|
|
130
|
+
declare function packConnector(connector: Connector, options: PackOptions): Promise<PackResult>;
|
|
452
131
|
|
|
453
132
|
interface ConnectorServerOptions {
|
|
454
133
|
/** Resolved connector configuration. Defaults to reading `process.env`. */
|
|
@@ -467,28 +146,34 @@ declare function createConnectorServer(connector: Connector, options?: Connector
|
|
|
467
146
|
/** Serve a connector on stdio. This is the one line a connector's bin needs. */
|
|
468
147
|
declare function serveConnector(connector: Connector, options?: ConnectorServerOptions): Promise<void>;
|
|
469
148
|
|
|
470
|
-
interface HarnessOptions {
|
|
471
|
-
config?: ConnectorConfig;
|
|
472
|
-
/** Fixed clock, so `updatedAt` defaults and cursors are deterministic. */
|
|
473
|
-
now?: () => string;
|
|
474
|
-
}
|
|
475
|
-
interface ConnectorHarness {
|
|
476
|
-
poll(triggerType: string, options?: RunPollOptions): Promise<PollPage>;
|
|
477
|
-
drain(triggerType: string, options?: RunPollOptions): Promise<NormalizedItem[]>;
|
|
478
|
-
execute(actionType: string, args?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
479
|
-
manifest(): ConnectorManifest;
|
|
480
|
-
/**
|
|
481
|
-
* Poll repeatedly the way Vorn does — carrying the newest `updatedAt`
|
|
482
|
-
* forward as the watermark — and return only items a real installation
|
|
483
|
-
* would treat as new. Catches the classic connector bug where a poll
|
|
484
|
-
* ignores its lower bound and re-delivers the same backlog forever.
|
|
485
|
-
*/
|
|
486
|
-
pollTwice(triggerType: string, options?: RunPollOptions): Promise<NormalizedItem[]>;
|
|
487
|
-
}
|
|
488
149
|
/**
|
|
489
|
-
*
|
|
490
|
-
*
|
|
150
|
+
* The files a new connector starts as.
|
|
151
|
+
*
|
|
152
|
+
* A connector is mostly boilerplate — a package that builds, an entry that
|
|
153
|
+
* serves, a definition, a test that proves it without a network — and getting
|
|
154
|
+
* that boilerplate right is the slowest part of writing the interesting bit.
|
|
155
|
+
* Generating it means every connector starts from the same shape, which is
|
|
156
|
+
* also the shape `check` and `pack` expect to find.
|
|
157
|
+
*
|
|
158
|
+
* The files are returned rather than written so the decision of what to write
|
|
159
|
+
* stays testable, and the writing stays in the CLI.
|
|
491
160
|
*/
|
|
492
|
-
|
|
161
|
+
interface ScaffoldOptions {
|
|
162
|
+
id: string;
|
|
163
|
+
/** Defaults to the id in title case. */
|
|
164
|
+
name?: string;
|
|
165
|
+
description?: string;
|
|
166
|
+
/** Emit the shape the connectors repository expects of a package inside it. */
|
|
167
|
+
repoConventions?: boolean;
|
|
168
|
+
}
|
|
169
|
+
interface ScaffoldFile {
|
|
170
|
+
/** Relative to the directory the connector is created in. */
|
|
171
|
+
path: string;
|
|
172
|
+
contents: string;
|
|
173
|
+
}
|
|
174
|
+
/** `acme-tickets` → `Acme Tickets`, so a generated name reads like a name. */
|
|
175
|
+
declare function titleCase(id: string): string;
|
|
176
|
+
/** Every file a new connector starts with, ready to build, check and pack. */
|
|
177
|
+
declare function scaffoldFiles(options: ScaffoldOptions): ScaffoldFile[];
|
|
493
178
|
|
|
494
|
-
export {
|
|
179
|
+
export { ActionRequest, BundleOutput, BundleRequest, CheckFinding, Connector, ConnectorConfig, ConnectorDefinition, ConnectorItem, type ConnectorServerOptions, MAX_REQUEST_PAGES, NormalizedItem, type PackOptions, type PackResult, PollContext, PollOutcome, PostReceiveOp, type RequestScope, type ResolvedRequest, type ScaffoldFile, type ScaffoldOptions, type Substitution, TriggerDefinition, applyPostReceive, asOutput, createConnectorServer, defineConnector, envNameFor, executeRequest, nextLink, normalizeItem, normalizeItems, packConnector, packFileName, pollWithDedupe, resolveConfig, resolveRequest, resolveTemplates, scaffoldFiles, serveConnector, titleCase, valueAt };
|