@standardagents/cli 0.11.0-next.41deba4 → 0.11.0-next.56def20

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/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
- import fs3, { readFileSync } from 'fs';
4
- import path3, { dirname, resolve } from 'path';
5
- import { fileURLToPath } from 'url';
3
+ import path3 from 'path';
4
+ import fs3 from 'fs';
6
5
  import crypto from 'crypto';
7
6
  import readline from 'readline';
8
7
  import { spawn } from 'child_process';
@@ -11,6 +10,7 @@ import { parse, modify, applyEdits } from 'jsonc-parser';
11
10
  import { loadFile, writeFile, generateCode } from 'magicast';
12
11
  import { addVitePlugin } from 'magicast/helpers';
13
12
  import net from 'net';
13
+ import { fileURLToPath } from 'url';
14
14
 
15
15
  var logger = {
16
16
  success: (message) => {
@@ -116,30 +116,32 @@ agents/
116
116
 
117
117
  Files are **auto-discovered** at runtime. No manual registration needed.
118
118
 
119
- ## FlowState
119
+ ## ThreadState
120
120
 
121
- \`FlowState\` is the central state object available in tools and hooks:
121
+ \`ThreadState\` is the state object available in tools and hooks:
122
122
 
123
123
  \`\`\`typescript
124
- interface FlowState {
125
- thread: {
126
- id: string; // Thread identifier
127
- instance: DurableThread; // Durable Object instance
128
- };
129
- agent: AgentConfig; // Current agent configuration
130
- prompt: PromptConfig; // Current prompt configuration
131
- model: ModelConfig; // Current model configuration
132
- messages: Message[]; // Conversation history
133
- env: Env; // Cloudflare Worker environment
134
- rootState: FlowState; // Parent state (for sub-prompts)
124
+ interface ThreadState {
125
+ // Identity (readonly)
126
+ threadId: string; // Thread identifier
127
+ agentId: string; // Agent identifier
128
+ userId: string | null; // User identifier (if set)
129
+ createdAt: number; // Creation timestamp
130
+
131
+ // Methods
132
+ getMessages(options?): Promise<MessagesResult>; // Get conversation history
133
+ injectMessage(input): Promise<Message>; // Add message to thread
134
+ loadModel(name): Promise<ModelConfig>; // Load model definition
135
+ loadPrompt(name): Promise<PromptConfig>; // Load prompt definition
136
+ loadAgent(name): Promise<AgentConfig>; // Load agent definition
135
137
  }
136
138
  \`\`\`
137
139
 
138
140
  Access in tools:
139
141
  \`\`\`typescript
140
142
  export default defineTool('...', schema, async (flow, args) => {
141
- const threadId = flow.thread.id;
142
- const messages = flow.messages;
143
+ const threadId = flow.threadId;
144
+ const { messages } = await flow.getMessages();
143
145
  // ...
144
146
  });
145
147
  \`\`\`
@@ -525,12 +527,12 @@ Tools extend agent capabilities beyond text generation. They allow LLMs to fetch
525
527
  ## Function Signature
526
528
 
527
529
  \`\`\`typescript
528
- defineTool(
530
+ defineTool({
529
531
  description: string, // What the tool does (shown to LLM)
530
- args: z.ZodObject, // Input validation schema
531
- handler: (flow, args) => ToolResult, // Implementation
532
- returnSchema?: z.ZodObject // Optional output schema
533
- )
532
+ args?: z.ZodObject, // Input validation schema (optional)
533
+ execute: (state, args) => ToolResult, // Implementation
534
+ tenvs?: z.ZodObject, // Thread environment variables (optional)
535
+ })
534
536
  \`\`\`
535
537
 
536
538
  ## Basic Example
@@ -539,20 +541,20 @@ defineTool(
539
541
  import { defineTool } from '@standardagents/builder';
540
542
  import { z } from 'zod';
541
543
 
542
- export default defineTool(
543
- 'Search the knowledge base for articles matching a query',
544
- z.object({
544
+ export default defineTool({
545
+ description: 'Search the knowledge base for articles matching a query',
546
+ args: z.object({
545
547
  query: z.string().describe('Search query'),
546
548
  limit: z.number().optional().default(10).describe('Max results'),
547
549
  }),
548
- async (flow, args) => {
550
+ execute: async (state, args) => {
549
551
  const results = await searchKB(args.query, args.limit);
550
552
  return {
551
553
  status: 'success',
552
554
  result: JSON.stringify(results),
553
555
  };
554
- }
555
- );
556
+ },
557
+ });
556
558
  \`\`\`
557
559
 
558
560
  ## ToolResult Interface
@@ -562,44 +564,45 @@ export default defineTool(
562
564
  | \`status\` | \`'success' \\| 'error'\` | Whether the tool succeeded |
563
565
  | \`result\` | \`string\` | Tool output (required for success) |
564
566
  | \`error\` | \`string\` | Error message (for error status) |
567
+ | \`attachments\` | \`ToolAttachment[]\` | Files to attach (images, etc.) |
565
568
 
566
- ## FlowState Access
569
+ ## ThreadState Access
567
570
 
568
- The \`flow\` parameter provides access to:
571
+ The \`state\` parameter provides access to:
569
572
 
570
573
  \`\`\`typescript
571
- async (flow, args) => {
574
+ execute: async (state, args) => {
572
575
  // Thread information
573
- const threadId = flow.thread.id;
574
- const thread = flow.thread.instance;
576
+ const threadId = state.thread.id;
577
+ const thread = state.thread.instance;
575
578
 
576
579
  // Configuration
577
- const agentName = flow.agent.name;
578
- const modelName = flow.model.name;
580
+ const agentName = state.agent.name;
581
+ const modelName = state.model.name;
579
582
 
580
583
  // Message history
581
- const messages = flow.messages;
584
+ const messages = state.messages;
582
585
 
583
586
  // Environment bindings
584
- const env = flow.env;
587
+ const env = state.env;
585
588
 
586
589
  // Parent state (for sub-prompts)
587
- const root = flow.rootState;
590
+ const root = state.rootState;
588
591
  }
589
592
  \`\`\`
590
593
 
591
594
  ## Tool Without Arguments
592
595
 
593
596
  \`\`\`typescript
594
- export default defineTool(
595
- 'Get current server time',
596
- async (flow) => {
597
+ export default defineTool({
598
+ description: 'Get current server time',
599
+ execute: async (state) => {
597
600
  return {
598
601
  status: 'success',
599
602
  result: new Date().toISOString(),
600
603
  };
601
- }
602
- );
604
+ },
605
+ });
603
606
  \`\`\`
604
607
 
605
608
  ## Error Handling
@@ -607,10 +610,10 @@ export default defineTool(
607
610
  Return errors gracefully instead of throwing:
608
611
 
609
612
  \`\`\`typescript
610
- export default defineTool(
611
- 'Fetch user data',
612
- z.object({ userId: z.string() }),
613
- async (flow, args) => {
613
+ export default defineTool({
614
+ description: 'Fetch user data',
615
+ args: z.object({ userId: z.string() }),
616
+ execute: async (state, args) => {
614
617
  try {
615
618
  const user = await fetchUser(args.userId);
616
619
  return { status: 'success', result: JSON.stringify(user) };
@@ -620,8 +623,8 @@ export default defineTool(
620
623
  error: \`Failed to fetch user: \${error.message}\`,
621
624
  };
622
625
  }
623
- }
624
- );
626
+ },
627
+ });
625
628
  \`\`\`
626
629
 
627
630
  ## Queueing Additional Tools
@@ -631,21 +634,21 @@ Queue another tool to run after the current one:
631
634
  \`\`\`typescript
632
635
  import { queueTool } from '@standardagents/builder';
633
636
 
634
- export default defineTool(
635
- 'Create order and send confirmation',
636
- z.object({ items: z.array(z.string()) }),
637
- async (flow, args) => {
637
+ export default defineTool({
638
+ description: 'Create order and send confirmation',
639
+ args: z.object({ items: z.array(z.string()) }),
640
+ execute: async (state, args) => {
638
641
  const order = await createOrder(args.items);
639
642
 
640
643
  // Queue email tool to run next
641
- queueTool(flow, 'send_confirmation_email', {
644
+ queueTool(state, 'send_confirmation_email', {
642
645
  orderId: order.id,
643
- email: flow.thread.metadata.userEmail,
646
+ email: state.thread.metadata.userEmail,
644
647
  });
645
648
 
646
649
  return { status: 'success', result: JSON.stringify(order) };
647
- }
648
- );
650
+ },
651
+ });
649
652
  \`\`\`
650
653
 
651
654
  ## Injecting Messages
@@ -655,17 +658,61 @@ Add messages without triggering re-execution:
655
658
  \`\`\`typescript
656
659
  import { injectMessage } from '@standardagents/builder';
657
660
 
658
- export default defineTool(
659
- 'Log audit event',
660
- z.object({ event: z.string() }),
661
- async (flow, args) => {
662
- await injectMessage(flow, {
661
+ export default defineTool({
662
+ description: 'Log audit event',
663
+ args: z.object({ event: z.string() }),
664
+ execute: async (state, args) => {
665
+ await injectMessage(state, {
663
666
  role: 'system',
664
667
  content: \`[AUDIT] \${args.event}\`,
665
668
  });
666
669
  return { status: 'success', result: 'Logged' };
667
- }
668
- );
670
+ },
671
+ });
672
+ \`\`\`
673
+
674
+ ## Thread Environment Variables (tenvs)
675
+
676
+ Tools can declare required thread environment variables:
677
+
678
+ \`\`\`typescript
679
+ export default defineTool({
680
+ description: 'Search uploaded documents',
681
+ args: z.object({ query: z.string() }),
682
+ execute: async (state, args) => {
683
+ const vectorStoreId = state.tenvs.vectorStoreId;
684
+ const results = await searchVectorStore(vectorStoreId, args.query);
685
+ return { status: 'success', result: JSON.stringify(results) };
686
+ },
687
+ tenvs: z.object({
688
+ vectorStoreId: z.string().describe('OpenAI Vector Store ID'),
689
+ }),
690
+ });
691
+ \`\`\`
692
+
693
+ ## Returning Attachments
694
+
695
+ Tools can return file attachments (e.g., generated images):
696
+
697
+ \`\`\`typescript
698
+ export default defineTool({
699
+ description: 'Generate a chart from data',
700
+ args: z.object({ data: z.array(z.number()) }),
701
+ execute: async (state, args) => {
702
+ const chartImage = await generateChart(args.data);
703
+ return {
704
+ status: 'success',
705
+ result: 'Chart generated successfully',
706
+ attachments: [{
707
+ name: 'chart.png',
708
+ mimeType: 'image/png',
709
+ data: chartImage.base64,
710
+ width: 800,
711
+ height: 600,
712
+ }],
713
+ };
714
+ },
715
+ });
669
716
  \`\`\`
670
717
 
671
718
  ## Best Practices
@@ -675,7 +722,7 @@ export default defineTool(
675
722
  - **Handle errors gracefully** - return error status, don't throw
676
723
  - **Use snake_case** for file names (\`search_knowledge_base.ts\`)
677
724
  - **Keep tools focused** - one task per tool
678
- - **Use \`flow.rootState\`** when queueing from sub-prompts
725
+ - **Use \`state.rootState\`** when queueing from sub-prompts
679
726
 
680
727
  ## Supported Zod Types
681
728
 
@@ -979,17 +1026,19 @@ Full reference: https://docs.standardagentbuilder.com/core-concepts/api
979
1026
  `;
980
1027
 
981
1028
  // src/commands/scaffold.ts
982
- var WRANGLER_TEMPLATE = (name) => `{
1029
+ var WRANGLER_TEMPLATE = (name) => {
1030
+ const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
1031
+ return `{
983
1032
  "$schema": "node_modules/wrangler/config-schema.json",
984
1033
  "name": "${name}",
985
1034
  "main": "worker/index.ts",
986
- "compatibility_date": "2025-01-01",
1035
+ "compatibility_date": "${today}",
987
1036
  "compatibility_flags": ["nodejs_compat"],
988
1037
  "observability": {
989
1038
  "enabled": true
990
1039
  },
991
1040
  "assets": {
992
- "directory": "dist",
1041
+ "directory": "dist/client",
993
1042
  "not_found_handling": "single-page-application",
994
1043
  "binding": "ASSETS",
995
1044
  "run_worker_first": ["/**"]
@@ -1018,6 +1067,7 @@ var WRANGLER_TEMPLATE = (name) => `{
1018
1067
  ]
1019
1068
  }
1020
1069
  `;
1070
+ };
1021
1071
  var THREAD_TS = `import { DurableThread } from 'virtual:@standardagents/builder'
1022
1072
 
1023
1073
  export default class Thread extends DurableThread {}
@@ -1043,9 +1093,9 @@ function getProjectName(cwd) {
1043
1093
  const packageJsonPath = path3.join(cwd, "package.json");
1044
1094
  if (fs3.existsSync(packageJsonPath)) {
1045
1095
  try {
1046
- const pkg2 = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
1047
- if (pkg2.name) {
1048
- return pkg2.name.replace(/^@[^/]+\//, "");
1096
+ const pkg = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
1097
+ if (pkg.name) {
1098
+ return pkg.name.replace(/^@[^/]+\//, "");
1049
1099
  }
1050
1100
  } catch {
1051
1101
  }
@@ -1082,14 +1132,6 @@ async function modifyViteConfig(configPath, force) {
1082
1132
  logger.info("Vite config already includes Standard Agents plugins");
1083
1133
  return true;
1084
1134
  }
1085
- if (!hasCloudflare || force) {
1086
- addVitePlugin(mod, {
1087
- from: "@cloudflare/vite-plugin",
1088
- imported: "cloudflare",
1089
- constructor: "cloudflare"
1090
- });
1091
- logger.success("Added cloudflare plugin to vite.config");
1092
- }
1093
1135
  if (!hasAgentBuilder || force) {
1094
1136
  addVitePlugin(mod, {
1095
1137
  from: "@standardagents/builder",
@@ -1099,6 +1141,14 @@ async function modifyViteConfig(configPath, force) {
1099
1141
  });
1100
1142
  logger.success("Added agentbuilder plugin to vite.config");
1101
1143
  }
1144
+ if (!hasCloudflare || force) {
1145
+ addVitePlugin(mod, {
1146
+ from: "@cloudflare/vite-plugin",
1147
+ imported: "cloudflare",
1148
+ constructor: "cloudflare"
1149
+ });
1150
+ logger.success("Added cloudflare plugin to vite.config");
1151
+ }
1102
1152
  await writeFile(mod, configPath);
1103
1153
  return true;
1104
1154
  } catch (error) {
@@ -1106,10 +1156,10 @@ async function modifyViteConfig(configPath, force) {
1106
1156
  logger.log("");
1107
1157
  logger.log("Please manually add the following to your vite.config.ts:");
1108
1158
  logger.log("");
1109
- logger.log(` import { cloudflare } from '@cloudflare/vite-plugin'`);
1110
1159
  logger.log(` import { agentbuilder } from '@standardagents/builder'`);
1160
+ logger.log(` import { cloudflare } from '@cloudflare/vite-plugin'`);
1111
1161
  logger.log("");
1112
- logger.log(` plugins: [cloudflare(), agentbuilder({ mountPoint: '/' })]`);
1162
+ logger.log(` plugins: [agentbuilder({ mountPoint: '/' }), cloudflare()]`);
1113
1163
  logger.log("");
1114
1164
  return false;
1115
1165
  }
@@ -1158,7 +1208,7 @@ function createOrUpdateWranglerConfig(cwd, projectName, force) {
1158
1208
  }
1159
1209
  if (!config.assets) {
1160
1210
  const edits = modify(result, ["assets"], {
1161
- directory: "dist",
1211
+ directory: "dist/client",
1162
1212
  not_found_handling: "single-page-application",
1163
1213
  binding: "ASSETS",
1164
1214
  run_worker_first: ["/**"]
@@ -1430,15 +1480,15 @@ async function prompt(question) {
1430
1480
  input: process.stdin,
1431
1481
  output: process.stdout
1432
1482
  });
1433
- return new Promise((resolve2) => {
1483
+ return new Promise((resolve) => {
1434
1484
  rl.question(question, (answer) => {
1435
1485
  rl.close();
1436
- resolve2(answer.trim());
1486
+ resolve(answer.trim());
1437
1487
  });
1438
1488
  });
1439
1489
  }
1440
1490
  async function promptPassword(question) {
1441
- return new Promise((resolve2) => {
1491
+ return new Promise((resolve) => {
1442
1492
  const stdin = process.stdin;
1443
1493
  const stdout = process.stdout;
1444
1494
  stdout.write(question);
@@ -1459,7 +1509,7 @@ async function promptPassword(question) {
1459
1509
  stdin.pause();
1460
1510
  stdin.removeListener("data", onData);
1461
1511
  stdout.write("\n");
1462
- resolve2(password);
1512
+ resolve(password);
1463
1513
  break;
1464
1514
  case "":
1465
1515
  stdout.write("\n");
@@ -1485,7 +1535,7 @@ async function promptPassword(question) {
1485
1535
  });
1486
1536
  }
1487
1537
  function runCommand(command, args, cwd) {
1488
- return new Promise((resolve2, reject) => {
1538
+ return new Promise((resolve, reject) => {
1489
1539
  const child = spawn(command, args, {
1490
1540
  cwd,
1491
1541
  stdio: "inherit",
@@ -1493,7 +1543,7 @@ function runCommand(command, args, cwd) {
1493
1543
  });
1494
1544
  child.on("close", (code) => {
1495
1545
  if (code === 0) {
1496
- resolve2();
1546
+ resolve();
1497
1547
  } else {
1498
1548
  reject(new Error(`Command failed with exit code ${code}`));
1499
1549
  }
@@ -1517,25 +1567,16 @@ function detectPackageManager() {
1517
1567
  if (fs3.existsSync("package-lock.json")) return "npm";
1518
1568
  return "npm";
1519
1569
  }
1520
- function getBuilderPackageVersion() {
1521
- try {
1522
- const __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
1523
- const pkgPath = path3.resolve(__dirname2, "../../package.json");
1524
- const pkg2 = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"));
1525
- const version = pkg2.version;
1526
- const prereleaseMatch = version.match(/-([a-z]+)\./i);
1527
- if (prereleaseMatch) {
1528
- return `@${prereleaseMatch[1]}`;
1529
- }
1530
- return `@^${version}`;
1531
- } catch {
1532
- return "";
1570
+ function getPackageVersion() {
1571
+ if (process.env.STANDARDAGENTS_WORKSPACE === "1") {
1572
+ return "workspace:*";
1533
1573
  }
1574
+ return "0.11.0-next.56def20";
1534
1575
  }
1535
1576
  async function selectPackageManager(detected) {
1536
1577
  const options = ["npm", "pnpm", "yarn", "bun"];
1537
1578
  const detectedIndex = options.indexOf(detected);
1538
- return new Promise((resolve2) => {
1579
+ return new Promise((resolve) => {
1539
1580
  const stdin = process.stdin;
1540
1581
  const stdout = process.stdout;
1541
1582
  let selectedIndex = detectedIndex;
@@ -1581,7 +1622,7 @@ async function selectPackageManager(detected) {
1581
1622
  renderOptions();
1582
1623
  } else if (key === "\r" || key === "\n") {
1583
1624
  cleanup();
1584
- resolve2(options[selectedIndex]);
1625
+ resolve(options[selectedIndex]);
1585
1626
  } else if (key === "") {
1586
1627
  cleanup();
1587
1628
  stdout.write("\n");
@@ -1667,31 +1708,7 @@ export default defineConfig({
1667
1708
  }
1668
1709
  }
1669
1710
  logger.log("");
1670
- logger.info("Step 2: Installing Standard Agents dependencies...");
1671
- logger.log("");
1672
- try {
1673
- const installCmd = pm === "npm" ? "install" : "add";
1674
- const devFlag = pm === "npm" ? "--save-dev" : "-D";
1675
- const builderVersion = getBuilderPackageVersion();
1676
- await runCommand(pm, [
1677
- installCmd,
1678
- devFlag,
1679
- "@cloudflare/vite-plugin",
1680
- `@standardagents/builder${builderVersion}`,
1681
- "wrangler",
1682
- "zod"
1683
- ], projectPath);
1684
- } catch (error) {
1685
- logger.error("Failed to install dependencies");
1686
- process.exit(1);
1687
- }
1688
- logger.log("");
1689
- logger.info("Step 3: Configuring Standard Agents...");
1690
- logger.log("");
1691
- process.chdir(projectPath);
1692
- await scaffold({ force: true });
1693
- logger.log("");
1694
- logger.info("Step 4: Configuring environment variables...");
1711
+ logger.info("Step 2: Configuring environment variables...");
1695
1712
  logger.log("");
1696
1713
  const encryptionKey = crypto.randomBytes(32).toString("hex");
1697
1714
  let openrouterKey = "";
@@ -1726,6 +1743,44 @@ export default defineConfig({
1726
1743
  if (!adminPassword) {
1727
1744
  adminPassword = "admin";
1728
1745
  }
1746
+ logger.log("");
1747
+ logger.info("Step 3: Installing Standard Agents dependencies...");
1748
+ logger.log("");
1749
+ try {
1750
+ const installCmd = pm === "npm" ? "install" : "add";
1751
+ const devFlag = pm === "npm" ? "--save-dev" : "-D";
1752
+ const packageVersion = getPackageVersion();
1753
+ await runCommand(pm, [
1754
+ installCmd,
1755
+ devFlag,
1756
+ "@cloudflare/vite-plugin",
1757
+ "wrangler"
1758
+ ], projectPath);
1759
+ const deps = [
1760
+ `@standardagents/builder@${packageVersion}`,
1761
+ `@standardagents/spec@${packageVersion}`,
1762
+ `@standardagents/sip@${packageVersion}`,
1763
+ "zod"
1764
+ ];
1765
+ if (openaiKey) {
1766
+ deps.push(`@standardagents/openai@${packageVersion}`);
1767
+ }
1768
+ if (openrouterKey) {
1769
+ deps.push(`@standardagents/openrouter@${packageVersion}`);
1770
+ }
1771
+ await runCommand(pm, [installCmd, ...deps], projectPath);
1772
+ } catch (error) {
1773
+ logger.error("Failed to install dependencies");
1774
+ process.exit(1);
1775
+ }
1776
+ logger.log("");
1777
+ logger.info("Step 4: Configuring Standard Agents...");
1778
+ logger.log("");
1779
+ process.chdir(projectPath);
1780
+ await scaffold({ force: true });
1781
+ logger.log("");
1782
+ logger.info("Writing environment configuration...");
1783
+ logger.log("");
1729
1784
  const devVarsLines = [
1730
1785
  "# Standard Agents Environment Variables",
1731
1786
  "# This file contains secrets for local development only",
@@ -1782,10 +1837,10 @@ export default defineConfig({
1782
1837
  }
1783
1838
  function getReactPackageVersion() {
1784
1839
  try {
1785
- const __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
1786
- const pkgPath = path3.resolve(__dirname2, "../package.json");
1787
- const pkg2 = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"));
1788
- const version = pkg2.version;
1840
+ const __dirname = path3.dirname(fileURLToPath(import.meta.url));
1841
+ const pkgPath = path3.resolve(__dirname, "../package.json");
1842
+ const pkg = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"));
1843
+ const version = pkg.version;
1789
1844
  const prereleaseMatch = version.match(/-([a-z]+)\./i);
1790
1845
  if (prereleaseMatch) {
1791
1846
  return prereleaseMatch[1];
@@ -1796,23 +1851,23 @@ function getReactPackageVersion() {
1796
1851
  }
1797
1852
  }
1798
1853
  function getChatSourceDir() {
1799
- const __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
1800
- return path3.resolve(__dirname2, "../chat");
1854
+ const __dirname = path3.dirname(fileURLToPath(import.meta.url));
1855
+ return path3.resolve(__dirname, "../chat");
1801
1856
  }
1802
1857
  async function prompt2(question) {
1803
1858
  const rl = readline.createInterface({
1804
1859
  input: process.stdin,
1805
1860
  output: process.stdout
1806
1861
  });
1807
- return new Promise((resolve2) => {
1862
+ return new Promise((resolve) => {
1808
1863
  rl.question(question, (answer) => {
1809
1864
  rl.close();
1810
- resolve2(answer.trim());
1865
+ resolve(answer.trim());
1811
1866
  });
1812
1867
  });
1813
1868
  }
1814
1869
  function runCommand2(command, args, cwd) {
1815
- return new Promise((resolve2, reject) => {
1870
+ return new Promise((resolve, reject) => {
1816
1871
  const child = spawn(command, args, {
1817
1872
  cwd,
1818
1873
  stdio: "inherit",
@@ -1820,7 +1875,7 @@ function runCommand2(command, args, cwd) {
1820
1875
  });
1821
1876
  child.on("close", (code) => {
1822
1877
  if (code === 0) {
1823
- resolve2();
1878
+ resolve();
1824
1879
  } else {
1825
1880
  reject(new Error(`Command failed with exit code ${code}`));
1826
1881
  }
@@ -1844,7 +1899,7 @@ function detectPackageManager2() {
1844
1899
  async function selectPackageManager2(detected) {
1845
1900
  const options = ["npm", "pnpm", "yarn", "bun"];
1846
1901
  const detectedIndex = options.indexOf(detected);
1847
- return new Promise((resolve2) => {
1902
+ return new Promise((resolve) => {
1848
1903
  const stdin = process.stdin;
1849
1904
  const stdout = process.stdout;
1850
1905
  let selectedIndex = detectedIndex;
@@ -1890,7 +1945,7 @@ async function selectPackageManager2(detected) {
1890
1945
  renderOptions();
1891
1946
  } else if (key === "\r" || key === "\n") {
1892
1947
  cleanup();
1893
- resolve2(options[selectedIndex]);
1948
+ resolve(options[selectedIndex]);
1894
1949
  } else if (key === "") {
1895
1950
  cleanup();
1896
1951
  stdout.write("\n");
@@ -1905,7 +1960,7 @@ async function selectFramework() {
1905
1960
  { value: "vite", label: "Vite (React + TypeScript)" },
1906
1961
  { value: "nextjs", label: "Next.js (App Router)" }
1907
1962
  ];
1908
- return new Promise((resolve2) => {
1963
+ return new Promise((resolve) => {
1909
1964
  const stdin = process.stdin;
1910
1965
  const stdout = process.stdout;
1911
1966
  let selectedIndex = 0;
@@ -1949,7 +2004,7 @@ async function selectFramework() {
1949
2004
  renderOptions();
1950
2005
  } else if (key === "\r" || key === "\n") {
1951
2006
  cleanup();
1952
- resolve2(options[selectedIndex].value);
2007
+ resolve(options[selectedIndex].value);
1953
2008
  } else if (key === "") {
1954
2009
  cleanup();
1955
2010
  stdout.write("\n");
@@ -1969,20 +2024,20 @@ function isValidUrl(url) {
1969
2024
  }
1970
2025
  async function isPortOpen(port) {
1971
2026
  const tryConnect = (host) => {
1972
- return new Promise((resolve2) => {
2027
+ return new Promise((resolve) => {
1973
2028
  const socket = new net.Socket();
1974
2029
  socket.setTimeout(200);
1975
2030
  socket.on("connect", () => {
1976
2031
  socket.destroy();
1977
- resolve2(true);
2032
+ resolve(true);
1978
2033
  });
1979
2034
  socket.on("timeout", () => {
1980
2035
  socket.destroy();
1981
- resolve2(false);
2036
+ resolve(false);
1982
2037
  });
1983
2038
  socket.on("error", () => {
1984
2039
  socket.destroy();
1985
- resolve2(false);
2040
+ resolve(false);
1986
2041
  });
1987
2042
  socket.connect(port, host);
1988
2043
  });
@@ -2206,21 +2261,21 @@ export default defineConfig({
2206
2261
  fs3.writeFileSync(path3.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
2207
2262
  logger.success("Created tsconfig.json");
2208
2263
  fs3.copyFileSync(path3.join(chatSourceDir, "package.json"), path3.join(projectPath, "package.json"));
2209
- const pkg2 = JSON.parse(fs3.readFileSync(path3.join(projectPath, "package.json"), "utf-8"));
2210
- pkg2.name = projectName;
2211
- pkg2.scripts = {
2264
+ const pkg = JSON.parse(fs3.readFileSync(path3.join(projectPath, "package.json"), "utf-8"));
2265
+ pkg.name = projectName;
2266
+ pkg.scripts = {
2212
2267
  dev: "vite",
2213
2268
  build: "vite build",
2214
2269
  preview: "vite preview"
2215
2270
  };
2216
- delete pkg2.private;
2217
- if (pkg2.dependencies?.["@standardagents/react"]) {
2218
- pkg2.dependencies["@standardagents/react"] = reactVersion;
2219
- }
2220
- delete pkg2.dependencies?.["next"];
2221
- delete pkg2.devDependencies?.["@tailwindcss/postcss"];
2222
- delete pkg2.devDependencies?.["postcss"];
2223
- fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
2271
+ delete pkg.private;
2272
+ if (pkg.dependencies?.["@standardagents/react"]) {
2273
+ pkg.dependencies["@standardagents/react"] = reactVersion;
2274
+ }
2275
+ delete pkg.dependencies?.["next"];
2276
+ delete pkg.devDependencies?.["@tailwindcss/postcss"];
2277
+ delete pkg.devDependencies?.["postcss"];
2278
+ fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg, null, 2) + "\n", "utf-8");
2224
2279
  logger.success("Created package.json");
2225
2280
  const envContent = `# Agentbuilder connection
2226
2281
  VITE_AGENTBUILDER_URL=${serverUrl}
@@ -2275,21 +2330,21 @@ async function scaffoldNextjs(projectPath, chatSourceDir, projectName, serverUrl
2275
2330
  };
2276
2331
  fs3.writeFileSync(path3.join(projectPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
2277
2332
  logger.success("Created tsconfig.json");
2278
- const pkg2 = JSON.parse(fs3.readFileSync(path3.join(chatSourceDir, "package.json"), "utf-8"));
2279
- pkg2.name = projectName;
2280
- pkg2.scripts = {
2333
+ const pkg = JSON.parse(fs3.readFileSync(path3.join(chatSourceDir, "package.json"), "utf-8"));
2334
+ pkg.name = projectName;
2335
+ pkg.scripts = {
2281
2336
  dev: "next dev",
2282
2337
  build: "next build",
2283
2338
  start: "next start"
2284
2339
  };
2285
- delete pkg2.private;
2286
- if (pkg2.dependencies?.["@standardagents/react"]) {
2287
- pkg2.dependencies["@standardagents/react"] = reactVersion;
2288
- }
2289
- delete pkg2.devDependencies?.["@tailwindcss/vite"];
2290
- delete pkg2.devDependencies?.["@vitejs/plugin-react"];
2291
- delete pkg2.devDependencies?.["vite"];
2292
- fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
2340
+ delete pkg.private;
2341
+ if (pkg.dependencies?.["@standardagents/react"]) {
2342
+ pkg.dependencies["@standardagents/react"] = reactVersion;
2343
+ }
2344
+ delete pkg.devDependencies?.["@tailwindcss/vite"];
2345
+ delete pkg.devDependencies?.["@vitejs/plugin-react"];
2346
+ delete pkg.devDependencies?.["vite"];
2347
+ fs3.writeFileSync(path3.join(projectPath, "package.json"), JSON.stringify(pkg, null, 2) + "\n", "utf-8");
2293
2348
  logger.success("Created package.json");
2294
2349
  const envContent = `# Agentbuilder connection
2295
2350
  NEXT_PUBLIC_AGENTBUILDER_URL=${serverUrl}
@@ -2311,10 +2366,8 @@ out
2311
2366
  }
2312
2367
 
2313
2368
  // src/index.ts
2314
- var __dirname$1 = dirname(fileURLToPath(import.meta.url));
2315
- var pkg = JSON.parse(readFileSync(resolve(__dirname$1, "../package.json"), "utf-8"));
2316
2369
  var program = new Command();
2317
- program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version(pkg.version);
2370
+ program.name("agents").description("CLI tool for Standard Agents / AgentBuilder").version("0.11.0-next.56def20");
2318
2371
  program.command("init [project-name]").description("Create a new Standard Agents project (runs create vite, then scaffold)").option("-y, --yes", "Skip prompts and use defaults").option("--template <template>", "Vite template to use", "vanilla-ts").action(init);
2319
2372
  program.command("scaffold").description("Add Standard Agents to an existing Vite project").option("--force", "Overwrite existing configuration").action(scaffold);
2320
2373
  program.command("init-chat [project-name]").description("Scaffold a frontend chat application").option("-y, --yes", "Skip prompts and use defaults").option("--framework <framework>", "Framework to use (vite or nextjs)").action(initChat);