@agentuity/runtime 0.0.30 → 0.0.32

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.
@@ -1 +1 @@
1
- {"version":3,"file":"_server.d.ts","sourceRoot":"","sources":["../src/_server.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,KAAK,MAAM,EAGX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAavC,wBAAgB,SAAS,wCAExB;AAED,wBAAgB,MAAM,4DAErB;AAED,wBAAgB,SAAS,kBAExB;AAED,wBAAgB,SAAS,kBAExB;AAcD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,QAExD;AA2CD,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,SAAS,iCA8H5E,CAAC"}
1
+ {"version":3,"file":"_server.d.ts","sourceRoot":"","sources":["../src/_server.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,KAAK,MAAM,EAGX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAavC,wBAAgB,SAAS,wCAExB;AAED,wBAAgB,MAAM,4DAErB;AAED,wBAAgB,SAAS,kBAExB;AAED,wBAAgB,SAAS,kBAExB;AAcD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,QAExD;AA2CD,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,SAAS,iCAmJ5E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/runtime",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "prepublishOnly": "bun run clean && bun run build"
24
24
  },
25
25
  "dependencies": {
26
- "@agentuity/core": "0.0.29",
27
- "@agentuity/server": "0.0.29",
26
+ "@agentuity/core": "0.0.31",
27
+ "@agentuity/server": "0.0.31",
28
28
  "@opentelemetry/api": "^1.9.0",
29
29
  "@opentelemetry/api-logs": "^0.207.0",
30
30
  "@opentelemetry/auto-instrumentations-node": "^0.66.0",
package/src/_server.ts CHANGED
@@ -149,6 +149,7 @@ export const createServer = <E extends Env>(app: Hono<E>, _config?: AppConfig) =
149
149
  status: (error.statusCode as number) ?? 500,
150
150
  });
151
151
  }
152
+ otel.logger.error('Unhandled Server Error: %s', error);
152
153
  return new Response('Internal Server Error', { status: 500 });
153
154
  });
154
155
 
@@ -179,8 +180,14 @@ export const createServer = <E extends Env>(app: Hono<E>, _config?: AppConfig) =
179
180
  app.use(
180
181
  '*',
181
182
  cors({
182
- origin: '*',
183
- allowHeaders: [],
183
+ origin: _config?.cors?.origin ?? ((origin) => origin),
184
+ allowHeaders: _config?.cors?.allowHeaders ?? [
185
+ 'Content-Type',
186
+ 'Authorization',
187
+ 'Accept',
188
+ 'Origin',
189
+ 'X-Requested-With',
190
+ ],
184
191
  allowMethods: ['POST', 'GET', 'OPTIONS', 'HEAD', 'PUT', 'DELETE', 'PATCH'],
185
192
  exposeHeaders: ['Content-Length'],
186
193
  maxAge: 600,
@@ -208,14 +215,28 @@ export const createServer = <E extends Env>(app: Hono<E>, _config?: AppConfig) =
208
215
  otel.logger.info('shutdown started');
209
216
  isShutdown = true;
210
217
  // Force exit after timeout if cleanup hangs
211
- setTimeout(() => process.exit(1), 30_000).unref();
212
- await server.stop();
213
- await otel.shutdown();
214
- otel.logger.info('shutdown completed');
218
+ const forceExitTimer = setTimeout(() => {
219
+ otel.logger.warn('shutdown timed out after 5s, forcing exit');
220
+ process.exit(1);
221
+ }, 5_000);
222
+ try {
223
+ await server.stop();
224
+ await otel.shutdown();
225
+ otel.logger.info('shutdown completed');
226
+ } finally {
227
+ clearTimeout(forceExitTimer);
228
+ }
215
229
  };
216
230
 
217
231
  process.on('beforeExit', async () => await shutdown());
218
- process.on('exit', async () => await shutdown());
232
+
233
+ // Handle synchronous exit event - can't do async work here
234
+ process.on('exit', (code) => {
235
+ if (!isShutdown) {
236
+ otel.logger.info('process exiting with code %d before shutdown completed', code);
237
+ }
238
+ });
239
+
219
240
  process.once('SIGINT', async () => {
220
241
  await shutdown();
221
242
  process.exit(0);
package/src/router.ts CHANGED
@@ -178,7 +178,7 @@ export const createRouter = <E extends Env = Env, S extends Schema = Schema>():
178
178
  if (streamResult instanceof Promise) streamResult = await streamResult;
179
179
  await s.pipe(streamResult);
180
180
  } catch (err) {
181
- console.error('Stream error:', err);
181
+ c.var.logger.error('Stream error:', err);
182
182
  throw err;
183
183
  }
184
184
  };