@agentuity/runtime 0.0.68 → 0.0.70
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/AGENTS.md +130 -10
- package/README.md +6 -8
- package/dist/_config.d.ts +16 -0
- package/dist/_config.d.ts.map +1 -1
- package/dist/_config.js +16 -0
- package/dist/_config.js.map +1 -1
- package/dist/_context.d.ts +17 -15
- package/dist/_context.d.ts.map +1 -1
- package/dist/_context.js +17 -8
- package/dist/_context.js.map +1 -1
- package/dist/_server.d.ts.map +1 -1
- package/dist/_server.js +27 -14
- package/dist/_server.js.map +1 -1
- package/dist/_services.d.ts.map +1 -1
- package/dist/_services.js +2 -29
- package/dist/_services.js.map +1 -1
- package/dist/_validation.d.ts +89 -0
- package/dist/_validation.d.ts.map +1 -0
- package/dist/_validation.js +29 -0
- package/dist/_validation.js.map +1 -0
- package/dist/agent.d.ts +476 -104
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +293 -97
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts +6 -18
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +1 -1
- package/dist/app.js.map +1 -1
- package/dist/eval.d.ts +4 -4
- package/dist/eval.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/otel/config.d.ts.map +1 -1
- package/dist/otel/config.js +5 -2
- package/dist/otel/config.js.map +1 -1
- package/dist/otel/console.d.ts +10 -6
- package/dist/otel/console.d.ts.map +1 -1
- package/dist/otel/console.js +31 -13
- package/dist/otel/console.js.map +1 -1
- package/dist/otel/logger.d.ts.map +1 -1
- package/dist/otel/logger.js +0 -19
- package/dist/otel/logger.js.map +1 -1
- package/dist/otel/otel.d.ts +2 -1
- package/dist/otel/otel.d.ts.map +1 -1
- package/dist/otel/otel.js +28 -15
- package/dist/otel/otel.js.map +1 -1
- package/dist/services/local/_db.d.ts.map +1 -1
- package/dist/services/local/_db.js +1 -22
- package/dist/services/local/_db.js.map +1 -1
- package/dist/services/local/_router.d.ts.map +1 -1
- package/dist/services/local/_router.js +0 -32
- package/dist/services/local/_router.js.map +1 -1
- package/dist/services/local/index.d.ts +0 -1
- package/dist/services/local/index.d.ts.map +1 -1
- package/dist/services/local/index.js +0 -1
- package/dist/services/local/index.js.map +1 -1
- package/dist/session.d.ts +18 -2
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +6 -0
- package/dist/session.js.map +1 -1
- package/dist/validator.d.ts +140 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +146 -0
- package/dist/validator.js.map +1 -0
- package/dist/workbench.d.ts.map +1 -1
- package/dist/workbench.js +38 -29
- package/dist/workbench.js.map +1 -1
- package/package.json +6 -6
- package/src/_config.ts +19 -0
- package/src/_context.ts +25 -31
- package/src/_server.ts +30 -14
- package/src/_services.ts +0 -28
- package/src/_validation.ts +119 -0
- package/src/agent.ts +872 -272
- package/src/app.ts +5 -18
- package/src/eval.ts +6 -6
- package/src/index.ts +3 -1
- package/src/otel/config.ts +5 -2
- package/src/otel/console.ts +34 -20
- package/src/otel/logger.ts +0 -18
- package/src/otel/otel.ts +43 -29
- package/src/services/local/_db.ts +1 -27
- package/src/services/local/_router.ts +0 -46
- package/src/services/local/index.ts +0 -1
- package/src/session.ts +22 -2
- package/src/validator.ts +277 -0
- package/src/workbench.ts +38 -32
- package/dist/services/local/objectstore.d.ts +0 -19
- package/dist/services/local/objectstore.d.ts.map +0 -1
- package/dist/services/local/objectstore.js +0 -117
- package/dist/services/local/objectstore.js.map +0 -1
- package/src/services/local/objectstore.ts +0 -177
package/src/_services.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { context, SpanKind, SpanStatusCode, trace } from '@opentelemetry/api';
|
|
2
2
|
import {
|
|
3
3
|
KeyValueStorageService,
|
|
4
|
-
ObjectStorageService,
|
|
5
4
|
StreamStorageService,
|
|
6
5
|
VectorStorageService,
|
|
7
6
|
type FetchAdapter,
|
|
8
7
|
type KeyValueStorage,
|
|
9
|
-
type ObjectStorage,
|
|
10
8
|
type StreamStorage,
|
|
11
9
|
type VectorStorage,
|
|
12
10
|
type ListStreamsResponse,
|
|
@@ -42,7 +40,6 @@ import {
|
|
|
42
40
|
} from './session';
|
|
43
41
|
import {
|
|
44
42
|
LocalKeyValueStorage,
|
|
45
|
-
LocalObjectStorage,
|
|
46
43
|
LocalStreamStorage,
|
|
47
44
|
LocalVectorStorage,
|
|
48
45
|
getLocalDB,
|
|
@@ -58,7 +55,6 @@ const serviceUrls = getServiceUrls(process.env.AGENTUITY_REGION ?? 'usc');
|
|
|
58
55
|
const kvBaseUrl = serviceUrls.keyvalue;
|
|
59
56
|
const streamBaseUrl = serviceUrls.stream;
|
|
60
57
|
const vectorBaseUrl = serviceUrls.vector;
|
|
61
|
-
const objectBaseUrl = serviceUrls.objectstore;
|
|
62
58
|
const catalystBaseUrl = serviceUrls.catalyst;
|
|
63
59
|
|
|
64
60
|
let adapter: FetchAdapter;
|
|
@@ -157,22 +153,6 @@ const createFetchAdapter = (logger: Logger) =>
|
|
|
157
153
|
}
|
|
158
154
|
break;
|
|
159
155
|
}
|
|
160
|
-
case 'agentuity.objectstore.get': {
|
|
161
|
-
if (result.response.status === 404) {
|
|
162
|
-
span?.addEvent('miss');
|
|
163
|
-
} else if (result.response.ok) {
|
|
164
|
-
span?.addEvent('hit');
|
|
165
|
-
}
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case 'agentuity.objectstore.delete': {
|
|
169
|
-
if (result.response.status === 404) {
|
|
170
|
-
span?.addEvent('not_found', { deleted: false });
|
|
171
|
-
} else if (result.response.ok) {
|
|
172
|
-
span?.addEvent('deleted', { deleted: true });
|
|
173
|
-
}
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
156
|
}
|
|
177
157
|
},
|
|
178
158
|
},
|
|
@@ -180,7 +160,6 @@ const createFetchAdapter = (logger: Logger) =>
|
|
|
180
160
|
);
|
|
181
161
|
|
|
182
162
|
let kv: KeyValueStorage;
|
|
183
|
-
let objectStore: ObjectStorage;
|
|
184
163
|
let stream: StreamStorage;
|
|
185
164
|
let vector: VectorStorage;
|
|
186
165
|
let session: SessionProvider;
|
|
@@ -217,7 +196,6 @@ export function createServices(logger: Logger, config?: AppConfig<any>, serverUr
|
|
|
217
196
|
logger.info('Using local services (development only)');
|
|
218
197
|
|
|
219
198
|
kv = config?.services?.keyvalue || new LocalKeyValueStorage(db, projectPath);
|
|
220
|
-
objectStore = config?.services?.object || new LocalObjectStorage(db, projectPath, serverUrl);
|
|
221
199
|
stream = config?.services?.stream || new LocalStreamStorage(db, projectPath, serverUrl);
|
|
222
200
|
vector = config?.services?.vector || new LocalVectorStorage(db, projectPath);
|
|
223
201
|
session = config?.services?.session || new DefaultSessionProvider();
|
|
@@ -245,7 +223,6 @@ export function createServices(logger: Logger, config?: AppConfig<any>, serverUr
|
|
|
245
223
|
|
|
246
224
|
// At this point we must be authenticated (since !authenticated would trigger local services above)
|
|
247
225
|
kv = config?.services?.keyvalue || new KeyValueStorageService(kvBaseUrl, adapter);
|
|
248
|
-
objectStore = config?.services?.object || new ObjectStorageService(objectBaseUrl, adapter);
|
|
249
226
|
stream = config?.services?.stream || new StreamStorageService(streamBaseUrl, adapter);
|
|
250
227
|
vector = config?.services?.vector || new VectorStorageService(vectorBaseUrl, adapter);
|
|
251
228
|
session = config?.services?.session || new DefaultSessionProvider();
|
|
@@ -304,11 +281,6 @@ export function registerServices(o: any, includeAgents = false) {
|
|
|
304
281
|
enumerable: false,
|
|
305
282
|
configurable: false,
|
|
306
283
|
});
|
|
307
|
-
Object.defineProperty(o, 'objectstore', {
|
|
308
|
-
get: () => objectStore,
|
|
309
|
-
enumerable: false,
|
|
310
|
-
configurable: false,
|
|
311
|
-
});
|
|
312
284
|
Object.defineProperty(o, 'stream', {
|
|
313
285
|
get: () => stream,
|
|
314
286
|
enumerable: false,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import type { StandardSchemaV1, InferInput, InferOutput } from '@agentuity/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Schema definition for routes that can have input (POST, PUT, PATCH, DELETE).
|
|
6
|
+
* Both input and output are optional, but output is recommended.
|
|
7
|
+
*
|
|
8
|
+
* @template TInput - Input schema (StandardSchemaV1 or undefined)
|
|
9
|
+
* @template TOutput - Output schema (StandardSchemaV1 or undefined)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const schema: RouteSchema<z.ZodObject<{name: z.ZodString}>, z.ZodString> = {
|
|
14
|
+
* input: z.object({ name: z.string() }),
|
|
15
|
+
* output: z.string()
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type RouteSchema<
|
|
20
|
+
TInput extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,
|
|
21
|
+
TOutput extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,
|
|
22
|
+
> = {
|
|
23
|
+
input?: TInput;
|
|
24
|
+
output?: TOutput;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Schema definition for GET routes.
|
|
29
|
+
* Input is not allowed (enforced as never), only output validation is supported.
|
|
30
|
+
*
|
|
31
|
+
* @template TOutput - Output schema (StandardSchemaV1 or undefined)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const schema: GetRouteSchema<z.ZodString> = {
|
|
36
|
+
* output: z.string()
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export type GetRouteSchema<
|
|
41
|
+
TOutput extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,
|
|
42
|
+
> = {
|
|
43
|
+
input?: never;
|
|
44
|
+
output?: TOutput;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Infer the input type from a StandardSchema.
|
|
49
|
+
* Returns the input type of the schema (before validation/transformation).
|
|
50
|
+
*
|
|
51
|
+
* @template T - Schema type
|
|
52
|
+
*/
|
|
53
|
+
export type InferSchemaInput<T> = T extends StandardSchemaV1 ? InferInput<T> : undefined;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Infer the output type from a StandardSchema.
|
|
57
|
+
* Returns the output type of the schema (after validation/transformation).
|
|
58
|
+
*
|
|
59
|
+
* @template T - Schema type
|
|
60
|
+
*/
|
|
61
|
+
export type InferSchemaOutput<T> = T extends StandardSchemaV1 ? InferOutput<T> : undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Extract input schema from RouteSchema or GetRouteSchema.
|
|
65
|
+
*
|
|
66
|
+
* @template T - RouteSchema or GetRouteSchema type
|
|
67
|
+
*/
|
|
68
|
+
export type ExtractInputSchema<T> =
|
|
69
|
+
T extends RouteSchema<infer I, any> ? I : T extends GetRouteSchema<any> ? never : never;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Extract output schema from RouteSchema or GetRouteSchema.
|
|
73
|
+
*
|
|
74
|
+
* @template T - RouteSchema or GetRouteSchema type
|
|
75
|
+
*/
|
|
76
|
+
export type ExtractOutputSchema<T> =
|
|
77
|
+
T extends RouteSchema<any, infer O> ? O : T extends GetRouteSchema<infer O> ? O : never;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Validation result from StandardSchema validation.
|
|
81
|
+
*/
|
|
82
|
+
export type ValidationResult<T> =
|
|
83
|
+
| { success: true; data: T }
|
|
84
|
+
| { success: false; issues: StandardSchemaV1.Issue[] };
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Validates a value against a StandardSchema.
|
|
88
|
+
*
|
|
89
|
+
* @param schema - The StandardSchema to validate against
|
|
90
|
+
* @param value - The value to validate
|
|
91
|
+
* @returns ValidationResult with success/failure and data/issues
|
|
92
|
+
*/
|
|
93
|
+
export async function validateSchema<T>(
|
|
94
|
+
schema: StandardSchemaV1,
|
|
95
|
+
value: unknown
|
|
96
|
+
): Promise<ValidationResult<T>> {
|
|
97
|
+
const result = await schema['~standard'].validate(value);
|
|
98
|
+
|
|
99
|
+
if ('issues' in result && result.issues) {
|
|
100
|
+
return { success: false, issues: Array.from(result.issues) };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return { success: true, data: result.value as T };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Format validation issues into a readable error message.
|
|
108
|
+
*
|
|
109
|
+
* @param issues - Array of validation issues
|
|
110
|
+
* @returns Formatted error message
|
|
111
|
+
*/
|
|
112
|
+
export function formatValidationIssues(issues: StandardSchemaV1.Issue[]): string {
|
|
113
|
+
return issues
|
|
114
|
+
.map((issue) => {
|
|
115
|
+
const path = issue.path?.map((p) => (typeof p === 'object' ? p.key : p)).join('.') || '';
|
|
116
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
117
|
+
})
|
|
118
|
+
.join(', ');
|
|
119
|
+
}
|