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