@looopy-ai/aws 1.0.6 → 1.0.7

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,19 +1,14 @@
1
- import { type HttpBindings } from '@hono/node-server';
2
1
  import { type Agent, type AuthContext } from '@looopy-ai/core';
3
2
  import { Hono } from 'hono';
4
3
  import type pino from 'pino';
5
- type ServeConfig = {
4
+ export type ServeConfig = {
6
5
  agent: (contextId: string) => Promise<Agent>;
7
6
  decodeAuthorization?: (authorization: string) => Promise<AuthContext | null>;
8
7
  port?: number;
9
8
  };
10
- declare module 'hono' {
11
- interface ContextVariableMap {
12
- logger: pino.Logger;
13
- }
14
- }
9
+ export type HonoVariables = {
10
+ logger: pino.Logger;
11
+ };
15
12
  export declare const hono: (config: ServeConfig) => Hono<{
16
- Bindings: HttpBindings;
13
+ Variables: HonoVariables;
17
14
  }>;
18
- export declare const serve: (config: ServeConfig) => void;
19
- export {};
@@ -1,8 +1,6 @@
1
- import { serve as serveNodeJs } from '@hono/node-server';
2
1
  import { getLogger, SSEServer } from '@looopy-ai/core';
3
2
  import { Hono } from 'hono';
4
3
  import { requestId } from 'hono/request-id';
5
- import { pinoHttp } from 'pino-http';
6
4
  import { z } from 'zod';
7
5
  const promptValidator = z.object({
8
6
  prompt: z.string().min(1),
@@ -10,11 +8,22 @@ const promptValidator = z.object({
10
8
  export const hono = (config) => {
11
9
  const app = new Hono();
12
10
  app.use(requestId());
13
- app.use(async (c, next) => {
14
- c.env.incoming.id = c.var.requestId;
15
- await new Promise((resolve) => pinoHttp({ logger: getLogger({}) })(c.env.incoming, c.env.outgoing, () => resolve(undefined)));
16
- c.set('logger', c.env.incoming.log);
17
- await next();
11
+ app.use('*', async (c, next) => {
12
+ const requestId = c.var.requestId;
13
+ const child = getLogger({
14
+ requestId,
15
+ method: c.req.method,
16
+ path: c.req.path,
17
+ });
18
+ const start = performance.now();
19
+ c.set('logger', child);
20
+ try {
21
+ await next();
22
+ }
23
+ finally {
24
+ const ms = performance.now() - start;
25
+ child.info({ status: c.res.status, ms }, 'request completed');
26
+ }
18
27
  });
19
28
  const state = { busy: false, agent: undefined };
20
29
  app.get('/ping', async (c) => {
@@ -101,13 +110,6 @@ export const hono = (config) => {
101
110
  });
102
111
  return app;
103
112
  };
104
- export const serve = (config) => {
105
- const app = hono(config);
106
- serveNodeJs({
107
- fetch: app.fetch,
108
- port: config.port || 8080,
109
- });
110
- };
111
113
  const getAuthContext = async (authorization, decoder) => {
112
114
  if (!authorization || !decoder) {
113
115
  return null;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './agentcore-runtime-server';
2
+ export * from './nodejs';
2
3
  export * from './secrets';
3
4
  export * from './stores';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './agentcore-runtime-server';
2
+ export * from './nodejs';
2
3
  export * from './secrets';
3
4
  export * from './stores';
@@ -0,0 +1,2 @@
1
+ import { type ServeConfig } from './agentcore-runtime-server';
2
+ export declare const serve: (config: ServeConfig) => void;
package/dist/nodejs.js ADDED
@@ -0,0 +1,9 @@
1
+ import { serve as serveNodeJs } from '@hono/node-server';
2
+ import { hono } from './agentcore-runtime-server';
3
+ export const serve = (config) => {
4
+ const app = hono(config);
5
+ serveNodeJs({
6
+ fetch: app.fetch,
7
+ port: config.port || 8080,
8
+ });
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looopy-ai/aws",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "AWS storage and providers for Looopy AI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",