@agentuity/runtime 1.0.31 → 1.0.33
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/_metadata.js +9 -1
- package/dist/_metadata.js.map +1 -1
- package/dist/_process-protection.js +1 -1
- package/dist/_process-protection.js.map +1 -1
- package/dist/_tokens.js +1 -1
- package/dist/_tokens.js.map +1 -1
- package/dist/dev-patches/aisdk.js +9 -1
- package/dist/dev-patches/aisdk.js.map +1 -1
- package/dist/dev-patches/otel-llm.js +9 -1
- package/dist/dev-patches/otel-llm.js.map +1 -1
- package/dist/eval.d.ts +2 -2
- package/dist/eval.d.ts.map +1 -1
- package/dist/eval.js.map +1 -1
- package/dist/handlers/cron.js +1 -1
- package/dist/handlers/cron.js.map +1 -1
- package/dist/middleware.js +1 -1
- package/dist/middleware.js.map +1 -1
- package/dist/otel/logger.js +9 -9
- package/dist/otel/logger.js.map +1 -1
- package/dist/router.d.ts +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +32 -33
- package/dist/router.js.map +1 -1
- package/dist/services/evalrun/http.js +2 -2
- package/dist/services/evalrun/http.js.map +1 -1
- package/dist/services/local/stream.d.ts.map +1 -1
- package/dist/services/local/stream.js +2 -0
- package/dist/services/local/stream.js.map +1 -1
- package/dist/services/local/task.d.ts.map +1 -1
- package/dist/services/local/task.js.map +1 -1
- package/dist/services/session/http.js +2 -2
- package/dist/services/session/http.js.map +1 -1
- package/dist/signature.js +1 -1
- package/dist/signature.js.map +1 -1
- package/dist/workbench.js.map +1 -1
- package/package.json +7 -7
- package/src/_process-protection.ts +1 -1
- package/src/_tokens.ts +1 -1
- package/src/eval.ts +2 -3
- package/src/handlers/cron.ts +1 -1
- package/src/middleware.ts +1 -1
- package/src/otel/logger.ts +9 -9
- package/src/router.ts +33 -34
- package/src/services/evalrun/http.ts +2 -2
- package/src/services/local/stream.ts +2 -0
- package/src/services/local/task.ts +1 -6
- package/src/services/session/http.ts +2 -2
- package/src/signature.ts +1 -1
- package/src/workbench.ts +1 -1
package/src/middleware.ts
CHANGED
|
@@ -74,7 +74,7 @@ export const AGENT_CONTEXT_PROPERTIES = [
|
|
|
74
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
75
|
function installContextPropertyHelpers(c: any): void {
|
|
76
76
|
for (const property of AGENT_CONTEXT_PROPERTIES) {
|
|
77
|
-
if (Object.
|
|
77
|
+
if (Object.hasOwn(c, property)) {
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
80
|
|
package/src/otel/logger.ts
CHANGED
|
@@ -77,20 +77,20 @@ export class OtelLogger implements Logger {
|
|
|
77
77
|
case 'debug':
|
|
78
78
|
return (
|
|
79
79
|
level === LogsAPI.SeverityNumber.DEBUG ||
|
|
80
|
-
level
|
|
81
|
-
level
|
|
82
|
-
level
|
|
80
|
+
level === LogsAPI.SeverityNumber.INFO ||
|
|
81
|
+
level === LogsAPI.SeverityNumber.WARN ||
|
|
82
|
+
level === LogsAPI.SeverityNumber.ERROR
|
|
83
83
|
);
|
|
84
84
|
case 'info':
|
|
85
85
|
return (
|
|
86
|
-
level
|
|
87
|
-
level
|
|
88
|
-
level
|
|
86
|
+
level === LogsAPI.SeverityNumber.INFO ||
|
|
87
|
+
level === LogsAPI.SeverityNumber.WARN ||
|
|
88
|
+
level === LogsAPI.SeverityNumber.ERROR
|
|
89
89
|
);
|
|
90
90
|
case 'warn':
|
|
91
|
-
return level
|
|
91
|
+
return level === LogsAPI.SeverityNumber.WARN || level === LogsAPI.SeverityNumber.ERROR;
|
|
92
92
|
case 'error':
|
|
93
|
-
return level
|
|
93
|
+
return level === LogsAPI.SeverityNumber.ERROR;
|
|
94
94
|
}
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
@@ -291,6 +291,6 @@ export function patchConsole(
|
|
|
291
291
|
delegate.debug('profileEnd:', ...args);
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
-
//
|
|
294
|
+
// biome-ignore lint/suspicious/noGlobalAssign: intentionally replacing console with instrumented version
|
|
295
295
|
console = globalThis.console = _patch;
|
|
296
296
|
}
|
package/src/router.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { type Context, Hono, type
|
|
2
|
+
import { type Context, Hono, type Env as HonoEnv, type Schema } from 'hono';
|
|
3
|
+
import { loadBuildMetadata } from './_metadata';
|
|
3
4
|
import { returnResponse } from './_util';
|
|
4
5
|
import type { Env } from './app';
|
|
5
|
-
import { loadBuildMetadata } from './_metadata';
|
|
6
6
|
|
|
7
7
|
// Re-export both Env types
|
|
8
8
|
export type { Env };
|
|
@@ -134,7 +134,6 @@ declare module 'hono' {
|
|
|
134
134
|
export const createRouter = <E extends Env = Env, S extends Schema = Schema>(): Hono<E, S> => {
|
|
135
135
|
const router = new Hono<E, S>();
|
|
136
136
|
// tslint:disable-next-line:no-any no-unused-variable
|
|
137
|
-
// biome-ignore lint:no-any
|
|
138
137
|
const _router = router as any;
|
|
139
138
|
|
|
140
139
|
for (const method of ['get', 'put', 'post', 'delete', 'options', 'patch']) {
|
|
@@ -211,68 +210,68 @@ export const createRouter = <E extends Env = Env, S extends Schema = Schema>():
|
|
|
211
210
|
// Deprecated stubs that throw errors with migration instructions
|
|
212
211
|
_router.websocket = (path: string, ..._args: any[]) => {
|
|
213
212
|
throw new Error(
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
'router.websocket() is deprecated and has been removed.\n\n' +
|
|
214
|
+
'Migration: Use the websocket middleware instead:\n\n' +
|
|
216
215
|
` import { createRouter, websocket } from '@agentuity/runtime';\n\n` +
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
' const router = createRouter();\n\n' +
|
|
217
|
+
' // Before (deprecated):\n' +
|
|
219
218
|
` // router.websocket('${path}', (c) => (ws) => { ... });\n\n` +
|
|
220
|
-
|
|
219
|
+
' // After:\n' +
|
|
221
220
|
` router.get('${path}', websocket((c, ws) => {\n` +
|
|
222
|
-
|
|
221
|
+
' ws.onMessage((event) => {\n' +
|
|
223
222
|
` ws.send('Echo: ' + event.data);\n` +
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
' });\n' +
|
|
224
|
+
' }));'
|
|
226
225
|
);
|
|
227
226
|
};
|
|
228
227
|
|
|
229
228
|
_router.sse = (path: string, ..._args: any[]) => {
|
|
230
229
|
throw new Error(
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
'router.sse() is deprecated and has been removed.\n\n' +
|
|
231
|
+
'Migration: Use the sse middleware instead:\n\n' +
|
|
233
232
|
` import { createRouter, sse } from '@agentuity/runtime';\n\n` +
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
' const router = createRouter();\n\n' +
|
|
234
|
+
' // Before (deprecated):\n' +
|
|
236
235
|
` // router.sse('${path}', (c) => async (stream) => { ... });\n\n` +
|
|
237
|
-
|
|
236
|
+
' // After:\n' +
|
|
238
237
|
` router.get('${path}', sse((c, stream) => {\n` +
|
|
239
238
|
` stream.writeSSE({ data: 'Hello', event: 'message' });\n` +
|
|
240
|
-
|
|
239
|
+
' }));'
|
|
241
240
|
);
|
|
242
241
|
};
|
|
243
242
|
|
|
244
243
|
_router.stream = (path: string, ..._args: any[]) => {
|
|
245
244
|
throw new Error(
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
'router.stream() is deprecated and has been removed.\n\n' +
|
|
246
|
+
'Migration: Use the stream middleware instead:\n\n' +
|
|
248
247
|
` import { createRouter, stream } from '@agentuity/runtime';\n\n` +
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
' const router = createRouter();\n\n' +
|
|
249
|
+
' // Before (deprecated):\n' +
|
|
251
250
|
` // router.stream('${path}', (c) => new ReadableStream({ ... }));\n\n` +
|
|
252
|
-
|
|
251
|
+
' // After:\n' +
|
|
253
252
|
` router.post('${path}', stream((c) => {\n` +
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
' return new ReadableStream({\n' +
|
|
254
|
+
' start(controller) {\n' +
|
|
256
255
|
` controller.enqueue('data\\n');\n` +
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
' controller.close();\n' +
|
|
257
|
+
' }\n' +
|
|
258
|
+
' });\n' +
|
|
259
|
+
' }));'
|
|
261
260
|
);
|
|
262
261
|
};
|
|
263
262
|
|
|
264
263
|
_router.cron = (schedule: string, ..._args: any[]) => {
|
|
265
264
|
throw new Error(
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
'router.cron() is deprecated and has been removed.\n\n' +
|
|
266
|
+
'Migration: Use the cron middleware instead:\n\n' +
|
|
268
267
|
` import { createRouter, cron } from '@agentuity/runtime';\n\n` +
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
' const router = createRouter();\n\n' +
|
|
269
|
+
' // Before (deprecated):\n' +
|
|
271
270
|
` // router.cron('${schedule}', (c) => { ... });\n\n` +
|
|
272
|
-
|
|
271
|
+
' // After:\n' +
|
|
273
272
|
` router.post('/your-cron-path', cron('${schedule}', (c) => {\n` +
|
|
274
273
|
` return { status: 'complete' };\n` +
|
|
275
|
-
|
|
274
|
+
' }));'
|
|
276
275
|
);
|
|
277
276
|
};
|
|
278
277
|
|
|
@@ -42,7 +42,7 @@ export class HTTPEvalRunEventProvider implements EvalRunEventProvider {
|
|
|
42
42
|
const currentContext = context.active();
|
|
43
43
|
const span = tracer.startSpan('Eval Start', {}, currentContext);
|
|
44
44
|
|
|
45
|
-
const endpoint = '/evalrun
|
|
45
|
+
const endpoint = '/evalrun';
|
|
46
46
|
const fullUrl = `${this.baseUrl}${endpoint}`;
|
|
47
47
|
|
|
48
48
|
const payload = { ...event, timestamp: Date.now() };
|
|
@@ -118,7 +118,7 @@ export class HTTPEvalRunEventProvider implements EvalRunEventProvider {
|
|
|
118
118
|
const currentContext = context.active();
|
|
119
119
|
const span = tracer.startSpan('Eval End', {}, currentContext);
|
|
120
120
|
|
|
121
|
-
const endpoint = '/evalrun
|
|
121
|
+
const endpoint = '/evalrun';
|
|
122
122
|
const fullUrl = `${this.baseUrl}${endpoint}`;
|
|
123
123
|
this.logger.debug('[EVALRUN HTTP] Sending eval run complete event: %s', event.id);
|
|
124
124
|
this.logger.debug('[EVALRUN HTTP] URL: %s %s', 'PUT', fullUrl);
|
|
@@ -126,6 +126,7 @@ export class LocalStreamStorage implements StreamStorage {
|
|
|
126
126
|
metadata: row.metadata ? JSON.parse(row.metadata) : {},
|
|
127
127
|
url: `${this.#serverUrl}/_agentuity/local/stream/${row.id}`,
|
|
128
128
|
sizeBytes: row.size_bytes,
|
|
129
|
+
expiresAt: null,
|
|
129
130
|
}));
|
|
130
131
|
|
|
131
132
|
return {
|
|
@@ -165,6 +166,7 @@ export class LocalStreamStorage implements StreamStorage {
|
|
|
165
166
|
metadata,
|
|
166
167
|
url,
|
|
167
168
|
sizeBytes: row.size_bytes,
|
|
169
|
+
expiresAt: null,
|
|
168
170
|
};
|
|
169
171
|
}
|
|
170
172
|
|
|
@@ -812,12 +812,7 @@ export class LocalTaskStorage implements TaskStorage {
|
|
|
812
812
|
SET status = 'closed', deleted = 1, closed_date = COALESCE(closed_date, ?), updated_at = ?
|
|
813
813
|
WHERE project_path = ? AND id IN (${placeholders})
|
|
814
814
|
`);
|
|
815
|
-
updateStmt.run(
|
|
816
|
-
new Date(timestamp).toISOString(),
|
|
817
|
-
timestamp,
|
|
818
|
-
this.#projectPath,
|
|
819
|
-
...ids
|
|
820
|
-
);
|
|
815
|
+
updateStmt.run(new Date(timestamp).toISOString(), timestamp, this.#projectPath, ...ids);
|
|
821
816
|
|
|
822
817
|
const changelogStmt = this.#db.prepare(`
|
|
823
818
|
INSERT INTO task_changelog_storage (
|
|
@@ -66,7 +66,7 @@ export class HTTPSessionEventProvider implements SessionEventProvider {
|
|
|
66
66
|
const spanContext = trace.setSpan(currentContext, span);
|
|
67
67
|
const resp = await context.with(spanContext, () =>
|
|
68
68
|
this.apiClient.post(
|
|
69
|
-
'/session
|
|
69
|
+
'/session',
|
|
70
70
|
{ ...event, timestamp: Date.now() },
|
|
71
71
|
APIResponseSchemaNoData(),
|
|
72
72
|
SessionStartEventDelayedSchema
|
|
@@ -136,7 +136,7 @@ export class HTTPSessionEventProvider implements SessionEventProvider {
|
|
|
136
136
|
const spanContext = trace.setSpan(currentContext, span);
|
|
137
137
|
const resp = await context.with(spanContext, () =>
|
|
138
138
|
this.apiClient.put(
|
|
139
|
-
'/session
|
|
139
|
+
'/session',
|
|
140
140
|
{ ...event, timestamp: Date.now() },
|
|
141
141
|
APIResponseSchemaNoData(),
|
|
142
142
|
SessionCompleteEventDelayedSchema
|
package/src/signature.ts
CHANGED
|
@@ -48,7 +48,7 @@ export async function verifySignature(
|
|
|
48
48
|
// Verify timestamp is within acceptable range (prevent replay attacks)
|
|
49
49
|
const ts = parseInt(timestamp, 10);
|
|
50
50
|
const now = Math.floor(Date.now() / 1000);
|
|
51
|
-
if (isNaN(ts) || Math.abs(now - ts) > MAX_SIGNATURE_AGE_SECONDS) {
|
|
51
|
+
if (Number.isNaN(ts) || Math.abs(now - ts) > MAX_SIGNATURE_AGE_SECONDS) {
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
|
package/src/workbench.ts
CHANGED
|
@@ -197,7 +197,7 @@ export const createWorkbenchExecutionRoute = (): Handler => {
|
|
|
197
197
|
// Execute the agent handler directly
|
|
198
198
|
// The agentMiddleware has already set up the AsyncLocalStorage context
|
|
199
199
|
// so the handler can access it via getAgentContext()
|
|
200
|
-
let result;
|
|
200
|
+
let result: unknown;
|
|
201
201
|
if (agentObj.inputSchema) {
|
|
202
202
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
203
|
result = await (agentObj as any).handler(input);
|