@gyoungwe/plugin-api 0.0.0-stage → 1.0.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 +14 -2
- package/dist/index.d.ts +146 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -5
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gyoungwe/plugin-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Stable, host-independent TypeScript contracts for Drone capability plugins.
|
|
4
|
+
The package contains no Electron, backend, Pi SDK, filesystem, or network
|
|
5
|
+
implementation. A host implements `DroneHostPort` and performs the capability
|
|
6
|
+
negotiation before loading a plugin.
|
|
7
|
+
|
|
8
|
+
The package is intentionally published at API major `1` while its npm scope is
|
|
9
|
+
still a project decision. Before publication, the host and `drone-plugins`
|
|
10
|
+
workspace use an `npm pack` tarball or a pinned git commit; they must never use
|
|
11
|
+
a relative path into the Drone source repository.
|
|
12
|
+
|
|
13
|
+
`compatible` and `incompatible` are the only negotiation outcomes in API v1.
|
|
14
|
+
There is no implicit partial or degraded load: a plugin that cannot satisfy its
|
|
15
|
+
declared requirements is refused with an actionable reason.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public host contract for Drone capability plugins.
|
|
3
|
+
*
|
|
4
|
+
* Keep this module dependency-free. It is consumed by native Pi packages and
|
|
5
|
+
* by the Desktop adapter, so it must not import Electron, the Pi SDK, or any
|
|
6
|
+
* Drone implementation package. Runtime values are deliberately limited to
|
|
7
|
+
* the API/contract identifiers and the pure negotiation helper below.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PLUGIN_API_VERSION: 1;
|
|
10
|
+
export declare const RESULT_CONTRACT: "drone-result/v3";
|
|
11
|
+
export type PluginApiVersion = typeof PLUGIN_API_VERSION;
|
|
12
|
+
export type ResultContractVersion = typeof RESULT_CONTRACT;
|
|
13
|
+
export type PluginHost = "native-pi" | "drone-desktop";
|
|
14
|
+
/** Capability identifiers are open-ended so new host features remain additive. */
|
|
15
|
+
export type HostCapability = "readSource" | "searchKnowledge" | "persistRun" | "runCompute" | "requestAuthorization" | (string & {});
|
|
16
|
+
export interface HostCapabilities {
|
|
17
|
+
readonly host: PluginHost;
|
|
18
|
+
readonly hostVersion: string;
|
|
19
|
+
/** Drone Plugin API major implemented by this host. */
|
|
20
|
+
readonly pluginApiVersion: number;
|
|
21
|
+
/** Pi extension API version, kept separate from the Drone contract. */
|
|
22
|
+
readonly piApiVersion?: number;
|
|
23
|
+
readonly capabilities: readonly HostCapability[];
|
|
24
|
+
}
|
|
25
|
+
export interface PluginRequirements {
|
|
26
|
+
readonly pluginApi: number;
|
|
27
|
+
readonly minHostVersion?: string;
|
|
28
|
+
readonly hosts?: readonly PluginHost[];
|
|
29
|
+
readonly capabilities?: readonly HostCapability[];
|
|
30
|
+
}
|
|
31
|
+
/** v1 intentionally has no degraded/partial loading state. */
|
|
32
|
+
export type CapabilityNegotiationStatus = "compatible" | "incompatible";
|
|
33
|
+
export interface CapabilityNegotiation {
|
|
34
|
+
readonly status: CapabilityNegotiationStatus;
|
|
35
|
+
readonly host: PluginHost;
|
|
36
|
+
readonly pluginApi: number;
|
|
37
|
+
readonly missingCapabilities: readonly HostCapability[];
|
|
38
|
+
readonly reason?: "plugin-api" | "host-version" | "host" | "capability";
|
|
39
|
+
readonly message?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compare the numeric components of a host version. Pre-release suffixes are
|
|
43
|
+
* intentionally treated as the same patch for the v1 minimum-version gate;
|
|
44
|
+
* the CI matrix is responsible for testing the exact supported Pi versions.
|
|
45
|
+
*/
|
|
46
|
+
export declare function compareHostVersions(left: string, right: string): number;
|
|
47
|
+
/** Validate a plugin manifest's host requirements without loading its code. */
|
|
48
|
+
export declare function negotiateCapabilities(requirements: PluginRequirements, host: HostCapabilities): CapabilityNegotiation;
|
|
49
|
+
export interface ReadSourceInput {
|
|
50
|
+
readonly sourceRef: string;
|
|
51
|
+
readonly revision?: string;
|
|
52
|
+
readonly locator?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface ReadReceipt {
|
|
55
|
+
readonly sourceRef: string;
|
|
56
|
+
readonly receiptRef: string;
|
|
57
|
+
readonly contentHash: string;
|
|
58
|
+
readonly readAt: string;
|
|
59
|
+
readonly version?: string;
|
|
60
|
+
readonly content: string;
|
|
61
|
+
}
|
|
62
|
+
export interface SearchInput {
|
|
63
|
+
readonly query: string;
|
|
64
|
+
readonly limit?: number;
|
|
65
|
+
readonly scope?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface SearchResultItem {
|
|
68
|
+
readonly sourceRef: string;
|
|
69
|
+
readonly title?: string;
|
|
70
|
+
readonly snippet?: string;
|
|
71
|
+
readonly contentHash?: string;
|
|
72
|
+
readonly receiptRef?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface SearchResult {
|
|
75
|
+
readonly query: string;
|
|
76
|
+
readonly items: readonly SearchResultItem[];
|
|
77
|
+
readonly searchedAt: string;
|
|
78
|
+
}
|
|
79
|
+
export type ResultStatus = "unknown" | "queued" | "running" | "succeeded" | "failed" | "blocked" | "cancelled";
|
|
80
|
+
export type ResultRedlineCode = "missing-source" | "stale-source" | "hash-mismatch" | "authorization-required" | "missing-provenance" | "unknown";
|
|
81
|
+
export interface ResultRedline {
|
|
82
|
+
readonly code: ResultRedlineCode;
|
|
83
|
+
readonly message: string;
|
|
84
|
+
readonly blocking: boolean;
|
|
85
|
+
readonly sourceRefs?: readonly string[];
|
|
86
|
+
}
|
|
87
|
+
export interface RunSnapshot {
|
|
88
|
+
readonly runId: string;
|
|
89
|
+
readonly status: ResultStatus;
|
|
90
|
+
readonly inputRefs: readonly string[];
|
|
91
|
+
readonly outputRefs: readonly string[];
|
|
92
|
+
readonly startedAt?: string;
|
|
93
|
+
readonly finishedAt?: string;
|
|
94
|
+
readonly redlines?: readonly ResultRedline[];
|
|
95
|
+
readonly error?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface RunReceipt {
|
|
98
|
+
readonly contract: ResultContractVersion;
|
|
99
|
+
readonly runId: string;
|
|
100
|
+
readonly status: ResultStatus;
|
|
101
|
+
readonly recordedAt: string;
|
|
102
|
+
readonly outputRefs: readonly string[];
|
|
103
|
+
readonly redlines: readonly ResultRedline[];
|
|
104
|
+
readonly receiptRef: string;
|
|
105
|
+
readonly error?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface ComputeRequest {
|
|
108
|
+
readonly runId: string;
|
|
109
|
+
readonly workflowId: string;
|
|
110
|
+
readonly inputRefs: readonly string[];
|
|
111
|
+
readonly parameters?: Readonly<Record<string, string | number | boolean | null>>;
|
|
112
|
+
readonly authorizationRef?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ComputeReceipt {
|
|
115
|
+
readonly contract: ResultContractVersion;
|
|
116
|
+
readonly runId: string;
|
|
117
|
+
readonly status: ResultStatus;
|
|
118
|
+
readonly receiptRef: string;
|
|
119
|
+
readonly outputRefs: readonly string[];
|
|
120
|
+
readonly redlines: readonly ResultRedline[];
|
|
121
|
+
readonly submittedAt?: string;
|
|
122
|
+
readonly finishedAt?: string;
|
|
123
|
+
readonly error?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface AuthorizationRequest {
|
|
126
|
+
readonly action: string;
|
|
127
|
+
readonly reason?: string;
|
|
128
|
+
readonly scope?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface AuthorizationReceipt {
|
|
131
|
+
readonly granted: boolean;
|
|
132
|
+
readonly authorizationRef?: string;
|
|
133
|
+
readonly decidedAt: string;
|
|
134
|
+
readonly reason?: string;
|
|
135
|
+
}
|
|
136
|
+
/** Stable host seam shared by native Pi and Drone Desktop adapters. */
|
|
137
|
+
export interface DroneHostPort {
|
|
138
|
+
readonly host: PluginHost;
|
|
139
|
+
capabilities(): HostCapabilities;
|
|
140
|
+
readSource(input: ReadSourceInput): Promise<ReadReceipt>;
|
|
141
|
+
searchKnowledge(input: SearchInput): Promise<SearchResult>;
|
|
142
|
+
persistRun(snapshot: RunSnapshot): Promise<RunReceipt>;
|
|
143
|
+
runCompute(input: ComputeRequest): Promise<ComputeReceipt>;
|
|
144
|
+
requestAuthorization(input: AuthorizationRequest): Promise<AuthorizationReceipt>;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,kBAAkB,EAAG,CAAU,CAAC;AAC7C,eAAO,MAAM,eAAe,EAAG,iBAA0B,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,OAAO,kBAAkB,CAAC;AACzD,MAAM,MAAM,qBAAqB,GAAG,OAAO,eAAe,CAAC;AAC3D,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,eAAe,CAAC;AAEvD,kFAAkF;AAClF,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,iBAAiB,GACjB,YAAY,GACZ,YAAY,GACZ,sBAAsB,GACtB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEjB,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,uEAAuE;IACvE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,SAAS,cAAc,EAAE,CAAC;CACjD;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;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ED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public host contract for Drone capability plugins.
|
|
3
|
+
*
|
|
4
|
+
* Keep this module dependency-free. It is consumed by native Pi packages and
|
|
5
|
+
* by the Desktop adapter, so it must not import Electron, the Pi SDK, or any
|
|
6
|
+
* Drone implementation package. Runtime values are deliberately limited to
|
|
7
|
+
* the API/contract identifiers and the pure negotiation helper below.
|
|
8
|
+
*/
|
|
9
|
+
export const PLUGIN_API_VERSION = 1;
|
|
10
|
+
export const RESULT_CONTRACT = "drone-result/v3";
|
|
11
|
+
/**
|
|
12
|
+
* Compare the numeric components of a host version. Pre-release suffixes are
|
|
13
|
+
* intentionally treated as the same patch for the v1 minimum-version gate;
|
|
14
|
+
* the CI matrix is responsible for testing the exact supported Pi versions.
|
|
15
|
+
*/
|
|
16
|
+
export function compareHostVersions(left, right) {
|
|
17
|
+
const parse = (value) => value
|
|
18
|
+
.trim()
|
|
19
|
+
.replace(/^v/i, "")
|
|
20
|
+
.split(".")
|
|
21
|
+
.slice(0, 3)
|
|
22
|
+
.map((part) => {
|
|
23
|
+
const match = part.match(/^\d+/);
|
|
24
|
+
return match ? Number(match[0]) : 0;
|
|
25
|
+
});
|
|
26
|
+
const a = parse(left);
|
|
27
|
+
const b = parse(right);
|
|
28
|
+
for (let i = 0; i < 3; i += 1) {
|
|
29
|
+
const delta = (a[i] ?? 0) - (b[i] ?? 0);
|
|
30
|
+
if (delta !== 0)
|
|
31
|
+
return delta;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
/** Validate a plugin manifest's host requirements without loading its code. */
|
|
36
|
+
export function negotiateCapabilities(requirements, host) {
|
|
37
|
+
if (requirements.pluginApi !== host.pluginApiVersion) {
|
|
38
|
+
return {
|
|
39
|
+
status: "incompatible",
|
|
40
|
+
host: host.host,
|
|
41
|
+
pluginApi: requirements.pluginApi,
|
|
42
|
+
missingCapabilities: [],
|
|
43
|
+
reason: "plugin-api",
|
|
44
|
+
message: `Plugin API ${requirements.pluginApi} requires host API ${requirements.pluginApi}; host provides ${host.pluginApiVersion}.`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (requirements.hosts && !requirements.hosts.includes(host.host)) {
|
|
48
|
+
return {
|
|
49
|
+
status: "incompatible",
|
|
50
|
+
host: host.host,
|
|
51
|
+
pluginApi: requirements.pluginApi,
|
|
52
|
+
missingCapabilities: [],
|
|
53
|
+
reason: "host",
|
|
54
|
+
message: `Plugin does not declare support for ${host.host}.`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (requirements.minHostVersion && compareHostVersions(host.hostVersion, requirements.minHostVersion) < 0) {
|
|
58
|
+
return {
|
|
59
|
+
status: "incompatible",
|
|
60
|
+
host: host.host,
|
|
61
|
+
pluginApi: requirements.pluginApi,
|
|
62
|
+
missingCapabilities: [],
|
|
63
|
+
reason: "host-version",
|
|
64
|
+
message: `Host ${host.hostVersion} is below the required ${requirements.minHostVersion}.`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const available = new Set(host.capabilities);
|
|
68
|
+
const missingCapabilities = (requirements.capabilities ?? []).filter((capability) => !available.has(capability));
|
|
69
|
+
if (missingCapabilities.length) {
|
|
70
|
+
return {
|
|
71
|
+
status: "incompatible",
|
|
72
|
+
host: host.host,
|
|
73
|
+
pluginApi: requirements.pluginApi,
|
|
74
|
+
missingCapabilities,
|
|
75
|
+
reason: "capability",
|
|
76
|
+
message: `Host is missing: ${missingCapabilities.join(", ")}.`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
status: "compatible",
|
|
81
|
+
host: host.host,
|
|
82
|
+
pluginApi: requirements.pluginApi,
|
|
83
|
+
missingCapabilities: [],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":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C;IACF,IAAI,mBAAmB,CAAC,MAAM,EAAE,CAAC;QAChC,OAAO;YACN,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,mBAAmB;YACnB,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,oBAAoB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SAC9D,CAAC;IACH,CAAC;IACD,OAAO;QACN,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,SAAS,EAAE,YAAY,CAAC,SAAS;QACjC,mBAAmB,EAAE,EAAE;KACvB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@gyoungwe/plugin-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Stable host contracts for Drone capability plugins",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Gyoungwe/Drone.git",
|
|
12
|
+
"directory": "packages/plugin-api"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md",
|
|
27
|
+
"package.json"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.build.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"check": "npm run typecheck && npm run build && node ../../scripts/check-plugin-api.mjs --package-only",
|
|
33
|
+
"test": "npm run check && node --test test/index.test.mjs"
|
|
34
|
+
}
|
|
35
|
+
}
|