@agentskit/cli 0.8.2 → 0.10.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/dist/bin.cjs +954 -2
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-FLIR7BRS.js → chunk-I5P3Y7NG.js} +956 -4
- package/dist/chunk-I5P3Y7NG.js.map +1 -0
- package/dist/index.cjs +954 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +11 -11
- package/dist/chunk-FLIR7BRS.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2079,6 +2079,940 @@ console.log(\`\\n\u2014 \${result.steps} steps \xB7 \${result.toolCalls.length}
|
|
|
2079
2079
|
"README.md": readmeFor(ctx)
|
|
2080
2080
|
};
|
|
2081
2081
|
}
|
|
2082
|
+
function buildAdapterServerImport(provider) {
|
|
2083
|
+
if (provider === "demo") return "";
|
|
2084
|
+
return `import { ${PROVIDER_IMPORT[provider]} } from '@agentskit/adapters'
|
|
2085
|
+
`;
|
|
2086
|
+
}
|
|
2087
|
+
function envExampleFor(provider) {
|
|
2088
|
+
const envKey = PROVIDER_ENV_KEY[provider];
|
|
2089
|
+
return envKey ? `${envKey}=
|
|
2090
|
+
` : "# No API key required for the demo provider\n";
|
|
2091
|
+
}
|
|
2092
|
+
function sveltekitStarter(ctx) {
|
|
2093
|
+
const deps = {
|
|
2094
|
+
"@agentskit/svelte": "^0.4.0",
|
|
2095
|
+
"@sveltejs/kit": "^2.0.0",
|
|
2096
|
+
svelte: "^5.0.0"
|
|
2097
|
+
};
|
|
2098
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2099
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
2100
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
2101
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2102
|
+
return {
|
|
2103
|
+
"package.json": JSON.stringify(
|
|
2104
|
+
{
|
|
2105
|
+
name: "agentskit-sveltekit-app",
|
|
2106
|
+
private: true,
|
|
2107
|
+
type: "module",
|
|
2108
|
+
scripts: {
|
|
2109
|
+
dev: "vite dev",
|
|
2110
|
+
build: "vite build",
|
|
2111
|
+
preview: "vite preview",
|
|
2112
|
+
check: "svelte-check --tsconfig ./tsconfig.json"
|
|
2113
|
+
},
|
|
2114
|
+
dependencies: deps,
|
|
2115
|
+
devDependencies: {
|
|
2116
|
+
"@sveltejs/adapter-auto": "^4.0.0",
|
|
2117
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
2118
|
+
"svelte-check": "^4.0.0",
|
|
2119
|
+
typescript: "^5.5.0",
|
|
2120
|
+
vite: "^7.0.0"
|
|
2121
|
+
}
|
|
2122
|
+
},
|
|
2123
|
+
null,
|
|
2124
|
+
2
|
|
2125
|
+
) + "\n",
|
|
2126
|
+
"svelte.config.js": `import adapter from '@sveltejs/adapter-auto'
|
|
2127
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
|
2128
|
+
|
|
2129
|
+
export default {
|
|
2130
|
+
preprocess: vitePreprocess(),
|
|
2131
|
+
kit: { adapter: adapter() },
|
|
2132
|
+
}
|
|
2133
|
+
`,
|
|
2134
|
+
"vite.config.ts": `import { sveltekit } from '@sveltejs/kit/vite'
|
|
2135
|
+
import { defineConfig } from 'vite'
|
|
2136
|
+
export default defineConfig({ plugins: [sveltekit()] })
|
|
2137
|
+
`,
|
|
2138
|
+
"tsconfig.json": JSON.stringify(
|
|
2139
|
+
{
|
|
2140
|
+
extends: "./.svelte-kit/tsconfig.json",
|
|
2141
|
+
compilerOptions: {
|
|
2142
|
+
allowJs: true,
|
|
2143
|
+
checkJs: true,
|
|
2144
|
+
esModuleInterop: true,
|
|
2145
|
+
forceConsistentCasingInFileNames: true,
|
|
2146
|
+
resolveJsonModule: true,
|
|
2147
|
+
skipLibCheck: true,
|
|
2148
|
+
sourceMap: true,
|
|
2149
|
+
strict: true,
|
|
2150
|
+
moduleResolution: "bundler"
|
|
2151
|
+
}
|
|
2152
|
+
},
|
|
2153
|
+
null,
|
|
2154
|
+
2
|
|
2155
|
+
) + "\n",
|
|
2156
|
+
"src/app.html": `<!doctype html>
|
|
2157
|
+
<html lang="en">
|
|
2158
|
+
<head>
|
|
2159
|
+
<meta charset="utf-8" />
|
|
2160
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
2161
|
+
%sveltekit.head%
|
|
2162
|
+
</head>
|
|
2163
|
+
<body>%sveltekit.body%</body>
|
|
2164
|
+
</html>
|
|
2165
|
+
`,
|
|
2166
|
+
"src/routes/+page.svelte": `<script lang="ts">
|
|
2167
|
+
import { useChat } from '@agentskit/svelte'
|
|
2168
|
+
import '@agentskit/svelte/theme'
|
|
2169
|
+
|
|
2170
|
+
const chat = useChat({ endpoint: '/api/chat' })
|
|
2171
|
+
</script>
|
|
2172
|
+
|
|
2173
|
+
<main>
|
|
2174
|
+
{#each $chat.messages as message (message.id)}
|
|
2175
|
+
<article data-ak-message data-role={message.role}>{message.content}</article>
|
|
2176
|
+
{/each}
|
|
2177
|
+
<form on:submit|preventDefault={() => chat.send($chat.input)}>
|
|
2178
|
+
<input bind:value={$chat.input} />
|
|
2179
|
+
<button>Send</button>
|
|
2180
|
+
</form>
|
|
2181
|
+
</main>
|
|
2182
|
+
`,
|
|
2183
|
+
"src/routes/api/chat/+server.ts": `import type { RequestHandler } from './$types'
|
|
2184
|
+
${adapterImport2}${demoSnippet}export const POST: RequestHandler = async ({ request }) => {
|
|
2185
|
+
const { messages } = await request.json()
|
|
2186
|
+
const adapter = ${adapterCallStr}
|
|
2187
|
+
const source = adapter.createSource({ messages: messages.map((m: { role: string; content: string }, i: number) => ({
|
|
2188
|
+
id: String(i), role: m.role, content: m.content,
|
|
2189
|
+
status: 'complete' as const, createdAt: new Date(0),
|
|
2190
|
+
})) })
|
|
2191
|
+
|
|
2192
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2193
|
+
async start(controller) {
|
|
2194
|
+
const encoder = new TextEncoder()
|
|
2195
|
+
for await (const chunk of source.stream()) {
|
|
2196
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2197
|
+
}
|
|
2198
|
+
controller.close()
|
|
2199
|
+
},
|
|
2200
|
+
})
|
|
2201
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
2202
|
+
}
|
|
2203
|
+
`,
|
|
2204
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2205
|
+
".gitignore": "node_modules\n.svelte-kit\nbuild\n.env\n.env.local\n",
|
|
2206
|
+
"README.md": readmeFor(ctx)
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2209
|
+
function nuxtStarter(ctx) {
|
|
2210
|
+
const deps = {
|
|
2211
|
+
"@agentskit/vue": "^0.4.0",
|
|
2212
|
+
nuxt: "^4.0.0",
|
|
2213
|
+
vue: "^3.5.0"
|
|
2214
|
+
};
|
|
2215
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2216
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
2217
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
2218
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2219
|
+
return {
|
|
2220
|
+
"package.json": JSON.stringify(
|
|
2221
|
+
{
|
|
2222
|
+
name: "agentskit-nuxt-app",
|
|
2223
|
+
private: true,
|
|
2224
|
+
type: "module",
|
|
2225
|
+
scripts: {
|
|
2226
|
+
dev: "nuxt dev",
|
|
2227
|
+
build: "nuxt build",
|
|
2228
|
+
preview: "nuxt preview",
|
|
2229
|
+
generate: "nuxt generate"
|
|
2230
|
+
},
|
|
2231
|
+
dependencies: deps,
|
|
2232
|
+
devDependencies: { typescript: "^5.5.0" }
|
|
2233
|
+
},
|
|
2234
|
+
null,
|
|
2235
|
+
2
|
|
2236
|
+
) + "\n",
|
|
2237
|
+
"nuxt.config.ts": `export default defineNuxtConfig({
|
|
2238
|
+
compatibilityDate: '2026-04-01',
|
|
2239
|
+
modules: [],
|
|
2240
|
+
typescript: { strict: true },
|
|
2241
|
+
})
|
|
2242
|
+
`,
|
|
2243
|
+
"tsconfig.json": JSON.stringify(
|
|
2244
|
+
{ extends: "./.nuxt/tsconfig.json" },
|
|
2245
|
+
null,
|
|
2246
|
+
2
|
|
2247
|
+
) + "\n",
|
|
2248
|
+
"app.vue": `<script setup lang="ts">
|
|
2249
|
+
import { useChat } from '@agentskit/vue'
|
|
2250
|
+
import '@agentskit/vue/theme'
|
|
2251
|
+
|
|
2252
|
+
const { messages, input, send } = useChat({ endpoint: '/api/chat' })
|
|
2253
|
+
</script>
|
|
2254
|
+
|
|
2255
|
+
<template>
|
|
2256
|
+
<main>
|
|
2257
|
+
<article v-for="message in messages" :key="message.id" :data-role="message.role">
|
|
2258
|
+
{{ message.content }}
|
|
2259
|
+
</article>
|
|
2260
|
+
<form @submit.prevent="send(input)">
|
|
2261
|
+
<input v-model="input" />
|
|
2262
|
+
<button>Send</button>
|
|
2263
|
+
</form>
|
|
2264
|
+
</main>
|
|
2265
|
+
</template>
|
|
2266
|
+
`,
|
|
2267
|
+
"server/api/chat.post.ts": `${adapterImport2}${demoSnippet}export default defineEventHandler(async (event) => {
|
|
2268
|
+
const { messages } = await readBody<{ messages: Array<{ role: string; content: string }> }>(event)
|
|
2269
|
+
const adapter = ${adapterCallStr}
|
|
2270
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2271
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2272
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2273
|
+
})) })
|
|
2274
|
+
|
|
2275
|
+
setHeader(event, 'content-type', 'text/plain; charset=utf-8')
|
|
2276
|
+
return sendStream(event, new ReadableStream<Uint8Array>({
|
|
2277
|
+
async start(controller) {
|
|
2278
|
+
const encoder = new TextEncoder()
|
|
2279
|
+
for await (const chunk of source.stream()) {
|
|
2280
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2281
|
+
}
|
|
2282
|
+
controller.close()
|
|
2283
|
+
},
|
|
2284
|
+
}))
|
|
2285
|
+
})
|
|
2286
|
+
`,
|
|
2287
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2288
|
+
".gitignore": "node_modules\n.nuxt\n.output\n.env\n.env.local\n",
|
|
2289
|
+
"README.md": readmeFor(ctx)
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2292
|
+
function viteInkStarter(ctx) {
|
|
2293
|
+
const deps = {
|
|
2294
|
+
"@agentskit/ink": "^0.4.0",
|
|
2295
|
+
ink: "^7.0.0",
|
|
2296
|
+
react: "^19.0.0"
|
|
2297
|
+
};
|
|
2298
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2299
|
+
if (ctx.tools.length > 0) deps["@agentskit/tools"] = "^0.4.0";
|
|
2300
|
+
return {
|
|
2301
|
+
"package.json": JSON.stringify(
|
|
2302
|
+
{
|
|
2303
|
+
name: "agentskit-vite-ink-app",
|
|
2304
|
+
private: true,
|
|
2305
|
+
type: "module",
|
|
2306
|
+
scripts: {
|
|
2307
|
+
dev: "vite-node --watch src/index.tsx",
|
|
2308
|
+
start: "vite-node src/index.tsx",
|
|
2309
|
+
build: "vite build"
|
|
2310
|
+
},
|
|
2311
|
+
dependencies: deps,
|
|
2312
|
+
devDependencies: {
|
|
2313
|
+
"@types/react": "^19.0.0",
|
|
2314
|
+
"vite-node": "^4.0.0",
|
|
2315
|
+
vite: "^7.0.0",
|
|
2316
|
+
typescript: "^5.5.0"
|
|
2317
|
+
}
|
|
2318
|
+
},
|
|
2319
|
+
null,
|
|
2320
|
+
2
|
|
2321
|
+
) + "\n",
|
|
2322
|
+
"vite.config.ts": `import { defineConfig } from 'vite'
|
|
2323
|
+
export default defineConfig({
|
|
2324
|
+
build: { ssr: true, target: 'node22', rollupOptions: { input: 'src/index.tsx' } },
|
|
2325
|
+
})
|
|
2326
|
+
`,
|
|
2327
|
+
"tsconfig.json": JSON.stringify(
|
|
2328
|
+
{
|
|
2329
|
+
compilerOptions: {
|
|
2330
|
+
target: "ES2022",
|
|
2331
|
+
module: "ESNext",
|
|
2332
|
+
moduleResolution: "bundler",
|
|
2333
|
+
jsx: "react-jsx",
|
|
2334
|
+
strict: true,
|
|
2335
|
+
noEmit: true,
|
|
2336
|
+
skipLibCheck: true
|
|
2337
|
+
},
|
|
2338
|
+
include: ["src"]
|
|
2339
|
+
},
|
|
2340
|
+
null,
|
|
2341
|
+
2
|
|
2342
|
+
) + "\n",
|
|
2343
|
+
"src/index.tsx": `import React from 'react'
|
|
2344
|
+
import { render } from 'ink'
|
|
2345
|
+
import { ChatContainer, InputBar, Message, useChat } from '@agentskit/ink'
|
|
2346
|
+
${adapterImport(ctx.provider)}${toolImports(ctx.tools)}
|
|
2347
|
+
${ctx.provider === "demo" ? demoAdapterSnippet() : ""}function App() {
|
|
2348
|
+
const chat = useChat({
|
|
2349
|
+
adapter: ${adapterCall(ctx.provider)},${ctx.tools.length > 0 ? `
|
|
2350
|
+
tools: ${toolList(ctx.tools)},` : ""}
|
|
2351
|
+
})
|
|
2352
|
+
|
|
2353
|
+
return (
|
|
2354
|
+
<ChatContainer>
|
|
2355
|
+
{chat.messages.map(message => (
|
|
2356
|
+
<Message key={message.id} message={message} />
|
|
2357
|
+
))}
|
|
2358
|
+
<InputBar chat={chat} />
|
|
2359
|
+
</ChatContainer>
|
|
2360
|
+
)
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
render(<App />)
|
|
2364
|
+
`,
|
|
2365
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2366
|
+
".gitignore": "node_modules\ndist\n.env\n.env.local\n.agentskit-history.*\n",
|
|
2367
|
+
"README.md": readmeFor(ctx)
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
function cloudflareWorkersStarter(ctx) {
|
|
2371
|
+
const deps = {
|
|
2372
|
+
"itty-router": "^5.0.0"
|
|
2373
|
+
};
|
|
2374
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2375
|
+
const adapterCallEdge = ctx.provider === "demo" ? "demoAdapter()" : ctx.provider === "ollama" ? `ollama({ model: '${PROVIDER_DEFAULT_MODEL[ctx.provider]}' })` : `${PROVIDER_IMPORT[ctx.provider]}({ apiKey: env.${PROVIDER_ENV_KEY[ctx.provider]} ?? '', model: '${PROVIDER_DEFAULT_MODEL[ctx.provider]}' })`;
|
|
2376
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
2377
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2378
|
+
const envKey = PROVIDER_ENV_KEY[ctx.provider];
|
|
2379
|
+
return {
|
|
2380
|
+
"package.json": JSON.stringify(
|
|
2381
|
+
{
|
|
2382
|
+
name: "agentskit-cf-worker",
|
|
2383
|
+
private: true,
|
|
2384
|
+
type: "module",
|
|
2385
|
+
scripts: {
|
|
2386
|
+
dev: "wrangler dev",
|
|
2387
|
+
deploy: "wrangler deploy"
|
|
2388
|
+
},
|
|
2389
|
+
dependencies: deps,
|
|
2390
|
+
devDependencies: {
|
|
2391
|
+
"@cloudflare/workers-types": "^4.0.0",
|
|
2392
|
+
typescript: "^5.5.0",
|
|
2393
|
+
wrangler: "^3.0.0"
|
|
2394
|
+
}
|
|
2395
|
+
},
|
|
2396
|
+
null,
|
|
2397
|
+
2
|
|
2398
|
+
) + "\n",
|
|
2399
|
+
"wrangler.toml": `name = "agentskit-cf-worker"
|
|
2400
|
+
main = "src/worker.ts"
|
|
2401
|
+
compatibility_date = "2026-04-01"
|
|
2402
|
+
compatibility_flags = ["nodejs_compat"]
|
|
2403
|
+
|
|
2404
|
+
# Bind D1 + KV when you wire memory:
|
|
2405
|
+
# [[d1_databases]]
|
|
2406
|
+
# binding = "DB"
|
|
2407
|
+
# database_name = "agentskit"
|
|
2408
|
+
#
|
|
2409
|
+
# [[kv_namespaces]]
|
|
2410
|
+
# binding = "KV"
|
|
2411
|
+
# id = "..."
|
|
2412
|
+
|
|
2413
|
+
[vars]
|
|
2414
|
+
${envKey ? `# Set ${envKey} via 'wrangler secret put ${envKey}'` : "# No API key required for the demo provider"}
|
|
2415
|
+
`,
|
|
2416
|
+
"tsconfig.json": JSON.stringify(
|
|
2417
|
+
{
|
|
2418
|
+
compilerOptions: {
|
|
2419
|
+
target: "ES2022",
|
|
2420
|
+
module: "ESNext",
|
|
2421
|
+
moduleResolution: "bundler",
|
|
2422
|
+
lib: ["ES2022"],
|
|
2423
|
+
types: ["@cloudflare/workers-types"],
|
|
2424
|
+
strict: true,
|
|
2425
|
+
noEmit: true,
|
|
2426
|
+
skipLibCheck: true
|
|
2427
|
+
},
|
|
2428
|
+
include: ["src"]
|
|
2429
|
+
},
|
|
2430
|
+
null,
|
|
2431
|
+
2
|
|
2432
|
+
) + "\n",
|
|
2433
|
+
"src/worker.ts": `import { Router } from 'itty-router'
|
|
2434
|
+
${adapterImport2}
|
|
2435
|
+
${demoSnippet}interface Env {
|
|
2436
|
+
${envKey ? `${envKey}: string` : "/* no env vars */"}
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
const router = Router()
|
|
2440
|
+
|
|
2441
|
+
router.post('/chat', async (request: Request, env: Env) => {
|
|
2442
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2443
|
+
const adapter = ${adapterCallEdge}
|
|
2444
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2445
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2446
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2447
|
+
})) })
|
|
2448
|
+
|
|
2449
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2450
|
+
async start(controller) {
|
|
2451
|
+
const encoder = new TextEncoder()
|
|
2452
|
+
for await (const chunk of source.stream()) {
|
|
2453
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2454
|
+
}
|
|
2455
|
+
controller.close()
|
|
2456
|
+
},
|
|
2457
|
+
})
|
|
2458
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
2459
|
+
})
|
|
2460
|
+
|
|
2461
|
+
router.all('*', () => new Response('not found', { status: 404 }))
|
|
2462
|
+
|
|
2463
|
+
export default {
|
|
2464
|
+
fetch: (req: Request, env: Env, ctx: ExecutionContext) => router.handle(req, env, ctx),
|
|
2465
|
+
} satisfies ExportedHandler<Env>
|
|
2466
|
+
`,
|
|
2467
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2468
|
+
".gitignore": "node_modules\n.wrangler\n.dev.vars\n.env\n.env.local\n",
|
|
2469
|
+
"README.md": readmeFor(ctx)
|
|
2470
|
+
};
|
|
2471
|
+
}
|
|
2472
|
+
function bunStarter(ctx) {
|
|
2473
|
+
const deps = {};
|
|
2474
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2475
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
2476
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
2477
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2478
|
+
return {
|
|
2479
|
+
"package.json": JSON.stringify(
|
|
2480
|
+
{
|
|
2481
|
+
name: "agentskit-bun-server",
|
|
2482
|
+
private: true,
|
|
2483
|
+
type: "module",
|
|
2484
|
+
scripts: {
|
|
2485
|
+
dev: "bun --hot src/server.ts",
|
|
2486
|
+
start: "bun src/server.ts"
|
|
2487
|
+
},
|
|
2488
|
+
dependencies: deps,
|
|
2489
|
+
devDependencies: { typescript: "^5.5.0" }
|
|
2490
|
+
},
|
|
2491
|
+
null,
|
|
2492
|
+
2
|
|
2493
|
+
) + "\n",
|
|
2494
|
+
"tsconfig.json": JSON.stringify(
|
|
2495
|
+
{
|
|
2496
|
+
compilerOptions: {
|
|
2497
|
+
target: "ES2022",
|
|
2498
|
+
module: "ESNext",
|
|
2499
|
+
moduleResolution: "bundler",
|
|
2500
|
+
types: ["bun-types"],
|
|
2501
|
+
strict: true,
|
|
2502
|
+
noEmit: true,
|
|
2503
|
+
skipLibCheck: true
|
|
2504
|
+
},
|
|
2505
|
+
include: ["src"]
|
|
2506
|
+
},
|
|
2507
|
+
null,
|
|
2508
|
+
2
|
|
2509
|
+
) + "\n",
|
|
2510
|
+
"src/server.ts": `${adapterImport2}${demoSnippet}const adapter = ${adapterCallStr}
|
|
2511
|
+
|
|
2512
|
+
const server = Bun.serve({
|
|
2513
|
+
port: Number(process.env.PORT ?? 3000),
|
|
2514
|
+
async fetch(request) {
|
|
2515
|
+
const url = new URL(request.url)
|
|
2516
|
+
if (request.method === 'POST' && url.pathname === '/chat') {
|
|
2517
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2518
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2519
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2520
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2521
|
+
})) })
|
|
2522
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2523
|
+
async start(controller) {
|
|
2524
|
+
const encoder = new TextEncoder()
|
|
2525
|
+
for await (const chunk of source.stream()) {
|
|
2526
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2527
|
+
}
|
|
2528
|
+
controller.close()
|
|
2529
|
+
},
|
|
2530
|
+
})
|
|
2531
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
2532
|
+
}
|
|
2533
|
+
if (url.pathname === '/') {
|
|
2534
|
+
return new Response(\`<!doctype html><title>AgentsKit Bun starter</title>
|
|
2535
|
+
<body><pre>POST /chat with { messages: [...] }</pre></body>\`, {
|
|
2536
|
+
headers: { 'content-type': 'text/html' },
|
|
2537
|
+
})
|
|
2538
|
+
}
|
|
2539
|
+
return new Response('not found', { status: 404 })
|
|
2540
|
+
},
|
|
2541
|
+
})
|
|
2542
|
+
|
|
2543
|
+
console.log(\`Listening on http://localhost:\${server.port}\`)
|
|
2544
|
+
`,
|
|
2545
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2546
|
+
".gitignore": "node_modules\n.env\n.env.local\nbun.lockb\n",
|
|
2547
|
+
"README.md": readmeFor(ctx)
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
function nextjsStarter(ctx) {
|
|
2551
|
+
const deps = {
|
|
2552
|
+
"@agentskit/react": "^0.4.0",
|
|
2553
|
+
next: "^15.0.0",
|
|
2554
|
+
react: "^19.0.0",
|
|
2555
|
+
"react-dom": "^19.0.0"
|
|
2556
|
+
};
|
|
2557
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2558
|
+
if (ctx.tools.length > 0) deps["@agentskit/tools"] = "^0.4.0";
|
|
2559
|
+
const envKey = PROVIDER_ENV_KEY[ctx.provider];
|
|
2560
|
+
const adapter = adapterCall(ctx.provider);
|
|
2561
|
+
const apiAdapterImport = ctx.provider === "demo" ? "" : `import { ${PROVIDER_IMPORT[ctx.provider]} } from '@agentskit/adapters'
|
|
2562
|
+
`;
|
|
2563
|
+
const apiDemoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2564
|
+
return {
|
|
2565
|
+
"package.json": JSON.stringify(
|
|
2566
|
+
{
|
|
2567
|
+
name: "agentskit-nextjs-app",
|
|
2568
|
+
private: true,
|
|
2569
|
+
type: "module",
|
|
2570
|
+
scripts: {
|
|
2571
|
+
dev: "next dev",
|
|
2572
|
+
build: "next build",
|
|
2573
|
+
start: "next start",
|
|
2574
|
+
lint: "next lint"
|
|
2575
|
+
},
|
|
2576
|
+
dependencies: deps,
|
|
2577
|
+
devDependencies: {
|
|
2578
|
+
"@types/node": "^22.0.0",
|
|
2579
|
+
"@types/react": "^19.0.0",
|
|
2580
|
+
"@types/react-dom": "^19.0.0",
|
|
2581
|
+
typescript: "^5.5.0"
|
|
2582
|
+
}
|
|
2583
|
+
},
|
|
2584
|
+
null,
|
|
2585
|
+
2
|
|
2586
|
+
) + "\n",
|
|
2587
|
+
"next.config.mjs": `/** @type {import('next').NextConfig} */
|
|
2588
|
+
const nextConfig = {}
|
|
2589
|
+
export default nextConfig
|
|
2590
|
+
`,
|
|
2591
|
+
"tsconfig.json": JSON.stringify(
|
|
2592
|
+
{
|
|
2593
|
+
compilerOptions: {
|
|
2594
|
+
target: "ES2022",
|
|
2595
|
+
lib: ["dom", "dom.iterable", "ES2022"],
|
|
2596
|
+
allowJs: true,
|
|
2597
|
+
skipLibCheck: true,
|
|
2598
|
+
strict: true,
|
|
2599
|
+
noEmit: true,
|
|
2600
|
+
esModuleInterop: true,
|
|
2601
|
+
module: "ESNext",
|
|
2602
|
+
moduleResolution: "bundler",
|
|
2603
|
+
resolveJsonModule: true,
|
|
2604
|
+
isolatedModules: true,
|
|
2605
|
+
jsx: "preserve",
|
|
2606
|
+
incremental: true,
|
|
2607
|
+
plugins: [{ name: "next" }],
|
|
2608
|
+
paths: { "@/*": ["./*"] }
|
|
2609
|
+
},
|
|
2610
|
+
include: ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
2611
|
+
exclude: ["node_modules"]
|
|
2612
|
+
},
|
|
2613
|
+
null,
|
|
2614
|
+
2
|
|
2615
|
+
) + "\n",
|
|
2616
|
+
"app/layout.tsx": `import type { ReactNode } from 'react'
|
|
2617
|
+
import '@agentskit/react/theme'
|
|
2618
|
+
|
|
2619
|
+
export const metadata = { title: 'AgentsKit \xB7 Next.js Starter' }
|
|
2620
|
+
|
|
2621
|
+
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
2622
|
+
return (
|
|
2623
|
+
<html lang="en">
|
|
2624
|
+
<body>{children}</body>
|
|
2625
|
+
</html>
|
|
2626
|
+
)
|
|
2627
|
+
}
|
|
2628
|
+
`,
|
|
2629
|
+
"app/page.tsx": `'use client'
|
|
2630
|
+
|
|
2631
|
+
import { ChatContainer, InputBar, Message, useChat } from '@agentskit/react'
|
|
2632
|
+
import { genericAdapter } from './chat-adapter'
|
|
2633
|
+
|
|
2634
|
+
export default function Page() {
|
|
2635
|
+
const chat = useChat({ adapter: genericAdapter('/api/chat') })
|
|
2636
|
+
|
|
2637
|
+
return (
|
|
2638
|
+
<main style={{ display: 'grid', placeItems: 'center', minHeight: '100dvh' }}>
|
|
2639
|
+
<ChatContainer>
|
|
2640
|
+
{chat.messages.map(message => (
|
|
2641
|
+
<Message key={message.id} message={message} />
|
|
2642
|
+
))}
|
|
2643
|
+
<InputBar chat={chat} />
|
|
2644
|
+
</ChatContainer>
|
|
2645
|
+
</main>
|
|
2646
|
+
)
|
|
2647
|
+
}
|
|
2648
|
+
`,
|
|
2649
|
+
"app/chat-adapter.ts": `import { generic } from '@agentskit/adapters'
|
|
2650
|
+
|
|
2651
|
+
export const genericAdapter = (route: string) => generic({
|
|
2652
|
+
fetch: async ({ messages, signal }) => {
|
|
2653
|
+
const response = await fetch(route, {
|
|
2654
|
+
method: 'POST',
|
|
2655
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2656
|
+
body: JSON.stringify({ messages }),
|
|
2657
|
+
signal,
|
|
2658
|
+
})
|
|
2659
|
+
if (!response.body) throw new Error('No body returned from /api/chat')
|
|
2660
|
+
return response
|
|
2661
|
+
},
|
|
2662
|
+
})
|
|
2663
|
+
`,
|
|
2664
|
+
"app/api/chat/route.ts": `${apiAdapterImport}${apiDemoSnippet}export const runtime = 'edge'
|
|
2665
|
+
|
|
2666
|
+
export async function POST(request: Request) {
|
|
2667
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2668
|
+
|
|
2669
|
+
const adapter = ${adapter}
|
|
2670
|
+
|
|
2671
|
+
const source = adapter.createSource({ messages: messages.map((message, index) => ({
|
|
2672
|
+
id: String(index),
|
|
2673
|
+
role: message.role as 'user' | 'assistant' | 'system',
|
|
2674
|
+
content: message.content,
|
|
2675
|
+
status: 'complete' as const,
|
|
2676
|
+
createdAt: new Date(0),
|
|
2677
|
+
})) })
|
|
2678
|
+
|
|
2679
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2680
|
+
async start(controller) {
|
|
2681
|
+
const encoder = new TextEncoder()
|
|
2682
|
+
try {
|
|
2683
|
+
for await (const chunk of source.stream()) {
|
|
2684
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2685
|
+
}
|
|
2686
|
+
} catch (err) {
|
|
2687
|
+
controller.error(err)
|
|
2688
|
+
return
|
|
2689
|
+
}
|
|
2690
|
+
controller.close()
|
|
2691
|
+
},
|
|
2692
|
+
})
|
|
2693
|
+
|
|
2694
|
+
return new Response(stream, {
|
|
2695
|
+
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'no-cache' },
|
|
2696
|
+
})
|
|
2697
|
+
}
|
|
2698
|
+
`,
|
|
2699
|
+
".env.example": envKey ? `${envKey}=
|
|
2700
|
+
` : "# No API key required for the demo provider\n",
|
|
2701
|
+
".gitignore": `node_modules
|
|
2702
|
+
.next
|
|
2703
|
+
out
|
|
2704
|
+
.env
|
|
2705
|
+
.env.local
|
|
2706
|
+
.agentskit-history.*
|
|
2707
|
+
`,
|
|
2708
|
+
"README.md": readmeFor(ctx)
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
function expoStarter(ctx) {
|
|
2712
|
+
const deps = {
|
|
2713
|
+
expo: "^54.0.0",
|
|
2714
|
+
"expo-router": "^7.0.0",
|
|
2715
|
+
"expo-secure-store": "^15.0.0",
|
|
2716
|
+
react: "^19.0.0",
|
|
2717
|
+
"react-native": "^0.84.0"
|
|
2718
|
+
};
|
|
2719
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2720
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
2721
|
+
const adapterImport2 = ctx.provider === "demo" ? "" : `import { ${PROVIDER_IMPORT[ctx.provider]} } from '@agentskit/adapters'
|
|
2722
|
+
`;
|
|
2723
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2724
|
+
return {
|
|
2725
|
+
"package.json": JSON.stringify(
|
|
2726
|
+
{
|
|
2727
|
+
name: "agentskit-expo-app",
|
|
2728
|
+
version: "1.0.0",
|
|
2729
|
+
main: "expo-router/entry",
|
|
2730
|
+
scripts: {
|
|
2731
|
+
start: "expo start",
|
|
2732
|
+
android: "expo start --android",
|
|
2733
|
+
ios: "expo start --ios",
|
|
2734
|
+
web: "expo start --web"
|
|
2735
|
+
},
|
|
2736
|
+
dependencies: deps,
|
|
2737
|
+
devDependencies: {
|
|
2738
|
+
"@types/react": "^19.0.0",
|
|
2739
|
+
typescript: "^5.5.0"
|
|
2740
|
+
}
|
|
2741
|
+
},
|
|
2742
|
+
null,
|
|
2743
|
+
2
|
|
2744
|
+
) + "\n",
|
|
2745
|
+
"app.json": JSON.stringify(
|
|
2746
|
+
{
|
|
2747
|
+
expo: {
|
|
2748
|
+
name: "AgentsKit Expo Starter",
|
|
2749
|
+
slug: "agentskit-expo",
|
|
2750
|
+
scheme: "agentskit",
|
|
2751
|
+
plugins: ["expo-router", "expo-secure-store"],
|
|
2752
|
+
ios: { bundleIdentifier: "com.example.agentskit" },
|
|
2753
|
+
android: { package: "com.example.agentskit" }
|
|
2754
|
+
}
|
|
2755
|
+
},
|
|
2756
|
+
null,
|
|
2757
|
+
2
|
|
2758
|
+
) + "\n",
|
|
2759
|
+
"tsconfig.json": JSON.stringify(
|
|
2760
|
+
{ extends: "expo/tsconfig.base", compilerOptions: { strict: true } },
|
|
2761
|
+
null,
|
|
2762
|
+
2
|
|
2763
|
+
) + "\n",
|
|
2764
|
+
"app/_layout.tsx": `import { Stack } from 'expo-router'
|
|
2765
|
+
import { AuthProvider } from '../lib/auth'
|
|
2766
|
+
|
|
2767
|
+
export default function RootLayout() {
|
|
2768
|
+
return (
|
|
2769
|
+
<AuthProvider>
|
|
2770
|
+
<Stack />
|
|
2771
|
+
</AuthProvider>
|
|
2772
|
+
)
|
|
2773
|
+
}
|
|
2774
|
+
`,
|
|
2775
|
+
"app/index.tsx": `import { useState } from 'react'
|
|
2776
|
+
import { Text, TextInput, View, Pressable, ScrollView } from 'react-native'
|
|
2777
|
+
import { useAuth } from '../lib/auth'
|
|
2778
|
+
${adapterImport2}${demoSnippet}export default function Chat() {
|
|
2779
|
+
const { token, signIn, signOut } = useAuth()
|
|
2780
|
+
const [messages, setMessages] = useState<{ role: 'user' | 'assistant'; content: string }[]>([])
|
|
2781
|
+
const [input, setInput] = useState('')
|
|
2782
|
+
|
|
2783
|
+
if (!token) {
|
|
2784
|
+
return (
|
|
2785
|
+
<View style={{ flex: 1, justifyContent: 'center', padding: 24 }}>
|
|
2786
|
+
<Text style={{ fontSize: 20, marginBottom: 12 }}>Sign in to chat</Text>
|
|
2787
|
+
<Pressable onPress={() => signIn('demo-token')}><Text>Sign in</Text></Pressable>
|
|
2788
|
+
</View>
|
|
2789
|
+
)
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
async function send() {
|
|
2793
|
+
if (!input.trim()) return
|
|
2794
|
+
const next = [...messages, { role: 'user' as const, content: input }]
|
|
2795
|
+
setMessages(next)
|
|
2796
|
+
setInput('')
|
|
2797
|
+
const adapter = ${adapterCallStr}
|
|
2798
|
+
const source = adapter.createSource({ messages: next.map((m, i) => ({
|
|
2799
|
+
id: String(i), role: m.role, content: m.content,
|
|
2800
|
+
status: 'complete' as const, createdAt: new Date(0),
|
|
2801
|
+
})) })
|
|
2802
|
+
let acc = ''
|
|
2803
|
+
for await (const chunk of source.stream()) {
|
|
2804
|
+
if (chunk.type === 'text') {
|
|
2805
|
+
acc += chunk.content
|
|
2806
|
+
setMessages([...next, { role: 'assistant', content: acc }])
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
return (
|
|
2812
|
+
<View style={{ flex: 1, padding: 16 }}>
|
|
2813
|
+
<Pressable onPress={signOut}><Text>Sign out</Text></Pressable>
|
|
2814
|
+
<ScrollView style={{ flex: 1 }}>
|
|
2815
|
+
{messages.map((m, i) => (
|
|
2816
|
+
<Text key={i} style={{ marginVertical: 4 }}>{m.role}: {m.content}</Text>
|
|
2817
|
+
))}
|
|
2818
|
+
</ScrollView>
|
|
2819
|
+
<TextInput value={input} onChangeText={setInput} onSubmitEditing={send} placeholder="Ask anything\u2026" />
|
|
2820
|
+
</View>
|
|
2821
|
+
)
|
|
2822
|
+
}
|
|
2823
|
+
`,
|
|
2824
|
+
"lib/auth.tsx": `import { createContext, useContext, useEffect, useState, type ReactNode } from 'react'
|
|
2825
|
+
import * as SecureStore from 'expo-secure-store'
|
|
2826
|
+
|
|
2827
|
+
interface AuthValue { token: string | null; signIn: (t: string) => void; signOut: () => void }
|
|
2828
|
+
const AuthCtx = createContext<AuthValue>({ token: null, signIn: () => {}, signOut: () => {} })
|
|
2829
|
+
|
|
2830
|
+
export function AuthProvider({ children }: { children: ReactNode }) {
|
|
2831
|
+
const [token, setToken] = useState<string | null>(null)
|
|
2832
|
+
|
|
2833
|
+
useEffect(() => {
|
|
2834
|
+
SecureStore.getItemAsync('agentskit_token').then(setToken).catch(() => {})
|
|
2835
|
+
}, [])
|
|
2836
|
+
|
|
2837
|
+
return (
|
|
2838
|
+
<AuthCtx.Provider
|
|
2839
|
+
value={{
|
|
2840
|
+
token,
|
|
2841
|
+
signIn: (t) => { SecureStore.setItemAsync('agentskit_token', t); setToken(t) },
|
|
2842
|
+
signOut: () => { SecureStore.deleteItemAsync('agentskit_token'); setToken(null) },
|
|
2843
|
+
}}
|
|
2844
|
+
>
|
|
2845
|
+
{children}
|
|
2846
|
+
</AuthCtx.Provider>
|
|
2847
|
+
)
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
export const useAuth = () => useContext(AuthCtx)
|
|
2851
|
+
`,
|
|
2852
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2853
|
+
".gitignore": "node_modules\n.expo\ndist\n.env\n.env.local\n",
|
|
2854
|
+
"README.md": readmeFor(ctx)
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
function denoDeployStarter(ctx) {
|
|
2858
|
+
const adapterCallEdge = ctx.provider === "demo" ? "demoAdapter()" : ctx.provider === "ollama" ? `ollama({ model: '${PROVIDER_DEFAULT_MODEL[ctx.provider]}' })` : `${PROVIDER_IMPORT[ctx.provider]}({ apiKey: Deno.env.get('${PROVIDER_ENV_KEY[ctx.provider]}') ?? '', model: '${PROVIDER_DEFAULT_MODEL[ctx.provider]}' })`;
|
|
2859
|
+
const adapterImport2 = ctx.provider === "demo" ? "" : `import { ${PROVIDER_IMPORT[ctx.provider]} } from 'npm:@agentskit/adapters'
|
|
2860
|
+
`;
|
|
2861
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2862
|
+
return {
|
|
2863
|
+
"deno.json": JSON.stringify(
|
|
2864
|
+
{
|
|
2865
|
+
tasks: {
|
|
2866
|
+
dev: "deno run --allow-net --allow-env --watch main.ts",
|
|
2867
|
+
start: "deno run --allow-net --allow-env main.ts",
|
|
2868
|
+
deploy: "deployctl deploy --project=agentskit-deno main.ts"
|
|
2869
|
+
},
|
|
2870
|
+
imports: {
|
|
2871
|
+
"@agentskit/adapters": "npm:@agentskit/adapters@^0.4.0"
|
|
2872
|
+
}
|
|
2873
|
+
},
|
|
2874
|
+
null,
|
|
2875
|
+
2
|
|
2876
|
+
) + "\n",
|
|
2877
|
+
"main.ts": `${adapterImport2}${demoSnippet}const adapter = ${adapterCallEdge}
|
|
2878
|
+
|
|
2879
|
+
Deno.serve(async (request) => {
|
|
2880
|
+
const url = new URL(request.url)
|
|
2881
|
+
if (request.method === 'POST' && url.pathname === '/chat') {
|
|
2882
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2883
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2884
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2885
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2886
|
+
})) })
|
|
2887
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2888
|
+
async start(controller) {
|
|
2889
|
+
const encoder = new TextEncoder()
|
|
2890
|
+
for await (const chunk of source.stream()) {
|
|
2891
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2892
|
+
}
|
|
2893
|
+
controller.close()
|
|
2894
|
+
},
|
|
2895
|
+
})
|
|
2896
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
2897
|
+
}
|
|
2898
|
+
return new Response(\`<!doctype html><title>AgentsKit Deno Deploy starter</title>
|
|
2899
|
+
<body><pre>POST /chat with { messages: [...] }</pre></body>\`, {
|
|
2900
|
+
headers: { 'content-type': 'text/html' },
|
|
2901
|
+
})
|
|
2902
|
+
})
|
|
2903
|
+
`,
|
|
2904
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2905
|
+
".gitignore": ".env\n.env.local\n",
|
|
2906
|
+
"README.md": readmeFor(ctx)
|
|
2907
|
+
};
|
|
2908
|
+
}
|
|
2909
|
+
function angularStarter(ctx) {
|
|
2910
|
+
const deps = {
|
|
2911
|
+
"@agentskit/angular": "^0.4.0",
|
|
2912
|
+
"@angular/core": "^21.0.0",
|
|
2913
|
+
"@angular/common": "^21.0.0",
|
|
2914
|
+
"@angular/compiler": "^21.0.0",
|
|
2915
|
+
"@angular/platform-browser": "^21.0.0",
|
|
2916
|
+
"@angular/platform-browser-dynamic": "^21.0.0",
|
|
2917
|
+
rxjs: "^7.8.0",
|
|
2918
|
+
"zone.js": "^0.16.1"
|
|
2919
|
+
};
|
|
2920
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2921
|
+
return {
|
|
2922
|
+
"package.json": JSON.stringify(
|
|
2923
|
+
{
|
|
2924
|
+
name: "agentskit-angular-app",
|
|
2925
|
+
private: true,
|
|
2926
|
+
scripts: {
|
|
2927
|
+
dev: "ng serve",
|
|
2928
|
+
build: "ng build",
|
|
2929
|
+
start: "ng serve"
|
|
2930
|
+
},
|
|
2931
|
+
dependencies: deps,
|
|
2932
|
+
devDependencies: {
|
|
2933
|
+
"@angular/cli": "^21.0.0",
|
|
2934
|
+
"@angular/compiler-cli": "^21.0.0",
|
|
2935
|
+
typescript: "^5.5.0"
|
|
2936
|
+
}
|
|
2937
|
+
},
|
|
2938
|
+
null,
|
|
2939
|
+
2
|
|
2940
|
+
) + "\n",
|
|
2941
|
+
"angular.json": JSON.stringify(
|
|
2942
|
+
{
|
|
2943
|
+
$schema: "./node_modules/@angular/cli/lib/config/schema.json",
|
|
2944
|
+
version: 1,
|
|
2945
|
+
projects: {
|
|
2946
|
+
app: {
|
|
2947
|
+
projectType: "application",
|
|
2948
|
+
root: "",
|
|
2949
|
+
sourceRoot: "src",
|
|
2950
|
+
prefix: "ak",
|
|
2951
|
+
architect: {
|
|
2952
|
+
build: {
|
|
2953
|
+
builder: "@angular/build:application",
|
|
2954
|
+
options: { browser: "src/main.ts", tsConfig: "tsconfig.json", index: "src/index.html" }
|
|
2955
|
+
},
|
|
2956
|
+
serve: { builder: "@angular/build:dev-server", options: { buildTarget: "app:build" } }
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
},
|
|
2961
|
+
null,
|
|
2962
|
+
2
|
|
2963
|
+
) + "\n",
|
|
2964
|
+
"tsconfig.json": JSON.stringify(
|
|
2965
|
+
{
|
|
2966
|
+
compilerOptions: {
|
|
2967
|
+
target: "ES2022",
|
|
2968
|
+
module: "preserve",
|
|
2969
|
+
moduleResolution: "bundler",
|
|
2970
|
+
strict: true,
|
|
2971
|
+
experimentalDecorators: true,
|
|
2972
|
+
useDefineForClassFields: false,
|
|
2973
|
+
lib: ["ES2022", "DOM"]
|
|
2974
|
+
},
|
|
2975
|
+
include: ["src/**/*.ts"]
|
|
2976
|
+
},
|
|
2977
|
+
null,
|
|
2978
|
+
2
|
|
2979
|
+
) + "\n",
|
|
2980
|
+
"src/index.html": `<!doctype html>
|
|
2981
|
+
<html><head><title>AgentsKit Angular</title></head>
|
|
2982
|
+
<body><ak-root></ak-root></body></html>
|
|
2983
|
+
`,
|
|
2984
|
+
"src/main.ts": `import { bootstrapApplication } from '@angular/platform-browser'
|
|
2985
|
+
import 'zone.js'
|
|
2986
|
+
import { AppComponent } from './app'
|
|
2987
|
+
|
|
2988
|
+
bootstrapApplication(AppComponent)
|
|
2989
|
+
`,
|
|
2990
|
+
"src/app.ts": `import { Component, signal } from '@angular/core'
|
|
2991
|
+
import { CommonModule } from '@angular/common'
|
|
2992
|
+
|
|
2993
|
+
@Component({
|
|
2994
|
+
selector: 'ak-root',
|
|
2995
|
+
standalone: true,
|
|
2996
|
+
imports: [CommonModule],
|
|
2997
|
+
template: \`
|
|
2998
|
+
<main style="max-width: 640px; margin: 2rem auto;">
|
|
2999
|
+
<h1>AgentsKit \xB7 Angular standalone</h1>
|
|
3000
|
+
<p>Wire @agentskit/angular here. See the docs for the chat service binding.</p>
|
|
3001
|
+
<p>Counter (sanity): {{ count() }}</p>
|
|
3002
|
+
<button (click)="bump()">+1</button>
|
|
3003
|
+
</main>
|
|
3004
|
+
\`,
|
|
3005
|
+
})
|
|
3006
|
+
export class AppComponent {
|
|
3007
|
+
readonly count = signal(0)
|
|
3008
|
+
bump() { this.count.update(n => n + 1) }
|
|
3009
|
+
}
|
|
3010
|
+
`,
|
|
3011
|
+
".env.example": envExampleFor(ctx.provider),
|
|
3012
|
+
".gitignore": "node_modules\ndist\n.angular\n.env\n.env.local\n",
|
|
3013
|
+
"README.md": readmeFor(ctx)
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
2082
3016
|
function readmeFor(ctx) {
|
|
2083
3017
|
const installCmd = ctx.pm === "npm" ? "npm install" : `${ctx.pm} install`;
|
|
2084
3018
|
const runCmd = ctx.pm === "npm" ? "npm run dev" : `${ctx.pm} dev`;
|
|
@@ -2116,9 +3050,18 @@ ISC
|
|
|
2116
3050
|
}
|
|
2117
3051
|
var TEMPLATE_FN = {
|
|
2118
3052
|
react: reactStarter,
|
|
3053
|
+
nextjs: nextjsStarter,
|
|
2119
3054
|
ink: inkStarter,
|
|
2120
3055
|
runtime: runtimeStarter,
|
|
2121
|
-
"multi-agent": multiAgentStarter
|
|
3056
|
+
"multi-agent": multiAgentStarter,
|
|
3057
|
+
sveltekit: sveltekitStarter,
|
|
3058
|
+
nuxt: nuxtStarter,
|
|
3059
|
+
"vite-ink": viteInkStarter,
|
|
3060
|
+
"cloudflare-workers": cloudflareWorkersStarter,
|
|
3061
|
+
bun: bunStarter,
|
|
3062
|
+
expo: expoStarter,
|
|
3063
|
+
"deno-deploy": denoDeployStarter,
|
|
3064
|
+
angular: angularStarter
|
|
2122
3065
|
};
|
|
2123
3066
|
async function writeStarterProject(options) {
|
|
2124
3067
|
const ctx = {
|
|
@@ -2159,7 +3102,16 @@ ${kleur__default.default.bold().green("\u25B2")} ${kleur__default.default.bold("
|
|
|
2159
3102
|
default: defaults.template ?? "react",
|
|
2160
3103
|
choices: [
|
|
2161
3104
|
{ name: "React chat (Vite + browser)", value: "react", description: "Streaming UI with @agentskit/react" },
|
|
3105
|
+
{ name: "Next.js chat (App Router + Route Handler)", value: "nextjs", description: "app/api/chat streams to a useChat client" },
|
|
3106
|
+
{ name: "SvelteKit chat", value: "sveltekit", description: "@agentskit/svelte client + server route streaming" },
|
|
3107
|
+
{ name: "Nuxt chat", value: "nuxt", description: "@agentskit/vue composable + Nitro server route streaming" },
|
|
2162
3108
|
{ name: "Ink chat (terminal UI)", value: "ink", description: "Same chat but in your terminal" },
|
|
3109
|
+
{ name: "Vite + Ink (terminal, hot-reload)", value: "vite-ink", description: "Ink chat with vite-node hot reload" },
|
|
3110
|
+
{ name: "Cloudflare Workers (edge)", value: "cloudflare-workers", description: "Edge runtime with itty-router + streaming" },
|
|
3111
|
+
{ name: "Bun server", value: "bun", description: "Bun.serve with hot reload" },
|
|
3112
|
+
{ name: "Deno Deploy", value: "deno-deploy", description: "Deno.serve with deployctl + npm: imports" },
|
|
3113
|
+
{ name: "Expo + auth (mobile)", value: "expo", description: "expo-router + expo-secure-store + chat screen" },
|
|
3114
|
+
{ name: "Angular standalone", value: "angular", description: "Angular 21 standalone bootstrap with @agentskit/angular" },
|
|
2163
3115
|
{ name: "Runtime (headless agent, no UI)", value: "runtime", description: "Autonomous task \u2192 result" },
|
|
2164
3116
|
{ name: "Multi-agent (planner + delegates)", value: "multi-agent", description: "Supervisor pattern, ready to extend" }
|
|
2165
3117
|
]
|
|
@@ -2268,7 +3220,7 @@ function printNextSteps(options) {
|
|
|
2268
3220
|
|
|
2269
3221
|
// src/commands/init.ts
|
|
2270
3222
|
function registerInitCommand(program) {
|
|
2271
|
-
program.command("init").description("Generate a starter project. Run with no flags for interactive mode.").option("--template <template>", "Starter template (react|ink|runtime|multi-agent)").option("--dir <directory>", "Target directory", "agentskit-app").option("--provider <provider>", "LLM provider (openai|anthropic|gemini|ollama|demo)").option("--tools <tools>", "Comma-separated tools (web_search,filesystem,shell)").option("--memory <backend>", "Memory backend (none|file|sqlite)").option("--pm <packageManager>", "Package manager (pnpm|npm|yarn|bun)").option("-y, --yes", "Skip interactive prompts; use flag values + defaults").action(async (rawOptions) => {
|
|
3223
|
+
program.command("init").description("Generate a starter project. Run with no flags for interactive mode.").option("--template <template>", "Starter template (react|nextjs|sveltekit|nuxt|ink|vite-ink|cloudflare-workers|bun|deno-deploy|expo|angular|runtime|multi-agent)").option("--dir <directory>", "Target directory", "agentskit-app").option("--provider <provider>", "LLM provider (openai|anthropic|gemini|ollama|demo)").option("--tools <tools>", "Comma-separated tools (web_search,filesystem,shell)").option("--memory <backend>", "Memory backend (none|file|sqlite)").option("--pm <packageManager>", "Package manager (pnpm|npm|yarn|bun)").option("-y, --yes", "Skip interactive prompts; use flag values + defaults").action(async (rawOptions) => {
|
|
2272
3224
|
const isCi = !process.stdout.isTTY || rawOptions.yes || rawOptions.template;
|
|
2273
3225
|
let resolved;
|
|
2274
3226
|
if (isCi) {
|