@kb-labs/gateway-contracts 0.2.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/dist/index.d.ts +1645 -0
- package/dist/index.js +417 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/config.ts
|
|
4
|
+
var UpstreamConfigSchema = z.object({
|
|
5
|
+
url: z.string().url(),
|
|
6
|
+
prefix: z.string().startsWith("/"),
|
|
7
|
+
/** Strip prefix before forwarding. Default: keep prefix as-is. Use "" to strip. */
|
|
8
|
+
rewritePrefix: z.string().optional(),
|
|
9
|
+
/** Enable WebSocket proxying for this upstream. Default: false. */
|
|
10
|
+
websocket: z.boolean().optional(),
|
|
11
|
+
/** Paths under this prefix that are NOT proxied (handled by gateway itself). */
|
|
12
|
+
excludePaths: z.array(z.string()).optional(),
|
|
13
|
+
description: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
var StaticTokenEntrySchema = z.object({
|
|
16
|
+
hostId: z.string(),
|
|
17
|
+
namespaceId: z.string()
|
|
18
|
+
});
|
|
19
|
+
var GatewayConfigSchema = z.object({
|
|
20
|
+
port: z.number().default(4e3),
|
|
21
|
+
upstreams: z.record(z.string(), UpstreamConfigSchema).default({}),
|
|
22
|
+
/** Static tokens seeded into ICache at bootstrap — for dev/service tokens before full auth */
|
|
23
|
+
staticTokens: z.record(z.string(), StaticTokenEntrySchema).default({})
|
|
24
|
+
});
|
|
25
|
+
var TraceContextSchema = z.object({
|
|
26
|
+
traceId: z.string(),
|
|
27
|
+
spanId: z.string(),
|
|
28
|
+
parentId: z.string().optional()
|
|
29
|
+
});
|
|
30
|
+
var WorkspaceInfoSchema = z.object({
|
|
31
|
+
workspaceId: z.string(),
|
|
32
|
+
repoFingerprint: z.string().optional(),
|
|
33
|
+
branch: z.string().optional()
|
|
34
|
+
});
|
|
35
|
+
var PluginInfoSchema = z.object({
|
|
36
|
+
id: z.string(),
|
|
37
|
+
version: z.string()
|
|
38
|
+
});
|
|
39
|
+
var HelloMessageSchema = z.object({
|
|
40
|
+
type: z.literal("hello"),
|
|
41
|
+
protocolVersion: z.string(),
|
|
42
|
+
agentVersion: z.string(),
|
|
43
|
+
hostId: z.string().optional(),
|
|
44
|
+
// для reconnect
|
|
45
|
+
capabilities: z.array(z.string()).optional(),
|
|
46
|
+
// адаптеры которые умеет этот хост
|
|
47
|
+
hostType: z.enum(["local", "cloud"]).optional(),
|
|
48
|
+
// Workspace Agent type
|
|
49
|
+
workspaces: z.array(WorkspaceInfoSchema).optional(),
|
|
50
|
+
// advertised workspaces
|
|
51
|
+
plugins: z.array(PluginInfoSchema).optional()
|
|
52
|
+
// installed plugins inventory
|
|
53
|
+
});
|
|
54
|
+
var ConnectedMessageSchema = z.object({
|
|
55
|
+
type: z.literal("connected"),
|
|
56
|
+
protocolVersion: z.string(),
|
|
57
|
+
hostId: z.string(),
|
|
58
|
+
sessionId: z.string()
|
|
59
|
+
});
|
|
60
|
+
var NegotiateMessageSchema = z.object({
|
|
61
|
+
type: z.literal("negotiate"),
|
|
62
|
+
supportedVersions: z.array(z.string())
|
|
63
|
+
});
|
|
64
|
+
var CallMessageSchema = z.object({
|
|
65
|
+
type: z.literal("call"),
|
|
66
|
+
requestId: z.string(),
|
|
67
|
+
adapter: z.string(),
|
|
68
|
+
method: z.string(),
|
|
69
|
+
args: z.array(z.unknown()),
|
|
70
|
+
bulk: z.boolean().optional(),
|
|
71
|
+
// true → BulkRedirect
|
|
72
|
+
trace: TraceContextSchema
|
|
73
|
+
});
|
|
74
|
+
var BulkRedirectMessageSchema = z.object({
|
|
75
|
+
type: z.literal("bulk-redirect"),
|
|
76
|
+
requestId: z.string(),
|
|
77
|
+
uploadUrl: z.string(),
|
|
78
|
+
expiresAt: z.number()
|
|
79
|
+
});
|
|
80
|
+
var ChunkMessageSchema = z.object({
|
|
81
|
+
type: z.literal("chunk"),
|
|
82
|
+
requestId: z.string(),
|
|
83
|
+
data: z.unknown(),
|
|
84
|
+
index: z.number()
|
|
85
|
+
});
|
|
86
|
+
var ResultMessageSchema = z.object({
|
|
87
|
+
type: z.literal("result"),
|
|
88
|
+
requestId: z.string(),
|
|
89
|
+
done: z.literal(true),
|
|
90
|
+
trace: TraceContextSchema.optional()
|
|
91
|
+
});
|
|
92
|
+
var ErrorMessageSchema = z.object({
|
|
93
|
+
type: z.literal("error"),
|
|
94
|
+
requestId: z.string(),
|
|
95
|
+
error: z.object({
|
|
96
|
+
code: z.string(),
|
|
97
|
+
message: z.string(),
|
|
98
|
+
retryable: z.boolean()
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
var HeartbeatMessageSchema = z.object({
|
|
102
|
+
type: z.literal("heartbeat")
|
|
103
|
+
});
|
|
104
|
+
var AckMessageSchema = z.object({
|
|
105
|
+
type: z.literal("ack")
|
|
106
|
+
});
|
|
107
|
+
var ExecutionOutputSchema = z.object({
|
|
108
|
+
type: z.literal("execution:output"),
|
|
109
|
+
requestId: z.string(),
|
|
110
|
+
executionId: z.string(),
|
|
111
|
+
stream: z.enum(["stdout", "stderr"]),
|
|
112
|
+
data: z.string(),
|
|
113
|
+
timestamp: z.number()
|
|
114
|
+
});
|
|
115
|
+
var ExecutionProgressSchema = z.object({
|
|
116
|
+
type: z.literal("execution:progress"),
|
|
117
|
+
requestId: z.string(),
|
|
118
|
+
executionId: z.string(),
|
|
119
|
+
step: z.number().int().nonnegative(),
|
|
120
|
+
total: z.number().int().positive(),
|
|
121
|
+
label: z.string(),
|
|
122
|
+
timestamp: z.number()
|
|
123
|
+
});
|
|
124
|
+
var ExecutionArtifactSchema = z.object({
|
|
125
|
+
type: z.literal("execution:artifact"),
|
|
126
|
+
requestId: z.string(),
|
|
127
|
+
executionId: z.string(),
|
|
128
|
+
name: z.string(),
|
|
129
|
+
mime: z.string(),
|
|
130
|
+
url: z.string(),
|
|
131
|
+
sizeBytes: z.number().optional()
|
|
132
|
+
});
|
|
133
|
+
var ExecutionErrorEventSchema = z.object({
|
|
134
|
+
type: z.literal("execution:error"),
|
|
135
|
+
requestId: z.string(),
|
|
136
|
+
executionId: z.string(),
|
|
137
|
+
code: z.string(),
|
|
138
|
+
message: z.string(),
|
|
139
|
+
retryable: z.boolean(),
|
|
140
|
+
attempt: z.number().int().optional(),
|
|
141
|
+
maxAttempts: z.number().int().optional()
|
|
142
|
+
});
|
|
143
|
+
var ExecutionDoneSchema = z.object({
|
|
144
|
+
type: z.literal("execution:done"),
|
|
145
|
+
requestId: z.string(),
|
|
146
|
+
executionId: z.string(),
|
|
147
|
+
exitCode: z.number().int(),
|
|
148
|
+
durationMs: z.number().int().nonnegative(),
|
|
149
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
150
|
+
});
|
|
151
|
+
var ExecutionRetrySchema = z.object({
|
|
152
|
+
type: z.literal("execution:retry"),
|
|
153
|
+
requestId: z.string(),
|
|
154
|
+
executionId: z.string(),
|
|
155
|
+
attempt: z.number().int().positive(),
|
|
156
|
+
maxAttempts: z.number().int().positive(),
|
|
157
|
+
delayMs: z.number().nonnegative(),
|
|
158
|
+
error: z.string()
|
|
159
|
+
});
|
|
160
|
+
var ExecutionCancelledSchema = z.object({
|
|
161
|
+
type: z.literal("execution:cancelled"),
|
|
162
|
+
requestId: z.string(),
|
|
163
|
+
executionId: z.string(),
|
|
164
|
+
reason: z.enum(["user", "timeout", "disconnect", "system"]),
|
|
165
|
+
durationMs: z.number().int().nonnegative()
|
|
166
|
+
});
|
|
167
|
+
var CancelMessageSchema = z.object({
|
|
168
|
+
type: z.literal("cancel"),
|
|
169
|
+
requestId: z.string(),
|
|
170
|
+
reason: z.enum(["user", "timeout", "disconnect"]).optional()
|
|
171
|
+
});
|
|
172
|
+
var SubscribeMessageSchema = z.object({
|
|
173
|
+
type: z.literal("subscribe"),
|
|
174
|
+
executionId: z.string()
|
|
175
|
+
});
|
|
176
|
+
var UnsubscribeMessageSchema = z.object({
|
|
177
|
+
type: z.literal("unsubscribe"),
|
|
178
|
+
executionId: z.string()
|
|
179
|
+
});
|
|
180
|
+
var SerializedErrorSchema = z.object({
|
|
181
|
+
code: z.string(),
|
|
182
|
+
message: z.string(),
|
|
183
|
+
retryable: z.boolean(),
|
|
184
|
+
details: z.unknown().optional()
|
|
185
|
+
});
|
|
186
|
+
var AdapterCallContextSchema = z.object({
|
|
187
|
+
namespaceId: z.string(),
|
|
188
|
+
hostId: z.string(),
|
|
189
|
+
workspaceId: z.string().optional(),
|
|
190
|
+
environmentId: z.string().optional(),
|
|
191
|
+
executionRequestId: z.string().optional()
|
|
192
|
+
});
|
|
193
|
+
var AdapterNameSchema = z.enum([
|
|
194
|
+
"llm",
|
|
195
|
+
"cache",
|
|
196
|
+
"vectorStore",
|
|
197
|
+
"embeddings",
|
|
198
|
+
"storage",
|
|
199
|
+
"state"
|
|
200
|
+
]);
|
|
201
|
+
var AdapterCallMessageSchema = z.object({
|
|
202
|
+
type: z.literal("adapter:call"),
|
|
203
|
+
requestId: z.string(),
|
|
204
|
+
adapter: AdapterNameSchema,
|
|
205
|
+
method: z.string(),
|
|
206
|
+
args: z.array(z.unknown()),
|
|
207
|
+
timeout: z.number().positive().optional(),
|
|
208
|
+
context: AdapterCallContextSchema
|
|
209
|
+
});
|
|
210
|
+
var AdapterResponseMessageSchema = z.object({
|
|
211
|
+
type: z.literal("adapter:response"),
|
|
212
|
+
requestId: z.string(),
|
|
213
|
+
result: z.unknown()
|
|
214
|
+
});
|
|
215
|
+
var AdapterErrorMessageSchema = z.object({
|
|
216
|
+
type: z.literal("adapter:error"),
|
|
217
|
+
requestId: z.string(),
|
|
218
|
+
error: SerializedErrorSchema
|
|
219
|
+
});
|
|
220
|
+
var AdapterChunkMessageSchema = z.object({
|
|
221
|
+
type: z.literal("adapter:chunk"),
|
|
222
|
+
requestId: z.string(),
|
|
223
|
+
data: z.unknown(),
|
|
224
|
+
index: z.number().int().nonnegative()
|
|
225
|
+
});
|
|
226
|
+
var AdapterCancelMessageSchema = z.object({
|
|
227
|
+
type: z.literal("adapter:cancel"),
|
|
228
|
+
requestId: z.string()
|
|
229
|
+
});
|
|
230
|
+
var ExecuteRequestSchema = z.object({
|
|
231
|
+
pluginId: z.string(),
|
|
232
|
+
handlerRef: z.string(),
|
|
233
|
+
exportName: z.string().optional(),
|
|
234
|
+
input: z.unknown(),
|
|
235
|
+
timeoutMs: z.number().int().positive().optional()
|
|
236
|
+
});
|
|
237
|
+
var SUPPORTED_PROTOCOL_VERSIONS = ["1.0"];
|
|
238
|
+
|
|
239
|
+
// src/host.ts
|
|
240
|
+
var HostCapabilitySchema = z.enum(["filesystem", "git", "editor-context", "execution"]);
|
|
241
|
+
var HostTypeSchema = z.enum(["local", "cloud"]);
|
|
242
|
+
var HostRegistrationSchema = z.object({
|
|
243
|
+
name: z.string(),
|
|
244
|
+
namespaceId: z.string(),
|
|
245
|
+
capabilities: z.array(HostCapabilitySchema),
|
|
246
|
+
workspacePaths: z.array(z.string()),
|
|
247
|
+
hostType: HostTypeSchema.optional()
|
|
248
|
+
});
|
|
249
|
+
var HostStatusSchema = z.enum(["online", "offline", "degraded", "reconnecting"]);
|
|
250
|
+
var HostDescriptorSchema = z.object({
|
|
251
|
+
hostId: z.string(),
|
|
252
|
+
name: z.string(),
|
|
253
|
+
namespaceId: z.string(),
|
|
254
|
+
capabilities: z.array(HostCapabilitySchema),
|
|
255
|
+
status: HostStatusSchema,
|
|
256
|
+
lastSeen: z.number(),
|
|
257
|
+
connections: z.array(z.string()),
|
|
258
|
+
// Workspace Agent metadata (populated from hello message)
|
|
259
|
+
hostType: HostTypeSchema.optional(),
|
|
260
|
+
workspaces: z.array(WorkspaceInfoSchema).optional(),
|
|
261
|
+
plugins: z.array(PluginInfoSchema).optional(),
|
|
262
|
+
// Persistence metadata
|
|
263
|
+
createdAt: z.number().optional(),
|
|
264
|
+
updatedAt: z.number().optional()
|
|
265
|
+
});
|
|
266
|
+
var HostRegisterResponseSchema = z.object({
|
|
267
|
+
hostId: z.string(),
|
|
268
|
+
machineToken: z.string(),
|
|
269
|
+
status: HostStatusSchema
|
|
270
|
+
});
|
|
271
|
+
var TokenTypeSchema = z.enum(["user", "cli", "machine"]);
|
|
272
|
+
var AuthContextSchema = z.object({
|
|
273
|
+
type: TokenTypeSchema,
|
|
274
|
+
userId: z.string(),
|
|
275
|
+
namespaceId: z.string(),
|
|
276
|
+
tier: z.enum(["free", "pro", "enterprise"]),
|
|
277
|
+
permissions: z.array(z.string())
|
|
278
|
+
});
|
|
279
|
+
var RegisterRequestSchema = z.object({
|
|
280
|
+
/** Human-readable name for this agent (e.g. "MacBook Pro") */
|
|
281
|
+
name: z.string().min(1).max(64),
|
|
282
|
+
namespaceId: z.string().min(1).max(64),
|
|
283
|
+
capabilities: z.array(z.string()).default([]),
|
|
284
|
+
/**
|
|
285
|
+
* X25519 public key for E2E encryption, base64url encoded.
|
|
286
|
+
* Generated by the agent; the server stores it for encrypting call payloads.
|
|
287
|
+
*/
|
|
288
|
+
publicKey: z.string().optional()
|
|
289
|
+
});
|
|
290
|
+
var RegisterResponseSchema = z.object({
|
|
291
|
+
clientId: z.string(),
|
|
292
|
+
clientSecret: z.string(),
|
|
293
|
+
hostId: z.string()
|
|
294
|
+
});
|
|
295
|
+
var TokenRequestSchema = z.object({
|
|
296
|
+
clientId: z.string(),
|
|
297
|
+
clientSecret: z.string()
|
|
298
|
+
});
|
|
299
|
+
var TokenResponseSchema = z.object({
|
|
300
|
+
accessToken: z.string(),
|
|
301
|
+
refreshToken: z.string(),
|
|
302
|
+
/** Seconds until accessToken expires */
|
|
303
|
+
expiresIn: z.number(),
|
|
304
|
+
tokenType: z.literal("Bearer")
|
|
305
|
+
});
|
|
306
|
+
var RefreshRequestSchema = z.object({
|
|
307
|
+
refreshToken: z.string()
|
|
308
|
+
});
|
|
309
|
+
var JwtPayloadSchema = z.object({
|
|
310
|
+
sub: z.string(),
|
|
311
|
+
// hostId
|
|
312
|
+
namespaceId: z.string(),
|
|
313
|
+
tier: z.enum(["free", "pro", "enterprise"]),
|
|
314
|
+
type: TokenTypeSchema,
|
|
315
|
+
iat: z.number(),
|
|
316
|
+
exp: z.number()
|
|
317
|
+
});
|
|
318
|
+
var ClientHelloSchema = z.object({
|
|
319
|
+
type: z.literal("client:hello"),
|
|
320
|
+
clientVersion: z.string()
|
|
321
|
+
});
|
|
322
|
+
var ClientSubscribeSchema = z.object({
|
|
323
|
+
type: z.literal("client:subscribe"),
|
|
324
|
+
executionId: z.string().uuid()
|
|
325
|
+
});
|
|
326
|
+
var ClientUnsubscribeSchema = z.object({
|
|
327
|
+
type: z.literal("client:unsubscribe"),
|
|
328
|
+
executionId: z.string().uuid()
|
|
329
|
+
});
|
|
330
|
+
var ClientCancelSchema = z.object({
|
|
331
|
+
type: z.literal("client:cancel"),
|
|
332
|
+
executionId: z.string().uuid(),
|
|
333
|
+
reason: z.enum(["user", "timeout"]).optional()
|
|
334
|
+
});
|
|
335
|
+
var ClientConnectedSchema = z.object({
|
|
336
|
+
type: z.literal("client:connected"),
|
|
337
|
+
protocolVersion: z.string(),
|
|
338
|
+
connectionId: z.string()
|
|
339
|
+
});
|
|
340
|
+
var ClientErrorSchema = z.object({
|
|
341
|
+
type: z.literal("client:error"),
|
|
342
|
+
code: z.enum([
|
|
343
|
+
"EXECUTION_NOT_FOUND",
|
|
344
|
+
"FORBIDDEN",
|
|
345
|
+
"INVALID_MESSAGE",
|
|
346
|
+
"CANCEL_FAILED"
|
|
347
|
+
]),
|
|
348
|
+
message: z.string(),
|
|
349
|
+
executionId: z.string().optional()
|
|
350
|
+
});
|
|
351
|
+
var CLIENT_PROTOCOL_VERSION = "1.0";
|
|
352
|
+
var LLMTierSchema = z.enum(["small", "medium", "large"]);
|
|
353
|
+
var ChatMessageSchema = z.object({
|
|
354
|
+
role: z.enum(["system", "user", "assistant", "tool"]),
|
|
355
|
+
content: z.string(),
|
|
356
|
+
tool_call_id: z.string().optional(),
|
|
357
|
+
tool_calls: z.array(
|
|
358
|
+
z.object({
|
|
359
|
+
id: z.string(),
|
|
360
|
+
type: z.literal("function"),
|
|
361
|
+
function: z.object({
|
|
362
|
+
name: z.string(),
|
|
363
|
+
arguments: z.string()
|
|
364
|
+
// JSON-stringified
|
|
365
|
+
})
|
|
366
|
+
})
|
|
367
|
+
).optional()
|
|
368
|
+
});
|
|
369
|
+
var ChatToolSchema = z.object({
|
|
370
|
+
type: z.literal("function"),
|
|
371
|
+
function: z.object({
|
|
372
|
+
name: z.string(),
|
|
373
|
+
description: z.string().optional(),
|
|
374
|
+
parameters: z.record(z.unknown()).optional()
|
|
375
|
+
})
|
|
376
|
+
});
|
|
377
|
+
var ChatCompletionRequestSchema = z.object({
|
|
378
|
+
/** Tier-based model selector: "small" | "medium" | "large" | "fast" */
|
|
379
|
+
model: LLMTierSchema,
|
|
380
|
+
messages: z.array(ChatMessageSchema).min(1),
|
|
381
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
382
|
+
max_tokens: z.number().int().positive().optional(),
|
|
383
|
+
stop: z.union([z.string(), z.array(z.string())]).optional(),
|
|
384
|
+
stream: z.boolean().optional().default(false),
|
|
385
|
+
tools: z.array(ChatToolSchema).optional(),
|
|
386
|
+
tool_choice: z.union([
|
|
387
|
+
z.enum(["auto", "required", "none"]),
|
|
388
|
+
z.object({
|
|
389
|
+
type: z.literal("function"),
|
|
390
|
+
function: z.object({ name: z.string() })
|
|
391
|
+
})
|
|
392
|
+
]).optional()
|
|
393
|
+
});
|
|
394
|
+
var TelemetryEventSchema = z.object({
|
|
395
|
+
/** Source product/service name (e.g., "my-api", "billing-service") */
|
|
396
|
+
source: z.string().min(1).max(128),
|
|
397
|
+
/** Event type/name using dot notation (e.g., "user.signup", "api.request") */
|
|
398
|
+
type: z.string().min(1).max(256),
|
|
399
|
+
/** ISO 8601 timestamp. Defaults to server ingest time if omitted. */
|
|
400
|
+
timestamp: z.string().datetime().optional(),
|
|
401
|
+
/** Free-form event data. No schema enforced — products decide what to send. */
|
|
402
|
+
payload: z.record(z.unknown()).optional(),
|
|
403
|
+
/** Flat key-value tags for filtering/aggregation (e.g., { env: "prod", region: "eu" }) */
|
|
404
|
+
tags: z.record(z.string()).optional()
|
|
405
|
+
});
|
|
406
|
+
var TelemetryIngestRequestSchema = z.object({
|
|
407
|
+
/** Array of events to ingest (1–500 per batch) */
|
|
408
|
+
events: z.array(TelemetryEventSchema).min(1).max(500)
|
|
409
|
+
});
|
|
410
|
+
var PlatformCallRequestSchema = z.object({
|
|
411
|
+
/** Arguments to pass to the adapter method. Order matters. */
|
|
412
|
+
args: z.array(z.unknown()).default([])
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
export { AckMessageSchema, AdapterCallContextSchema, AdapterCallMessageSchema, AdapterCancelMessageSchema, AdapterChunkMessageSchema, AdapterErrorMessageSchema, AdapterNameSchema, AdapterResponseMessageSchema, AuthContextSchema, BulkRedirectMessageSchema, CLIENT_PROTOCOL_VERSION, CallMessageSchema, CancelMessageSchema, ChatCompletionRequestSchema, ChatMessageSchema, ChatToolSchema, ChunkMessageSchema, ClientCancelSchema, ClientConnectedSchema, ClientErrorSchema, ClientHelloSchema, ClientSubscribeSchema, ClientUnsubscribeSchema, ConnectedMessageSchema, ErrorMessageSchema, ExecuteRequestSchema, ExecutionArtifactSchema, ExecutionCancelledSchema, ExecutionDoneSchema, ExecutionErrorEventSchema, ExecutionOutputSchema, ExecutionProgressSchema, ExecutionRetrySchema, GatewayConfigSchema, HeartbeatMessageSchema, HelloMessageSchema, HostCapabilitySchema, HostDescriptorSchema, HostRegisterResponseSchema, HostRegistrationSchema, HostStatusSchema, HostTypeSchema, JwtPayloadSchema, LLMTierSchema, NegotiateMessageSchema, PlatformCallRequestSchema, PluginInfoSchema, RefreshRequestSchema, RegisterRequestSchema, RegisterResponseSchema, ResultMessageSchema, SUPPORTED_PROTOCOL_VERSIONS, SerializedErrorSchema, StaticTokenEntrySchema, SubscribeMessageSchema, TelemetryEventSchema, TelemetryIngestRequestSchema, TokenRequestSchema, TokenResponseSchema, TokenTypeSchema, TraceContextSchema, UnsubscribeMessageSchema, UpstreamConfigSchema, WorkspaceInfoSchema };
|
|
416
|
+
//# sourceMappingURL=index.js.map
|
|
417
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts","../src/protocol.ts","../src/host.ts","../src/auth.ts","../src/client-protocol.ts","../src/llm-gateway.ts","../src/telemetry.ts","../src/platform-api.ts"],"names":["z"],"mappings":";;;AAEO,IAAM,oBAAA,GAAuB,EAAE,MAAA,CAAO;AAAA,EAC3C,GAAA,EAAK,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI;AAAA,EACpB,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,WAAW,GAAG,CAAA;AAAA;AAAA,EAEjC,aAAA,EAAe,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA,EAEnC,SAAA,EAAW,CAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA;AAAA,EAEhC,cAAc,CAAA,CAAE,KAAA,CAAM,EAAE,MAAA,EAAQ,EAAE,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AAC1B,CAAC;AAEM,IAAM,sBAAA,GAAyB,EAAE,MAAA,CAAO;AAAA,EAC7C,MAAA,EAAQ,EAAE,MAAA,EAAO;AAAA,EACjB,WAAA,EAAa,EAAE,MAAA;AACjB,CAAC;AAEM,IAAM,mBAAA,GAAsB,EAAE,MAAA,CAAO;AAAA,EAC1C,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,QAAQ,GAAI,CAAA;AAAA,EAC7B,SAAA,EAAW,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,IAAU,oBAAoB,CAAA,CAAE,OAAA,CAAQ,EAAE,CAAA;AAAA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AAE,OAAA,CAAQ,EAAE;AACvC,CAAC","file":"index.js","sourcesContent":["import { z } from 'zod';\n\nexport const UpstreamConfigSchema = z.object({\n url: z.string().url(),\n prefix: z.string().startsWith('/'),\n /** Strip prefix before forwarding. Default: keep prefix as-is. Use \"\" to strip. */\n rewritePrefix: z.string().optional(),\n /** Enable WebSocket proxying for this upstream. Default: false. */\n websocket: z.boolean().optional(),\n /** Paths under this prefix that are NOT proxied (handled by gateway itself). */\n excludePaths: z.array(z.string()).optional(),\n description: z.string().optional(),\n});\n\nexport const StaticTokenEntrySchema = z.object({\n hostId: z.string(),\n namespaceId: z.string(),\n});\n\nexport const GatewayConfigSchema = z.object({\n port: z.number().default(4000),\n upstreams: z.record(z.string(), UpstreamConfigSchema).default({}),\n /** Static tokens seeded into ICache at bootstrap — for dev/service tokens before full auth */\n staticTokens: z.record(z.string(), StaticTokenEntrySchema).default({}),\n});\n\nexport type UpstreamConfig = z.infer<typeof UpstreamConfigSchema>;\nexport type GatewayConfig = z.infer<typeof GatewayConfigSchema>;\n","import { z } from 'zod';\n\nexport const TraceContextSchema = z.object({\n traceId: z.string(),\n spanId: z.string(),\n parentId: z.string().optional(),\n});\n\n// Workspace info advertised by host on connect\nexport const WorkspaceInfoSchema = z.object({\n workspaceId: z.string(),\n repoFingerprint: z.string().optional(),\n branch: z.string().optional(),\n});\n\n// Plugin inventory advertised by host on connect\nexport const PluginInfoSchema = z.object({\n id: z.string(),\n version: z.string(),\n});\n\n// Host → Gateway: первое сообщение после подключения\nexport const HelloMessageSchema = z.object({\n type: z.literal('hello'),\n protocolVersion: z.string(),\n agentVersion: z.string(),\n hostId: z.string().optional(), // для reconnect\n capabilities: z.array(z.string()).optional(), // адаптеры которые умеет этот хост\n hostType: z.enum(['local', 'cloud']).optional(), // Workspace Agent type\n workspaces: z.array(WorkspaceInfoSchema).optional(), // advertised workspaces\n plugins: z.array(PluginInfoSchema).optional(), // installed plugins inventory\n});\n\n// Gateway → Host: подтверждение подключения\nexport const ConnectedMessageSchema = z.object({\n type: z.literal('connected'),\n protocolVersion: z.string(),\n hostId: z.string(),\n sessionId: z.string(),\n});\n\n// Gateway → Host: версия несовместима\nexport const NegotiateMessageSchema = z.object({\n type: z.literal('negotiate'),\n supportedVersions: z.array(z.string()),\n});\n\n// Gateway → Host: вызов адаптера\nexport const CallMessageSchema = z.object({\n type: z.literal('call'),\n requestId: z.string(),\n adapter: z.string(),\n method: z.string(),\n args: z.array(z.unknown()),\n bulk: z.boolean().optional(), // true → BulkRedirect\n trace: TraceContextSchema,\n});\n\n// Gateway → Host: redirect для bulk операций (большие файлы)\nexport const BulkRedirectMessageSchema = z.object({\n type: z.literal('bulk-redirect'),\n requestId: z.string(),\n uploadUrl: z.string(),\n expiresAt: z.number(),\n});\n\n// Host → Gateway: чанк данных (стриминг)\nexport const ChunkMessageSchema = z.object({\n type: z.literal('chunk'),\n requestId: z.string(),\n data: z.unknown(),\n index: z.number(),\n});\n\n// Host → Gateway: завершение вызова\nexport const ResultMessageSchema = z.object({\n type: z.literal('result'),\n requestId: z.string(),\n done: z.literal(true),\n trace: TraceContextSchema.optional(),\n});\n\n// Host → Gateway: ошибка при вызове\nexport const ErrorMessageSchema = z.object({\n type: z.literal('error'),\n requestId: z.string(),\n error: z.object({\n code: z.string(),\n message: z.string(),\n retryable: z.boolean(),\n }),\n});\n\n// Host → Gateway: heartbeat\nexport const HeartbeatMessageSchema = z.object({\n type: z.literal('heartbeat'),\n});\n\n// Gateway → Host: ack heartbeat\nexport const AckMessageSchema = z.object({\n type: z.literal('ack'),\n});\n\n// ── Execution event schemas (CC1 — Streaming) ──\n\n// Execution output event (stdout/stderr from handler)\nexport const ExecutionOutputSchema = z.object({\n type: z.literal('execution:output'),\n requestId: z.string(),\n executionId: z.string(),\n stream: z.enum(['stdout', 'stderr']),\n data: z.string(),\n timestamp: z.number(),\n});\n\n// Execution progress event\nexport const ExecutionProgressSchema = z.object({\n type: z.literal('execution:progress'),\n requestId: z.string(),\n executionId: z.string(),\n step: z.number().int().nonnegative(),\n total: z.number().int().positive(),\n label: z.string(),\n timestamp: z.number(),\n});\n\n// Execution artifact event (file created during execution)\nexport const ExecutionArtifactSchema = z.object({\n type: z.literal('execution:artifact'),\n requestId: z.string(),\n executionId: z.string(),\n name: z.string(),\n mime: z.string(),\n url: z.string(),\n sizeBytes: z.number().optional(),\n});\n\n// Execution error event\nexport const ExecutionErrorEventSchema = z.object({\n type: z.literal('execution:error'),\n requestId: z.string(),\n executionId: z.string(),\n code: z.string(),\n message: z.string(),\n retryable: z.boolean(),\n attempt: z.number().int().optional(),\n maxAttempts: z.number().int().optional(),\n});\n\n// Execution done event (final — execution completed)\nexport const ExecutionDoneSchema = z.object({\n type: z.literal('execution:done'),\n requestId: z.string(),\n executionId: z.string(),\n exitCode: z.number().int(),\n durationMs: z.number().int().nonnegative(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\n// Execution retry event (between attempts — CC3)\nexport const ExecutionRetrySchema = z.object({\n type: z.literal('execution:retry'),\n requestId: z.string(),\n executionId: z.string(),\n attempt: z.number().int().positive(),\n maxAttempts: z.number().int().positive(),\n delayMs: z.number().nonnegative(),\n error: z.string(),\n});\n\n// Execution cancelled event\nexport const ExecutionCancelledSchema = z.object({\n type: z.literal('execution:cancelled'),\n requestId: z.string(),\n executionId: z.string(),\n reason: z.enum(['user', 'timeout', 'disconnect', 'system']),\n durationMs: z.number().int().nonnegative(),\n});\n\n// Cancel message: client → Gateway\nexport const CancelMessageSchema = z.object({\n type: z.literal('cancel'),\n requestId: z.string(),\n reason: z.enum(['user', 'timeout', 'disconnect']).optional(),\n});\n\n// Subscribe message: client → Gateway (multi-client pub/sub, CC5)\nexport const SubscribeMessageSchema = z.object({\n type: z.literal('subscribe'),\n executionId: z.string(),\n});\n\n// Unsubscribe message: client → Gateway\nexport const UnsubscribeMessageSchema = z.object({\n type: z.literal('unsubscribe'),\n executionId: z.string(),\n});\n\n// ── Adapter reverse proxy schemas (Workspace Agent → Gateway → Platform) ──\n\n/** Serialized error for adapter:error messages */\nexport const SerializedErrorSchema = z.object({\n code: z.string(),\n message: z.string(),\n retryable: z.boolean(),\n details: z.unknown().optional(),\n});\n\n/** Adapter call context — propagated from host to platform */\nexport const AdapterCallContextSchema = z.object({\n namespaceId: z.string(),\n hostId: z.string(),\n workspaceId: z.string().optional(),\n environmentId: z.string().optional(),\n executionRequestId: z.string().optional(),\n});\n\n/** Allowed adapter names for reverse proxy */\nexport const AdapterNameSchema = z.enum([\n 'llm',\n 'cache',\n 'vectorStore',\n 'embeddings',\n 'storage',\n 'state',\n]);\n\n// Host → Gateway: вызов platform adapter (reverse proxy)\nexport const AdapterCallMessageSchema = z.object({\n type: z.literal('adapter:call'),\n requestId: z.string(),\n adapter: AdapterNameSchema,\n method: z.string(),\n args: z.array(z.unknown()),\n timeout: z.number().positive().optional(),\n context: AdapterCallContextSchema,\n});\n\n// Gateway → Host: успешный ответ на adapter:call\nexport const AdapterResponseMessageSchema = z.object({\n type: z.literal('adapter:response'),\n requestId: z.string(),\n result: z.unknown(),\n});\n\n// Gateway → Host: ошибка при adapter:call\nexport const AdapterErrorMessageSchema = z.object({\n type: z.literal('adapter:error'),\n requestId: z.string(),\n error: SerializedErrorSchema,\n});\n\n// Gateway → Host: streaming chunk для adapter:call (Phase 2+)\nexport const AdapterChunkMessageSchema = z.object({\n type: z.literal('adapter:chunk'),\n requestId: z.string(),\n data: z.unknown(),\n index: z.number().int().nonnegative(),\n});\n\n// Host → Gateway: cancel in-flight adapter:call (Phase 2+)\nexport const AdapterCancelMessageSchema = z.object({\n type: z.literal('adapter:cancel'),\n requestId: z.string(),\n});\n\n// ── Execute request schema (for POST /api/v1/execute) ──\n\nexport const ExecuteRequestSchema = z.object({\n pluginId: z.string(),\n handlerRef: z.string(),\n exportName: z.string().optional(),\n input: z.unknown(),\n timeoutMs: z.number().int().positive().optional(),\n});\n\nexport const SUPPORTED_PROTOCOL_VERSIONS = ['1.0'] as const;\n\nexport type TraceContext = z.infer<typeof TraceContextSchema>;\nexport type HelloMessage = z.infer<typeof HelloMessageSchema>;\nexport type ConnectedMessage = z.infer<typeof ConnectedMessageSchema>;\nexport type NegotiateMessage = z.infer<typeof NegotiateMessageSchema>;\nexport type CallMessage = z.infer<typeof CallMessageSchema>;\nexport type BulkRedirectMessage = z.infer<typeof BulkRedirectMessageSchema>;\nexport type ChunkMessage = z.infer<typeof ChunkMessageSchema>;\nexport type ResultMessage = z.infer<typeof ResultMessageSchema>;\nexport type ErrorMessage = z.infer<typeof ErrorMessageSchema>;\nexport type HeartbeatMessage = z.infer<typeof HeartbeatMessageSchema>;\nexport type AckMessage = z.infer<typeof AckMessageSchema>;\nexport type ExecutionOutputMessage = z.infer<typeof ExecutionOutputSchema>;\nexport type ExecutionProgressMessage = z.infer<typeof ExecutionProgressSchema>;\nexport type ExecutionArtifactMessage = z.infer<typeof ExecutionArtifactSchema>;\nexport type ExecutionErrorEventMessage = z.infer<typeof ExecutionErrorEventSchema>;\nexport type ExecutionDoneMessage = z.infer<typeof ExecutionDoneSchema>;\nexport type ExecutionRetryMessage = z.infer<typeof ExecutionRetrySchema>;\nexport type ExecutionCancelledMessage = z.infer<typeof ExecutionCancelledSchema>;\nexport type CancelMessage = z.infer<typeof CancelMessageSchema>;\nexport type SubscribeMessage = z.infer<typeof SubscribeMessageSchema>;\nexport type UnsubscribeMessage = z.infer<typeof UnsubscribeMessageSchema>;\nexport type ExecuteRequest = z.infer<typeof ExecuteRequestSchema>;\nexport type WorkspaceInfo = z.infer<typeof WorkspaceInfoSchema>;\nexport type PluginInfo = z.infer<typeof PluginInfoSchema>;\nexport type SerializedError = z.infer<typeof SerializedErrorSchema>;\nexport type AdapterCallContext = z.infer<typeof AdapterCallContextSchema>;\nexport type AdapterName = z.infer<typeof AdapterNameSchema>;\nexport type AdapterCallMessage = z.infer<typeof AdapterCallMessageSchema>;\nexport type AdapterResponseMessage = z.infer<typeof AdapterResponseMessageSchema>;\nexport type AdapterErrorMessage = z.infer<typeof AdapterErrorMessageSchema>;\nexport type AdapterChunkMessage = z.infer<typeof AdapterChunkMessageSchema>;\nexport type AdapterCancelMessage = z.infer<typeof AdapterCancelMessageSchema>;\n\nexport type ExecutionEventMessage =\n | ExecutionOutputMessage\n | ExecutionProgressMessage\n | ExecutionArtifactMessage\n | ExecutionErrorEventMessage\n | ExecutionDoneMessage\n | ExecutionRetryMessage\n | ExecutionCancelledMessage;\n\nexport type InboundMessage =\n | HelloMessage\n | HeartbeatMessage\n | ChunkMessage\n | ResultMessage\n | ErrorMessage\n | CancelMessage\n | SubscribeMessage\n | UnsubscribeMessage\n | AdapterCallMessage\n | AdapterCancelMessage;\n\nexport type OutboundMessage =\n | ConnectedMessage\n | NegotiateMessage\n | CallMessage\n | BulkRedirectMessage\n | AckMessage\n | ExecutionOutputMessage\n | ExecutionProgressMessage\n | ExecutionArtifactMessage\n | ExecutionErrorEventMessage\n | ExecutionDoneMessage\n | AdapterResponseMessage\n | AdapterErrorMessage\n | AdapterChunkMessage;\n","import { z } from 'zod';\nimport { WorkspaceInfoSchema, PluginInfoSchema } from './protocol.js';\n\nexport const HostCapabilitySchema = z.enum(['filesystem', 'git', 'editor-context', 'execution']);\n\nexport const HostTypeSchema = z.enum(['local', 'cloud']);\n\nexport const HostRegistrationSchema = z.object({\n name: z.string(),\n namespaceId: z.string(),\n capabilities: z.array(HostCapabilitySchema),\n workspacePaths: z.array(z.string()),\n hostType: HostTypeSchema.optional(),\n});\n\nexport const HostStatusSchema = z.enum(['online', 'offline', 'degraded', 'reconnecting']);\n\nexport const HostDescriptorSchema = z.object({\n hostId: z.string(),\n name: z.string(),\n namespaceId: z.string(),\n capabilities: z.array(HostCapabilitySchema),\n status: HostStatusSchema,\n lastSeen: z.number(),\n connections: z.array(z.string()),\n // Workspace Agent metadata (populated from hello message)\n hostType: HostTypeSchema.optional(),\n workspaces: z.array(WorkspaceInfoSchema).optional(),\n plugins: z.array(PluginInfoSchema).optional(),\n // Persistence metadata\n createdAt: z.number().optional(),\n updatedAt: z.number().optional(),\n});\n\nexport const HostRegisterResponseSchema = z.object({\n hostId: z.string(),\n machineToken: z.string(),\n status: HostStatusSchema,\n});\n\nexport type HostStatus = z.infer<typeof HostStatusSchema>;\nexport type HostCapability = z.infer<typeof HostCapabilitySchema>;\nexport type HostType = z.infer<typeof HostTypeSchema>;\nexport type HostRegistration = z.infer<typeof HostRegistrationSchema>;\nexport type HostDescriptor = z.infer<typeof HostDescriptorSchema>;\nexport type HostRegisterResponse = z.infer<typeof HostRegisterResponseSchema>;\n\n/**\n * Durable host storage abstraction.\n *\n * Implementations persist host descriptors and tokens across restarts.\n * The registry uses this as the \"cold\" layer while ICache serves as \"hot\" layer.\n */\nexport interface IHostStore {\n /** Persist or update a host descriptor. */\n save(descriptor: HostDescriptor): Promise<void>;\n\n /** Retrieve a host by id + namespace. */\n get(hostId: string, namespaceId: string): Promise<HostDescriptor | null>;\n\n /** List all hosts in a namespace. */\n list(namespaceId: string): Promise<HostDescriptor[]>;\n\n /** List all hosts across all namespaces. */\n listAll(): Promise<HostDescriptor[]>;\n\n /** Remove a host. Returns true if it existed. */\n delete(hostId: string, namespaceId: string): Promise<boolean>;\n\n /** Persist a machine token → host mapping. */\n saveToken(token: string, hostId: string, namespaceId: string): Promise<void>;\n\n /** Resolve a machine token to its host. */\n resolveToken(token: string): Promise<{ hostId: string; namespaceId: string } | null>;\n\n /** Remove a machine token. */\n deleteToken(token: string): Promise<void>;\n}\n","import { z } from 'zod';\n\nexport const TokenTypeSchema = z.enum(['user', 'cli', 'machine']);\n\nexport const AuthContextSchema = z.object({\n type: TokenTypeSchema,\n userId: z.string(),\n namespaceId: z.string(),\n tier: z.enum(['free', 'pro', 'enterprise']),\n permissions: z.array(z.string()),\n});\n\nexport type TokenType = z.infer<typeof TokenTypeSchema>;\nexport type AuthContext = z.infer<typeof AuthContextSchema>;\n\n// ── JWT / Auth service contracts ─────────────────────────────────────────────\n\nexport const RegisterRequestSchema = z.object({\n /** Human-readable name for this agent (e.g. \"MacBook Pro\") */\n name: z.string().min(1).max(64),\n namespaceId: z.string().min(1).max(64),\n capabilities: z.array(z.string()).default([]),\n /**\n * X25519 public key for E2E encryption, base64url encoded.\n * Generated by the agent; the server stores it for encrypting call payloads.\n */\n publicKey: z.string().optional(),\n});\n\nexport const RegisterResponseSchema = z.object({\n clientId: z.string(),\n clientSecret: z.string(),\n hostId: z.string(),\n});\n\nexport const TokenRequestSchema = z.object({\n clientId: z.string(),\n clientSecret: z.string(),\n});\n\nexport const TokenResponseSchema = z.object({\n accessToken: z.string(),\n refreshToken: z.string(),\n /** Seconds until accessToken expires */\n expiresIn: z.number(),\n tokenType: z.literal('Bearer'),\n});\n\nexport const RefreshRequestSchema = z.object({\n refreshToken: z.string(),\n});\n\n/** JWT payload (sub = hostId) */\nexport const JwtPayloadSchema = z.object({\n sub: z.string(), // hostId\n namespaceId: z.string(),\n tier: z.enum(['free', 'pro', 'enterprise']),\n type: TokenTypeSchema,\n iat: z.number(),\n exp: z.number(),\n});\n\nexport type RegisterRequest = z.infer<typeof RegisterRequestSchema>;\nexport type RegisterResponse = z.infer<typeof RegisterResponseSchema>;\nexport type TokenRequest = z.infer<typeof TokenRequestSchema>;\nexport type TokenResponse = z.infer<typeof TokenResponseSchema>;\nexport type RefreshRequest = z.infer<typeof RefreshRequestSchema>;\nexport type JwtPayload = z.infer<typeof JwtPayloadSchema>;\n","/**\n * @module gateway-contracts/client-protocol\n *\n * WS protocol for observer clients (CLI, Studio, IDE).\n * Endpoint: /clients/connect\n *\n * Separate from host-protocol (protocol.ts) — clients observe executions,\n * they don't serve adapter calls.\n *\n * Client → Gateway inbound messages:\n * - client:hello — handshake\n * - client:subscribe — subscribe to execution events\n * - client:unsubscribe\n * - client:cancel — cancel an execution (convenience, same as POST /execute/:id/cancel)\n *\n * Gateway → Client outbound messages:\n * - client:connected — handshake ack\n * - execution:output — (reused from protocol.ts ExecutionEventMessage)\n * - execution:progress\n * - execution:artifact\n * - execution:error\n * - execution:done\n * - client:error — protocol-level error (bad subscribe, not found, etc.)\n */\n\nimport { z } from 'zod';\nimport type { ExecutionEventMessage } from './protocol.js';\n\n// ── Inbound (Client → Gateway) ────────────────────────────────────────────────\n\nexport const ClientHelloSchema = z.object({\n type: z.literal('client:hello'),\n clientVersion: z.string(),\n});\n\nexport const ClientSubscribeSchema = z.object({\n type: z.literal('client:subscribe'),\n executionId: z.string().uuid(),\n});\n\nexport const ClientUnsubscribeSchema = z.object({\n type: z.literal('client:unsubscribe'),\n executionId: z.string().uuid(),\n});\n\nexport const ClientCancelSchema = z.object({\n type: z.literal('client:cancel'),\n executionId: z.string().uuid(),\n reason: z.enum(['user', 'timeout']).optional(),\n});\n\n// ── Outbound (Gateway → Client) ───────────────────────────────────────────────\n\nexport const ClientConnectedSchema = z.object({\n type: z.literal('client:connected'),\n protocolVersion: z.string(),\n connectionId: z.string(),\n});\n\nexport const ClientErrorSchema = z.object({\n type: z.literal('client:error'),\n code: z.enum([\n 'EXECUTION_NOT_FOUND',\n 'FORBIDDEN',\n 'INVALID_MESSAGE',\n 'CANCEL_FAILED',\n ]),\n message: z.string(),\n executionId: z.string().optional(),\n});\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type ClientHello = z.infer<typeof ClientHelloSchema>;\nexport type ClientSubscribe = z.infer<typeof ClientSubscribeSchema>;\nexport type ClientUnsubscribe = z.infer<typeof ClientUnsubscribeSchema>;\nexport type ClientCancel = z.infer<typeof ClientCancelSchema>;\nexport type ClientConnected = z.infer<typeof ClientConnectedSchema>;\nexport type ClientError = z.infer<typeof ClientErrorSchema>;\n\nexport type ClientInboundMessage =\n | ClientHello\n | ClientSubscribe\n | ClientUnsubscribe\n | ClientCancel;\n\nexport type ClientOutboundMessage =\n | ClientConnected\n | ClientError\n | ExecutionEventMessage;\n\nexport const CLIENT_PROTOCOL_VERSION = '1.0';\n","/**\n * @module @kb-labs/gateway-contracts/llm-gateway\n * OpenAI-compatible AI Gateway schemas and types.\n *\n * Clients interact using OpenAI ChatCompletion format, but `model` field\n * is a tier abstraction (small/medium/large/fast), NOT a literal model name.\n * The platform resolves the tier to a concrete provider + model via LLMRouter config.\n */\nimport { z } from 'zod';\n\n// ── Request ─────────────────────────────────────────────────────────────────\n\n/** Tier-based model selector. Clients never specify a concrete model. */\nexport const LLMTierSchema = z.enum(['small', 'medium', 'large']);\n\nexport const ChatMessageSchema = z.object({\n role: z.enum(['system', 'user', 'assistant', 'tool']),\n content: z.string(),\n tool_call_id: z.string().optional(),\n tool_calls: z\n .array(\n z.object({\n id: z.string(),\n type: z.literal('function'),\n function: z.object({\n name: z.string(),\n arguments: z.string(), // JSON-stringified\n }),\n }),\n )\n .optional(),\n});\n\nexport const ChatToolSchema = z.object({\n type: z.literal('function'),\n function: z.object({\n name: z.string(),\n description: z.string().optional(),\n parameters: z.record(z.unknown()).optional(),\n }),\n});\n\nexport const ChatCompletionRequestSchema = z.object({\n /** Tier-based model selector: \"small\" | \"medium\" | \"large\" | \"fast\" */\n model: LLMTierSchema,\n messages: z.array(ChatMessageSchema).min(1),\n temperature: z.number().min(0).max(2).optional(),\n max_tokens: z.number().int().positive().optional(),\n stop: z.union([z.string(), z.array(z.string())]).optional(),\n stream: z.boolean().optional().default(false),\n tools: z.array(ChatToolSchema).optional(),\n tool_choice: z\n .union([\n z.enum(['auto', 'required', 'none']),\n z.object({\n type: z.literal('function'),\n function: z.object({ name: z.string() }),\n }),\n ])\n .optional(),\n});\n\nexport type ChatCompletionRequest = z.infer<typeof ChatCompletionRequestSchema>;\n\n// ── Response ────────────────────────────────────────────────────────────────\n\nexport interface ChatCompletionChoice {\n index: number;\n message: {\n role: 'assistant';\n content: string | null;\n tool_calls?: Array<{\n id: string;\n type: 'function';\n function: { name: string; arguments: string };\n }>;\n };\n finish_reason: 'stop' | 'tool_calls' | 'length' | null;\n}\n\nexport interface ChatCompletionUsage {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n}\n\nexport interface ChatCompletionResponse {\n id: string;\n object: 'chat.completion';\n created: number;\n /** Returns the tier used, not the concrete model (abstraction preserved) */\n model: string;\n choices: ChatCompletionChoice[];\n usage: ChatCompletionUsage;\n}\n\n// ── Streaming ───────────────────────────────────────────────────────────────\n\nexport interface ChatCompletionChunkDelta {\n role?: 'assistant';\n content?: string | null;\n tool_calls?: Array<{\n index: number;\n id?: string;\n type?: 'function';\n function?: { name?: string; arguments?: string };\n }>;\n}\n\nexport interface ChatCompletionChunk {\n id: string;\n object: 'chat.completion.chunk';\n created: number;\n model: string;\n choices: Array<{\n index: number;\n delta: ChatCompletionChunkDelta;\n finish_reason: 'stop' | 'tool_calls' | 'length' | null;\n }>;\n}\n","/**\n * @module @kb-labs/gateway-contracts/telemetry\n * Telemetry ingestion schemas for the AI Gateway.\n *\n * External products send events through `POST /telemetry/v1/ingest`.\n * Events are written to platform analytics (SQLite/DuckDB/File) via IAnalytics.track().\n *\n * Schema is intentionally minimal — `payload` is free-form.\n * Platform provides recommended presets but does not enforce them.\n */\nimport { z } from 'zod';\n\n// ── Single event ────────────────────────────────────────────────────────────\n\nexport const TelemetryEventSchema = z.object({\n /** Source product/service name (e.g., \"my-api\", \"billing-service\") */\n source: z.string().min(1).max(128),\n /** Event type/name using dot notation (e.g., \"user.signup\", \"api.request\") */\n type: z.string().min(1).max(256),\n /** ISO 8601 timestamp. Defaults to server ingest time if omitted. */\n timestamp: z.string().datetime().optional(),\n /** Free-form event data. No schema enforced — products decide what to send. */\n payload: z.record(z.unknown()).optional(),\n /** Flat key-value tags for filtering/aggregation (e.g., { env: \"prod\", region: \"eu\" }) */\n tags: z.record(z.string()).optional(),\n});\n\nexport type TelemetryEvent = z.infer<typeof TelemetryEventSchema>;\n\n// ── Batch ingestion request ─────────────────────────────────────────────────\n\nexport const TelemetryIngestRequestSchema = z.object({\n /** Array of events to ingest (1–500 per batch) */\n events: z.array(TelemetryEventSchema).min(1).max(500),\n});\n\nexport type TelemetryIngestRequest = z.infer<typeof TelemetryIngestRequestSchema>;\n\n// ── Ingestion response ──────────────────────────────────────────────────────\n\nexport interface TelemetryIngestResponse {\n /** Number of events accepted */\n accepted: number;\n /** Number of events rejected (validation errors) */\n rejected: number;\n /** Errors for rejected events, if any */\n errors?: Array<{ index: number; message: string }>;\n}\n","/**\n * @module @kb-labs/gateway-contracts/platform-api\n * Unified Platform API — single dispatch endpoint for any adapter.\n *\n * Route: POST /platform/v1/{adapter}/{method}\n * Adapter and method come from URL params; args come from the request body.\n */\nimport { z } from 'zod';\n\n// ── Request ─────────────────────────────────────────────────────────────────\n\nexport const PlatformCallRequestSchema = z.object({\n /** Arguments to pass to the adapter method. Order matters. */\n args: z.array(z.unknown()).default([]),\n});\n\nexport type PlatformCallRequest = z.infer<typeof PlatformCallRequestSchema>;\n\n// ── Response ────────────────────────────────────────────────────────────────\n\nexport interface PlatformCallResponse {\n ok: boolean;\n result?: unknown;\n error?: { message: string; code?: string };\n /** Wall-clock duration of the adapter call in milliseconds. */\n durationMs: number;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kb-labs/gateway-contracts",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rimraf dist",
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"dev": "tsup --watch",
|
|
22
|
+
"type-check": "tsc --noEmit",
|
|
23
|
+
"lint": "eslint .",
|
|
24
|
+
"lint:fix": "eslint . --fix",
|
|
25
|
+
"test": "vitest run -c ../../vitest.config.ts",
|
|
26
|
+
"test:watch": "vitest -c ../../vitest.config.ts"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"zod": "^3.23.8"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@kb-labs/devkit": "link:../../../kb-labs-devkit",
|
|
33
|
+
"tsup": "^8.5.0",
|
|
34
|
+
"vitest": "^3.2.4"
|
|
35
|
+
}
|
|
36
|
+
}
|