@vornrun/connector-sdk 0.6.0-beta.1 → 0.6.0-beta.3
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/dist/{chunk-VBE6WCLN.js → chunk-457KOZUU.js} +29 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -541,6 +541,7 @@ function pollToolName(triggerType) {
|
|
|
541
541
|
return `poll_${triggerType}`;
|
|
542
542
|
}
|
|
543
543
|
var MANIFEST_TOOL = "vorn_connector_manifest";
|
|
544
|
+
var PREFLIGHT_TOOL = "vorn_connector_preflight";
|
|
544
545
|
function connectionSetup(connector, triggerType) {
|
|
545
546
|
const trigger = connector.triggers.find((entry) => entry.type === triggerType);
|
|
546
547
|
if (!trigger) {
|
|
@@ -654,6 +655,33 @@ function createConnectorServer(connector, options = {}) {
|
|
|
654
655
|
},
|
|
655
656
|
() => json(connectorManifest(connector))
|
|
656
657
|
);
|
|
658
|
+
if (connector.preflight) {
|
|
659
|
+
const preflight = connector.preflight.bind(connector);
|
|
660
|
+
server.registerTool(
|
|
661
|
+
PREFLIGHT_TOOL,
|
|
662
|
+
{
|
|
663
|
+
description: `Check whether ${connector.name} can run right now`,
|
|
664
|
+
inputSchema: {},
|
|
665
|
+
// Declared rather than left open like the manifest's: this shape is
|
|
666
|
+
// fixed, so a caller can validate against it. Still loose, because a
|
|
667
|
+
// connector adding a field of its own should not fail the call.
|
|
668
|
+
outputSchema: z.looseObject({
|
|
669
|
+
ok: z.boolean().describe("Whether the connector could run right now"),
|
|
670
|
+
message: z.string().optional().describe("What to do about it, when it could not")
|
|
671
|
+
})
|
|
672
|
+
},
|
|
673
|
+
async () => {
|
|
674
|
+
try {
|
|
675
|
+
return json({ ...await preflight() });
|
|
676
|
+
} catch (error) {
|
|
677
|
+
return json({
|
|
678
|
+
ok: false,
|
|
679
|
+
message: error instanceof Error ? error.message : String(error)
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
);
|
|
684
|
+
}
|
|
657
685
|
for (const trigger of connector.triggers) {
|
|
658
686
|
server.registerTool(
|
|
659
687
|
pollToolName(trigger.type),
|
|
@@ -737,6 +765,7 @@ export {
|
|
|
737
765
|
resolveConfig,
|
|
738
766
|
pollToolName,
|
|
739
767
|
MANIFEST_TOOL,
|
|
768
|
+
PREFLIGHT_TOOL,
|
|
740
769
|
connectionSetup,
|
|
741
770
|
connectorManifest,
|
|
742
771
|
createConnectorServer,
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -218,6 +218,16 @@ interface ConnectorIcon {
|
|
|
218
218
|
/** SVG path `d` data, drawn with `fill="currentColor"` so it inherits color. */
|
|
219
219
|
paths: string[];
|
|
220
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
|
+
}
|
|
221
231
|
interface ConnectorDefinition {
|
|
222
232
|
/** Stable connector id, e.g. `azure-devops`. */
|
|
223
233
|
id: string;
|
|
@@ -228,6 +238,26 @@ interface ConnectorDefinition {
|
|
|
228
238
|
config?: ConnectorConfigField[];
|
|
229
239
|
triggers?: TriggerDefinition[];
|
|
230
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;
|
|
231
261
|
}
|
|
232
262
|
/** A validated definition. Every accessor below is guaranteed non-null. */
|
|
233
263
|
interface Connector extends ConnectorDefinition {
|
|
@@ -351,6 +381,12 @@ declare function runAction(connector: Connector, actionType: string, args: Recor
|
|
|
351
381
|
declare function pollToolName(triggerType: string): string;
|
|
352
382
|
/** Tool that reports the connector's manifest and setup hints. */
|
|
353
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";
|
|
354
390
|
interface ConnectionSetup {
|
|
355
391
|
connectorId: string;
|
|
356
392
|
triggerType: string;
|
|
@@ -455,4 +491,4 @@ interface ConnectorHarness {
|
|
|
455
491
|
*/
|
|
456
492
|
declare function createConnectorHarness(connector: Connector, harnessOptions?: HarnessOptions): ConnectorHarness;
|
|
457
493
|
|
|
458
|
-
export { type ActionContext, type ActionDefinition, type ActionInputField, type CheckFinding, type CheckOptions, type ConnectionSetup, type Connector, type ConnectorConfig, type ConnectorConfigField, type ConnectorDefinition, type ConnectorHarness, type ConnectorIcon, type ConnectorItem, type ConnectorManifest, type ConnectorServerOptions, type DedupeStrategy, type DefaultWorkflow, type FetchContext, type HarnessOptions, MANIFEST_TOOL, MAX_POLL_PAGES, type NormalizedItem, type PollContext, type PollOutcome, type PollPage, type RunActionOptions, type RunPollOptions, type StatusSuggestion, type TriggerDefinition, checkConnector, connectionSetup, connectorManifest, createConnectorHarness, createConnectorServer, defineConnector, drainPoll, envNameFor, formatFindings, normalizeItem, normalizeItems, pollToolName, pollWithDedupe, resolveConfig, runAction, runPoll, serveConnector };
|
|
494
|
+
export { type ActionContext, type ActionDefinition, type ActionInputField, type CheckFinding, type CheckOptions, type ConnectionSetup, type Connector, type ConnectorConfig, type ConnectorConfigField, type ConnectorDefinition, type ConnectorHarness, type ConnectorIcon, type ConnectorItem, type ConnectorManifest, type ConnectorServerOptions, type DedupeStrategy, type DefaultWorkflow, type FetchContext, type HarnessOptions, MANIFEST_TOOL, MAX_POLL_PAGES, type NormalizedItem, PREFLIGHT_TOOL, type PollContext, type PollOutcome, type PollPage, type PreflightResult, type RunActionOptions, type RunPollOptions, type StatusSuggestion, type TriggerDefinition, checkConnector, connectionSetup, connectorManifest, createConnectorHarness, createConnectorServer, defineConnector, drainPoll, envNameFor, formatFindings, normalizeItem, normalizeItems, pollToolName, pollWithDedupe, resolveConfig, runAction, runPoll, serveConnector };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MANIFEST_TOOL,
|
|
3
3
|
MAX_POLL_PAGES,
|
|
4
|
+
PREFLIGHT_TOOL,
|
|
4
5
|
checkConnector,
|
|
5
6
|
connectionSetup,
|
|
6
7
|
connectorManifest,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
runAction,
|
|
18
19
|
runPoll,
|
|
19
20
|
serveConnector
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-457KOZUU.js";
|
|
21
22
|
|
|
22
23
|
// src/harness.ts
|
|
23
24
|
function createConnectorHarness(connector, harnessOptions = {}) {
|
|
@@ -52,6 +53,7 @@ function createConnectorHarness(connector, harnessOptions = {}) {
|
|
|
52
53
|
export {
|
|
53
54
|
MANIFEST_TOOL,
|
|
54
55
|
MAX_POLL_PAGES,
|
|
56
|
+
PREFLIGHT_TOOL,
|
|
55
57
|
checkConnector,
|
|
56
58
|
connectionSetup,
|
|
57
59
|
connectorManifest,
|