@autonoma-ai/server-web 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +83 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @autonoma-ai/server-web
2
+
3
+ Web standard server adapter for the Autonoma SDK. Works with Next.js App Router, Hono, Bun, and Deno — any framework that uses the standard `Request`/`Response` API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @autonoma-ai/sdk @autonoma-ai/sdk-prisma @autonoma-ai/server-web
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Next.js App Router
14
+
15
+ ```typescript
16
+ // app/api/autonoma/route.ts
17
+ import { createHandler } from '@autonoma-ai/server-web'
18
+ import { prismaAdapter } from '@autonoma-ai/sdk-prisma'
19
+ import { prisma } from '@/lib/db'
20
+
21
+ export const POST = createHandler({
22
+ adapter: prismaAdapter(prisma, { scopeField: 'organizationId' }),
23
+ sharedSecret: process.env.AUTONOMA_SHARED_SECRET!,
24
+ signingSecret: process.env.AUTONOMA_SIGNING_SECRET!,
25
+ auth: async (user) => {
26
+ const session = await createSession(user.id as string)
27
+ return { token: session.token }
28
+ },
29
+ })
30
+ ```
31
+
32
+ ### Hono
33
+
34
+ ```typescript
35
+ import { Hono } from 'hono'
36
+ import { createHandler } from '@autonoma-ai/server-web'
37
+
38
+ const app = new Hono()
39
+ const handler = createHandler(config)
40
+
41
+ app.post('/api/autonoma', (c) => handler(c.req.raw))
42
+ ```
43
+
44
+ ### Bun
45
+
46
+ ```typescript
47
+ import { createHandler } from '@autonoma-ai/server-web'
48
+
49
+ const handler = createHandler(config)
50
+
51
+ Bun.serve({
52
+ fetch(req) {
53
+ if (req.method === 'POST' && new URL(req.url).pathname === '/api/autonoma') {
54
+ return handler(req)
55
+ }
56
+ return new Response('Not found', { status: 404 })
57
+ },
58
+ })
59
+ ```
60
+
61
+ ## Auth callback
62
+
63
+ The `auth` callback receives the first `User` created during setup and must return real credentials that the test runner can use to log in:
64
+
65
+ ```typescript
66
+ // Session cookie
67
+ auth: async (user) => {
68
+ const session = await createSession(user.id as string)
69
+ return {
70
+ cookies: [{ name: 'session', value: session.token, httpOnly: true, sameSite: 'lax', path: '/' }],
71
+ }
72
+ }
73
+
74
+ // Bearer token
75
+ auth: async (user) => {
76
+ const token = jwt.sign({ sub: user.id }, SECRET)
77
+ return { token }
78
+ }
79
+ ```
80
+
81
+ ## Documentation
82
+
83
+ Full docs: [docs/](../../docs/) — see [setup guide](../../docs/setup.txt).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autonoma-ai/server-web",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Web standard (Hono, Next App Router, Bun, Deno) server adapter for Autonoma SDK",
5
5
  "type": "module",
6
6
  "exports": {
@@ -16,7 +16,7 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@autonoma-ai/sdk": "0.1.0"
19
+ "@autonoma-ai/sdk": "0.1.2"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^22.0.0",