@looopy-ai/aws 2.0.3 → 2.0.5

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,9 +1,10 @@
1
- import { type Agent, type AuthContext } from '@looopy-ai/core';
1
+ import { type Agent, type AuthContext, type ShutdownManager } from '@looopy-ai/core';
2
2
  import { Hono } from 'hono';
3
3
  import type pino from 'pino';
4
4
  export type ServeConfig = {
5
5
  agent: (contextId: string) => Promise<Agent>;
6
6
  decodeAuthorization?: (authorization: string) => Promise<AuthContext | null>;
7
+ shutdown?: ShutdownManager;
7
8
  logger?: pino.Logger;
8
9
  port?: number;
9
10
  };
@@ -1,4 +1,4 @@
1
- import { getLogger, SSEServer } from '@looopy-ai/core';
1
+ import { getLogger, SSEServer, } from '@looopy-ai/core';
2
2
  import { Hono } from 'hono';
3
3
  import { requestId } from 'hono/request-id';
4
4
  import { z } from 'zod';
@@ -59,6 +59,10 @@ export const hono = (config) => {
59
59
  if (!state.agent) {
60
60
  state.agent = await config.agent(contextId);
61
61
  logger.info({ contextId }, 'Created new agent instance');
62
+ config.shutdown?.registerWatcher(async () => {
63
+ logger.info({ contextId }, 'Shutting down agent');
64
+ state.agent = undefined;
65
+ });
62
66
  }
63
67
  const agent = state.agent;
64
68
  if (agent.contextId !== contextId) {
package/dist/nodejs.js CHANGED
@@ -2,8 +2,12 @@ import { serve as serveNodeJs } from '@hono/node-server';
2
2
  import { hono } from './agentcore-runtime-server';
3
3
  export const serve = (config) => {
4
4
  const app = hono(config);
5
- serveNodeJs({
5
+ const server = serveNodeJs({
6
6
  fetch: app.fetch,
7
7
  port: config.port || 8080,
8
8
  });
9
+ config.shutdown?.registerWatcher(async () => {
10
+ server.close();
11
+ config.logger?.info('Server has been shut down');
12
+ }, 1000);
9
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looopy-ai/aws",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "AWS storage and providers for Looopy AI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  "@smithy/types": "^4.9.0",
53
53
  "hono": "^4.10.5",
54
54
  "pino-http": "^11.0.0",
55
- "@looopy-ai/core": "1.1.0"
55
+ "@looopy-ai/core": "1.1.2"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"