@pellux/goodvibes-sdk 0.21.2 → 0.21.4
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/_internal/contracts/zod-schemas/accounts.d.ts.map +1 -1
- package/dist/_internal/contracts/zod-schemas/accounts.js +1 -0
- package/dist/_internal/contracts/zod-schemas/auth.d.ts.map +1 -1
- package/dist/_internal/contracts/zod-schemas/auth.js +1 -0
- package/dist/_internal/contracts/zod-schemas/events.d.ts.map +1 -1
- package/dist/_internal/contracts/zod-schemas/events.js +1 -0
- package/dist/_internal/contracts/zod-schemas/index.d.ts +2 -0
- package/dist/_internal/contracts/zod-schemas/index.d.ts.map +1 -1
- package/dist/_internal/contracts/zod-schemas/index.js +2 -0
- package/dist/_internal/contracts/zod-schemas/providers.d.ts +139 -0
- package/dist/_internal/contracts/zod-schemas/providers.d.ts.map +1 -0
- package/dist/_internal/contracts/zod-schemas/providers.js +65 -0
- package/dist/_internal/contracts/zod-schemas/session.d.ts.map +1 -1
- package/dist/_internal/contracts/zod-schemas/session.js +1 -0
- package/dist/_internal/platform/control-plane/gateway.d.ts +2 -1
- package/dist/_internal/platform/control-plane/gateway.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/gateway.js +7 -0
- package/dist/_internal/platform/daemon/http/provider-routes.d.ts +5 -0
- package/dist/_internal/platform/daemon/http/provider-routes.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/provider-routes.js +100 -44
- package/dist/_internal/platform/version.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/accounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAyC3B;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Synced from packages/contracts/src/zod-schemas/accounts.ts
|
|
1
2
|
import { z } from 'zod/v4';
|
|
2
3
|
const RouteKindSchema = z.enum(['api-key', 'service-oauth', 'subscription', 'unconfigured']);
|
|
3
4
|
const AuthFreshnessSchema = z.enum(['expired', 'expiring', 'healthy', 'pending', 'unconfigured']);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;;;;iBAKzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF;;;;GAIG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;iBAW3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;iBAQxC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;kCAEb,CAAC;AAEzB,eAAO,MAAM,kCAAkC;;;;;;;;;;iBAE7C,CAAC;AAEH,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC"}
|
|
@@ -6,4 +6,6 @@ export { SerializedEventEnvelopeSchema, TypedSerializedEventEnvelopeSchema, Runt
|
|
|
6
6
|
export type { SerializedEventEnvelopeShape, TypedSerializedEventEnvelopeShape, } from './events.js';
|
|
7
7
|
export { ControlStatusResponseSchema, LocalAuthStatusResponseSchema, } from './session.js';
|
|
8
8
|
export type { ControlStatusResponse, LocalAuthStatusResponse, } from './session.js';
|
|
9
|
+
export { ProviderModelRefSchema, ProviderModelEntrySchema, ConfiguredViaSchema, ProviderEntrySchema, ListProvidersResponseSchema, CurrentModelResponseSchema, PatchCurrentModelBodySchema, PatchCurrentModelErrorSchema, PatchCurrentModelResponseSchema, ModelChangedEventSchema, } from './providers.js';
|
|
10
|
+
export type { ProviderModelRef, ProviderModelEntry, ConfiguredVia, ProviderEntry, ListProvidersResponse, CurrentModelResponse, PatchCurrentModelBody, PatchCurrentModelError, PatchCurrentModelResponse, ModelChangedEvent, } from './providers.js';
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,8BAA8B,GAC/B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// Synced from packages/contracts/src/zod-schemas/index.ts
|
|
1
2
|
export { ControlAuthLoginResponseSchema, ControlAuthCurrentResponseSchema, } from './auth.js';
|
|
2
3
|
export { AccountsSnapshotResponseSchema, } from './accounts.js';
|
|
3
4
|
export { SerializedEventEnvelopeSchema, TypedSerializedEventEnvelopeSchema, RuntimeEventRecordSchema, } from './events.js';
|
|
4
5
|
export { ControlStatusResponseSchema, LocalAuthStatusResponseSchema, } from './session.js';
|
|
6
|
+
export { ProviderModelRefSchema, ProviderModelEntrySchema, ConfiguredViaSchema, ProviderEntrySchema, ListProvidersResponseSchema, CurrentModelResponseSchema, PatchCurrentModelBodySchema, PatchCurrentModelErrorSchema, PatchCurrentModelResponseSchema, ModelChangedEventSchema, } from './providers.js';
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/**
|
|
3
|
+
* Schemas for the provider/model discovery and selection HTTP API.
|
|
4
|
+
*
|
|
5
|
+
* Endpoints:
|
|
6
|
+
* GET /api/providers → ListProvidersResponseSchema
|
|
7
|
+
* GET /api/providers/current → CurrentModelResponseSchema
|
|
8
|
+
* PATCH /api/providers/current → PatchCurrentModelBodySchema (request) / CurrentModelResponseSchema (response)
|
|
9
|
+
*/
|
|
10
|
+
export declare const ProviderModelRefSchema: z.ZodObject<{
|
|
11
|
+
registryKey: z.ZodString;
|
|
12
|
+
provider: z.ZodString;
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type ProviderModelRef = z.infer<typeof ProviderModelRefSchema>;
|
|
16
|
+
export declare const ProviderModelEntrySchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
registryKey: z.ZodString;
|
|
19
|
+
provider: z.ZodString;
|
|
20
|
+
label: z.ZodOptional<z.ZodString>;
|
|
21
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type ProviderModelEntry = z.infer<typeof ProviderModelEntrySchema>;
|
|
24
|
+
export declare const ConfiguredViaSchema: z.ZodEnum<{
|
|
25
|
+
env: "env";
|
|
26
|
+
anonymous: "anonymous";
|
|
27
|
+
subscription: "subscription";
|
|
28
|
+
secrets: "secrets";
|
|
29
|
+
}>;
|
|
30
|
+
export type ConfiguredVia = z.infer<typeof ConfiguredViaSchema>;
|
|
31
|
+
export declare const ProviderEntrySchema: z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
label: z.ZodString;
|
|
34
|
+
configured: z.ZodBoolean;
|
|
35
|
+
configuredVia: z.ZodOptional<z.ZodEnum<{
|
|
36
|
+
env: "env";
|
|
37
|
+
anonymous: "anonymous";
|
|
38
|
+
subscription: "subscription";
|
|
39
|
+
secrets: "secrets";
|
|
40
|
+
}>>;
|
|
41
|
+
envVars: z.ZodArray<z.ZodString>;
|
|
42
|
+
models: z.ZodArray<z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
registryKey: z.ZodString;
|
|
45
|
+
provider: z.ZodString;
|
|
46
|
+
label: z.ZodOptional<z.ZodString>;
|
|
47
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type ProviderEntry = z.infer<typeof ProviderEntrySchema>;
|
|
51
|
+
export declare const ListProvidersResponseSchema: z.ZodObject<{
|
|
52
|
+
providers: z.ZodArray<z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
label: z.ZodString;
|
|
55
|
+
configured: z.ZodBoolean;
|
|
56
|
+
configuredVia: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
env: "env";
|
|
58
|
+
anonymous: "anonymous";
|
|
59
|
+
subscription: "subscription";
|
|
60
|
+
secrets: "secrets";
|
|
61
|
+
}>>;
|
|
62
|
+
envVars: z.ZodArray<z.ZodString>;
|
|
63
|
+
models: z.ZodArray<z.ZodObject<{
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
registryKey: z.ZodString;
|
|
66
|
+
provider: z.ZodString;
|
|
67
|
+
label: z.ZodOptional<z.ZodString>;
|
|
68
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
currentModel: z.ZodNullable<z.ZodObject<{
|
|
72
|
+
registryKey: z.ZodString;
|
|
73
|
+
provider: z.ZodString;
|
|
74
|
+
id: z.ZodString;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type ListProvidersResponse = z.infer<typeof ListProvidersResponseSchema>;
|
|
78
|
+
export declare const CurrentModelResponseSchema: z.ZodObject<{
|
|
79
|
+
model: z.ZodNullable<z.ZodObject<{
|
|
80
|
+
registryKey: z.ZodString;
|
|
81
|
+
provider: z.ZodString;
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
configured: z.ZodBoolean;
|
|
85
|
+
configuredVia: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
env: "env";
|
|
87
|
+
anonymous: "anonymous";
|
|
88
|
+
subscription: "subscription";
|
|
89
|
+
secrets: "secrets";
|
|
90
|
+
}>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
export type CurrentModelResponse = z.infer<typeof CurrentModelResponseSchema>;
|
|
93
|
+
export declare const PatchCurrentModelBodySchema: z.ZodObject<{
|
|
94
|
+
registryKey: z.ZodString;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
export type PatchCurrentModelBody = z.infer<typeof PatchCurrentModelBodySchema>;
|
|
97
|
+
export declare const PatchCurrentModelErrorSchema: z.ZodObject<{
|
|
98
|
+
error: z.ZodString;
|
|
99
|
+
code: z.ZodEnum<{
|
|
100
|
+
INVALID_REQUEST: "INVALID_REQUEST";
|
|
101
|
+
MODEL_NOT_FOUND: "MODEL_NOT_FOUND";
|
|
102
|
+
PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
|
|
103
|
+
SET_MODEL_FAILED: "SET_MODEL_FAILED";
|
|
104
|
+
}>;
|
|
105
|
+
missingEnvVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
export type PatchCurrentModelError = z.infer<typeof PatchCurrentModelErrorSchema>;
|
|
108
|
+
export declare const PatchCurrentModelResponseSchema: z.ZodObject<{
|
|
109
|
+
model: z.ZodNullable<z.ZodObject<{
|
|
110
|
+
registryKey: z.ZodString;
|
|
111
|
+
provider: z.ZodString;
|
|
112
|
+
id: z.ZodString;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
configured: z.ZodBoolean;
|
|
115
|
+
configuredVia: z.ZodOptional<z.ZodEnum<{
|
|
116
|
+
env: "env";
|
|
117
|
+
anonymous: "anonymous";
|
|
118
|
+
subscription: "subscription";
|
|
119
|
+
secrets: "secrets";
|
|
120
|
+
}>>;
|
|
121
|
+
persisted: z.ZodBoolean;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
export type PatchCurrentModelResponse = z.infer<typeof PatchCurrentModelResponseSchema>;
|
|
124
|
+
/**
|
|
125
|
+
* SSE event shape emitted on `model.changed` events.
|
|
126
|
+
*
|
|
127
|
+
* Forwarded to companion SSE streams when the current model changes.
|
|
128
|
+
*/
|
|
129
|
+
export declare const ModelChangedEventSchema: z.ZodObject<{
|
|
130
|
+
type: z.ZodLiteral<"MODEL_CHANGED">;
|
|
131
|
+
registryKey: z.ZodString;
|
|
132
|
+
provider: z.ZodString;
|
|
133
|
+
previous: z.ZodOptional<z.ZodObject<{
|
|
134
|
+
registryKey: z.ZodString;
|
|
135
|
+
provider: z.ZodString;
|
|
136
|
+
}, z.core.$strip>>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
export type ModelChangedEvent = z.infer<typeof ModelChangedEventSchema>;
|
|
139
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B;;;;;;;GAOG;AAEH,eAAO,MAAM,sBAAsB;;;;iBAIjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sB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BAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Synced from packages/contracts/src/zod-schemas/providers.ts
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
/**
|
|
4
|
+
* Schemas for the provider/model discovery and selection HTTP API.
|
|
5
|
+
*
|
|
6
|
+
* Endpoints:
|
|
7
|
+
* GET /api/providers → ListProvidersResponseSchema
|
|
8
|
+
* GET /api/providers/current → CurrentModelResponseSchema
|
|
9
|
+
* PATCH /api/providers/current → PatchCurrentModelBodySchema (request) / CurrentModelResponseSchema (response)
|
|
10
|
+
*/
|
|
11
|
+
export const ProviderModelRefSchema = z.object({
|
|
12
|
+
registryKey: z.string(),
|
|
13
|
+
provider: z.string(),
|
|
14
|
+
id: z.string(),
|
|
15
|
+
});
|
|
16
|
+
export const ProviderModelEntrySchema = z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
registryKey: z.string(),
|
|
19
|
+
provider: z.string(),
|
|
20
|
+
label: z.string().optional(),
|
|
21
|
+
contextWindow: z.number().optional(),
|
|
22
|
+
});
|
|
23
|
+
export const ConfiguredViaSchema = z.enum(['env', 'secrets', 'subscription', 'anonymous']);
|
|
24
|
+
export const ProviderEntrySchema = z.object({
|
|
25
|
+
id: z.string(),
|
|
26
|
+
label: z.string(),
|
|
27
|
+
configured: z.boolean(),
|
|
28
|
+
configuredVia: ConfiguredViaSchema.optional(),
|
|
29
|
+
envVars: z.array(z.string()),
|
|
30
|
+
models: z.array(ProviderModelEntrySchema),
|
|
31
|
+
});
|
|
32
|
+
export const ListProvidersResponseSchema = z.object({
|
|
33
|
+
providers: z.array(ProviderEntrySchema),
|
|
34
|
+
currentModel: ProviderModelRefSchema.nullable(),
|
|
35
|
+
});
|
|
36
|
+
export const CurrentModelResponseSchema = z.object({
|
|
37
|
+
model: ProviderModelRefSchema.nullable(),
|
|
38
|
+
configured: z.boolean(),
|
|
39
|
+
configuredVia: ConfiguredViaSchema.optional(),
|
|
40
|
+
});
|
|
41
|
+
export const PatchCurrentModelBodySchema = z.object({
|
|
42
|
+
registryKey: z.string().min(1),
|
|
43
|
+
});
|
|
44
|
+
export const PatchCurrentModelErrorSchema = z.object({
|
|
45
|
+
error: z.string(),
|
|
46
|
+
code: z.enum(['INVALID_REQUEST', 'MODEL_NOT_FOUND', 'PROVIDER_NOT_CONFIGURED', 'SET_MODEL_FAILED']),
|
|
47
|
+
missingEnvVars: z.array(z.string()).optional(),
|
|
48
|
+
});
|
|
49
|
+
export const PatchCurrentModelResponseSchema = CurrentModelResponseSchema.extend({
|
|
50
|
+
persisted: z.boolean(),
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* SSE event shape emitted on `model.changed` events.
|
|
54
|
+
*
|
|
55
|
+
* Forwarded to companion SSE streams when the current model changes.
|
|
56
|
+
*/
|
|
57
|
+
export const ModelChangedEventSchema = z.object({
|
|
58
|
+
type: z.literal('MODEL_CHANGED'),
|
|
59
|
+
registryKey: z.string(),
|
|
60
|
+
provider: z.string(),
|
|
61
|
+
previous: z.object({
|
|
62
|
+
registryKey: z.string(),
|
|
63
|
+
provider: z.string(),
|
|
64
|
+
}).optional(),
|
|
65
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/_internal/contracts/zod-schemas/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B;;;kCAGlB,CAAC;AAEzB,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RuntimeStore } from '../runtime/store/index.js';
|
|
2
2
|
import type { RuntimeEventBus, RuntimeEventDomain } from '../runtime/events/index.js';
|
|
3
3
|
import type { ControlPlaneClientDescriptor, ControlPlaneServerConfig, ControlPlaneSurfaceMessage } from './types.js';
|
|
4
|
+
declare const DEFAULT_DOMAINS: readonly RuntimeEventDomain[];
|
|
4
5
|
export interface ControlPlaneGatewayConfig {
|
|
5
6
|
readonly runtimeBus?: RuntimeEventBus | null;
|
|
6
7
|
readonly runtimeStore?: RuntimeStore | null;
|
|
@@ -98,5 +99,5 @@ export declare class ControlPlaneGateway {
|
|
|
98
99
|
private _scheduleControlPlaneSync;
|
|
99
100
|
private rememberEvent;
|
|
100
101
|
}
|
|
101
|
-
export {};
|
|
102
|
+
export { DEFAULT_DOMAINS as DEFAULT_DOMAINS_TEST_EXPORT };
|
|
102
103
|
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/control-plane/gateway.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAyC,MAAM,4BAA4B,CAAC;AAU7H,OAAO,KAAK,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/control-plane/gateway.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAyC,MAAM,4BAA4B,CAAC;AAU7H,OAAO,KAA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,mBAAmB;IAa3B,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,8BAAmC,GAAG,QAAQ;IAiK3F,WAAW,CAAC,aAAa,SAAK,GAAG,QAAQ;IAIzC,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,aAAa;CAgBtB;AAOD,OAAO,EAAE,eAAe,IAAI,2BAA2B,EAAE,CAAC"}
|
|
@@ -15,6 +15,7 @@ const DEFAULT_DOMAINS = [
|
|
|
15
15
|
'transport',
|
|
16
16
|
'ops',
|
|
17
17
|
'knowledge',
|
|
18
|
+
'providers',
|
|
18
19
|
];
|
|
19
20
|
const DEFAULT_SERVER_CONFIG = {
|
|
20
21
|
enabled: false,
|
|
@@ -617,3 +618,9 @@ export class ControlPlaneGateway {
|
|
|
617
618
|
return record;
|
|
618
619
|
}
|
|
619
620
|
}
|
|
621
|
+
// ---------------------------------------------------------------------------
|
|
622
|
+
// Test export — exposes DEFAULT_DOMAINS for regression tests.
|
|
623
|
+
// This export is intentional; the const itself is module-scoped so tests
|
|
624
|
+
// cannot otherwise verify its contents without runtime inspection.
|
|
625
|
+
// ---------------------------------------------------------------------------
|
|
626
|
+
export { DEFAULT_DOMAINS as DEFAULT_DOMAINS_TEST_EXPORT };
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import type { ProviderRegistry } from '../../providers/registry.js';
|
|
15
15
|
import type { ConfigManager } from '../../config/manager.js';
|
|
16
16
|
import type { RuntimeEventBus } from '../../runtime/events/index.js';
|
|
17
|
+
import type { SecretsManager } from '../../config/secrets.js';
|
|
17
18
|
export interface ProviderModelRef {
|
|
18
19
|
readonly registryKey: string;
|
|
19
20
|
readonly provider: string;
|
|
@@ -44,11 +45,15 @@ export interface CurrentModelResponse {
|
|
|
44
45
|
readonly configured: boolean;
|
|
45
46
|
readonly configuredVia?: ConfiguredVia;
|
|
46
47
|
}
|
|
48
|
+
export interface PatchCurrentModelResponse extends CurrentModelResponse {
|
|
49
|
+
readonly persisted: boolean;
|
|
50
|
+
}
|
|
47
51
|
export interface ProviderRouteContext {
|
|
48
52
|
readonly providerRegistry: ProviderRegistry;
|
|
49
53
|
readonly configManager: ConfigManager;
|
|
50
54
|
readonly runtimeBus: RuntimeEventBus;
|
|
51
55
|
readonly parseJsonBody: (req: Request) => Promise<Record<string, unknown> | Response>;
|
|
56
|
+
readonly secretsManager?: Pick<SecretsManager, 'get'> | null;
|
|
52
57
|
}
|
|
53
58
|
export declare function dispatchProviderRoutes(req: Request, context: ProviderRouteContext): Promise<Response | null>;
|
|
54
59
|
//# sourceMappingURL=provider-routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-routes.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/daemon/http/provider-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-routes.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/daemon/http/provider-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAyD9D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED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,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;IACtF,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;CAC9D;AAwFD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAiB1B"}
|
|
@@ -11,30 +11,97 @@
|
|
|
11
11
|
* All routes require the existing daemon bearer-token auth (enforced by the
|
|
12
12
|
* caller — DaemonHttpRouter.handleRequest validates auth before dispatching).
|
|
13
13
|
*/
|
|
14
|
-
import { emitModelChanged } from '../../runtime/emitters/index.js';
|
|
15
14
|
import { findModelDefinition } from '../../providers/registry-models.js';
|
|
16
|
-
import { BUILTIN_PROVIDER_ENV_KEYS } from '../../providers/builtin-catalog.js';
|
|
15
|
+
import { BUILTIN_COMPAT_PROVIDERS, BUILTIN_PROVIDER_ENV_KEYS } from '../../providers/builtin-catalog.js';
|
|
16
|
+
import { logger } from '../../utils/logger.js';
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Provider label map — brand-accurate display names
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
const BUILTIN_LABEL_MAP = {
|
|
21
|
+
// Native / first-party providers (not in BUILTIN_COMPAT_PROVIDERS)
|
|
22
|
+
openai: 'OpenAI',
|
|
23
|
+
anthropic: 'Anthropic',
|
|
24
|
+
gemini: 'Gemini',
|
|
25
|
+
inceptionlabs: 'Inception Labs',
|
|
26
|
+
'amazon-bedrock': 'Amazon Bedrock',
|
|
27
|
+
'amazon-bedrock-mantle': 'Amazon Bedrock (Mantle)',
|
|
28
|
+
'anthropic-vertex': 'Anthropic (Vertex)',
|
|
29
|
+
'github-copilot': 'GitHub Copilot',
|
|
30
|
+
groq: 'Groq',
|
|
31
|
+
cerebras: 'Cerebras',
|
|
32
|
+
mistral: 'Mistral',
|
|
33
|
+
'ollama-cloud': 'Ollama Cloud',
|
|
34
|
+
huggingface: 'Hugging Face',
|
|
35
|
+
nvidia: 'NVIDIA',
|
|
36
|
+
llm7: 'LLM7',
|
|
37
|
+
perplexity: 'Perplexity',
|
|
38
|
+
deepgram: 'Deepgram',
|
|
39
|
+
elevenlabs: 'ElevenLabs',
|
|
40
|
+
microsoft: 'Microsoft',
|
|
41
|
+
vydra: 'Vydra',
|
|
42
|
+
byteplus: 'BytePlus',
|
|
43
|
+
fal: 'fal.ai',
|
|
44
|
+
comfy: 'ComfyUI',
|
|
45
|
+
runway: 'Runway',
|
|
46
|
+
alibaba: 'Alibaba Cloud',
|
|
47
|
+
synthetic: 'Synthetic (Local)',
|
|
48
|
+
};
|
|
49
|
+
// Build label map from the compat catalog (these already carry a label field)
|
|
50
|
+
const _catalogLabelMap = {};
|
|
51
|
+
for (const def of BUILTIN_COMPAT_PROVIDERS) {
|
|
52
|
+
if (def.label)
|
|
53
|
+
_catalogLabelMap[def.id] = def.label;
|
|
54
|
+
}
|
|
55
|
+
function getProviderLabel(providerId) {
|
|
56
|
+
return (BUILTIN_LABEL_MAP[providerId] ??
|
|
57
|
+
_catalogLabelMap[providerId] ??
|
|
58
|
+
providerId.charAt(0).toUpperCase() + providerId.slice(1));
|
|
59
|
+
}
|
|
17
60
|
// ---------------------------------------------------------------------------
|
|
18
61
|
// Helpers
|
|
19
62
|
// ---------------------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Pre-resolve all non-env secret keys stored in SecretsManager in one async
|
|
65
|
+
* batch. The resulting set is passed into the synchronous getConfiguredVia so
|
|
66
|
+
* that the secrets tier check remains pure/non-async.
|
|
67
|
+
*/
|
|
68
|
+
async function resolveSecretKeys(secretsManager) {
|
|
69
|
+
if (!secretsManager)
|
|
70
|
+
return new Set();
|
|
71
|
+
// Enumerate all env var names that any known provider might use
|
|
72
|
+
const allEnvVarNames = Object.values(BUILTIN_PROVIDER_ENV_KEYS).flat();
|
|
73
|
+
const results = await Promise.all(allEnvVarNames.map(async (v) => {
|
|
74
|
+
if (typeof process.env[v] === 'string' && process.env[v].length > 0) {
|
|
75
|
+
// Already in env; skip the secrets lookup to avoid redundant I/O
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const val = await secretsManager.get(v);
|
|
79
|
+
return val !== null ? v : null;
|
|
80
|
+
}));
|
|
81
|
+
return new Set(results.filter((v) => v !== null));
|
|
82
|
+
}
|
|
83
|
+
function getConfiguredVia(providerId, envVars, providerRegistry, secretKeys) {
|
|
84
|
+
// Tier 1: env var present
|
|
22
85
|
const hasEnvKey = envVars.some((v) => {
|
|
23
86
|
const val = process.env[v];
|
|
24
87
|
return typeof val === 'string' && val.length > 0;
|
|
25
88
|
});
|
|
26
89
|
if (hasEnvKey)
|
|
27
90
|
return 'env';
|
|
28
|
-
//
|
|
29
|
-
|
|
91
|
+
// Tier 2: SecretsManager has a stored value for any of the provider's env var names
|
|
92
|
+
if (secretKeys && envVars.some((v) => secretKeys.has(v)))
|
|
93
|
+
return 'secrets';
|
|
94
|
+
// Tier 3: detect anonymous providers (no env vars required by design)
|
|
95
|
+
const catalogDef = BUILTIN_COMPAT_PROVIDERS.find((d) => d.id === providerId);
|
|
96
|
+
if (catalogDef?.allowAnonymous && catalogDef?.anonymousConfigured)
|
|
97
|
+
return 'anonymous';
|
|
98
|
+
// Tier 4: present in configuredProviderIds but not env — subscription-backed
|
|
30
99
|
const configuredIds = providerRegistry.getConfiguredProviderIds();
|
|
31
|
-
if (configuredIds.includes(providerId))
|
|
32
|
-
// It's configured but not via env — could be subscription or anonymous
|
|
100
|
+
if (configuredIds.includes(providerId))
|
|
33
101
|
return 'subscription';
|
|
34
|
-
}
|
|
35
102
|
return undefined;
|
|
36
103
|
}
|
|
37
|
-
function buildCurrentModelResponse(providerRegistry) {
|
|
104
|
+
function buildCurrentModelResponse(providerRegistry, secretKeys) {
|
|
38
105
|
let model = null;
|
|
39
106
|
let configured = false;
|
|
40
107
|
let configuredVia;
|
|
@@ -44,20 +111,10 @@ function buildCurrentModelResponse(providerRegistry) {
|
|
|
44
111
|
model = { registryKey, provider: current.provider, id: current.id };
|
|
45
112
|
// Determine configured status for the current model's provider
|
|
46
113
|
const envVars = (BUILTIN_PROVIDER_ENV_KEYS[current.provider] ?? []);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
return typeof val === 'string' && val.length > 0;
|
|
50
|
-
});
|
|
51
|
-
if (hasEnvKey) {
|
|
114
|
+
const via = getConfiguredVia(current.provider, envVars, providerRegistry, secretKeys);
|
|
115
|
+
if (via !== undefined) {
|
|
52
116
|
configured = true;
|
|
53
|
-
configuredVia =
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const configuredIds = providerRegistry.getConfiguredProviderIds();
|
|
57
|
-
if (configuredIds.includes(current.provider)) {
|
|
58
|
-
configured = true;
|
|
59
|
-
configuredVia = 'subscription';
|
|
60
|
-
}
|
|
117
|
+
configuredVia = via;
|
|
61
118
|
}
|
|
62
119
|
}
|
|
63
120
|
catch {
|
|
@@ -86,7 +143,9 @@ export async function dispatchProviderRoutes(req, context) {
|
|
|
86
143
|
// GET /api/providers
|
|
87
144
|
// ---------------------------------------------------------------------------
|
|
88
145
|
async function handleListProviders(context) {
|
|
89
|
-
const { providerRegistry } = context;
|
|
146
|
+
const { providerRegistry, secretsManager } = context;
|
|
147
|
+
// Pre-resolve which secret keys are stored (one async batch, then sync logic below)
|
|
148
|
+
const secretKeys = await resolveSecretKeys(secretsManager);
|
|
90
149
|
const allModels = providerRegistry.listModels();
|
|
91
150
|
const configuredIds = new Set(providerRegistry.getConfiguredProviderIds());
|
|
92
151
|
// Group models by provider
|
|
@@ -106,12 +165,10 @@ async function handleListProviders(context) {
|
|
|
106
165
|
const providers = [];
|
|
107
166
|
for (const [providerId, models] of byProvider) {
|
|
108
167
|
const envVars = (BUILTIN_PROVIDER_ENV_KEYS[providerId] ?? []);
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// Infer label from provider id (capitalize first letter)
|
|
114
|
-
const label = providerId.charAt(0).toUpperCase() + providerId.slice(1);
|
|
168
|
+
const via = getConfiguredVia(providerId, envVars, providerRegistry, secretKeys);
|
|
169
|
+
const configured = via !== undefined;
|
|
170
|
+
const configuredVia = configured ? via : undefined;
|
|
171
|
+
const label = getProviderLabel(providerId);
|
|
115
172
|
providers.push({ id: providerId, label, configured, configuredVia, envVars, models });
|
|
116
173
|
}
|
|
117
174
|
// Sort: configured first, then alphabetical
|
|
@@ -120,7 +177,7 @@ async function handleListProviders(context) {
|
|
|
120
177
|
return a.configured ? -1 : 1;
|
|
121
178
|
return a.id.localeCompare(b.id);
|
|
122
179
|
});
|
|
123
|
-
const currentModel = buildCurrentModelResponse(providerRegistry).model;
|
|
180
|
+
const currentModel = buildCurrentModelResponse(providerRegistry, secretKeys).model;
|
|
124
181
|
const body = { providers, currentModel };
|
|
125
182
|
return Response.json(body);
|
|
126
183
|
}
|
|
@@ -128,13 +185,14 @@ async function handleListProviders(context) {
|
|
|
128
185
|
// GET /api/providers/current
|
|
129
186
|
// ---------------------------------------------------------------------------
|
|
130
187
|
async function handleGetCurrentModel(context) {
|
|
131
|
-
|
|
188
|
+
const secretKeys = await resolveSecretKeys(context.secretsManager);
|
|
189
|
+
return Response.json(buildCurrentModelResponse(context.providerRegistry, secretKeys));
|
|
132
190
|
}
|
|
133
191
|
// ---------------------------------------------------------------------------
|
|
134
192
|
// PATCH /api/providers/current
|
|
135
193
|
// ---------------------------------------------------------------------------
|
|
136
194
|
async function handlePatchCurrentModel(req, context) {
|
|
137
|
-
const { providerRegistry, configManager
|
|
195
|
+
const { providerRegistry, configManager } = context;
|
|
138
196
|
const bodyOrErr = await context.parseJsonBody(req);
|
|
139
197
|
if (bodyOrErr instanceof Response)
|
|
140
198
|
return bodyOrErr;
|
|
@@ -169,20 +227,18 @@ async function handlePatchCurrentModel(req, context) {
|
|
|
169
227
|
return Response.json({ error: message, code: 'SET_MODEL_FAILED' }, { status: 400 });
|
|
170
228
|
}
|
|
171
229
|
// Persist to config
|
|
230
|
+
let persisted = false;
|
|
172
231
|
try {
|
|
173
232
|
configManager.set('provider.model', modelDef.id);
|
|
174
233
|
configManager.set('provider.provider', modelDef.provider);
|
|
234
|
+
persisted = true;
|
|
175
235
|
}
|
|
176
|
-
catch {
|
|
177
|
-
|
|
236
|
+
catch (persistErr) {
|
|
237
|
+
const msg = persistErr instanceof Error ? persistErr.message : String(persistErr);
|
|
238
|
+
logger.warn(`[provider-routes] Failed to persist model selection to config: ${msg}`);
|
|
178
239
|
}
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
emitModelChanged(runtimeBus, { sessionId: 'system', source: 'http-api', traceId }, {
|
|
184
|
-
registryKey,
|
|
185
|
-
provider: modelDef.provider,
|
|
186
|
-
});
|
|
187
|
-
return Response.json(buildCurrentModelResponse(providerRegistry));
|
|
240
|
+
// setCurrentModel emits MODEL_CHANGED synchronously on the same runtimeBus —
|
|
241
|
+
// no second emission needed here.
|
|
242
|
+
const secretKeys = await resolveSecretKeys(context.secretsManager);
|
|
243
|
+
return Response.json({ ...buildCurrentModelResponse(providerRegistry, secretKeys), persisted });
|
|
188
244
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
let version = '0.21.
|
|
3
|
+
let version = '0.21.4';
|
|
4
4
|
try {
|
|
5
5
|
const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', '..', 'package.json'), 'utf-8'));
|
|
6
6
|
version = pkg.version ?? version;
|