@leitwerk-dev/process-sdk 0.2.0 → 0.2.1
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/browser-ui-extension.d.ts +20 -0
- package/dist/browser-ui-extension.d.ts.map +1 -1
- package/dist/capabilities.d.ts +6 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/{chunk-LIIP7FMU.js → chunk-5R6MVLHC.js} +1 -1
- package/dist/chunk-5R6MVLHC.js.map +1 -0
- package/dist/chunk-DVXW2ZUV.js +1 -0
- package/dist/chunk-DVXW2ZUV.js.map +1 -0
- package/dist/{chunk-TA4KO53Q.js → chunk-I7U6HCLN.js} +1 -7
- package/dist/chunk-I7U6HCLN.js.map +1 -0
- package/dist/{chunk-WFY2WWZE.js → chunk-TM2LTSW4.js} +1 -1
- package/dist/chunk-TM2LTSW4.js.map +1 -0
- package/dist/codecs.d.ts +1 -0
- package/dist/codecs.d.ts.map +1 -1
- package/dist/commit-message.d.ts +5 -0
- package/dist/commit-message.d.ts.map +1 -1
- package/dist/core-capabilities.d.ts +336 -20
- package/dist/core-capabilities.d.ts.map +1 -1
- package/dist/define-process.d.ts +195 -18
- package/dist/define-process.d.ts.map +1 -1
- package/dist/event-bus.d.ts +1 -0
- package/dist/event-bus.d.ts.map +1 -1
- package/dist/{extension-api-CcqZCYJx.d.ts → extension-api-B4gG5w1K.d.ts} +1000 -108
- package/dist/extension-api.d.ts +385 -50
- package/dist/extension-api.d.ts.map +1 -1
- package/dist/external-action-source.d.ts +3 -1
- package/dist/external-action-source.d.ts.map +1 -1
- package/dist/external-source-poll.d.ts +8 -1
- package/dist/external-source-poll.d.ts.map +1 -1
- package/dist/flow.d.ts +308 -11
- package/dist/flow.d.ts.map +1 -1
- package/dist/form-contract.d.ts +1 -1
- package/dist/form-contract.d.ts.map +1 -1
- package/dist/fs-utils.d.ts +4 -0
- package/dist/fs-utils.d.ts.map +1 -1
- package/dist/git-binary.d.ts +2 -1
- package/dist/git-binary.d.ts.map +1 -1
- package/dist/git-binary.js.map +1 -1
- package/dist/graph-fragments.d.ts +16 -0
- package/dist/graph-fragments.d.ts.map +1 -1
- package/dist/host-capabilities.d.ts +9 -3
- package/dist/host-capabilities.d.ts.map +1 -1
- package/dist/index.d.ts +24 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +262 -80
- package/dist/index.js.map +1 -1
- package/dist/integration-http.d.ts +14 -3
- package/dist/integration-http.d.ts.map +1 -1
- package/dist/json-data.d.ts +1 -1
- package/dist/json-data.d.ts.map +1 -1
- package/dist/leaf-outcome-renderer.d.ts +35 -0
- package/dist/leaf-outcome-renderer.d.ts.map +1 -1
- package/dist/leaf-outcome-renderer.js +12 -0
- package/dist/leaf-outcome-renderer.js.map +1 -1
- package/dist/leaf-outcomes.d.ts +3 -0
- package/dist/leaf-outcomes.d.ts.map +1 -1
- package/dist/model-provider.d.ts +144 -12
- package/dist/model-provider.d.ts.map +1 -1
- package/dist/pi-config-public.d.ts +2 -0
- package/dist/pi-config-public.d.ts.map +1 -0
- package/dist/pi-config-public.js +15 -0
- package/dist/pi-config-public.js.map +1 -0
- package/dist/pi-config.d.ts +40 -0
- package/dist/pi-config.d.ts.map +1 -1
- package/dist/pi-config.js +1 -1
- package/dist/process-definition-internals.d.ts +4 -0
- package/dist/process-definition-internals.d.ts.map +1 -1
- package/dist/process-flow-view.d.ts +2 -0
- package/dist/process-flow-view.d.ts.map +1 -1
- package/dist/process-graph.d.ts +34 -0
- package/dist/process-graph.d.ts.map +1 -1
- package/dist/process-launcher-builder.d.ts +5 -0
- package/dist/process-launcher-builder.d.ts.map +1 -1
- package/dist/process-watcher-builder.d.ts +5 -0
- package/dist/process-watcher-builder.d.ts.map +1 -1
- package/dist/process-watcher-source.d.ts +3 -1
- package/dist/process-watcher-source.d.ts.map +1 -1
- package/dist/project-binding.d.ts +5 -1
- package/dist/project-binding.d.ts.map +1 -1
- package/dist/registry-utils.d.ts +6 -0
- package/dist/registry-utils.d.ts.map +1 -1
- package/dist/repository-feedback.d.ts +20 -2
- package/dist/repository-feedback.d.ts.map +1 -1
- package/dist/repository-git-env.d.ts +6 -2
- package/dist/repository-git-env.d.ts.map +1 -1
- package/dist/repository-http.d.ts +13 -1
- package/dist/repository-http.d.ts.map +1 -1
- package/dist/repository-https.d.ts +1 -1
- package/dist/repository-https.d.ts.map +1 -1
- package/dist/repository-issue-watcher.d.ts +21 -1
- package/dist/repository-issue-watcher.d.ts.map +1 -1
- package/dist/repository-reconciliation.d.ts +5 -0
- package/dist/repository-reconciliation.d.ts.map +1 -0
- package/dist/repository-source-config.d.ts +27 -1
- package/dist/repository-source-config.d.ts.map +1 -1
- package/dist/repository-types.d.ts +28 -1
- package/dist/repository-types.d.ts.map +1 -1
- package/dist/review-flow-public.d.ts +2 -0
- package/dist/review-flow-public.d.ts.map +1 -0
- package/dist/review-flow-public.js +11 -0
- package/dist/review-flow-public.js.map +1 -0
- package/dist/review-flow.d.ts +6 -0
- package/dist/review-flow.d.ts.map +1 -1
- package/dist/review-flow.js +1 -1
- package/dist/runtime-internals-public.d.ts +2 -0
- package/dist/runtime-internals-public.d.ts.map +1 -0
- package/dist/runtime-internals-public.js +16 -0
- package/dist/runtime-internals-public.js.map +1 -0
- package/dist/runtime-internals.js +2 -1
- package/dist/server-events.d.ts +67 -0
- package/dist/server-events.d.ts.map +1 -1
- package/dist/server-process-builder.d.ts +7 -0
- package/dist/server-process-builder.d.ts.map +1 -1
- package/dist/state-helpers.d.ts +6 -0
- package/dist/state-helpers.d.ts.map +1 -1
- package/dist/subprocess-env.d.ts +3 -0
- package/dist/subprocess-env.d.ts.map +1 -1
- package/dist/tool-arguments.d.ts +4 -2
- package/dist/tool-arguments.d.ts.map +1 -1
- package/dist/tool-renderers.d.ts +6 -0
- package/dist/tool-renderers.d.ts.map +1 -1
- package/dist/turn-semantics.d.ts +14 -1
- package/dist/turn-semantics.d.ts.map +1 -1
- package/dist/types.d.ts +205 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/ui-process-builder.d.ts +5 -0
- package/dist/ui-process-builder.d.ts.map +1 -1
- package/dist/worker-process-builder.d.ts +5 -0
- package/dist/worker-process-builder.d.ts.map +1 -1
- package/package.json +16 -15
- package/src/browser-ui-extension.ts +20 -0
- package/src/capabilities.ts +9 -1
- package/src/codecs.ts +1 -0
- package/src/commit-message.ts +5 -0
- package/src/core-capabilities.ts +396 -35
- package/src/define-process.ts +198 -23
- package/src/event-bus.ts +1 -0
- package/src/extension-api.ts +399 -55
- package/src/external-action-source.ts +7 -2
- package/src/external-source-poll.ts +15 -3
- package/src/flow.ts +352 -23
- package/src/form-contract.ts +0 -4
- package/src/fs-utils.ts +4 -0
- package/src/git-binary.ts +2 -1
- package/src/graph-fragments.ts +16 -0
- package/src/host-capabilities.ts +9 -6
- package/src/index.ts +5 -201
- package/src/integration-http.ts +15 -3
- package/src/json-data.ts +1 -1
- package/src/leaf-outcome-renderer.ts +35 -0
- package/src/leaf-outcomes.ts +3 -0
- package/src/model-provider.ts +169 -20
- package/src/pi-config-public.ts +7 -0
- package/src/pi-config.ts +47 -2
- package/src/process-definition-internals.ts +4 -0
- package/src/process-flow-view.ts +2 -0
- package/src/process-graph.ts +34 -0
- package/src/process-launcher-builder.ts +5 -0
- package/src/process-watcher-builder.ts +5 -0
- package/src/process-watcher-source.ts +6 -4
- package/src/project-binding.ts +5 -1
- package/src/registry-utils.ts +6 -0
- package/src/repository-feedback.ts +30 -4
- package/src/repository-git-env.ts +6 -2
- package/src/repository-http.ts +19 -2
- package/src/repository-https.ts +1 -1
- package/src/repository-issue-watcher.ts +35 -5
- package/src/repository-reconciliation.ts +30 -0
- package/src/repository-source-config.ts +20 -1
- package/src/repository-types.ts +43 -5
- package/src/review-flow-public.ts +5 -0
- package/src/review-flow.ts +6 -0
- package/src/runtime-internals-public.ts +7 -0
- package/src/server-events.ts +67 -0
- package/src/server-process-builder.ts +10 -1
- package/src/state-helpers.ts +6 -0
- package/src/subprocess-env.ts +3 -0
- package/src/tool-arguments.ts +4 -2
- package/src/tool-renderers.ts +6 -0
- package/src/turn-semantics.ts +15 -2
- package/src/types.ts +212 -30
- package/src/ui-process-builder.ts +8 -1
- package/src/worker-process-builder.ts +8 -1
- package/dist/chunk-LIIP7FMU.js.map +0 -1
- package/dist/chunk-TA4KO53Q.js.map +0 -1
- package/dist/chunk-WFY2WWZE.js.map +0 -1
|
@@ -1,33 +1,53 @@
|
|
|
1
1
|
import escapeHtml from "escape-html";
|
|
2
2
|
|
|
3
|
+
/** @internal */
|
|
3
4
|
export interface LeafOutcomeRendererMeta {
|
|
5
|
+
/** @internal */
|
|
4
6
|
instanceId: string;
|
|
7
|
+
/** @internal */
|
|
5
8
|
snapshotId: string;
|
|
9
|
+
/** @internal */
|
|
6
10
|
leafEntryId: string;
|
|
11
|
+
/** @internal */
|
|
7
12
|
turnRecordId: string | null;
|
|
13
|
+
/** @internal */
|
|
8
14
|
createdAt: string;
|
|
15
|
+
/** @internal */
|
|
9
16
|
schemaVersion: number | null;
|
|
17
|
+
/** @internal */
|
|
10
18
|
lifecycleStatus?: string | null;
|
|
19
|
+
/** @internal */
|
|
11
20
|
selectedTurnId?: string | null;
|
|
21
|
+
/** @internal */
|
|
12
22
|
processUpdatedAt?: string | null;
|
|
13
23
|
}
|
|
14
24
|
|
|
25
|
+
/** @internal */
|
|
15
26
|
export interface LeafOutcomeRendererRuntime {
|
|
27
|
+
/** @internal */
|
|
16
28
|
apiVersion: 1;
|
|
29
|
+
/** @internal */
|
|
17
30
|
markdown: {
|
|
31
|
+
/** @internal */
|
|
18
32
|
render(markdown: string): string;
|
|
19
33
|
};
|
|
34
|
+
/** @internal */
|
|
20
35
|
server: {
|
|
36
|
+
/** @internal */
|
|
21
37
|
resolveUrl(path: string): string;
|
|
38
|
+
/** @internal */
|
|
22
39
|
fetch(path: string, init?: RequestInit): Promise<Response>;
|
|
23
40
|
};
|
|
41
|
+
/** @internal */
|
|
24
42
|
formatRelativeTime(iso: string): string;
|
|
25
43
|
}
|
|
26
44
|
|
|
45
|
+
/** @internal */
|
|
27
46
|
export function escapeLeafOutcomeHtml(value: string): string {
|
|
28
47
|
return escapeHtml(value);
|
|
29
48
|
}
|
|
30
49
|
|
|
50
|
+
/** @internal */
|
|
31
51
|
export function normalizeLeafOutcomeOptionalText(value: unknown): string | null {
|
|
32
52
|
if (typeof value !== "string") {
|
|
33
53
|
return null;
|
|
@@ -36,55 +56,68 @@ export function normalizeLeafOutcomeOptionalText(value: unknown): string | null
|
|
|
36
56
|
return trimmed === "" ? null : trimmed;
|
|
37
57
|
}
|
|
38
58
|
|
|
59
|
+
/** @internal */
|
|
39
60
|
const LeafOutcomeElementBase = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement;
|
|
40
61
|
|
|
62
|
+
/** @internal */
|
|
41
63
|
export abstract class LeafOutcomeCustomElement<TPayload> extends LeafOutcomeElementBase {
|
|
64
|
+
/** @internal */
|
|
42
65
|
protected readonly shadowRootRef: ShadowRoot;
|
|
43
66
|
private payloadValue: TPayload | null = null;
|
|
44
67
|
private runtimeValue: LeafOutcomeRendererRuntime | null = null;
|
|
45
68
|
private metaValue: LeafOutcomeRendererMeta | null = null;
|
|
46
69
|
private signaledReady = false;
|
|
47
70
|
|
|
71
|
+
/** @internal */
|
|
48
72
|
constructor() {
|
|
49
73
|
super();
|
|
50
74
|
this.shadowRootRef = this.attachShadow({ mode: "open" });
|
|
51
75
|
}
|
|
52
76
|
|
|
77
|
+
/** @internal */
|
|
53
78
|
set payload(value: TPayload | null) {
|
|
54
79
|
this.payloadValue = value;
|
|
55
80
|
this.renderContent();
|
|
56
81
|
}
|
|
57
82
|
|
|
83
|
+
/** @internal */
|
|
58
84
|
get payload(): TPayload | null {
|
|
59
85
|
return this.payloadValue;
|
|
60
86
|
}
|
|
61
87
|
|
|
88
|
+
/** @internal */
|
|
62
89
|
set runtime(value: LeafOutcomeRendererRuntime | null) {
|
|
63
90
|
this.runtimeValue = value;
|
|
64
91
|
this.renderContent();
|
|
65
92
|
}
|
|
66
93
|
|
|
94
|
+
/** @internal */
|
|
67
95
|
get runtime(): LeafOutcomeRendererRuntime | null {
|
|
68
96
|
return this.runtimeValue;
|
|
69
97
|
}
|
|
70
98
|
|
|
99
|
+
/** @internal */
|
|
71
100
|
set meta(value: LeafOutcomeRendererMeta | null) {
|
|
72
101
|
this.metaValue = value;
|
|
73
102
|
this.renderContent();
|
|
74
103
|
}
|
|
75
104
|
|
|
105
|
+
/** @internal */
|
|
76
106
|
get meta(): LeafOutcomeRendererMeta | null {
|
|
77
107
|
return this.metaValue;
|
|
78
108
|
}
|
|
79
109
|
|
|
110
|
+
/** @internal */
|
|
80
111
|
connectedCallback(): void {
|
|
81
112
|
this.renderContent();
|
|
82
113
|
}
|
|
83
114
|
|
|
115
|
+
/** @internal */
|
|
84
116
|
protected canRender(): this is this & { runtime: LeafOutcomeRendererRuntime } {
|
|
85
117
|
return this.isConnected && this.runtimeValue !== null;
|
|
86
118
|
}
|
|
87
119
|
|
|
120
|
+
/** @internal */
|
|
88
121
|
protected emitReady(): void {
|
|
89
122
|
if (this.signaledReady) {
|
|
90
123
|
return;
|
|
@@ -98,6 +131,7 @@ export abstract class LeafOutcomeCustomElement<TPayload> extends LeafOutcomeElem
|
|
|
98
131
|
);
|
|
99
132
|
}
|
|
100
133
|
|
|
134
|
+
/** @internal */
|
|
101
135
|
protected emitError(code: string, message: string): void {
|
|
102
136
|
this.dispatchEvent(
|
|
103
137
|
new CustomEvent("o2-leaf-outcome-error", {
|
|
@@ -108,5 +142,6 @@ export abstract class LeafOutcomeCustomElement<TPayload> extends LeafOutcomeElem
|
|
|
108
142
|
);
|
|
109
143
|
}
|
|
110
144
|
|
|
145
|
+
/** @internal */
|
|
111
146
|
protected abstract renderContent(): void;
|
|
112
147
|
}
|
package/src/leaf-outcomes.ts
CHANGED
|
@@ -6,6 +6,7 @@ function isNonEmptyString(value: unknown): value is string {
|
|
|
6
6
|
return typeof value === "string" && value.trim() !== "";
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/** @internal */
|
|
9
10
|
export function validateProcessLeafOutcomeDefinition(def: ProcessLeafOutcomeDefinition): string[] {
|
|
10
11
|
const errors: string[] = [];
|
|
11
12
|
if (!isNonEmptyString(def.rendererId)) {
|
|
@@ -17,6 +18,7 @@ export function validateProcessLeafOutcomeDefinition(def: ProcessLeafOutcomeDefi
|
|
|
17
18
|
return errors;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
/** @internal */
|
|
20
22
|
export function validateLeafOutcomeCaptureResult(
|
|
21
23
|
result: unknown,
|
|
22
24
|
expectedRendererId?: string,
|
|
@@ -54,6 +56,7 @@ export function validateLeafOutcomeCaptureResult(
|
|
|
54
56
|
return errors;
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/** @internal */
|
|
57
60
|
export function normalizeLeafOutcomeCaptureResult(
|
|
58
61
|
result: LeafOutcomeCaptureResult,
|
|
59
62
|
): LeafOutcomeCaptureResult {
|
package/src/model-provider.ts
CHANGED
|
@@ -1,67 +1,106 @@
|
|
|
1
|
-
/** JSON values that may cross the server/worker bootstrap boundary. */
|
|
1
|
+
/** JSON values that may cross the server/worker bootstrap boundary. @public */
|
|
2
2
|
export type ProviderJsonPrimitive = string | number | boolean | null;
|
|
3
|
+
/** @public */
|
|
3
4
|
export type ProviderJsonValue =
|
|
4
5
|
| ProviderJsonPrimitive
|
|
5
6
|
| ProviderJsonValue[]
|
|
6
|
-
| {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
| {
|
|
8
|
+
/** @internal */
|
|
9
|
+
[key: string]: ProviderJsonValue;
|
|
10
|
+
};
|
|
11
|
+
/** @public */
|
|
12
|
+
export type ProviderJsonObject = {
|
|
13
|
+
/** @internal */
|
|
14
|
+
[key: string]: ProviderJsonValue;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
9
18
|
export interface ConfiguredProviderModel {
|
|
19
|
+
/** @public */
|
|
10
20
|
readonly profileId: string;
|
|
21
|
+
/** @public */
|
|
11
22
|
readonly modelId: string;
|
|
12
23
|
}
|
|
13
24
|
|
|
25
|
+
/** @public */
|
|
14
26
|
export type ProviderAvailability = "available" | "unavailable" | "stale";
|
|
15
27
|
|
|
28
|
+
/** @public */
|
|
16
29
|
export interface ProviderModelStatus {
|
|
30
|
+
/** @public */
|
|
17
31
|
readonly modelId: string;
|
|
32
|
+
/** @public */
|
|
18
33
|
readonly availability: ProviderAvailability;
|
|
19
|
-
/** Safe operator-facing reason. It must not contain credential material. */
|
|
34
|
+
/** Safe operator-facing reason. It must not contain credential material. @internal */
|
|
20
35
|
readonly safeReason?: string;
|
|
21
36
|
}
|
|
22
37
|
|
|
38
|
+
/** @public */
|
|
23
39
|
export interface ProviderCredentialStatus {
|
|
40
|
+
/** @public */
|
|
24
41
|
readonly available: boolean;
|
|
42
|
+
/** @public */
|
|
25
43
|
readonly revision: number | null;
|
|
26
44
|
}
|
|
27
45
|
|
|
46
|
+
/** @public */
|
|
28
47
|
export interface ModelProviderModelsContext<TConfig = unknown> {
|
|
48
|
+
/** @internal */
|
|
29
49
|
readonly config: TConfig;
|
|
50
|
+
/** @public */
|
|
30
51
|
readonly configuredModels: readonly ConfiguredProviderModel[];
|
|
52
|
+
/** @public */
|
|
31
53
|
readonly credentialStatus: ProviderCredentialStatus;
|
|
32
54
|
}
|
|
33
55
|
|
|
56
|
+
/** @public */
|
|
34
57
|
export interface ProviderOptionChoice {
|
|
58
|
+
/** @internal */
|
|
35
59
|
readonly value: string;
|
|
60
|
+
/** @internal */
|
|
36
61
|
readonly label: string;
|
|
37
62
|
}
|
|
38
63
|
|
|
64
|
+
/** @public */
|
|
39
65
|
export interface ProviderOptionChoicesContext<TConfig = unknown> {
|
|
66
|
+
/** @internal */
|
|
40
67
|
readonly config: TConfig;
|
|
68
|
+
/** @internal */
|
|
41
69
|
readonly credentialStatus: ProviderCredentialStatus;
|
|
42
70
|
}
|
|
43
71
|
|
|
72
|
+
/** @internal */
|
|
44
73
|
export interface ProviderOptionDefaultContext<TConfig = unknown> {
|
|
74
|
+
/** @internal */
|
|
45
75
|
readonly config: TConfig;
|
|
46
76
|
}
|
|
47
77
|
|
|
78
|
+
/** @public */
|
|
48
79
|
export interface ProviderOptionField<TConfig = unknown> {
|
|
80
|
+
/** @public */
|
|
49
81
|
readonly label: string;
|
|
82
|
+
/** @public */
|
|
50
83
|
readonly required?: boolean;
|
|
84
|
+
/** @internal */
|
|
51
85
|
readonly minLength?: number;
|
|
86
|
+
/** @public */
|
|
52
87
|
readonly maxLength?: number;
|
|
53
88
|
/**
|
|
54
89
|
* Explicit provider default. Dynamic choices are advisory and are never used
|
|
55
90
|
* as an implicit default.
|
|
56
91
|
*/
|
|
92
|
+
/** @internal */
|
|
57
93
|
readonly defaultValue?:
|
|
58
94
|
| string
|
|
59
95
|
| null
|
|
60
96
|
| ((ctx: ProviderOptionDefaultContext<TConfig>) => string | null | undefined);
|
|
61
97
|
}
|
|
62
98
|
|
|
99
|
+
/** @public */
|
|
63
100
|
export interface ProviderOptionsDefinition<TConfig = unknown> {
|
|
101
|
+
/** @public */
|
|
64
102
|
readonly fields: Readonly<Record<string, ProviderOptionField<TConfig>>>;
|
|
103
|
+
/** @public */
|
|
65
104
|
choices?(
|
|
66
105
|
ctx: ProviderOptionChoicesContext<TConfig>,
|
|
67
106
|
):
|
|
@@ -69,6 +108,7 @@ export interface ProviderOptionsDefinition<TConfig = unknown> {
|
|
|
69
108
|
| Promise<Readonly<Record<string, readonly ProviderOptionChoice[]>>>;
|
|
70
109
|
}
|
|
71
110
|
|
|
111
|
+
/** @public */
|
|
72
112
|
export function defineProviderOptions<TConfig = unknown>(
|
|
73
113
|
definition: ProviderOptionsDefinition<TConfig>,
|
|
74
114
|
): ProviderOptionsDefinition<TConfig> {
|
|
@@ -93,22 +133,42 @@ export function defineProviderOptions<TConfig = unknown>(
|
|
|
93
133
|
return { ...definition, fields: { ...definition.fields } };
|
|
94
134
|
}
|
|
95
135
|
|
|
136
|
+
/** @internal */
|
|
96
137
|
export interface ProviderOptionsResolutionInput<TConfig = unknown> {
|
|
138
|
+
/** @internal */
|
|
97
139
|
readonly definition: ProviderOptionsDefinition<TConfig> | null | undefined;
|
|
140
|
+
/** @internal */
|
|
98
141
|
readonly config: TConfig;
|
|
142
|
+
/** @internal */
|
|
99
143
|
readonly explicit?: Readonly<Record<string, unknown>> | null;
|
|
144
|
+
/** @internal */
|
|
100
145
|
readonly profileDefaults?: Readonly<Record<string, unknown>> | null;
|
|
101
146
|
}
|
|
102
147
|
|
|
148
|
+
/** @internal */
|
|
103
149
|
export interface ProviderOptionValidationIssue {
|
|
150
|
+
/** @internal */
|
|
104
151
|
readonly fieldId: string;
|
|
152
|
+
/** @internal */
|
|
105
153
|
readonly code: "unknown" | "not_string" | "too_short" | "too_long" | "required";
|
|
154
|
+
/** @internal */
|
|
106
155
|
readonly message: string;
|
|
107
156
|
}
|
|
108
157
|
|
|
158
|
+
/** @internal */
|
|
109
159
|
export type ProviderOptionsResolution =
|
|
110
|
-
| {
|
|
111
|
-
|
|
160
|
+
| {
|
|
161
|
+
/** @internal */
|
|
162
|
+
readonly ok: true;
|
|
163
|
+
/** @internal */
|
|
164
|
+
readonly value: Readonly<Record<string, string>>;
|
|
165
|
+
}
|
|
166
|
+
| {
|
|
167
|
+
/** @internal */
|
|
168
|
+
readonly ok: false;
|
|
169
|
+
/** @internal */
|
|
170
|
+
readonly issues: readonly ProviderOptionValidationIssue[];
|
|
171
|
+
};
|
|
112
172
|
|
|
113
173
|
function validateOptionValue<TConfig>(
|
|
114
174
|
fieldId: string,
|
|
@@ -143,6 +203,7 @@ function validateOptionValue<TConfig>(
|
|
|
143
203
|
* Resolve explicit values, profile defaults, then declared provider defaults.
|
|
144
204
|
* Dynamic choices deliberately do not participate in validation or fallback.
|
|
145
205
|
*/
|
|
206
|
+
/** @internal */
|
|
146
207
|
export function resolveProviderOptions<TConfig = unknown>(
|
|
147
208
|
input: ProviderOptionsResolutionInput<TConfig>,
|
|
148
209
|
): ProviderOptionsResolution {
|
|
@@ -192,7 +253,7 @@ export function resolveProviderOptions<TConfig = unknown>(
|
|
|
192
253
|
return issues.length > 0 ? { ok: false, issues } : { ok: true, value: resolved };
|
|
193
254
|
}
|
|
194
255
|
|
|
195
|
-
/** Keep only fields declared by a newly selected provider. */
|
|
256
|
+
/** Keep only fields declared by a newly selected provider. @internal */
|
|
196
257
|
export function filterProviderOptionsForDefinition<TConfig = unknown>(
|
|
197
258
|
definition: ProviderOptionsDefinition<TConfig> | null | undefined,
|
|
198
259
|
values: Readonly<Record<string, string>>,
|
|
@@ -205,24 +266,34 @@ export function filterProviderOptionsForDefinition<TConfig = unknown>(
|
|
|
205
266
|
* Runtime-independent schema boundary for non-secret provider worker config.
|
|
206
267
|
* Adapters may wrap Valibot, TypeBox, Zod, or another validator behind parse.
|
|
207
268
|
*/
|
|
269
|
+
/** @public */
|
|
208
270
|
export interface ProviderWorkerConfigSchema<TValue extends ProviderJsonObject> {
|
|
271
|
+
/** @public */
|
|
209
272
|
parse(value: unknown): TValue;
|
|
210
273
|
}
|
|
211
274
|
|
|
275
|
+
/** @public */
|
|
212
276
|
export interface ProviderWorkerConfigContext<TConfig = unknown> {
|
|
277
|
+
/** @public */
|
|
213
278
|
readonly config: TConfig;
|
|
279
|
+
/** @internal */
|
|
214
280
|
readonly options: Readonly<Record<string, string>>;
|
|
215
281
|
}
|
|
216
282
|
|
|
283
|
+
/** @public */
|
|
217
284
|
export interface ProviderWorkerConfigDefinition<
|
|
218
285
|
TConfig = unknown,
|
|
219
286
|
TValue extends ProviderJsonObject = ProviderJsonObject,
|
|
220
287
|
> {
|
|
288
|
+
/** @public */
|
|
221
289
|
readonly version: number;
|
|
290
|
+
/** @public */
|
|
222
291
|
readonly schema: ProviderWorkerConfigSchema<TValue>;
|
|
292
|
+
/** @public */
|
|
223
293
|
resolve(ctx: ProviderWorkerConfigContext<TConfig>): TValue;
|
|
224
294
|
}
|
|
225
295
|
|
|
296
|
+
/** @public */
|
|
226
297
|
export function defineWorkerConfig<
|
|
227
298
|
TConfig = unknown,
|
|
228
299
|
TValue extends ProviderJsonObject = ProviderJsonObject,
|
|
@@ -235,42 +306,63 @@ export function defineWorkerConfig<
|
|
|
235
306
|
return definition;
|
|
236
307
|
}
|
|
237
308
|
|
|
309
|
+
/** @public */
|
|
238
310
|
export interface PiWorkerReference<
|
|
239
311
|
TConfig = unknown,
|
|
240
312
|
TValue extends ProviderJsonObject = ProviderJsonObject,
|
|
241
313
|
> {
|
|
314
|
+
/** @public */
|
|
242
315
|
readonly kind: "extension_pi_worker";
|
|
316
|
+
/** @internal */
|
|
243
317
|
readonly config?: ProviderWorkerConfigDefinition<TConfig, TValue>;
|
|
244
|
-
/** Mutable, flat JSON credential files required by this provider's Pi extension. */
|
|
318
|
+
/** Mutable, flat JSON credential files required by this provider's Pi extension. @internal */
|
|
245
319
|
readonly credentialFiles?: readonly string[];
|
|
246
320
|
}
|
|
247
321
|
|
|
322
|
+
/** @public */
|
|
248
323
|
export interface PiServerReference {
|
|
324
|
+
/** @internal */
|
|
249
325
|
readonly kind: "extension_pi_server";
|
|
250
326
|
}
|
|
251
327
|
|
|
328
|
+
/** @public */
|
|
252
329
|
export interface PiServerGenerateTextInput<TConfig = unknown> {
|
|
330
|
+
/** @public */
|
|
253
331
|
readonly providerId: string;
|
|
332
|
+
/** @public */
|
|
254
333
|
readonly modelId: string;
|
|
334
|
+
/** @public */
|
|
255
335
|
readonly thinkingLevel: string;
|
|
336
|
+
/** @public */
|
|
256
337
|
readonly prompt: string;
|
|
338
|
+
/** @public */
|
|
257
339
|
readonly systemPrompt: string;
|
|
340
|
+
/** @public */
|
|
258
341
|
readonly maxTokens: number;
|
|
342
|
+
/** @public */
|
|
259
343
|
readonly config: TConfig;
|
|
344
|
+
/** @public */
|
|
260
345
|
readonly options: Readonly<Record<string, string>>;
|
|
346
|
+
/** @public */
|
|
261
347
|
readonly secrets: Readonly<Record<string, string>>;
|
|
348
|
+
/** @public */
|
|
262
349
|
readonly request: {
|
|
350
|
+
/** @public */
|
|
263
351
|
readonly timeoutMs?: number;
|
|
352
|
+
/** @internal */
|
|
264
353
|
readonly maxRetries?: number;
|
|
354
|
+
/** @public */
|
|
265
355
|
readonly maxRetryDelayMs: number;
|
|
266
356
|
};
|
|
267
357
|
}
|
|
268
358
|
|
|
269
|
-
/** Server-only provider boundary for title generation and future cheap LLM consumers. */
|
|
359
|
+
/** Server-only provider boundary for title generation and future cheap LLM consumers. @public */
|
|
270
360
|
export interface PiServerAdapter<TConfig = unknown> {
|
|
361
|
+
/** @public */
|
|
271
362
|
generateText(input: PiServerGenerateTextInput<TConfig>): Promise<string>;
|
|
272
363
|
}
|
|
273
364
|
|
|
365
|
+
/** @public */
|
|
274
366
|
export function definePiServerAdapter<TConfig = unknown>(
|
|
275
367
|
adapter: PiServerAdapter<TConfig>,
|
|
276
368
|
): PiServerAdapter<TConfig> {
|
|
@@ -280,21 +372,33 @@ export function definePiServerAdapter<TConfig = unknown>(
|
|
|
280
372
|
return adapter;
|
|
281
373
|
}
|
|
282
374
|
|
|
375
|
+
/** @public */
|
|
283
376
|
export interface BuiltinPiProviderReference {
|
|
377
|
+
/** @public */
|
|
284
378
|
readonly kind: "builtin_pi_provider";
|
|
379
|
+
/** @internal */
|
|
285
380
|
readonly providerId: string;
|
|
286
381
|
}
|
|
287
382
|
|
|
383
|
+
/** @public */
|
|
288
384
|
export interface ConfiguredPiProviderReference<TConfig = unknown> {
|
|
385
|
+
/** @public */
|
|
289
386
|
readonly kind: "configured_pi_provider";
|
|
387
|
+
/** @internal */
|
|
290
388
|
readonly providerId: string;
|
|
291
|
-
/** Resolve the credential-blind models.json document pinned into each worker snapshot. */
|
|
292
|
-
resolveModels(ctx: {
|
|
389
|
+
/** Resolve the credential-blind models.json document pinned into each worker snapshot. @internal */
|
|
390
|
+
resolveModels(ctx: {
|
|
391
|
+
/** @internal */
|
|
392
|
+
readonly config: TConfig;
|
|
393
|
+
}): ProviderJsonObject;
|
|
293
394
|
}
|
|
294
395
|
|
|
396
|
+
/** @public */
|
|
295
397
|
export function piWorker<TConfig = unknown, TValue extends ProviderJsonObject = ProviderJsonObject>(
|
|
296
398
|
input: {
|
|
399
|
+
/** @public */
|
|
297
400
|
config?: ProviderWorkerConfigDefinition<TConfig, TValue>;
|
|
401
|
+
/** @public */
|
|
298
402
|
credentialFiles?: readonly string[];
|
|
299
403
|
} = {},
|
|
300
404
|
): PiWorkerReference<TConfig, TValue> {
|
|
@@ -311,10 +415,12 @@ export function piWorker<TConfig = unknown, TValue extends ProviderJsonObject =
|
|
|
311
415
|
};
|
|
312
416
|
}
|
|
313
417
|
|
|
418
|
+
/** @public */
|
|
314
419
|
export function piServer(): PiServerReference {
|
|
315
420
|
return { kind: "extension_pi_server" };
|
|
316
421
|
}
|
|
317
422
|
|
|
423
|
+
/** @public */
|
|
318
424
|
export function builtinPiProvider(providerId: string): BuiltinPiProviderReference {
|
|
319
425
|
if (providerId.trim() === "") {
|
|
320
426
|
throw new Error("Built-in Pi provider id must not be empty");
|
|
@@ -322,6 +428,7 @@ export function builtinPiProvider(providerId: string): BuiltinPiProviderReferenc
|
|
|
322
428
|
return { kind: "builtin_pi_provider", providerId };
|
|
323
429
|
}
|
|
324
430
|
|
|
431
|
+
/** @internal */
|
|
325
432
|
export function configuredPiProvider<TConfig>(
|
|
326
433
|
providerId: string,
|
|
327
434
|
resolveModels: ConfiguredPiProviderReference<TConfig>["resolveModels"],
|
|
@@ -332,6 +439,7 @@ export function configuredPiProvider<TConfig>(
|
|
|
332
439
|
return { kind: "configured_pi_provider", providerId, resolveModels };
|
|
333
440
|
}
|
|
334
441
|
|
|
442
|
+
/** @public */
|
|
335
443
|
export type ModelProviderWorker<
|
|
336
444
|
TConfig = unknown,
|
|
337
445
|
TValue extends ProviderJsonObject = ProviderJsonObject,
|
|
@@ -340,43 +448,60 @@ export type ModelProviderWorker<
|
|
|
340
448
|
| BuiltinPiProviderReference
|
|
341
449
|
| ConfiguredPiProviderReference<TConfig>;
|
|
342
450
|
|
|
451
|
+
/** @public */
|
|
343
452
|
export type ModelProviderServer = PiServerReference | BuiltinPiProviderReference;
|
|
344
453
|
|
|
454
|
+
/** @public */
|
|
345
455
|
export interface ModelProviderSecretsContext<TConfig = unknown, TCredential = unknown> {
|
|
456
|
+
/** @internal */
|
|
346
457
|
readonly config: TConfig;
|
|
458
|
+
/** @public */
|
|
347
459
|
readonly credential: TCredential | null;
|
|
460
|
+
/** @internal */
|
|
348
461
|
readonly options: Readonly<Record<string, string>>;
|
|
349
462
|
}
|
|
350
463
|
|
|
464
|
+
/** @public */
|
|
351
465
|
export interface ParsedModelProviderConfig<TConfig = unknown, TCredential = unknown> {
|
|
352
|
-
/** Restart-scoped, non-secret provider configuration. */
|
|
466
|
+
/** Restart-scoped, non-secret provider configuration. @public */
|
|
353
467
|
readonly config: TConfig;
|
|
354
|
-
/** Optional credential used only to initialize an empty durable credential store. */
|
|
468
|
+
/** Optional credential used only to initialize an empty durable credential store. @internal */
|
|
355
469
|
readonly credential?: TCredential;
|
|
356
470
|
}
|
|
357
471
|
|
|
472
|
+
/** @public */
|
|
358
473
|
export interface ModelProviderCredentialDefinition<TCredential = unknown> {
|
|
359
|
-
/** Validates configured, durable, and worker-refreshed credential data. */
|
|
474
|
+
/** Validates configured, durable, and worker-refreshed credential data. @public */
|
|
360
475
|
parse?(value: unknown): TCredential;
|
|
361
476
|
}
|
|
362
477
|
|
|
478
|
+
/** @public */
|
|
363
479
|
export interface ModelProviderDefinition<
|
|
364
480
|
TConfig = unknown,
|
|
365
481
|
TCredential = unknown,
|
|
366
482
|
TWorkerConfig extends ProviderJsonObject = ProviderJsonObject,
|
|
367
483
|
> {
|
|
484
|
+
/** @public */
|
|
368
485
|
readonly id: string;
|
|
486
|
+
/** @public */
|
|
369
487
|
parseConfig(raw: unknown): ParsedModelProviderConfig<TConfig, TCredential>;
|
|
488
|
+
/** @public */
|
|
370
489
|
readonly worker: ModelProviderWorker<TConfig, TWorkerConfig>;
|
|
490
|
+
/** @public */
|
|
371
491
|
readonly server?: ModelProviderServer;
|
|
492
|
+
/** @public */
|
|
372
493
|
models(
|
|
373
494
|
ctx: ModelProviderModelsContext<TConfig>,
|
|
374
495
|
): readonly ProviderModelStatus[] | Promise<readonly ProviderModelStatus[]>;
|
|
496
|
+
/** @public */
|
|
375
497
|
readonly options?: ProviderOptionsDefinition<TConfig>;
|
|
498
|
+
/** @public */
|
|
376
499
|
secrets(ctx: ModelProviderSecretsContext<TConfig, TCredential>): Readonly<Record<string, string>>;
|
|
500
|
+
/** @public */
|
|
377
501
|
readonly credential?: ModelProviderCredentialDefinition<TCredential>;
|
|
378
502
|
}
|
|
379
503
|
|
|
504
|
+
/** @public */
|
|
380
505
|
export function defineModelProvider<
|
|
381
506
|
TConfig = unknown,
|
|
382
507
|
TCredential = unknown,
|
|
@@ -390,42 +515,65 @@ export function defineModelProvider<
|
|
|
390
515
|
return definition;
|
|
391
516
|
}
|
|
392
517
|
|
|
393
|
-
/** Type-erased provider definition used after its typed boundary has been established. */
|
|
518
|
+
/** Type-erased provider definition used after its typed boundary has been established. @public */
|
|
394
519
|
// biome-ignore lint/suspicious/noExplicitAny: provider sets intentionally erase provider-owned generic types
|
|
395
520
|
export type ErasedModelProviderDefinition = ModelProviderDefinition<any, any, any>;
|
|
396
521
|
|
|
522
|
+
/** @public */
|
|
397
523
|
export interface ModelProviderSetEntry {
|
|
524
|
+
/** @public */
|
|
398
525
|
readonly definition: ErasedModelProviderDefinition;
|
|
399
|
-
/** Owner-scoped fragment passed to this provider's parseConfig(). */
|
|
526
|
+
/** Owner-scoped fragment passed to this provider's parseConfig(). @public */
|
|
400
527
|
readonly rawConfig: unknown;
|
|
401
528
|
}
|
|
402
529
|
|
|
403
|
-
/** Resolves every provider owned by one extension from its owner-scoped configuration. */
|
|
530
|
+
/** Resolves every provider owned by one extension from its owner-scoped configuration. @public */
|
|
404
531
|
export type ModelProviderSet = (ownerConfig: unknown) => readonly ModelProviderSetEntry[];
|
|
405
532
|
|
|
533
|
+
/** @public */
|
|
406
534
|
export function defineModelProviders(resolve: ModelProviderSet): ModelProviderSet {
|
|
407
535
|
return resolve;
|
|
408
536
|
}
|
|
409
537
|
|
|
538
|
+
/** @public */
|
|
410
539
|
export interface PiWorkerSecretBag {
|
|
540
|
+
/** @public */
|
|
411
541
|
get(key: string): string | undefined;
|
|
542
|
+
/** @public */
|
|
412
543
|
require(key: string): string;
|
|
544
|
+
/** @public */
|
|
413
545
|
keys(): readonly string[];
|
|
414
546
|
}
|
|
415
547
|
|
|
548
|
+
/** @public */
|
|
416
549
|
export interface PiWorkerContributionContext {
|
|
417
|
-
|
|
550
|
+
/** @public */
|
|
551
|
+
readonly model: {
|
|
552
|
+
/** @public */
|
|
553
|
+
readonly providerId: string;
|
|
554
|
+
/** @public */
|
|
555
|
+
readonly modelId: string;
|
|
556
|
+
};
|
|
557
|
+
/** @public */
|
|
418
558
|
readonly options: Readonly<Record<string, string>>;
|
|
559
|
+
/** @public */
|
|
419
560
|
readonly workerConfig: ProviderJsonObject | null;
|
|
561
|
+
/** @public */
|
|
420
562
|
readonly secrets: PiWorkerSecretBag;
|
|
563
|
+
/** @public */
|
|
421
564
|
report(event: Readonly<Record<string, ProviderJsonValue>>): void;
|
|
422
565
|
}
|
|
423
566
|
|
|
567
|
+
/** @public */
|
|
424
568
|
export type PiWorkerContribution = (
|
|
425
|
-
pi: {
|
|
569
|
+
pi: {
|
|
570
|
+
/** @public */
|
|
571
|
+
registerProvider(name: string, config: object): void;
|
|
572
|
+
},
|
|
426
573
|
ctx: PiWorkerContributionContext,
|
|
427
574
|
) => void | Promise<void>;
|
|
428
575
|
|
|
576
|
+
/** @public */
|
|
429
577
|
export function definePiWorker(contribution: PiWorkerContribution): PiWorkerContribution {
|
|
430
578
|
return contribution;
|
|
431
579
|
}
|
|
@@ -435,6 +583,7 @@ export function definePiWorker(contribution: PiWorkerContribution): PiWorkerCont
|
|
|
435
583
|
* on credential status. Providers that do not perform runtime model probing can
|
|
436
584
|
* delegate their `models()` callback to this helper.
|
|
437
585
|
*/
|
|
586
|
+
/** @public */
|
|
438
587
|
export function credentialBasedModelStatuses(
|
|
439
588
|
configuredModels: readonly ConfiguredProviderModel[],
|
|
440
589
|
credentialStatus: ProviderCredentialStatus,
|