@tangle-network/create-agent-app 0.51.4 → 0.51.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  Scaffold a Tangle agent product on
4
4
  [`@tangle-network/agent-app`](https://github.com/tangle-network/agent-app).
5
- Use **`--chat` for the browser sign-in and chat walkthrough below**. Without it,
6
- the CLI generates the unchanged tool-loop skeleton, not the assembled chat variant.
5
+ The default is the full shared browser workspace: sign-in, chat, History, uploads
6
+ and replay. Use `--headless` for the unchanged tool-loop skeleton; `--chat` remains
7
+ an explicit alias for the default.
7
8
 
8
9
  ## Choose a published version
9
10
 
@@ -14,7 +15,7 @@ package's engine requirement and record the version you will run:
14
15
  CREATE_VERSION=$(npm view @tangle-network/create-agent-app@latest version) &&
15
16
  npm view "@tangle-network/create-agent-app@$CREATE_VERSION" engines --json &&
16
17
  npm view "@tangle-network/agent-app@$CREATE_VERSION" version peerDependencies --json &&
17
- npm create "@tangle-network/agent-app@$CREATE_VERSION" my-agent -- --chat
18
+ npm create "@tangle-network/agent-app@$CREATE_VERSION" my-agent
18
19
  ```
19
20
 
20
21
  Do not continue after a failed registry lookup. The CLI defaults the generated
@@ -55,12 +56,12 @@ is at [`examples/default-workspace.md`](../examples/default-workspace.md).
55
56
  ```bash
56
57
  cd my-agent
57
58
  pnpm install
58
- cp .dev.vars.example .dev.vars
59
59
  ```
60
60
 
61
- Keep `.dev.vars` out of version control. Replace its auth-secret placeholder with
62
- a fresh secret (for example, `openssl rand -base64 32`) and fill the development
63
- `TANGLE_API_KEY`, `SANDBOX_API_KEY`, and `SANDBOX_GATEWAY_URL` credentials.
61
+ The scaffolder creates ignored `.dev.vars` with a fresh random local auth secret
62
+ (mode 0600 on POSIX). It does not print the secret or rotate an existing file,
63
+ even with `--force`. Fill the development `TANGLE_API_KEY`, `SANDBOX_API_KEY`,
64
+ and `SANDBOX_GATEWAY_URL` credentials.
64
65
  These are server-side Router and Sandbox credentials, not your app password.
65
66
  Missing sandbox credentials do not select a demo agent: real turns fail.
66
67
 
package/index.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  // create-agent-app — scaffold a new Tangle agent product on @tangle-network/agent-app.
3
3
  //
4
4
  // Dependency-light by design: Node built-ins only. The CLI copies one template
5
- // tree verbatim (`template/` by default, `template-chat/` with `--chat`),
5
+ // tree verbatim (`template-chat/` by default, `template/` with `--headless`),
6
6
  // substitutes a small set of `__TOKEN__` placeholders, and renames
7
7
  // files whose template name would otherwise interfere with tooling (a template's
8
8
  // own `package.json` must not be read by the scaffolder's package manager; a
@@ -14,15 +14,16 @@
14
14
 
15
15
  import { cp, mkdir, readFile, readdir, rename, stat, writeFile } from 'node:fs/promises'
16
16
  import { existsSync } from 'node:fs'
17
+ import { randomBytes } from 'node:crypto'
17
18
  import { dirname, join, resolve } from 'node:path'
18
19
  import { fileURLToPath } from 'node:url'
19
20
 
20
21
  const HERE = dirname(fileURLToPath(import.meta.url))
21
- // Template variants: the default tool-loop skeleton, and `--chat` — the
22
+ // Template variants: the explicit headless tool-loop skeleton, and the default
22
23
  // assembled multimodal chat vertical (auth + chat-store + chat-routes +
23
24
  // sandbox producer + uploads + replay) from `examples/chat-app.md`.
24
25
  const TEMPLATES = {
25
- default: join(HERE, 'template'),
26
+ headless: join(HERE, 'template'),
26
27
  chat: join(HERE, 'template-chat'),
27
28
  }
28
29
  const COMMON_TEMPLATE = join(HERE, 'template-common')
@@ -46,7 +47,11 @@ function parseArgs(argv) {
46
47
  const a = argv[i]
47
48
  if (a === '--name') args.name = argv[++i]
48
49
  else if (a === '--agent-app-version') args.agentAppVersion = argv[++i]
49
- else if (a === '--chat') args.template = 'chat'
50
+ else if (a === '--chat' || a === '--headless') {
51
+ const template = a === '--headless' ? 'headless' : 'chat'
52
+ if (args.template && args.template !== template) throw new Error('--chat and --headless cannot be combined')
53
+ args.template = template
54
+ }
50
55
  else if (a === '--force') args.force = true
51
56
  else if (a === '-h' || a === '--help') args.help = true
52
57
  else if (!a.startsWith('-')) args._.push(a)
@@ -62,10 +67,8 @@ function usage() {
62
67
  'Scaffolds a new Tangle agent product on @tangle-network/agent-app.',
63
68
  '',
64
69
  'Options:',
65
- ' --chat Scaffold the multimodal chat variant instead: the',
66
- ' assembled chat vertical (auth, thread/message store,',
67
- ' streaming turns + replay, uploads, agent asks) with',
68
- ' its own end-to-end test. Default: the tool-loop skeleton.',
70
+ ' --chat Full shared chat workspace (the default).',
71
+ ' --headless Tool-loop skeleton without the browser workspace.',
69
72
  ' --name <name> Project name (default: the target dir basename).',
70
73
  ' --agent-app-version <range> @tangle-network/agent-app version (default: ' + DEFAULT_AGENT_APP_VERSION + ').',
71
74
  ' --force Write into a non-empty directory.',
@@ -133,6 +136,20 @@ async function materializeTemplate(templateDir, targetDir, tokens) {
133
136
  }
134
137
  }
135
138
 
139
+ // Initialize only this new app's local session secret. Never copy account
140
+ // credentials, print the value, or rotate an existing development session.
141
+ async function initializeLocalAuth(targetDir) {
142
+ const example = await readFile(join(targetDir, '.dev.vars.example'), 'utf8')
143
+ const placeholder = 'BETTER_AUTH_SECRET=REPLACE_WITH_RANDOM_SECRET'
144
+ if (!example.includes(placeholder)) throw new Error('Chat template is missing its local auth-secret placeholder')
145
+ const local = example.replace(placeholder, `BETTER_AUTH_SECRET=${randomBytes(32).toString('base64url')}`)
146
+ try {
147
+ await writeFile(join(targetDir, '.dev.vars'), local, { flag: 'wx', mode: 0o600 })
148
+ } catch (error) {
149
+ if (error.code !== 'EEXIST') throw error
150
+ }
151
+ }
152
+
136
153
  async function main() {
137
154
  const args = parseArgs(process.argv.slice(2))
138
155
  if (args.help || (args._.length === 0 && !args.name)) {
@@ -144,7 +161,8 @@ async function main() {
144
161
  const projectName = args.name ?? targetDir.split(/[\\/]/).pop()
145
162
  const packageName = toPackageName(projectName)
146
163
  const agentAppVersion = args.agentAppVersion ?? DEFAULT_AGENT_APP_VERSION
147
- const templateDir = TEMPLATES[args.template ?? 'default']
164
+ const variant = args.template ?? 'chat'
165
+ const templateDir = TEMPLATES[variant]
148
166
 
149
167
  if (existsSync(targetDir)) {
150
168
  const entries = await readdir(targetDir).catch(() => [])
@@ -166,6 +184,7 @@ async function main() {
166
184
 
167
185
  await materializeTemplate(COMMON_TEMPLATE, targetDir, tokens)
168
186
  await materializeTemplate(templateDir, targetDir, tokens)
187
+ if (variant === 'chat') await initializeLocalAuth(targetDir)
169
188
 
170
189
  process.stdout.write(
171
190
  [
@@ -174,7 +193,11 @@ async function main() {
174
193
  'Next:',
175
194
  ` cd ${targetDir}`,
176
195
  ' pnpm install',
177
- ' pnpm typecheck && pnpm test',
196
+ ...(variant === 'chat' ? [
197
+ ' # Fill scoped Router/Sandbox access in .dev.vars and choose a model in agent.config.ts.',
198
+ ' pnpm db:migrate:local',
199
+ ' pnpm dev',
200
+ ] : [' pnpm typecheck && pnpm test']),
178
201
  '',
179
202
  'Then walk CUSTOMIZE.md (the fill-checklist) and AGENTS.md (the behavior contract).',
180
203
  '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/create-agent-app",
3
- "version": "0.51.4",
3
+ "version": "0.51.6",
4
4
  "description": "Create a tested Tangle agent application with either a tool loop or a complete chat interface.",
5
5
  "keywords": [
6
6
  "tangle",
@@ -1,7 +1,8 @@
1
- # Copy to .dev.vars for local development (never commit .dev.vars).
1
+ # The scaffolder creates private .dev.vars with a fresh local session secret.
2
+ # This example remains a recovery template; never commit .dev.vars.
2
3
  # Production: `wrangler secret put <NAME>` for each secret.
3
4
 
4
- # better-auth HMAC secret — generate one: openssl rand -base64 32
5
+ # The scaffolder replaces this placeholder only in the new local .dev.vars.
5
6
  BETTER_AUTH_SECRET=REPLACE_WITH_RANDOM_SECRET
6
7
 
7
8
  # Tangle Router key the harness bills model calls against.
@@ -1,6 +1,6 @@
1
1
  # __PROJECT_NAME__
2
2
 
3
- A React chat workspace scaffolded with `create-agent-app --chat`, built on
3
+ A React chat workspace scaffolded with `create-agent-app`, built on
4
4
  `@tangle-network/agent-app` and its public UI packages. The maintained
5
5
  `AgentWorkspaceLayout` owns the rail and History. `ChatComposer`, `ChatMessages`,
6
6
  and the interaction cards supply the conversation surface.
@@ -36,8 +36,10 @@ pnpm build
36
36
  pnpm test
37
37
  ```
38
38
 
39
- Read `AGENTS.md` and follow `CUSTOMIZE.md`. Set up the development D1 binding
40
- and `.dev.vars`, then:
39
+ The scaffolder creates ignored `.dev.vars` with a fresh local session secret;
40
+ it never prints the value or overwrites an existing file. Fill the scoped
41
+ Router/Sandbox credentials, choose an authorized model in `agent.config.ts`,
42
+ and configure the development D1 binding described in `CUSTOMIZE.md`. Then:
41
43
 
42
44
  ```bash
43
45
  pnpm db:migrate:local