@agentuity/migrate 2.0.10 → 3.0.0-alpha.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.
- package/README.md +46 -17
- package/bin/migrate.ts +0 -0
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ CLI tool to migrate Agentuity SDK projects from v1 to v2.
|
|
|
4
4
|
|
|
5
5
|
## What's Changed in v2
|
|
6
6
|
|
|
7
|
-
v2 introduces
|
|
7
|
+
v2 introduces seven fundamental architectural changes:
|
|
8
8
|
|
|
9
9
|
### 1. Agents are Declarative
|
|
10
10
|
|
|
@@ -14,10 +14,10 @@ v2 introduces six fundamental architectural changes:
|
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
16
|
import { createApp } from '@agentuity/runtime';
|
|
17
|
-
import
|
|
17
|
+
import agents from './agent'; // Barrel default export (AgentRunner[])
|
|
18
18
|
|
|
19
|
-
export default createApp({
|
|
20
|
-
agents,
|
|
19
|
+
export default await createApp({
|
|
20
|
+
agents,
|
|
21
21
|
});
|
|
22
22
|
```
|
|
23
23
|
|
|
@@ -33,28 +33,29 @@ createApp({
|
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
**v2**: Use standard patterns:
|
|
36
|
-
- **Initialization**: Module-level code
|
|
37
|
-
-
|
|
36
|
+
- **Initialization**: Module-level code only for env-independent setup
|
|
37
|
+
(for env-dependent SDK clients, initialize inside agent `setup()`)
|
|
38
|
+
- **Cleanup**: `registerShutdownHook()` from `@agentuity/runtime`, or Bun's `process.on('beforeExit', ...)`
|
|
38
39
|
|
|
39
|
-
### 3. Router
|
|
40
|
+
### 3. Explicit Router Configuration
|
|
40
41
|
|
|
41
42
|
**v1**: File-based auto-discovery — routes in `src/api/*.ts` were automatically mounted.
|
|
42
43
|
|
|
43
|
-
**v2**:
|
|
44
|
+
**v2**: Routes are explicitly provided to `createApp()` when needed:
|
|
44
45
|
|
|
45
46
|
```typescript
|
|
46
47
|
import router from './api'; // Your Hono router
|
|
47
48
|
|
|
48
|
-
export default createApp({
|
|
49
|
-
router,
|
|
49
|
+
export default await createApp({
|
|
50
|
+
router,
|
|
50
51
|
});
|
|
51
52
|
```
|
|
52
53
|
|
|
53
54
|
The old file-based approach no longer works. Routes must be composed into a barrel (`src/api/index.ts`) and exported as a Hono instance.
|
|
54
55
|
|
|
55
|
-
### 4.
|
|
56
|
+
### 4. Hono-Based Routing
|
|
56
57
|
|
|
57
|
-
**v1**: `createRouter()` was a wrapper around Hono:
|
|
58
|
+
**v1**: `createRouter()` was a wrapper around Hono using mutating methods:
|
|
58
59
|
|
|
59
60
|
```typescript
|
|
60
61
|
import { createRouter } from '@agentuity/runtime';
|
|
@@ -63,9 +64,16 @@ const router = createRouter();
|
|
|
63
64
|
router.get('/hello', async (c) => c.json({ msg: 'hi' }));
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
**v2**: Use Hono
|
|
67
|
+
**v2**: Use `createRouter()` or `new Hono<Env>()` with chained methods:
|
|
67
68
|
|
|
68
69
|
```typescript
|
|
70
|
+
// Option A: createRouter() from @agentuity/runtime
|
|
71
|
+
import { createRouter } from '@agentuity/runtime';
|
|
72
|
+
|
|
73
|
+
const router = createRouter()
|
|
74
|
+
.get('/hello', async (c) => c.json({ msg: 'hi' }));
|
|
75
|
+
|
|
76
|
+
// Option B: plain Hono instance
|
|
69
77
|
import { Hono } from 'hono';
|
|
70
78
|
import type { Env } from '@agentuity/runtime';
|
|
71
79
|
|
|
@@ -75,7 +83,7 @@ const router = new Hono<Env>()
|
|
|
75
83
|
|
|
76
84
|
### 5. React Helpers Removed
|
|
77
85
|
|
|
78
|
-
**v1**: `@agentuity/react` exported `createClient`, `useAPI`, `RPCRouteRegistry` for API calls.
|
|
86
|
+
**v1**: `@agentuity/react` exported `createClient`, `useAPI`, `useAgentuity`, `RPCRouteRegistry` for API calls.
|
|
79
87
|
|
|
80
88
|
**v2**: These are removed. Use your preferred data fetching library:
|
|
81
89
|
- **Hono client directly**: `hc<AppRouter>()` from `hono/client`
|
|
@@ -123,13 +131,34 @@ export default defineConfig({
|
|
|
123
131
|
// app.ts
|
|
124
132
|
import { createApp } from '@agentuity/runtime';
|
|
125
133
|
|
|
126
|
-
export default createApp({
|
|
134
|
+
export default await createApp({
|
|
127
135
|
analytics: true,
|
|
128
136
|
workbench: true,
|
|
129
137
|
});
|
|
130
138
|
```
|
|
131
139
|
|
|
132
140
|
> **Note**: v2 doesn't include a default Vite plugin. You must add the plugin for your frontend framework (React, Vue, Svelte, Solid, etc.).
|
|
141
|
+
>
|
|
142
|
+
> **Note**: If your frontend entry is at `src/web/index.html` (not the project root), either add `build.rollupOptions.input` to your config, or omit `vite.config.ts` entirely and let the CLI generate a correct fallback.
|
|
143
|
+
|
|
144
|
+
### 7. Build-Time Agent Imports
|
|
145
|
+
|
|
146
|
+
v2's build system imports agent files at build time to extract metadata. Module-scope code that requires environment variables (like `new OpenAI()`) will fail during `agentuity build`.
|
|
147
|
+
|
|
148
|
+
Move SDK client constructors into the agent's `setup()` function:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
// ❌ Fails at build time (module scope)
|
|
152
|
+
const openai = new OpenAI();
|
|
153
|
+
|
|
154
|
+
// ✅ Runs at startup (agent setup)
|
|
155
|
+
export default createAgent('my-agent', {
|
|
156
|
+
setup: async () => ({ openai: new OpenAI() }),
|
|
157
|
+
handler: async (ctx, input) => {
|
|
158
|
+
const result = await ctx.config.openai.chat.completions.create({...});
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
```
|
|
133
162
|
|
|
134
163
|
---
|
|
135
164
|
|
|
@@ -166,7 +195,7 @@ Run in your project root (or pass a path). The tool checks that your **git workt
|
|
|
166
195
|
| Finding | What happens |
|
|
167
196
|
|---|---|
|
|
168
197
|
| `setup` in `createApp()` | Migration comment added — move init to module level |
|
|
169
|
-
| `shutdown` in `createApp()` | Guidance to use
|
|
198
|
+
| `shutdown` in `createApp()` | Guidance to use `registerShutdownHook()` from `@agentuity/runtime` instead |
|
|
170
199
|
| No `router`/`agents` in `createApp()` | Guidance shown — wire up the generated barrels |
|
|
171
200
|
| `agentuity.config.ts` has Vite keys | Guidance to create `vite.config.ts` with plugins/define/render/bundle |
|
|
172
201
|
| `agentuity.config.ts` has analytics/workbench | Remove — keep only in `createApp()` |
|
|
@@ -200,4 +229,4 @@ Run in your project root (or pass a path). The tool checks that your **git workt
|
|
|
200
229
|
|
|
201
230
|
**Setup/shutdown lifecycle**
|
|
202
231
|
- v1: `createApp({ setup, shutdown })` with generic state via `ctx.app`
|
|
203
|
-
- v2:
|
|
232
|
+
- v2: Module-level init for env-independent setup; agent `setup()` for SDK clients; `registerShutdownHook()` for cleanup
|
package/bin/migrate.ts
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/migrate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"description": "Migration tool from Agentuity SDK v1 to v2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Agentuity employees and contributors",
|
|
@@ -30,16 +30,21 @@
|
|
|
30
30
|
"prepublishOnly": "bun run clean && bun run build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@agentuity/core": "
|
|
33
|
+
"@agentuity/core": "3.0.0-alpha.0",
|
|
34
34
|
"typescript": "^5.9.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@agentuity/test-utils": "
|
|
37
|
+
"@agentuity/test-utils": "3.0.0-alpha.0",
|
|
38
38
|
"@types/bun": "latest",
|
|
39
39
|
"bun-types": "latest"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"sideEffects": false
|
|
44
|
+
"sideEffects": false,
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/agentuity/sdk.git",
|
|
48
|
+
"directory": "packages/migrate"
|
|
49
|
+
}
|
|
45
50
|
}
|