@clearideas/agent-runtime-server 0.0.0-stage → 0.10.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.
@@ -0,0 +1,350 @@
1
+ import { z } from "zod";
2
+ export declare const SERVER_CONFIG_SCHEMA_VERSION: "1.0";
3
+ /** Server configuration files discovered in the working directory, in order. */
4
+ export declare const SERVER_CONFIG_FILE_NAMES: readonly ["agent-runtime.server.yaml", "agent-runtime.server.yml", "agent-runtime.server.json"];
5
+ /** Parse `250ms`, `15s`, `5m`, `1h`, `7d`, or a number of milliseconds. */
6
+ export declare const parseDuration: (value: number | string) => number;
7
+ /** An OpenAI model id: letters, digits, and `.`, `_`, `-`, `:`, `/`. */
8
+ export declare const servedModelNameSchema: z.ZodString;
9
+ declare const keyValueStoreSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
10
+ driver: z.ZodLiteral<"memory">;
11
+ maxEntries: z.ZodDefault<z.ZodNumber>;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ driver: z.ZodLiteral<"sqlite">;
14
+ path: z.ZodString;
15
+ }, z.core.$strict>], "driver">;
16
+ export type KeyValueStoreConfig = z.infer<typeof keyValueStoreSchema>;
17
+ /** Where one variable of a run gets its value from a chat request. */
18
+ declare const inputSourceSchema: z.ZodUnion<readonly [z.ZodEnum<{
19
+ client: "client";
20
+ json: "json";
21
+ "last-user": "last-user";
22
+ system: "system";
23
+ transcript: "transcript";
24
+ }>, z.ZodObject<{
25
+ source: z.ZodLiteral<"last-user">;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ source: z.ZodLiteral<"transcript">;
28
+ maxMessages: z.ZodOptional<z.ZodNumber>;
29
+ }, z.core.$strict>, z.ZodObject<{
30
+ source: z.ZodLiteral<"system">;
31
+ }, z.core.$strict>, z.ZodObject<{
32
+ source: z.ZodLiteral<"json">;
33
+ key: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strict>, z.ZodObject<{
35
+ source: z.ZodLiteral<"client">;
36
+ key: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strict>]>;
38
+ export type InputSourceConfig = z.infer<typeof inputSourceSchema>;
39
+ /** A normalized input mapping entry. */
40
+ export type InputMapping = {
41
+ variable: string;
42
+ source: "last-user";
43
+ } | {
44
+ variable: string;
45
+ source: "transcript";
46
+ maxMessages?: number;
47
+ } | {
48
+ variable: string;
49
+ source: "system";
50
+ } | {
51
+ variable: string;
52
+ source: "json";
53
+ key: string;
54
+ } | {
55
+ variable: string;
56
+ source: "client";
57
+ key: string;
58
+ };
59
+ export declare const normalizeInputMapping: (variable: string, source: InputSourceConfig) => InputMapping;
60
+ export declare const servedModelConfigSchema: z.ZodObject<{
61
+ name: z.ZodString;
62
+ manifest: z.ZodString;
63
+ description: z.ZodOptional<z.ZodString>;
64
+ clientInstructions: z.ZodDefault<z.ZodString>;
65
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
66
+ client: "client";
67
+ json: "json";
68
+ "last-user": "last-user";
69
+ system: "system";
70
+ transcript: "transcript";
71
+ }>, z.ZodObject<{
72
+ source: z.ZodLiteral<"last-user">;
73
+ }, z.core.$strict>, z.ZodObject<{
74
+ source: z.ZodLiteral<"transcript">;
75
+ maxMessages: z.ZodOptional<z.ZodNumber>;
76
+ }, z.core.$strict>, z.ZodObject<{
77
+ source: z.ZodLiteral<"system">;
78
+ }, z.core.$strict>, z.ZodObject<{
79
+ source: z.ZodLiteral<"json">;
80
+ key: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strict>, z.ZodObject<{
82
+ source: z.ZodLiteral<"client">;
83
+ key: z.ZodOptional<z.ZodString>;
84
+ }, z.core.$strict>]>>>;
85
+ output: z.ZodDefault<z.ZodObject<{
86
+ from: z.ZodDefault<z.ZodString>;
87
+ }, z.core.$strict>>;
88
+ stream: z.ZodDefault<z.ZodObject<{
89
+ mode: z.ZodDefault<z.ZodEnum<{
90
+ auto: "auto";
91
+ committed: "committed";
92
+ live: "live";
93
+ }>>;
94
+ progress: z.ZodDefault<z.ZodEnum<{
95
+ none: "none";
96
+ status: "status";
97
+ }>>;
98
+ reasoning: z.ZodDefault<z.ZodEnum<{
99
+ "answer-step": "answer-step";
100
+ none: "none";
101
+ }>>;
102
+ progressField: z.ZodDefault<z.ZodEnum<{
103
+ reasoning: "reasoning";
104
+ reasoning_content: "reasoning_content";
105
+ }>>;
106
+ }, z.core.$strict>>;
107
+ budget: z.ZodOptional<z.ZodObject<{
108
+ maxTotalTokens: z.ZodNumber;
109
+ }, z.core.$strict>>;
110
+ execution: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown>>>;
111
+ policies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
112
+ enforcedPolicies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
113
+ limits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
114
+ enforcedLimits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
115
+ onDisconnect: z.ZodDefault<z.ZodEnum<{
116
+ cancel: "cancel";
117
+ continue: "continue";
118
+ }>>;
119
+ maxTokens: z.ZodDefault<z.ZodEnum<{
120
+ budget: "budget";
121
+ ignore: "ignore";
122
+ }>>;
123
+ clientTools: z.ZodDefault<z.ZodEnum<{
124
+ ignore: "ignore";
125
+ reject: "reject";
126
+ }>>;
127
+ }, z.core.$strict>;
128
+ export type ServedModelConfig = z.infer<typeof servedModelConfigSchema>;
129
+ declare const apiKeySchema: z.ZodObject<{
130
+ id: z.ZodString;
131
+ key: z.ZodUnion<readonly [z.ZodObject<{
132
+ env: z.ZodString;
133
+ }, z.core.$strict>, z.ZodObject<{
134
+ sha256: z.ZodString;
135
+ }, z.core.$strict>]>;
136
+ models: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
137
+ maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
138
+ maxTotalTokensPerRequest: z.ZodOptional<z.ZodNumber>;
139
+ }, z.core.$strict>;
140
+ export type ApiKeyConfig = z.infer<typeof apiKeySchema>;
141
+ export declare const serverConfigSchema: z.ZodObject<{
142
+ version: z.ZodLiteral<"1.0">;
143
+ server: z.ZodDefault<z.ZodObject<{
144
+ host: z.ZodDefault<z.ZodString>;
145
+ port: z.ZodDefault<z.ZodNumber>;
146
+ maxRequestBytes: z.ZodDefault<z.ZodNumber>;
147
+ requestTimeoutMs: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>>;
148
+ shutdownGraceMs: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>>;
149
+ heartbeatMs: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>>;
150
+ maxConcurrentRuns: z.ZodDefault<z.ZodNumber>;
151
+ maxQueuedRequests: z.ZodDefault<z.ZodNumber>;
152
+ queueTimeoutMs: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>>;
153
+ cors: z.ZodDefault<z.ZodObject<{
154
+ origins: z.ZodDefault<z.ZodArray<z.ZodString>>;
155
+ }, z.core.$strict>>;
156
+ exposeErrors: z.ZodDefault<z.ZodBoolean>;
157
+ allowUnauthenticated: z.ZodDefault<z.ZodBoolean>;
158
+ }, z.core.$strict>>;
159
+ runtimeConfig: z.ZodOptional<z.ZodString>;
160
+ runtimeModule: z.ZodOptional<z.ZodString>;
161
+ store: z.ZodDefault<z.ZodObject<{
162
+ driver: z.ZodDefault<z.ZodEnum<{
163
+ memory: "memory";
164
+ module: "module";
165
+ sqlite: "sqlite";
166
+ }>>;
167
+ path: z.ZodOptional<z.ZodString>;
168
+ retention: z.ZodDefault<z.ZodObject<{
169
+ completed: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>>;
170
+ failed: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>>;
171
+ }, z.core.$strict>>;
172
+ }, z.core.$strict>>;
173
+ artifacts: z.ZodDefault<z.ZodObject<{
174
+ path: z.ZodOptional<z.ZodString>;
175
+ }, z.core.$strict>>;
176
+ stores: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
177
+ driver: z.ZodLiteral<"memory">;
178
+ maxEntries: z.ZodDefault<z.ZodNumber>;
179
+ }, z.core.$strict>, z.ZodObject<{
180
+ driver: z.ZodLiteral<"sqlite">;
181
+ path: z.ZodString;
182
+ }, z.core.$strict>], "driver">>>;
183
+ conversations: z.ZodDefault<z.ZodObject<{
184
+ ledger: z.ZodDefault<z.ZodObject<{
185
+ store: z.ZodDefault<z.ZodString>;
186
+ ttl: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>>;
187
+ }, z.core.$strict>>;
188
+ scope: z.ZodDefault<z.ZodObject<{
189
+ includeUser: z.ZodDefault<z.ZodBoolean>;
190
+ }, z.core.$strict>>;
191
+ match: z.ZodDefault<z.ZodEnum<{
192
+ exact: "exact";
193
+ "user-turns": "user-turns";
194
+ }>>;
195
+ onUnrecognized: z.ZodOptional<z.ZodEnum<{
196
+ reject: "reject";
197
+ restart: "restart";
198
+ unsigned: "unsigned";
199
+ }>>;
200
+ onManifestChange: z.ZodDefault<z.ZodEnum<{
201
+ continue: "continue";
202
+ restart: "restart";
203
+ }>>;
204
+ media: z.ZodDefault<z.ZodObject<{
205
+ urls: z.ZodDefault<z.ZodEnum<{
206
+ allow: "allow";
207
+ reject: "reject";
208
+ }>>;
209
+ allowOrigins: z.ZodDefault<z.ZodArray<z.ZodURL>>;
210
+ }, z.core.$strict>>;
211
+ }, z.core.$strict>>;
212
+ auth: z.ZodDefault<z.ZodObject<{
213
+ apiKeys: z.ZodDefault<z.ZodArray<z.ZodObject<{
214
+ id: z.ZodString;
215
+ key: z.ZodUnion<readonly [z.ZodObject<{
216
+ env: z.ZodString;
217
+ }, z.core.$strict>, z.ZodObject<{
218
+ sha256: z.ZodString;
219
+ }, z.core.$strict>]>;
220
+ models: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
221
+ maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
222
+ maxTotalTokensPerRequest: z.ZodOptional<z.ZodNumber>;
223
+ }, z.core.$strict>>>;
224
+ }, z.core.$strict>>;
225
+ models: z.ZodArray<z.ZodObject<{
226
+ name: z.ZodString;
227
+ manifest: z.ZodString;
228
+ description: z.ZodOptional<z.ZodString>;
229
+ clientInstructions: z.ZodDefault<z.ZodString>;
230
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
231
+ client: "client";
232
+ json: "json";
233
+ "last-user": "last-user";
234
+ system: "system";
235
+ transcript: "transcript";
236
+ }>, z.ZodObject<{
237
+ source: z.ZodLiteral<"last-user">;
238
+ }, z.core.$strict>, z.ZodObject<{
239
+ source: z.ZodLiteral<"transcript">;
240
+ maxMessages: z.ZodOptional<z.ZodNumber>;
241
+ }, z.core.$strict>, z.ZodObject<{
242
+ source: z.ZodLiteral<"system">;
243
+ }, z.core.$strict>, z.ZodObject<{
244
+ source: z.ZodLiteral<"json">;
245
+ key: z.ZodOptional<z.ZodString>;
246
+ }, z.core.$strict>, z.ZodObject<{
247
+ source: z.ZodLiteral<"client">;
248
+ key: z.ZodOptional<z.ZodString>;
249
+ }, z.core.$strict>]>>>;
250
+ output: z.ZodDefault<z.ZodObject<{
251
+ from: z.ZodDefault<z.ZodString>;
252
+ }, z.core.$strict>>;
253
+ stream: z.ZodDefault<z.ZodObject<{
254
+ mode: z.ZodDefault<z.ZodEnum<{
255
+ auto: "auto";
256
+ committed: "committed";
257
+ live: "live";
258
+ }>>;
259
+ progress: z.ZodDefault<z.ZodEnum<{
260
+ none: "none";
261
+ status: "status";
262
+ }>>;
263
+ reasoning: z.ZodDefault<z.ZodEnum<{
264
+ "answer-step": "answer-step";
265
+ none: "none";
266
+ }>>;
267
+ progressField: z.ZodDefault<z.ZodEnum<{
268
+ reasoning: "reasoning";
269
+ reasoning_content: "reasoning_content";
270
+ }>>;
271
+ }, z.core.$strict>>;
272
+ budget: z.ZodOptional<z.ZodObject<{
273
+ maxTotalTokens: z.ZodNumber;
274
+ }, z.core.$strict>>;
275
+ execution: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown>>>;
276
+ policies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
277
+ enforcedPolicies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
278
+ limits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
279
+ enforcedLimits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
280
+ onDisconnect: z.ZodDefault<z.ZodEnum<{
281
+ cancel: "cancel";
282
+ continue: "continue";
283
+ }>>;
284
+ maxTokens: z.ZodDefault<z.ZodEnum<{
285
+ budget: "budget";
286
+ ignore: "ignore";
287
+ }>>;
288
+ clientTools: z.ZodDefault<z.ZodEnum<{
289
+ ignore: "ignore";
290
+ reject: "reject";
291
+ }>>;
292
+ }, z.core.$strict>>;
293
+ }, z.core.$strict>;
294
+ export type ServerConfig = z.infer<typeof serverConfigSchema>;
295
+ export type ServerConfigInput = z.input<typeof serverConfigSchema>;
296
+ export declare const parseServerConfig: (input: unknown) => ServerConfig;
297
+ /**
298
+ * Resolve paths in a configuration against the directory it was loaded
299
+ * from, so a server file works wherever the server is started.
300
+ */
301
+ export declare const resolveServerConfigPaths: (config: ServerConfig, baseDirectory: string) => ServerConfig;
302
+ /** A loaded server configuration and where it came from. */
303
+ export interface LoadedServerConfig {
304
+ config: ServerConfig;
305
+ /** The file it was loaded from; undefined when built from command-line options. */
306
+ file?: string;
307
+ /** The directory relative paths and runtime-configuration discovery use. */
308
+ baseDirectory: string;
309
+ }
310
+ /** Where a configuration file keeps durable state unless it says otherwise. */
311
+ export declare const SERVER_STATE_DIRECTORY = ".agent-runtime/serve";
312
+ /** Load and validate a server configuration file (YAML or JSON). */
313
+ export declare const loadServerConfig: (file: string) => Promise<LoadedServerConfig>;
314
+ /** The first discovered server configuration file in a directory, if any. */
315
+ export declare const discoverServerConfigFile: (directory: string) => Promise<string | undefined>;
316
+ /** Command-line options for serving one manifest without a configuration file. */
317
+ export interface SingleManifestOptions {
318
+ manifest: string;
319
+ servedModelName?: string;
320
+ runtimeConfig?: string;
321
+ runtimeModule?: string;
322
+ input?: Record<string, InputSourceConfig>;
323
+ output?: string;
324
+ streamMode?: "auto" | "live" | "committed";
325
+ progress?: "none" | "status";
326
+ store?: {
327
+ driver: "memory" | "sqlite";
328
+ path?: string;
329
+ };
330
+ ledger?: {
331
+ driver: "memory";
332
+ } | {
333
+ driver: "sqlite";
334
+ path: string;
335
+ };
336
+ onUnrecognized?: "unsigned" | "reject" | "restart";
337
+ clientTools?: "ignore" | "reject";
338
+ }
339
+ /** The served model name a manifest gets when none is given: its id, else the file name. */
340
+ export declare const defaultServedModelName: (manifestFile: string, manifestId?: string) => string;
341
+ /**
342
+ * Build a one-model configuration from command-line options. Single-manifest
343
+ * mode keeps runs, the ledger, and stored media for the life of the process
344
+ * unless told otherwise; a SQLite ledger keeps stored media beside it, so
345
+ * conversations and their media survive restarts together.
346
+ */
347
+ export declare const singleManifestServerConfig: (options: SingleManifestOptions & {
348
+ servedModelName: string;
349
+ }) => LoadedServerConfig;
350
+ export {};