optio-contracts 0.11.3 → 0.11.5
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/pools/api-to-frontend.d.ts +647 -0
- package/dist/pools/api-to-frontend.d.ts.map +1 -0
- package/dist/pools/api-to-frontend.js +134 -0
- package/dist/pools/api-to-frontend.js.map +1 -0
- package/dist/pools/optio-pools-to-api.d.ts +606 -0
- package/dist/pools/optio-pools-to-api.d.ts.map +1 -0
- package/dist/pools/optio-pools-to-api.js +91 -0
- package/dist/pools/optio-pools-to-api.js.map +1 -0
- package/dist/pools/schemas.d.ts +1071 -0
- package/dist/pools/schemas.d.ts.map +1 -0
- package/dist/pools/schemas.js +137 -0
- package/dist/pools/schemas.js.map +1 -0
- package/dist/route-error-reasons.d.ts +7 -0
- package/dist/route-error-reasons.d.ts.map +1 -1
- package/dist/route-error-reasons.js +12 -0
- package/dist/route-error-reasons.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Login pools: the routes optio-api serves to its clients (mounted under /api,
|
|
2
|
+
// like processesContract). Spec: docs/2026-11-29-login-pools-design.md section
|
|
3
|
+
// 12.3. The live rows (GET /api/pools/stream) are raw SSE, outside this contract
|
|
4
|
+
// (PoolsStreamFrameSchema).
|
|
5
|
+
import { initContract } from '@ts-rest/core';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { GatewayConfigureBodySchema, GatewayModelsBodySchema, ModelChoiceSchema, PoolsQuerySchema, } from './schemas.js';
|
|
8
|
+
const c = initContract();
|
|
9
|
+
/** 409 reasons of a route that starts the setup process (setup, gateway configure). */
|
|
10
|
+
export const PoolSetupConflictReason = z.enum(['setup-running', 'unsupported', 'launch-refused']);
|
|
11
|
+
/** 409 reasons of a route the kind may not support (bury dead, sort out, gateway models). */
|
|
12
|
+
export const PoolUnsupportedReason = z.enum(['unsupported']);
|
|
13
|
+
/** 409 reasons of the retest (the form kind's test task: optio refused its launch). */
|
|
14
|
+
export const PoolRetestConflictReason = z.enum(['launch-refused']);
|
|
15
|
+
/** 422 reasons of the gateway model list. */
|
|
16
|
+
export const PoolGatewayModelsReason = z.enum(['no-key', 'key-rejected', 'unreachable', 'no-models', 'unknown-region']);
|
|
17
|
+
/** 422 reasons of the gateway configuration: the model list's, then the ticks' checks. */
|
|
18
|
+
export const PoolGatewayConfigureReason = z.enum([
|
|
19
|
+
...PoolGatewayModelsReason.options,
|
|
20
|
+
'unknown-model',
|
|
21
|
+
'default-not-ticked',
|
|
22
|
+
]);
|
|
23
|
+
const KindParams = z.object({ kind: z.string().min(1) });
|
|
24
|
+
// 403: no owner (the host's owner hook answered null) or authorize refused.
|
|
25
|
+
// 500: the owner hook answered a malformed owner (never echoed).
|
|
26
|
+
const MessageBody = z.object({ message: z.string() });
|
|
27
|
+
const UnknownKindBody = z.object({ reason: z.literal('unknown-kind'), message: z.string() });
|
|
28
|
+
const EngineUnavailableBody = z.object({ reason: z.literal('engine-unavailable'), message: z.string() });
|
|
29
|
+
const common = {
|
|
30
|
+
403: MessageBody,
|
|
31
|
+
404: UnknownKindBody,
|
|
32
|
+
500: MessageBody,
|
|
33
|
+
503: EngineUnavailableBody,
|
|
34
|
+
};
|
|
35
|
+
const ProcessIdBody = z.object({ processId: z.string() });
|
|
36
|
+
const Count = z.number().int().min(0);
|
|
37
|
+
export const poolsContract = c.router({
|
|
38
|
+
setup: {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
path: '/pools/:kind/setup',
|
|
41
|
+
pathParams: KindParams,
|
|
42
|
+
query: PoolsQuerySchema,
|
|
43
|
+
body: c.noBody(),
|
|
44
|
+
responses: {
|
|
45
|
+
202: ProcessIdBody,
|
|
46
|
+
...common,
|
|
47
|
+
409: z.object({ reason: PoolSetupConflictReason, message: z.string() }),
|
|
48
|
+
},
|
|
49
|
+
summary: 'Start (or follow) the pool\'s login setup task',
|
|
50
|
+
},
|
|
51
|
+
retest: {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
path: '/pools/:kind/retest',
|
|
54
|
+
pathParams: KindParams,
|
|
55
|
+
query: PoolsQuerySchema,
|
|
56
|
+
body: c.noBody(),
|
|
57
|
+
responses: {
|
|
58
|
+
// unverified: logins the provider could not be asked about; left as they were.
|
|
59
|
+
200: z.object({ verified: Count, dead: Count, unverified: Count, processId: z.string().nullable() }),
|
|
60
|
+
...common,
|
|
61
|
+
409: z.object({ reason: PoolRetestConflictReason, message: z.string() }),
|
|
62
|
+
},
|
|
63
|
+
summary: 'Retest the pool\'s logins (the form kind: relaunch its test task)',
|
|
64
|
+
},
|
|
65
|
+
buryDead: {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
path: '/pools/:kind/bury-dead',
|
|
68
|
+
pathParams: KindParams,
|
|
69
|
+
query: PoolsQuerySchema,
|
|
70
|
+
body: c.noBody(),
|
|
71
|
+
responses: {
|
|
72
|
+
200: z.object({ buried: Count }),
|
|
73
|
+
...common,
|
|
74
|
+
409: z.object({ reason: PoolUnsupportedReason, message: z.string() }),
|
|
75
|
+
},
|
|
76
|
+
summary: 'Remove the pool\'s dead logins',
|
|
77
|
+
},
|
|
78
|
+
removeAll: {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
path: '/pools/:kind/remove-all',
|
|
81
|
+
pathParams: KindParams,
|
|
82
|
+
query: PoolsQuerySchema,
|
|
83
|
+
body: c.noBody(),
|
|
84
|
+
responses: {
|
|
85
|
+
// skipped: logins a running agent holds; they stay.
|
|
86
|
+
200: z.object({ removed: Count, skipped: Count }),
|
|
87
|
+
...common,
|
|
88
|
+
},
|
|
89
|
+
summary: 'Remove every login of the pool no running agent holds (the form kind: its configuration)',
|
|
90
|
+
},
|
|
91
|
+
sortOut: {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
path: '/pools/:kind/sort-out',
|
|
94
|
+
pathParams: KindParams,
|
|
95
|
+
query: PoolsQuerySchema,
|
|
96
|
+
body: c.noBody(),
|
|
97
|
+
responses: {
|
|
98
|
+
// skipped: differing logins a running agent holds; they stay.
|
|
99
|
+
200: z.object({ removed: Count, skipped: Count }),
|
|
100
|
+
...common,
|
|
101
|
+
409: z.object({ reason: PoolUnsupportedReason, message: z.string() }),
|
|
102
|
+
},
|
|
103
|
+
summary: 'Remove every login whose signature differs from the pool\'s first one (none a running agent holds)',
|
|
104
|
+
},
|
|
105
|
+
gatewayModels: {
|
|
106
|
+
method: 'POST',
|
|
107
|
+
path: '/pools/:kind/gateway/models',
|
|
108
|
+
pathParams: KindParams,
|
|
109
|
+
query: PoolsQuerySchema,
|
|
110
|
+
body: GatewayModelsBodySchema,
|
|
111
|
+
responses: {
|
|
112
|
+
200: z.object({ models: z.array(ModelChoiceSchema) }),
|
|
113
|
+
...common,
|
|
114
|
+
409: z.object({ reason: PoolUnsupportedReason, message: z.string() }),
|
|
115
|
+
422: z.object({ reason: PoolGatewayModelsReason, message: z.string() }),
|
|
116
|
+
},
|
|
117
|
+
summary: 'List the gateway account\'s models in a region',
|
|
118
|
+
},
|
|
119
|
+
gatewayConfigure: {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
path: '/pools/:kind/gateway/configure',
|
|
122
|
+
pathParams: KindParams,
|
|
123
|
+
query: PoolsQuerySchema,
|
|
124
|
+
body: GatewayConfigureBodySchema,
|
|
125
|
+
responses: {
|
|
126
|
+
202: ProcessIdBody,
|
|
127
|
+
...common,
|
|
128
|
+
409: z.object({ reason: PoolSetupConflictReason, message: z.string() }),
|
|
129
|
+
422: z.object({ reason: PoolGatewayConfigureReason, message: z.string() }),
|
|
130
|
+
},
|
|
131
|
+
summary: 'Save the gateway configuration and launch its test task',
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=api-to-frontend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-to-frontend.js","sourceRoot":"","sources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