@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.
- package/dist/agentcore-runtime-server.d.ts +5 -10
- package/dist/agentcore-runtime-server.js +16 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/nodejs.d.ts +2 -0
- package/dist/nodejs.js +9 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
}
|
|
9
|
+
export type HonoVariables = {
|
|
10
|
+
logger: pino.Logger;
|
|
11
|
+
};
|
|
15
12
|
export declare const hono: (config: ServeConfig) => Hono<{
|
|
16
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
package/dist/index.js
CHANGED
package/dist/nodejs.d.ts
ADDED
package/dist/nodejs.js
ADDED