@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
|
@@ -1819,6 +1819,940 @@ console.log(\`\\n\u2014 \${result.steps} steps \xB7 \${result.toolCalls.length}
|
|
|
1819
1819
|
"README.md": readmeFor(ctx)
|
|
1820
1820
|
};
|
|
1821
1821
|
}
|
|
1822
|
+
function buildAdapterServerImport(provider) {
|
|
1823
|
+
if (provider === "demo") return "";
|
|
1824
|
+
return `import { ${PROVIDER_IMPORT[provider]} } from '@agentskit/adapters'
|
|
1825
|
+
`;
|
|
1826
|
+
}
|
|
1827
|
+
function envExampleFor(provider) {
|
|
1828
|
+
const envKey = PROVIDER_ENV_KEY[provider];
|
|
1829
|
+
return envKey ? `${envKey}=
|
|
1830
|
+
` : "# No API key required for the demo provider\n";
|
|
1831
|
+
}
|
|
1832
|
+
function sveltekitStarter(ctx) {
|
|
1833
|
+
const deps = {
|
|
1834
|
+
"@agentskit/svelte": "^0.4.0",
|
|
1835
|
+
"@sveltejs/kit": "^2.0.0",
|
|
1836
|
+
svelte: "^5.0.0"
|
|
1837
|
+
};
|
|
1838
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
1839
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
1840
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
1841
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
1842
|
+
return {
|
|
1843
|
+
"package.json": JSON.stringify(
|
|
1844
|
+
{
|
|
1845
|
+
name: "agentskit-sveltekit-app",
|
|
1846
|
+
private: true,
|
|
1847
|
+
type: "module",
|
|
1848
|
+
scripts: {
|
|
1849
|
+
dev: "vite dev",
|
|
1850
|
+
build: "vite build",
|
|
1851
|
+
preview: "vite preview",
|
|
1852
|
+
check: "svelte-check --tsconfig ./tsconfig.json"
|
|
1853
|
+
},
|
|
1854
|
+
dependencies: deps,
|
|
1855
|
+
devDependencies: {
|
|
1856
|
+
"@sveltejs/adapter-auto": "^4.0.0",
|
|
1857
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
1858
|
+
"svelte-check": "^4.0.0",
|
|
1859
|
+
typescript: "^5.5.0",
|
|
1860
|
+
vite: "^7.0.0"
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
null,
|
|
1864
|
+
2
|
|
1865
|
+
) + "\n",
|
|
1866
|
+
"svelte.config.js": `import adapter from '@sveltejs/adapter-auto'
|
|
1867
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
|
1868
|
+
|
|
1869
|
+
export default {
|
|
1870
|
+
preprocess: vitePreprocess(),
|
|
1871
|
+
kit: { adapter: adapter() },
|
|
1872
|
+
}
|
|
1873
|
+
`,
|
|
1874
|
+
"vite.config.ts": `import { sveltekit } from '@sveltejs/kit/vite'
|
|
1875
|
+
import { defineConfig } from 'vite'
|
|
1876
|
+
export default defineConfig({ plugins: [sveltekit()] })
|
|
1877
|
+
`,
|
|
1878
|
+
"tsconfig.json": JSON.stringify(
|
|
1879
|
+
{
|
|
1880
|
+
extends: "./.svelte-kit/tsconfig.json",
|
|
1881
|
+
compilerOptions: {
|
|
1882
|
+
allowJs: true,
|
|
1883
|
+
checkJs: true,
|
|
1884
|
+
esModuleInterop: true,
|
|
1885
|
+
forceConsistentCasingInFileNames: true,
|
|
1886
|
+
resolveJsonModule: true,
|
|
1887
|
+
skipLibCheck: true,
|
|
1888
|
+
sourceMap: true,
|
|
1889
|
+
strict: true,
|
|
1890
|
+
moduleResolution: "bundler"
|
|
1891
|
+
}
|
|
1892
|
+
},
|
|
1893
|
+
null,
|
|
1894
|
+
2
|
|
1895
|
+
) + "\n",
|
|
1896
|
+
"src/app.html": `<!doctype html>
|
|
1897
|
+
<html lang="en">
|
|
1898
|
+
<head>
|
|
1899
|
+
<meta charset="utf-8" />
|
|
1900
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
1901
|
+
%sveltekit.head%
|
|
1902
|
+
</head>
|
|
1903
|
+
<body>%sveltekit.body%</body>
|
|
1904
|
+
</html>
|
|
1905
|
+
`,
|
|
1906
|
+
"src/routes/+page.svelte": `<script lang="ts">
|
|
1907
|
+
import { useChat } from '@agentskit/svelte'
|
|
1908
|
+
import '@agentskit/svelte/theme'
|
|
1909
|
+
|
|
1910
|
+
const chat = useChat({ endpoint: '/api/chat' })
|
|
1911
|
+
</script>
|
|
1912
|
+
|
|
1913
|
+
<main>
|
|
1914
|
+
{#each $chat.messages as message (message.id)}
|
|
1915
|
+
<article data-ak-message data-role={message.role}>{message.content}</article>
|
|
1916
|
+
{/each}
|
|
1917
|
+
<form on:submit|preventDefault={() => chat.send($chat.input)}>
|
|
1918
|
+
<input bind:value={$chat.input} />
|
|
1919
|
+
<button>Send</button>
|
|
1920
|
+
</form>
|
|
1921
|
+
</main>
|
|
1922
|
+
`,
|
|
1923
|
+
"src/routes/api/chat/+server.ts": `import type { RequestHandler } from './$types'
|
|
1924
|
+
${adapterImport2}${demoSnippet}export const POST: RequestHandler = async ({ request }) => {
|
|
1925
|
+
const { messages } = await request.json()
|
|
1926
|
+
const adapter = ${adapterCallStr}
|
|
1927
|
+
const source = adapter.createSource({ messages: messages.map((m: { role: string; content: string }, i: number) => ({
|
|
1928
|
+
id: String(i), role: m.role, content: m.content,
|
|
1929
|
+
status: 'complete' as const, createdAt: new Date(0),
|
|
1930
|
+
})) })
|
|
1931
|
+
|
|
1932
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
1933
|
+
async start(controller) {
|
|
1934
|
+
const encoder = new TextEncoder()
|
|
1935
|
+
for await (const chunk of source.stream()) {
|
|
1936
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
1937
|
+
}
|
|
1938
|
+
controller.close()
|
|
1939
|
+
},
|
|
1940
|
+
})
|
|
1941
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
1942
|
+
}
|
|
1943
|
+
`,
|
|
1944
|
+
".env.example": envExampleFor(ctx.provider),
|
|
1945
|
+
".gitignore": "node_modules\n.svelte-kit\nbuild\n.env\n.env.local\n",
|
|
1946
|
+
"README.md": readmeFor(ctx)
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
function nuxtStarter(ctx) {
|
|
1950
|
+
const deps = {
|
|
1951
|
+
"@agentskit/vue": "^0.4.0",
|
|
1952
|
+
nuxt: "^4.0.0",
|
|
1953
|
+
vue: "^3.5.0"
|
|
1954
|
+
};
|
|
1955
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
1956
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
1957
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
1958
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
1959
|
+
return {
|
|
1960
|
+
"package.json": JSON.stringify(
|
|
1961
|
+
{
|
|
1962
|
+
name: "agentskit-nuxt-app",
|
|
1963
|
+
private: true,
|
|
1964
|
+
type: "module",
|
|
1965
|
+
scripts: {
|
|
1966
|
+
dev: "nuxt dev",
|
|
1967
|
+
build: "nuxt build",
|
|
1968
|
+
preview: "nuxt preview",
|
|
1969
|
+
generate: "nuxt generate"
|
|
1970
|
+
},
|
|
1971
|
+
dependencies: deps,
|
|
1972
|
+
devDependencies: { typescript: "^5.5.0" }
|
|
1973
|
+
},
|
|
1974
|
+
null,
|
|
1975
|
+
2
|
|
1976
|
+
) + "\n",
|
|
1977
|
+
"nuxt.config.ts": `export default defineNuxtConfig({
|
|
1978
|
+
compatibilityDate: '2026-04-01',
|
|
1979
|
+
modules: [],
|
|
1980
|
+
typescript: { strict: true },
|
|
1981
|
+
})
|
|
1982
|
+
`,
|
|
1983
|
+
"tsconfig.json": JSON.stringify(
|
|
1984
|
+
{ extends: "./.nuxt/tsconfig.json" },
|
|
1985
|
+
null,
|
|
1986
|
+
2
|
|
1987
|
+
) + "\n",
|
|
1988
|
+
"app.vue": `<script setup lang="ts">
|
|
1989
|
+
import { useChat } from '@agentskit/vue'
|
|
1990
|
+
import '@agentskit/vue/theme'
|
|
1991
|
+
|
|
1992
|
+
const { messages, input, send } = useChat({ endpoint: '/api/chat' })
|
|
1993
|
+
</script>
|
|
1994
|
+
|
|
1995
|
+
<template>
|
|
1996
|
+
<main>
|
|
1997
|
+
<article v-for="message in messages" :key="message.id" :data-role="message.role">
|
|
1998
|
+
{{ message.content }}
|
|
1999
|
+
</article>
|
|
2000
|
+
<form @submit.prevent="send(input)">
|
|
2001
|
+
<input v-model="input" />
|
|
2002
|
+
<button>Send</button>
|
|
2003
|
+
</form>
|
|
2004
|
+
</main>
|
|
2005
|
+
</template>
|
|
2006
|
+
`,
|
|
2007
|
+
"server/api/chat.post.ts": `${adapterImport2}${demoSnippet}export default defineEventHandler(async (event) => {
|
|
2008
|
+
const { messages } = await readBody<{ messages: Array<{ role: string; content: string }> }>(event)
|
|
2009
|
+
const adapter = ${adapterCallStr}
|
|
2010
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2011
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2012
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2013
|
+
})) })
|
|
2014
|
+
|
|
2015
|
+
setHeader(event, 'content-type', 'text/plain; charset=utf-8')
|
|
2016
|
+
return sendStream(event, new ReadableStream<Uint8Array>({
|
|
2017
|
+
async start(controller) {
|
|
2018
|
+
const encoder = new TextEncoder()
|
|
2019
|
+
for await (const chunk of source.stream()) {
|
|
2020
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2021
|
+
}
|
|
2022
|
+
controller.close()
|
|
2023
|
+
},
|
|
2024
|
+
}))
|
|
2025
|
+
})
|
|
2026
|
+
`,
|
|
2027
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2028
|
+
".gitignore": "node_modules\n.nuxt\n.output\n.env\n.env.local\n",
|
|
2029
|
+
"README.md": readmeFor(ctx)
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
function viteInkStarter(ctx) {
|
|
2033
|
+
const deps = {
|
|
2034
|
+
"@agentskit/ink": "^0.4.0",
|
|
2035
|
+
ink: "^7.0.0",
|
|
2036
|
+
react: "^19.0.0"
|
|
2037
|
+
};
|
|
2038
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2039
|
+
if (ctx.tools.length > 0) deps["@agentskit/tools"] = "^0.4.0";
|
|
2040
|
+
return {
|
|
2041
|
+
"package.json": JSON.stringify(
|
|
2042
|
+
{
|
|
2043
|
+
name: "agentskit-vite-ink-app",
|
|
2044
|
+
private: true,
|
|
2045
|
+
type: "module",
|
|
2046
|
+
scripts: {
|
|
2047
|
+
dev: "vite-node --watch src/index.tsx",
|
|
2048
|
+
start: "vite-node src/index.tsx",
|
|
2049
|
+
build: "vite build"
|
|
2050
|
+
},
|
|
2051
|
+
dependencies: deps,
|
|
2052
|
+
devDependencies: {
|
|
2053
|
+
"@types/react": "^19.0.0",
|
|
2054
|
+
"vite-node": "^4.0.0",
|
|
2055
|
+
vite: "^7.0.0",
|
|
2056
|
+
typescript: "^5.5.0"
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2059
|
+
null,
|
|
2060
|
+
2
|
|
2061
|
+
) + "\n",
|
|
2062
|
+
"vite.config.ts": `import { defineConfig } from 'vite'
|
|
2063
|
+
export default defineConfig({
|
|
2064
|
+
build: { ssr: true, target: 'node22', rollupOptions: { input: 'src/index.tsx' } },
|
|
2065
|
+
})
|
|
2066
|
+
`,
|
|
2067
|
+
"tsconfig.json": JSON.stringify(
|
|
2068
|
+
{
|
|
2069
|
+
compilerOptions: {
|
|
2070
|
+
target: "ES2022",
|
|
2071
|
+
module: "ESNext",
|
|
2072
|
+
moduleResolution: "bundler",
|
|
2073
|
+
jsx: "react-jsx",
|
|
2074
|
+
strict: true,
|
|
2075
|
+
noEmit: true,
|
|
2076
|
+
skipLibCheck: true
|
|
2077
|
+
},
|
|
2078
|
+
include: ["src"]
|
|
2079
|
+
},
|
|
2080
|
+
null,
|
|
2081
|
+
2
|
|
2082
|
+
) + "\n",
|
|
2083
|
+
"src/index.tsx": `import React from 'react'
|
|
2084
|
+
import { render } from 'ink'
|
|
2085
|
+
import { ChatContainer, InputBar, Message, useChat } from '@agentskit/ink'
|
|
2086
|
+
${adapterImport(ctx.provider)}${toolImports(ctx.tools)}
|
|
2087
|
+
${ctx.provider === "demo" ? demoAdapterSnippet() : ""}function App() {
|
|
2088
|
+
const chat = useChat({
|
|
2089
|
+
adapter: ${adapterCall(ctx.provider)},${ctx.tools.length > 0 ? `
|
|
2090
|
+
tools: ${toolList(ctx.tools)},` : ""}
|
|
2091
|
+
})
|
|
2092
|
+
|
|
2093
|
+
return (
|
|
2094
|
+
<ChatContainer>
|
|
2095
|
+
{chat.messages.map(message => (
|
|
2096
|
+
<Message key={message.id} message={message} />
|
|
2097
|
+
))}
|
|
2098
|
+
<InputBar chat={chat} />
|
|
2099
|
+
</ChatContainer>
|
|
2100
|
+
)
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
render(<App />)
|
|
2104
|
+
`,
|
|
2105
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2106
|
+
".gitignore": "node_modules\ndist\n.env\n.env.local\n.agentskit-history.*\n",
|
|
2107
|
+
"README.md": readmeFor(ctx)
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2110
|
+
function cloudflareWorkersStarter(ctx) {
|
|
2111
|
+
const deps = {
|
|
2112
|
+
"itty-router": "^5.0.0"
|
|
2113
|
+
};
|
|
2114
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2115
|
+
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]}' })`;
|
|
2116
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
2117
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2118
|
+
const envKey = PROVIDER_ENV_KEY[ctx.provider];
|
|
2119
|
+
return {
|
|
2120
|
+
"package.json": JSON.stringify(
|
|
2121
|
+
{
|
|
2122
|
+
name: "agentskit-cf-worker",
|
|
2123
|
+
private: true,
|
|
2124
|
+
type: "module",
|
|
2125
|
+
scripts: {
|
|
2126
|
+
dev: "wrangler dev",
|
|
2127
|
+
deploy: "wrangler deploy"
|
|
2128
|
+
},
|
|
2129
|
+
dependencies: deps,
|
|
2130
|
+
devDependencies: {
|
|
2131
|
+
"@cloudflare/workers-types": "^4.0.0",
|
|
2132
|
+
typescript: "^5.5.0",
|
|
2133
|
+
wrangler: "^3.0.0"
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2136
|
+
null,
|
|
2137
|
+
2
|
|
2138
|
+
) + "\n",
|
|
2139
|
+
"wrangler.toml": `name = "agentskit-cf-worker"
|
|
2140
|
+
main = "src/worker.ts"
|
|
2141
|
+
compatibility_date = "2026-04-01"
|
|
2142
|
+
compatibility_flags = ["nodejs_compat"]
|
|
2143
|
+
|
|
2144
|
+
# Bind D1 + KV when you wire memory:
|
|
2145
|
+
# [[d1_databases]]
|
|
2146
|
+
# binding = "DB"
|
|
2147
|
+
# database_name = "agentskit"
|
|
2148
|
+
#
|
|
2149
|
+
# [[kv_namespaces]]
|
|
2150
|
+
# binding = "KV"
|
|
2151
|
+
# id = "..."
|
|
2152
|
+
|
|
2153
|
+
[vars]
|
|
2154
|
+
${envKey ? `# Set ${envKey} via 'wrangler secret put ${envKey}'` : "# No API key required for the demo provider"}
|
|
2155
|
+
`,
|
|
2156
|
+
"tsconfig.json": JSON.stringify(
|
|
2157
|
+
{
|
|
2158
|
+
compilerOptions: {
|
|
2159
|
+
target: "ES2022",
|
|
2160
|
+
module: "ESNext",
|
|
2161
|
+
moduleResolution: "bundler",
|
|
2162
|
+
lib: ["ES2022"],
|
|
2163
|
+
types: ["@cloudflare/workers-types"],
|
|
2164
|
+
strict: true,
|
|
2165
|
+
noEmit: true,
|
|
2166
|
+
skipLibCheck: true
|
|
2167
|
+
},
|
|
2168
|
+
include: ["src"]
|
|
2169
|
+
},
|
|
2170
|
+
null,
|
|
2171
|
+
2
|
|
2172
|
+
) + "\n",
|
|
2173
|
+
"src/worker.ts": `import { Router } from 'itty-router'
|
|
2174
|
+
${adapterImport2}
|
|
2175
|
+
${demoSnippet}interface Env {
|
|
2176
|
+
${envKey ? `${envKey}: string` : "/* no env vars */"}
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
const router = Router()
|
|
2180
|
+
|
|
2181
|
+
router.post('/chat', async (request: Request, env: Env) => {
|
|
2182
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2183
|
+
const adapter = ${adapterCallEdge}
|
|
2184
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2185
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2186
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2187
|
+
})) })
|
|
2188
|
+
|
|
2189
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2190
|
+
async start(controller) {
|
|
2191
|
+
const encoder = new TextEncoder()
|
|
2192
|
+
for await (const chunk of source.stream()) {
|
|
2193
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2194
|
+
}
|
|
2195
|
+
controller.close()
|
|
2196
|
+
},
|
|
2197
|
+
})
|
|
2198
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
2199
|
+
})
|
|
2200
|
+
|
|
2201
|
+
router.all('*', () => new Response('not found', { status: 404 }))
|
|
2202
|
+
|
|
2203
|
+
export default {
|
|
2204
|
+
fetch: (req: Request, env: Env, ctx: ExecutionContext) => router.handle(req, env, ctx),
|
|
2205
|
+
} satisfies ExportedHandler<Env>
|
|
2206
|
+
`,
|
|
2207
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2208
|
+
".gitignore": "node_modules\n.wrangler\n.dev.vars\n.env\n.env.local\n",
|
|
2209
|
+
"README.md": readmeFor(ctx)
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
function bunStarter(ctx) {
|
|
2213
|
+
const deps = {};
|
|
2214
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2215
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
2216
|
+
const adapterImport2 = buildAdapterServerImport(ctx.provider);
|
|
2217
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2218
|
+
return {
|
|
2219
|
+
"package.json": JSON.stringify(
|
|
2220
|
+
{
|
|
2221
|
+
name: "agentskit-bun-server",
|
|
2222
|
+
private: true,
|
|
2223
|
+
type: "module",
|
|
2224
|
+
scripts: {
|
|
2225
|
+
dev: "bun --hot src/server.ts",
|
|
2226
|
+
start: "bun src/server.ts"
|
|
2227
|
+
},
|
|
2228
|
+
dependencies: deps,
|
|
2229
|
+
devDependencies: { typescript: "^5.5.0" }
|
|
2230
|
+
},
|
|
2231
|
+
null,
|
|
2232
|
+
2
|
|
2233
|
+
) + "\n",
|
|
2234
|
+
"tsconfig.json": JSON.stringify(
|
|
2235
|
+
{
|
|
2236
|
+
compilerOptions: {
|
|
2237
|
+
target: "ES2022",
|
|
2238
|
+
module: "ESNext",
|
|
2239
|
+
moduleResolution: "bundler",
|
|
2240
|
+
types: ["bun-types"],
|
|
2241
|
+
strict: true,
|
|
2242
|
+
noEmit: true,
|
|
2243
|
+
skipLibCheck: true
|
|
2244
|
+
},
|
|
2245
|
+
include: ["src"]
|
|
2246
|
+
},
|
|
2247
|
+
null,
|
|
2248
|
+
2
|
|
2249
|
+
) + "\n",
|
|
2250
|
+
"src/server.ts": `${adapterImport2}${demoSnippet}const adapter = ${adapterCallStr}
|
|
2251
|
+
|
|
2252
|
+
const server = Bun.serve({
|
|
2253
|
+
port: Number(process.env.PORT ?? 3000),
|
|
2254
|
+
async fetch(request) {
|
|
2255
|
+
const url = new URL(request.url)
|
|
2256
|
+
if (request.method === 'POST' && url.pathname === '/chat') {
|
|
2257
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2258
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2259
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2260
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2261
|
+
})) })
|
|
2262
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2263
|
+
async start(controller) {
|
|
2264
|
+
const encoder = new TextEncoder()
|
|
2265
|
+
for await (const chunk of source.stream()) {
|
|
2266
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2267
|
+
}
|
|
2268
|
+
controller.close()
|
|
2269
|
+
},
|
|
2270
|
+
})
|
|
2271
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
2272
|
+
}
|
|
2273
|
+
if (url.pathname === '/') {
|
|
2274
|
+
return new Response(\`<!doctype html><title>AgentsKit Bun starter</title>
|
|
2275
|
+
<body><pre>POST /chat with { messages: [...] }</pre></body>\`, {
|
|
2276
|
+
headers: { 'content-type': 'text/html' },
|
|
2277
|
+
})
|
|
2278
|
+
}
|
|
2279
|
+
return new Response('not found', { status: 404 })
|
|
2280
|
+
},
|
|
2281
|
+
})
|
|
2282
|
+
|
|
2283
|
+
console.log(\`Listening on http://localhost:\${server.port}\`)
|
|
2284
|
+
`,
|
|
2285
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2286
|
+
".gitignore": "node_modules\n.env\n.env.local\nbun.lockb\n",
|
|
2287
|
+
"README.md": readmeFor(ctx)
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
function nextjsStarter(ctx) {
|
|
2291
|
+
const deps = {
|
|
2292
|
+
"@agentskit/react": "^0.4.0",
|
|
2293
|
+
next: "^15.0.0",
|
|
2294
|
+
react: "^19.0.0",
|
|
2295
|
+
"react-dom": "^19.0.0"
|
|
2296
|
+
};
|
|
2297
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2298
|
+
if (ctx.tools.length > 0) deps["@agentskit/tools"] = "^0.4.0";
|
|
2299
|
+
const envKey = PROVIDER_ENV_KEY[ctx.provider];
|
|
2300
|
+
const adapter = adapterCall(ctx.provider);
|
|
2301
|
+
const apiAdapterImport = ctx.provider === "demo" ? "" : `import { ${PROVIDER_IMPORT[ctx.provider]} } from '@agentskit/adapters'
|
|
2302
|
+
`;
|
|
2303
|
+
const apiDemoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2304
|
+
return {
|
|
2305
|
+
"package.json": JSON.stringify(
|
|
2306
|
+
{
|
|
2307
|
+
name: "agentskit-nextjs-app",
|
|
2308
|
+
private: true,
|
|
2309
|
+
type: "module",
|
|
2310
|
+
scripts: {
|
|
2311
|
+
dev: "next dev",
|
|
2312
|
+
build: "next build",
|
|
2313
|
+
start: "next start",
|
|
2314
|
+
lint: "next lint"
|
|
2315
|
+
},
|
|
2316
|
+
dependencies: deps,
|
|
2317
|
+
devDependencies: {
|
|
2318
|
+
"@types/node": "^22.0.0",
|
|
2319
|
+
"@types/react": "^19.0.0",
|
|
2320
|
+
"@types/react-dom": "^19.0.0",
|
|
2321
|
+
typescript: "^5.5.0"
|
|
2322
|
+
}
|
|
2323
|
+
},
|
|
2324
|
+
null,
|
|
2325
|
+
2
|
|
2326
|
+
) + "\n",
|
|
2327
|
+
"next.config.mjs": `/** @type {import('next').NextConfig} */
|
|
2328
|
+
const nextConfig = {}
|
|
2329
|
+
export default nextConfig
|
|
2330
|
+
`,
|
|
2331
|
+
"tsconfig.json": JSON.stringify(
|
|
2332
|
+
{
|
|
2333
|
+
compilerOptions: {
|
|
2334
|
+
target: "ES2022",
|
|
2335
|
+
lib: ["dom", "dom.iterable", "ES2022"],
|
|
2336
|
+
allowJs: true,
|
|
2337
|
+
skipLibCheck: true,
|
|
2338
|
+
strict: true,
|
|
2339
|
+
noEmit: true,
|
|
2340
|
+
esModuleInterop: true,
|
|
2341
|
+
module: "ESNext",
|
|
2342
|
+
moduleResolution: "bundler",
|
|
2343
|
+
resolveJsonModule: true,
|
|
2344
|
+
isolatedModules: true,
|
|
2345
|
+
jsx: "preserve",
|
|
2346
|
+
incremental: true,
|
|
2347
|
+
plugins: [{ name: "next" }],
|
|
2348
|
+
paths: { "@/*": ["./*"] }
|
|
2349
|
+
},
|
|
2350
|
+
include: ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
2351
|
+
exclude: ["node_modules"]
|
|
2352
|
+
},
|
|
2353
|
+
null,
|
|
2354
|
+
2
|
|
2355
|
+
) + "\n",
|
|
2356
|
+
"app/layout.tsx": `import type { ReactNode } from 'react'
|
|
2357
|
+
import '@agentskit/react/theme'
|
|
2358
|
+
|
|
2359
|
+
export const metadata = { title: 'AgentsKit \xB7 Next.js Starter' }
|
|
2360
|
+
|
|
2361
|
+
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
2362
|
+
return (
|
|
2363
|
+
<html lang="en">
|
|
2364
|
+
<body>{children}</body>
|
|
2365
|
+
</html>
|
|
2366
|
+
)
|
|
2367
|
+
}
|
|
2368
|
+
`,
|
|
2369
|
+
"app/page.tsx": `'use client'
|
|
2370
|
+
|
|
2371
|
+
import { ChatContainer, InputBar, Message, useChat } from '@agentskit/react'
|
|
2372
|
+
import { genericAdapter } from './chat-adapter'
|
|
2373
|
+
|
|
2374
|
+
export default function Page() {
|
|
2375
|
+
const chat = useChat({ adapter: genericAdapter('/api/chat') })
|
|
2376
|
+
|
|
2377
|
+
return (
|
|
2378
|
+
<main style={{ display: 'grid', placeItems: 'center', minHeight: '100dvh' }}>
|
|
2379
|
+
<ChatContainer>
|
|
2380
|
+
{chat.messages.map(message => (
|
|
2381
|
+
<Message key={message.id} message={message} />
|
|
2382
|
+
))}
|
|
2383
|
+
<InputBar chat={chat} />
|
|
2384
|
+
</ChatContainer>
|
|
2385
|
+
</main>
|
|
2386
|
+
)
|
|
2387
|
+
}
|
|
2388
|
+
`,
|
|
2389
|
+
"app/chat-adapter.ts": `import { generic } from '@agentskit/adapters'
|
|
2390
|
+
|
|
2391
|
+
export const genericAdapter = (route: string) => generic({
|
|
2392
|
+
fetch: async ({ messages, signal }) => {
|
|
2393
|
+
const response = await fetch(route, {
|
|
2394
|
+
method: 'POST',
|
|
2395
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2396
|
+
body: JSON.stringify({ messages }),
|
|
2397
|
+
signal,
|
|
2398
|
+
})
|
|
2399
|
+
if (!response.body) throw new Error('No body returned from /api/chat')
|
|
2400
|
+
return response
|
|
2401
|
+
},
|
|
2402
|
+
})
|
|
2403
|
+
`,
|
|
2404
|
+
"app/api/chat/route.ts": `${apiAdapterImport}${apiDemoSnippet}export const runtime = 'edge'
|
|
2405
|
+
|
|
2406
|
+
export async function POST(request: Request) {
|
|
2407
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2408
|
+
|
|
2409
|
+
const adapter = ${adapter}
|
|
2410
|
+
|
|
2411
|
+
const source = adapter.createSource({ messages: messages.map((message, index) => ({
|
|
2412
|
+
id: String(index),
|
|
2413
|
+
role: message.role as 'user' | 'assistant' | 'system',
|
|
2414
|
+
content: message.content,
|
|
2415
|
+
status: 'complete' as const,
|
|
2416
|
+
createdAt: new Date(0),
|
|
2417
|
+
})) })
|
|
2418
|
+
|
|
2419
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2420
|
+
async start(controller) {
|
|
2421
|
+
const encoder = new TextEncoder()
|
|
2422
|
+
try {
|
|
2423
|
+
for await (const chunk of source.stream()) {
|
|
2424
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2425
|
+
}
|
|
2426
|
+
} catch (err) {
|
|
2427
|
+
controller.error(err)
|
|
2428
|
+
return
|
|
2429
|
+
}
|
|
2430
|
+
controller.close()
|
|
2431
|
+
},
|
|
2432
|
+
})
|
|
2433
|
+
|
|
2434
|
+
return new Response(stream, {
|
|
2435
|
+
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'no-cache' },
|
|
2436
|
+
})
|
|
2437
|
+
}
|
|
2438
|
+
`,
|
|
2439
|
+
".env.example": envKey ? `${envKey}=
|
|
2440
|
+
` : "# No API key required for the demo provider\n",
|
|
2441
|
+
".gitignore": `node_modules
|
|
2442
|
+
.next
|
|
2443
|
+
out
|
|
2444
|
+
.env
|
|
2445
|
+
.env.local
|
|
2446
|
+
.agentskit-history.*
|
|
2447
|
+
`,
|
|
2448
|
+
"README.md": readmeFor(ctx)
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
function expoStarter(ctx) {
|
|
2452
|
+
const deps = {
|
|
2453
|
+
expo: "^54.0.0",
|
|
2454
|
+
"expo-router": "^7.0.0",
|
|
2455
|
+
"expo-secure-store": "^15.0.0",
|
|
2456
|
+
react: "^19.0.0",
|
|
2457
|
+
"react-native": "^0.84.0"
|
|
2458
|
+
};
|
|
2459
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2460
|
+
const adapterCallStr = adapterCall(ctx.provider);
|
|
2461
|
+
const adapterImport2 = ctx.provider === "demo" ? "" : `import { ${PROVIDER_IMPORT[ctx.provider]} } from '@agentskit/adapters'
|
|
2462
|
+
`;
|
|
2463
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2464
|
+
return {
|
|
2465
|
+
"package.json": JSON.stringify(
|
|
2466
|
+
{
|
|
2467
|
+
name: "agentskit-expo-app",
|
|
2468
|
+
version: "1.0.0",
|
|
2469
|
+
main: "expo-router/entry",
|
|
2470
|
+
scripts: {
|
|
2471
|
+
start: "expo start",
|
|
2472
|
+
android: "expo start --android",
|
|
2473
|
+
ios: "expo start --ios",
|
|
2474
|
+
web: "expo start --web"
|
|
2475
|
+
},
|
|
2476
|
+
dependencies: deps,
|
|
2477
|
+
devDependencies: {
|
|
2478
|
+
"@types/react": "^19.0.0",
|
|
2479
|
+
typescript: "^5.5.0"
|
|
2480
|
+
}
|
|
2481
|
+
},
|
|
2482
|
+
null,
|
|
2483
|
+
2
|
|
2484
|
+
) + "\n",
|
|
2485
|
+
"app.json": JSON.stringify(
|
|
2486
|
+
{
|
|
2487
|
+
expo: {
|
|
2488
|
+
name: "AgentsKit Expo Starter",
|
|
2489
|
+
slug: "agentskit-expo",
|
|
2490
|
+
scheme: "agentskit",
|
|
2491
|
+
plugins: ["expo-router", "expo-secure-store"],
|
|
2492
|
+
ios: { bundleIdentifier: "com.example.agentskit" },
|
|
2493
|
+
android: { package: "com.example.agentskit" }
|
|
2494
|
+
}
|
|
2495
|
+
},
|
|
2496
|
+
null,
|
|
2497
|
+
2
|
|
2498
|
+
) + "\n",
|
|
2499
|
+
"tsconfig.json": JSON.stringify(
|
|
2500
|
+
{ extends: "expo/tsconfig.base", compilerOptions: { strict: true } },
|
|
2501
|
+
null,
|
|
2502
|
+
2
|
|
2503
|
+
) + "\n",
|
|
2504
|
+
"app/_layout.tsx": `import { Stack } from 'expo-router'
|
|
2505
|
+
import { AuthProvider } from '../lib/auth'
|
|
2506
|
+
|
|
2507
|
+
export default function RootLayout() {
|
|
2508
|
+
return (
|
|
2509
|
+
<AuthProvider>
|
|
2510
|
+
<Stack />
|
|
2511
|
+
</AuthProvider>
|
|
2512
|
+
)
|
|
2513
|
+
}
|
|
2514
|
+
`,
|
|
2515
|
+
"app/index.tsx": `import { useState } from 'react'
|
|
2516
|
+
import { Text, TextInput, View, Pressable, ScrollView } from 'react-native'
|
|
2517
|
+
import { useAuth } from '../lib/auth'
|
|
2518
|
+
${adapterImport2}${demoSnippet}export default function Chat() {
|
|
2519
|
+
const { token, signIn, signOut } = useAuth()
|
|
2520
|
+
const [messages, setMessages] = useState<{ role: 'user' | 'assistant'; content: string }[]>([])
|
|
2521
|
+
const [input, setInput] = useState('')
|
|
2522
|
+
|
|
2523
|
+
if (!token) {
|
|
2524
|
+
return (
|
|
2525
|
+
<View style={{ flex: 1, justifyContent: 'center', padding: 24 }}>
|
|
2526
|
+
<Text style={{ fontSize: 20, marginBottom: 12 }}>Sign in to chat</Text>
|
|
2527
|
+
<Pressable onPress={() => signIn('demo-token')}><Text>Sign in</Text></Pressable>
|
|
2528
|
+
</View>
|
|
2529
|
+
)
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
async function send() {
|
|
2533
|
+
if (!input.trim()) return
|
|
2534
|
+
const next = [...messages, { role: 'user' as const, content: input }]
|
|
2535
|
+
setMessages(next)
|
|
2536
|
+
setInput('')
|
|
2537
|
+
const adapter = ${adapterCallStr}
|
|
2538
|
+
const source = adapter.createSource({ messages: next.map((m, i) => ({
|
|
2539
|
+
id: String(i), role: m.role, content: m.content,
|
|
2540
|
+
status: 'complete' as const, createdAt: new Date(0),
|
|
2541
|
+
})) })
|
|
2542
|
+
let acc = ''
|
|
2543
|
+
for await (const chunk of source.stream()) {
|
|
2544
|
+
if (chunk.type === 'text') {
|
|
2545
|
+
acc += chunk.content
|
|
2546
|
+
setMessages([...next, { role: 'assistant', content: acc }])
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
return (
|
|
2552
|
+
<View style={{ flex: 1, padding: 16 }}>
|
|
2553
|
+
<Pressable onPress={signOut}><Text>Sign out</Text></Pressable>
|
|
2554
|
+
<ScrollView style={{ flex: 1 }}>
|
|
2555
|
+
{messages.map((m, i) => (
|
|
2556
|
+
<Text key={i} style={{ marginVertical: 4 }}>{m.role}: {m.content}</Text>
|
|
2557
|
+
))}
|
|
2558
|
+
</ScrollView>
|
|
2559
|
+
<TextInput value={input} onChangeText={setInput} onSubmitEditing={send} placeholder="Ask anything\u2026" />
|
|
2560
|
+
</View>
|
|
2561
|
+
)
|
|
2562
|
+
}
|
|
2563
|
+
`,
|
|
2564
|
+
"lib/auth.tsx": `import { createContext, useContext, useEffect, useState, type ReactNode } from 'react'
|
|
2565
|
+
import * as SecureStore from 'expo-secure-store'
|
|
2566
|
+
|
|
2567
|
+
interface AuthValue { token: string | null; signIn: (t: string) => void; signOut: () => void }
|
|
2568
|
+
const AuthCtx = createContext<AuthValue>({ token: null, signIn: () => {}, signOut: () => {} })
|
|
2569
|
+
|
|
2570
|
+
export function AuthProvider({ children }: { children: ReactNode }) {
|
|
2571
|
+
const [token, setToken] = useState<string | null>(null)
|
|
2572
|
+
|
|
2573
|
+
useEffect(() => {
|
|
2574
|
+
SecureStore.getItemAsync('agentskit_token').then(setToken).catch(() => {})
|
|
2575
|
+
}, [])
|
|
2576
|
+
|
|
2577
|
+
return (
|
|
2578
|
+
<AuthCtx.Provider
|
|
2579
|
+
value={{
|
|
2580
|
+
token,
|
|
2581
|
+
signIn: (t) => { SecureStore.setItemAsync('agentskit_token', t); setToken(t) },
|
|
2582
|
+
signOut: () => { SecureStore.deleteItemAsync('agentskit_token'); setToken(null) },
|
|
2583
|
+
}}
|
|
2584
|
+
>
|
|
2585
|
+
{children}
|
|
2586
|
+
</AuthCtx.Provider>
|
|
2587
|
+
)
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
export const useAuth = () => useContext(AuthCtx)
|
|
2591
|
+
`,
|
|
2592
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2593
|
+
".gitignore": "node_modules\n.expo\ndist\n.env\n.env.local\n",
|
|
2594
|
+
"README.md": readmeFor(ctx)
|
|
2595
|
+
};
|
|
2596
|
+
}
|
|
2597
|
+
function denoDeployStarter(ctx) {
|
|
2598
|
+
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]}' })`;
|
|
2599
|
+
const adapterImport2 = ctx.provider === "demo" ? "" : `import { ${PROVIDER_IMPORT[ctx.provider]} } from 'npm:@agentskit/adapters'
|
|
2600
|
+
`;
|
|
2601
|
+
const demoSnippet = ctx.provider === "demo" ? demoAdapterSnippet() : "";
|
|
2602
|
+
return {
|
|
2603
|
+
"deno.json": JSON.stringify(
|
|
2604
|
+
{
|
|
2605
|
+
tasks: {
|
|
2606
|
+
dev: "deno run --allow-net --allow-env --watch main.ts",
|
|
2607
|
+
start: "deno run --allow-net --allow-env main.ts",
|
|
2608
|
+
deploy: "deployctl deploy --project=agentskit-deno main.ts"
|
|
2609
|
+
},
|
|
2610
|
+
imports: {
|
|
2611
|
+
"@agentskit/adapters": "npm:@agentskit/adapters@^0.4.0"
|
|
2612
|
+
}
|
|
2613
|
+
},
|
|
2614
|
+
null,
|
|
2615
|
+
2
|
|
2616
|
+
) + "\n",
|
|
2617
|
+
"main.ts": `${adapterImport2}${demoSnippet}const adapter = ${adapterCallEdge}
|
|
2618
|
+
|
|
2619
|
+
Deno.serve(async (request) => {
|
|
2620
|
+
const url = new URL(request.url)
|
|
2621
|
+
if (request.method === 'POST' && url.pathname === '/chat') {
|
|
2622
|
+
const { messages } = await request.json() as { messages: Array<{ role: string; content: string }> }
|
|
2623
|
+
const source = adapter.createSource({ messages: messages.map((m, i) => ({
|
|
2624
|
+
id: String(i), role: m.role as 'user' | 'assistant' | 'system',
|
|
2625
|
+
content: m.content, status: 'complete' as const, createdAt: new Date(0),
|
|
2626
|
+
})) })
|
|
2627
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
2628
|
+
async start(controller) {
|
|
2629
|
+
const encoder = new TextEncoder()
|
|
2630
|
+
for await (const chunk of source.stream()) {
|
|
2631
|
+
if (chunk.type === 'text') controller.enqueue(encoder.encode(chunk.content))
|
|
2632
|
+
}
|
|
2633
|
+
controller.close()
|
|
2634
|
+
},
|
|
2635
|
+
})
|
|
2636
|
+
return new Response(stream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
|
|
2637
|
+
}
|
|
2638
|
+
return new Response(\`<!doctype html><title>AgentsKit Deno Deploy starter</title>
|
|
2639
|
+
<body><pre>POST /chat with { messages: [...] }</pre></body>\`, {
|
|
2640
|
+
headers: { 'content-type': 'text/html' },
|
|
2641
|
+
})
|
|
2642
|
+
})
|
|
2643
|
+
`,
|
|
2644
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2645
|
+
".gitignore": ".env\n.env.local\n",
|
|
2646
|
+
"README.md": readmeFor(ctx)
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
function angularStarter(ctx) {
|
|
2650
|
+
const deps = {
|
|
2651
|
+
"@agentskit/angular": "^0.4.0",
|
|
2652
|
+
"@angular/core": "^21.0.0",
|
|
2653
|
+
"@angular/common": "^21.0.0",
|
|
2654
|
+
"@angular/compiler": "^21.0.0",
|
|
2655
|
+
"@angular/platform-browser": "^21.0.0",
|
|
2656
|
+
"@angular/platform-browser-dynamic": "^21.0.0",
|
|
2657
|
+
rxjs: "^7.8.0",
|
|
2658
|
+
"zone.js": "^0.16.1"
|
|
2659
|
+
};
|
|
2660
|
+
if (ctx.provider !== "demo") deps["@agentskit/adapters"] = "^0.4.0";
|
|
2661
|
+
return {
|
|
2662
|
+
"package.json": JSON.stringify(
|
|
2663
|
+
{
|
|
2664
|
+
name: "agentskit-angular-app",
|
|
2665
|
+
private: true,
|
|
2666
|
+
scripts: {
|
|
2667
|
+
dev: "ng serve",
|
|
2668
|
+
build: "ng build",
|
|
2669
|
+
start: "ng serve"
|
|
2670
|
+
},
|
|
2671
|
+
dependencies: deps,
|
|
2672
|
+
devDependencies: {
|
|
2673
|
+
"@angular/cli": "^21.0.0",
|
|
2674
|
+
"@angular/compiler-cli": "^21.0.0",
|
|
2675
|
+
typescript: "^5.5.0"
|
|
2676
|
+
}
|
|
2677
|
+
},
|
|
2678
|
+
null,
|
|
2679
|
+
2
|
|
2680
|
+
) + "\n",
|
|
2681
|
+
"angular.json": JSON.stringify(
|
|
2682
|
+
{
|
|
2683
|
+
$schema: "./node_modules/@angular/cli/lib/config/schema.json",
|
|
2684
|
+
version: 1,
|
|
2685
|
+
projects: {
|
|
2686
|
+
app: {
|
|
2687
|
+
projectType: "application",
|
|
2688
|
+
root: "",
|
|
2689
|
+
sourceRoot: "src",
|
|
2690
|
+
prefix: "ak",
|
|
2691
|
+
architect: {
|
|
2692
|
+
build: {
|
|
2693
|
+
builder: "@angular/build:application",
|
|
2694
|
+
options: { browser: "src/main.ts", tsConfig: "tsconfig.json", index: "src/index.html" }
|
|
2695
|
+
},
|
|
2696
|
+
serve: { builder: "@angular/build:dev-server", options: { buildTarget: "app:build" } }
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
},
|
|
2701
|
+
null,
|
|
2702
|
+
2
|
|
2703
|
+
) + "\n",
|
|
2704
|
+
"tsconfig.json": JSON.stringify(
|
|
2705
|
+
{
|
|
2706
|
+
compilerOptions: {
|
|
2707
|
+
target: "ES2022",
|
|
2708
|
+
module: "preserve",
|
|
2709
|
+
moduleResolution: "bundler",
|
|
2710
|
+
strict: true,
|
|
2711
|
+
experimentalDecorators: true,
|
|
2712
|
+
useDefineForClassFields: false,
|
|
2713
|
+
lib: ["ES2022", "DOM"]
|
|
2714
|
+
},
|
|
2715
|
+
include: ["src/**/*.ts"]
|
|
2716
|
+
},
|
|
2717
|
+
null,
|
|
2718
|
+
2
|
|
2719
|
+
) + "\n",
|
|
2720
|
+
"src/index.html": `<!doctype html>
|
|
2721
|
+
<html><head><title>AgentsKit Angular</title></head>
|
|
2722
|
+
<body><ak-root></ak-root></body></html>
|
|
2723
|
+
`,
|
|
2724
|
+
"src/main.ts": `import { bootstrapApplication } from '@angular/platform-browser'
|
|
2725
|
+
import 'zone.js'
|
|
2726
|
+
import { AppComponent } from './app'
|
|
2727
|
+
|
|
2728
|
+
bootstrapApplication(AppComponent)
|
|
2729
|
+
`,
|
|
2730
|
+
"src/app.ts": `import { Component, signal } from '@angular/core'
|
|
2731
|
+
import { CommonModule } from '@angular/common'
|
|
2732
|
+
|
|
2733
|
+
@Component({
|
|
2734
|
+
selector: 'ak-root',
|
|
2735
|
+
standalone: true,
|
|
2736
|
+
imports: [CommonModule],
|
|
2737
|
+
template: \`
|
|
2738
|
+
<main style="max-width: 640px; margin: 2rem auto;">
|
|
2739
|
+
<h1>AgentsKit \xB7 Angular standalone</h1>
|
|
2740
|
+
<p>Wire @agentskit/angular here. See the docs for the chat service binding.</p>
|
|
2741
|
+
<p>Counter (sanity): {{ count() }}</p>
|
|
2742
|
+
<button (click)="bump()">+1</button>
|
|
2743
|
+
</main>
|
|
2744
|
+
\`,
|
|
2745
|
+
})
|
|
2746
|
+
export class AppComponent {
|
|
2747
|
+
readonly count = signal(0)
|
|
2748
|
+
bump() { this.count.update(n => n + 1) }
|
|
2749
|
+
}
|
|
2750
|
+
`,
|
|
2751
|
+
".env.example": envExampleFor(ctx.provider),
|
|
2752
|
+
".gitignore": "node_modules\ndist\n.angular\n.env\n.env.local\n",
|
|
2753
|
+
"README.md": readmeFor(ctx)
|
|
2754
|
+
};
|
|
2755
|
+
}
|
|
1822
2756
|
function readmeFor(ctx) {
|
|
1823
2757
|
const installCmd = ctx.pm === "npm" ? "npm install" : `${ctx.pm} install`;
|
|
1824
2758
|
const runCmd = ctx.pm === "npm" ? "npm run dev" : `${ctx.pm} dev`;
|
|
@@ -1856,9 +2790,18 @@ ISC
|
|
|
1856
2790
|
}
|
|
1857
2791
|
var TEMPLATE_FN = {
|
|
1858
2792
|
react: reactStarter,
|
|
2793
|
+
nextjs: nextjsStarter,
|
|
1859
2794
|
ink: inkStarter,
|
|
1860
2795
|
runtime: runtimeStarter,
|
|
1861
|
-
"multi-agent": multiAgentStarter
|
|
2796
|
+
"multi-agent": multiAgentStarter,
|
|
2797
|
+
sveltekit: sveltekitStarter,
|
|
2798
|
+
nuxt: nuxtStarter,
|
|
2799
|
+
"vite-ink": viteInkStarter,
|
|
2800
|
+
"cloudflare-workers": cloudflareWorkersStarter,
|
|
2801
|
+
bun: bunStarter,
|
|
2802
|
+
expo: expoStarter,
|
|
2803
|
+
"deno-deploy": denoDeployStarter,
|
|
2804
|
+
angular: angularStarter
|
|
1862
2805
|
};
|
|
1863
2806
|
async function writeStarterProject(options) {
|
|
1864
2807
|
const ctx = {
|
|
@@ -2657,7 +3600,16 @@ ${kleur3.bold().green("\u25B2")} ${kleur3.bold("agentskit init")}
|
|
|
2657
3600
|
default: defaults.template ?? "react",
|
|
2658
3601
|
choices: [
|
|
2659
3602
|
{ name: "React chat (Vite + browser)", value: "react", description: "Streaming UI with @agentskit/react" },
|
|
3603
|
+
{ name: "Next.js chat (App Router + Route Handler)", value: "nextjs", description: "app/api/chat streams to a useChat client" },
|
|
3604
|
+
{ name: "SvelteKit chat", value: "sveltekit", description: "@agentskit/svelte client + server route streaming" },
|
|
3605
|
+
{ name: "Nuxt chat", value: "nuxt", description: "@agentskit/vue composable + Nitro server route streaming" },
|
|
2660
3606
|
{ name: "Ink chat (terminal UI)", value: "ink", description: "Same chat but in your terminal" },
|
|
3607
|
+
{ name: "Vite + Ink (terminal, hot-reload)", value: "vite-ink", description: "Ink chat with vite-node hot reload" },
|
|
3608
|
+
{ name: "Cloudflare Workers (edge)", value: "cloudflare-workers", description: "Edge runtime with itty-router + streaming" },
|
|
3609
|
+
{ name: "Bun server", value: "bun", description: "Bun.serve with hot reload" },
|
|
3610
|
+
{ name: "Deno Deploy", value: "deno-deploy", description: "Deno.serve with deployctl + npm: imports" },
|
|
3611
|
+
{ name: "Expo + auth (mobile)", value: "expo", description: "expo-router + expo-secure-store + chat screen" },
|
|
3612
|
+
{ name: "Angular standalone", value: "angular", description: "Angular 21 standalone bootstrap with @agentskit/angular" },
|
|
2661
3613
|
{ name: "Runtime (headless agent, no UI)", value: "runtime", description: "Autonomous task \u2192 result" },
|
|
2662
3614
|
{ name: "Multi-agent (planner + delegates)", value: "multi-agent", description: "Supervisor pattern, ready to extend" }
|
|
2663
3615
|
]
|
|
@@ -2766,7 +3718,7 @@ function printNextSteps(options) {
|
|
|
2766
3718
|
|
|
2767
3719
|
// src/commands/init.ts
|
|
2768
3720
|
function registerInitCommand(program) {
|
|
2769
|
-
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) => {
|
|
3721
|
+
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) => {
|
|
2770
3722
|
const isCi = !process.stdout.isTTY || rawOptions.yes || rawOptions.template;
|
|
2771
3723
|
let resolved;
|
|
2772
3724
|
if (isCi) {
|
|
@@ -3149,5 +4101,5 @@ function createCli() {
|
|
|
3149
4101
|
}
|
|
3150
4102
|
|
|
3151
4103
|
export { ChatApp, HookDispatcher, McpClient, applyPolicyToTool, applyPolicyToTools, bridgeMcpServers, buildRagFromConfig, computeCost, configHooksToHandlers, createCli, createOpenAiEmbedder, defaultPolicy, derivePreview, disposeMcpClients, evaluatePolicy, findLatestSession, findSession, forkSession, generateSessionId, getPricing, indexSources, listSessions, loadConfig, loadPlugins, mergePluginsIntoBundle, registerPricing, renameSession, renderChatHeader, renderReport, resolveChatProvider, resolveSession, runAgent, runDoctor, sessionFilePath, startDev, startTunnel, writeSessionMeta, writeStarterProject };
|
|
3152
|
-
//# sourceMappingURL=chunk-
|
|
3153
|
-
//# sourceMappingURL=chunk-
|
|
4104
|
+
//# sourceMappingURL=chunk-I5P3Y7NG.js.map
|
|
4105
|
+
//# sourceMappingURL=chunk-I5P3Y7NG.js.map
|