@looopy-ai/aws 1.0.6 → 2.0.0

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,15 @@
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>;
7
+ logger: pino.Logger;
8
8
  port?: number;
9
9
  };
10
- declare module 'hono' {
11
- interface ContextVariableMap {
12
- logger: pino.Logger;
13
- }
14
- }
10
+ export type HonoVariables = {
11
+ logger: pino.Logger;
12
+ };
15
13
  export declare const hono: (config: ServeConfig) => Hono<{
16
- Bindings: HttpBindings;
14
+ Variables: HonoVariables;
17
15
  }>;
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,24 @@ 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 = (config.logger.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
+ if (c.req.path !== '/ping') {
25
+ const ms = performance.now() - start;
26
+ child.info({ status: c.res.status, ms }, 'request completed');
27
+ }
28
+ }
18
29
  });
19
30
  const state = { busy: false, agent: undefined };
20
31
  app.get('/ping', async (c) => {
@@ -23,7 +34,7 @@ export const hono = (config) => {
23
34
  time_of_last_update: Date.now(),
24
35
  }));
25
36
  });
26
- app.post('/invocation', async (c) => {
37
+ app.post('/invocations', async (c) => {
27
38
  const logger = c.var.logger;
28
39
  if (state.busy) {
29
40
  return c.json({ error: 'Agent is currently busy' }, 503);
@@ -101,13 +112,6 @@ export const hono = (config) => {
101
112
  });
102
113
  return app;
103
114
  };
104
- export const serve = (config) => {
105
- const app = hono(config);
106
- serveNodeJs({
107
- fetch: app.fetch,
108
- port: config.port || 8080,
109
- });
110
- };
111
115
  const getAuthContext = async (authorization, decoder) => {
112
116
  if (!authorization || !decoder) {
113
117
  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": "2.0.0",
4
4
  "description": "AWS storage and providers for Looopy AI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",