@standardagents/cli 0.10.1-next.82e11d5 → 0.10.1-next.9e1860c

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.
@@ -0,0 +1,168 @@
1
+ @import "tailwindcss";
2
+
3
+ @source "./**/*.{ts,tsx}";
4
+ @source "../vite/**/*.{ts,tsx,html}";
5
+ @source "../next/**/*.{ts,tsx}";
6
+
7
+ /* Theme variables */
8
+ :root {
9
+ /* Dark mode (default) */
10
+ --bg-primary: #0a0a0b;
11
+ --bg-secondary: #111113;
12
+ --bg-tertiary: #1a1a1c;
13
+ --bg-elevated: #1f1f23;
14
+ --bg-hover: rgba(63, 63, 70, 0.4);
15
+ --bg-active: rgba(63, 63, 70, 0.8);
16
+
17
+ --border-primary: rgba(63, 63, 70, 0.5);
18
+ --border-secondary: #3f3f46;
19
+
20
+ --text-primary: #fafafa;
21
+ --text-secondary: #a1a1aa;
22
+ --text-tertiary: #71717a;
23
+ --text-muted: #52525b;
24
+
25
+ --scrollbar-thumb: #3f3f46;
26
+ --scrollbar-thumb-hover: #52525b;
27
+
28
+ --code-bg: #1f1f22;
29
+ --shimmer-color: rgba(255, 255, 255, 0.05);
30
+ }
31
+
32
+ .light {
33
+ --bg-primary: #ffffff;
34
+ --bg-secondary: #f9fafb;
35
+ --bg-tertiary: #f3f4f6;
36
+ --bg-elevated: #ffffff;
37
+ --bg-hover: rgba(0, 0, 0, 0.05);
38
+ --bg-active: rgba(0, 0, 0, 0.1);
39
+
40
+ --border-primary: #e5e7eb;
41
+ --border-secondary: #d1d5db;
42
+
43
+ --text-primary: #111827;
44
+ --text-secondary: #4b5563;
45
+ --text-tertiary: #6b7280;
46
+ --text-muted: #9ca3af;
47
+
48
+ --scrollbar-thumb: #d1d5db;
49
+ --scrollbar-thumb-hover: #9ca3af;
50
+
51
+ --code-bg: #F8F7F7;
52
+ --shimmer-color: rgba(0, 0, 0, 0.05);
53
+ }
54
+
55
+ /* Custom scrollbar */
56
+ ::-webkit-scrollbar {
57
+ width: 6px;
58
+ }
59
+
60
+ ::-webkit-scrollbar-track {
61
+ background: transparent;
62
+ }
63
+
64
+ ::-webkit-scrollbar-thumb {
65
+ background: var(--scrollbar-thumb);
66
+ border-radius: 3px;
67
+ }
68
+
69
+ ::-webkit-scrollbar-thumb:hover {
70
+ background: var(--scrollbar-thumb-hover);
71
+ }
72
+
73
+ /* Smooth transitions */
74
+ * {
75
+ scroll-behavior: smooth;
76
+ }
77
+
78
+ /* Input placeholder styling */
79
+ textarea::placeholder {
80
+ color: var(--text-tertiary);
81
+ }
82
+
83
+ /* Hide scrollbar utility */
84
+ .scrollbar-hide {
85
+ -ms-overflow-style: none;
86
+ scrollbar-width: none;
87
+ }
88
+ .scrollbar-hide::-webkit-scrollbar {
89
+ display: none;
90
+ }
91
+
92
+ /* Focus ring override */
93
+ *:focus {
94
+ outline: none;
95
+ }
96
+
97
+ /* Animation keyframes */
98
+ @keyframes fadeIn {
99
+ from { opacity: 0; transform: translateY(4px); }
100
+ to { opacity: 1; transform: translateY(0); }
101
+ }
102
+
103
+ @keyframes pulse {
104
+ 0%, 100% { opacity: 1; }
105
+ 50% { opacity: 0.5; }
106
+ }
107
+
108
+ @keyframes slideIn {
109
+ from {
110
+ opacity: 0;
111
+ transform: translateX(-8px);
112
+ }
113
+ to {
114
+ opacity: 1;
115
+ transform: translateX(0);
116
+ }
117
+ }
118
+
119
+ @keyframes shimmer {
120
+ 0% { background-position: -200% 0; }
121
+ 100% { background-position: 200% 0; }
122
+ }
123
+
124
+ .animate-fade-in {
125
+ animation: fadeIn 0.2s ease-out;
126
+ }
127
+
128
+ .animate-slide-in {
129
+ animation: slideIn 0.2s ease-out;
130
+ }
131
+
132
+ .animate-pulse-slow {
133
+ animation: pulse 2s ease-in-out infinite;
134
+ }
135
+
136
+ /* Workblock loading shimmer */
137
+ .workblock-shimmer {
138
+ background: linear-gradient(
139
+ 90deg,
140
+ transparent 0%,
141
+ var(--shimmer-color) 50%,
142
+ transparent 100%
143
+ );
144
+ background-size: 200% 100%;
145
+ animation: shimmer 1.5s infinite;
146
+ }
147
+
148
+ /* Theme transition and base styles */
149
+ html, body {
150
+ background-color: var(--bg-primary);
151
+ color: var(--text-primary);
152
+ transition: background-color 0.2s ease, color 0.2s ease;
153
+ }
154
+
155
+ /* Color scheme for light-dark() CSS function */
156
+ :root {
157
+ color-scheme: dark;
158
+ }
159
+ .light {
160
+ color-scheme: light;
161
+ }
162
+
163
+ /* Override Shiki's inline background color */
164
+ .shiki,
165
+ .shiki pre,
166
+ .shiki code {
167
+ background-color: var(--code-bg) !important;
168
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "jsx": "react-jsx",
14
+ "strict": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "types": ["vite/client"],
19
+ "paths": {
20
+ "@/*": ["./src/*"]
21
+ }
22
+ },
23
+ "include": ["src", "vite"]
24
+ }
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 150">
2
+ <path fill="#000" d="M44.06,0v44.08H0v105.92h105.93v-44.07h44.07V0H44.06ZM19.09,130.91c-16.47-16.47-5.29-54.45,24.96-85.18v60.2h60.23c-30.73,30.27-68.71,41.47-85.2,24.98ZM105.93,104.29v-60.21h-60.21C76.46,13.8,114.42,2.6,130.91,19.09c16.51,16.49,5.31,54.47-24.98,85.2Z"/>
3
+ </svg>
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="en" class="dark">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
+ <title>Chat</title>
8
+ <link rel="preconnect" href="https://fonts.googleapis.com">
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
11
+ <style>body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }</style>
12
+ </head>
13
+ <body class="bg-[#0a0a0b] text-zinc-100 antialiased">
14
+ <div id="root"></div>
15
+ <script type="module" src="/main.tsx"></script>
16
+ </body>
17
+ </html>
@@ -0,0 +1,25 @@
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import { AgentBuilderProvider } from '@standardagents/react'
4
+ import { ThemeProvider } from '../src/hooks/useTheme'
5
+ import { AuthProvider } from '../src/hooks/useAuth'
6
+ import App from '../src/App'
7
+ import '../src/index.css'
8
+
9
+ // Get agentbuilder URL from environment
10
+ const AGENTBUILDER_URL = import.meta.env.VITE_AGENTBUILDER_URL || ''
11
+
12
+ // Append /api to the endpoint for SDK routes
13
+ const SDK_ENDPOINT = AGENTBUILDER_URL ? `${AGENTBUILDER_URL}/api` : '/api'
14
+
15
+ ReactDOM.createRoot(document.getElementById('root')!).render(
16
+ <React.StrictMode>
17
+ <ThemeProvider>
18
+ <AuthProvider>
19
+ <AgentBuilderProvider config={{ endpoint: SDK_ENDPOINT }}>
20
+ <App />
21
+ </AgentBuilderProvider>
22
+ </AuthProvider>
23
+ </ThemeProvider>
24
+ </React.StrictMode>
25
+ )
@@ -0,0 +1,23 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import tailwindcss from '@tailwindcss/vite'
4
+ import path from 'path'
5
+
6
+ export default defineConfig({
7
+ root: __dirname,
8
+ plugins: [
9
+ react(),
10
+ tailwindcss(),
11
+ ],
12
+ resolve: {
13
+ alias: {
14
+ '@': path.resolve(__dirname, '../src'),
15
+ },
16
+ },
17
+ server: {
18
+ port: 5174,
19
+ },
20
+ build: {
21
+ outDir: '../dist/vite',
22
+ },
23
+ })
package/dist/index.js CHANGED
@@ -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
  \`\`\`
@@ -283,15 +285,12 @@ Prompts define system instructions, model selection, and available tools for LLM
283
285
  | \`toolDescription\` | \`string\` | Yes | Description shown when used as a tool |
284
286
  | \`prompt\` | \`string \\| StructuredPrompt\` | Yes | System instructions |
285
287
  | \`model\` | \`string\` | Yes | Model name to use (references \`agents/models/\`) |
286
- | \`tools\` | \`(string \\| ToolConfig)[]\` | No | Available tools for LLM |
287
- | \`handoffAgents\` | \`string[]\` | No | Agents this prompt can hand off to |
288
+ | \`tools\` | \`(string \\| ToolConfig)[]\` | No | Available tools (include ai_human agent names for handoffs) |
288
289
  | \`includeChat\` | \`boolean\` | No | Include full conversation history |
289
290
  | \`includePastTools\` | \`boolean\` | No | Include previous tool results |
290
291
  | \`parallelToolCalls\` | \`boolean\` | No | Allow multiple concurrent tool calls |
291
292
  | \`toolChoice\` | \`'auto' \\| 'none' \\| 'required'\` | No | Tool calling strategy |
292
293
  | \`requiredSchema\` | \`z.ZodObject\` | No | Input validation when called as tool |
293
- | \`beforeTool\` | \`string\` | No | Tool to run before LLM request |
294
- | \`afterTool\` | \`string\` | No | Tool to run after LLM response |
295
294
  | \`reasoning\` | \`ReasoningConfig\` | No | Extended thinking configuration |
296
295
 
297
296
  ## Basic Example
@@ -491,7 +490,7 @@ export default defineAgent({
491
490
  });
492
491
  \`\`\`
493
492
 
494
- Other prompts can then include it in their \`handoffAgents\` array.
493
+ Other prompts can then include the agent name in their \`tools\` array to enable handoffs.
495
494
 
496
495
  ## Stop Conditions (Priority Order)
497
496
 
@@ -566,28 +565,27 @@ export default defineTool(
566
565
  | \`result\` | \`string\` | Tool output (required for success) |
567
566
  | \`error\` | \`string\` | Error message (for error status) |
568
567
 
569
- ## FlowState Access
568
+ ## ThreadState Access
570
569
 
571
- The \`flow\` parameter provides access to:
570
+ The \`flow\` parameter (a \`ThreadState\` object) provides access to:
572
571
 
573
572
  \`\`\`typescript
574
573
  async (flow, args) => {
575
- // Thread information
576
- const threadId = flow.thread.id;
577
- const thread = flow.thread.instance;
578
-
579
- // Configuration
580
- const agentName = flow.agent.name;
581
- const modelName = flow.model.name;
574
+ // Thread identity (readonly)
575
+ const threadId = flow.threadId;
576
+ const agentId = flow.agentId;
577
+ const userId = flow.userId; // string | null
582
578
 
583
579
  // Message history
584
- const messages = flow.messages;
580
+ const { messages } = await flow.getMessages();
581
+ const { messages: recent } = await flow.getMessages({ limit: 10, order: 'desc' });
585
582
 
586
- // Environment bindings
587
- const env = flow.env;
583
+ // Resource loading
584
+ const model = await flow.loadModel('gpt-4o');
585
+ const prompt = await flow.loadPrompt('support-prompt');
588
586
 
589
- // Parent state (for sub-prompts)
590
- const root = flow.rootState;
587
+ // Inject messages
588
+ await flow.injectMessage({ role: 'system', content: 'Note: ...' });
591
589
  }
592
590
  \`\`\`
593
591
 
@@ -636,14 +634,14 @@ import { queueTool } from '@standardagents/builder';
636
634
 
637
635
  export default defineTool(
638
636
  'Create order and send confirmation',
639
- z.object({ items: z.array(z.string()) }),
637
+ z.object({ items: z.array(z.string()), email: z.string() }),
640
638
  async (flow, args) => {
641
639
  const order = await createOrder(args.items);
642
640
 
643
641
  // Queue email tool to run next
644
642
  queueTool(flow, 'send_confirmation_email', {
645
643
  orderId: order.id,
646
- email: flow.thread.metadata.userEmail,
644
+ email: args.email,
647
645
  });
648
646
 
649
647
  return { status: 'success', result: JSON.stringify(order) };
@@ -982,17 +980,19 @@ Full reference: https://docs.standardagentbuilder.com/core-concepts/api
982
980
  `;
983
981
 
984
982
  // src/commands/scaffold.ts
985
- var WRANGLER_TEMPLATE = (name) => `{
983
+ var WRANGLER_TEMPLATE = (name) => {
984
+ const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
985
+ return `{
986
986
  "$schema": "node_modules/wrangler/config-schema.json",
987
987
  "name": "${name}",
988
988
  "main": "worker/index.ts",
989
- "compatibility_date": "2025-01-01",
989
+ "compatibility_date": "${today}",
990
990
  "compatibility_flags": ["nodejs_compat"],
991
991
  "observability": {
992
992
  "enabled": true
993
993
  },
994
994
  "assets": {
995
- "directory": "dist",
995
+ "directory": "dist/client",
996
996
  "not_found_handling": "single-page-application",
997
997
  "binding": "ASSETS",
998
998
  "run_worker_first": ["/**"]
@@ -1021,6 +1021,7 @@ var WRANGLER_TEMPLATE = (name) => `{
1021
1021
  ]
1022
1022
  }
1023
1023
  `;
1024
+ };
1024
1025
  var THREAD_TS = `import { DurableThread } from 'virtual:@standardagents/builder'
1025
1026
 
1026
1027
  export default class Thread extends DurableThread {}
@@ -1085,14 +1086,6 @@ async function modifyViteConfig(configPath, force) {
1085
1086
  logger.info("Vite config already includes Standard Agents plugins");
1086
1087
  return true;
1087
1088
  }
1088
- if (!hasCloudflare || force) {
1089
- addVitePlugin(mod, {
1090
- from: "@cloudflare/vite-plugin",
1091
- imported: "cloudflare",
1092
- constructor: "cloudflare"
1093
- });
1094
- logger.success("Added cloudflare plugin to vite.config");
1095
- }
1096
1089
  if (!hasAgentBuilder || force) {
1097
1090
  addVitePlugin(mod, {
1098
1091
  from: "@standardagents/builder",
@@ -1102,6 +1095,14 @@ async function modifyViteConfig(configPath, force) {
1102
1095
  });
1103
1096
  logger.success("Added agentbuilder plugin to vite.config");
1104
1097
  }
1098
+ if (!hasCloudflare || force) {
1099
+ addVitePlugin(mod, {
1100
+ from: "@cloudflare/vite-plugin",
1101
+ imported: "cloudflare",
1102
+ constructor: "cloudflare"
1103
+ });
1104
+ logger.success("Added cloudflare plugin to vite.config");
1105
+ }
1105
1106
  await writeFile(mod, configPath);
1106
1107
  return true;
1107
1108
  } catch (error) {
@@ -1109,10 +1110,10 @@ async function modifyViteConfig(configPath, force) {
1109
1110
  logger.log("");
1110
1111
  logger.log("Please manually add the following to your vite.config.ts:");
1111
1112
  logger.log("");
1112
- logger.log(` import { cloudflare } from '@cloudflare/vite-plugin'`);
1113
1113
  logger.log(` import { agentbuilder } from '@standardagents/builder'`);
1114
+ logger.log(` import { cloudflare } from '@cloudflare/vite-plugin'`);
1114
1115
  logger.log("");
1115
- logger.log(` plugins: [cloudflare(), agentbuilder({ mountPoint: '/' })]`);
1116
+ logger.log(` plugins: [agentbuilder({ mountPoint: '/' }), cloudflare()]`);
1116
1117
  logger.log("");
1117
1118
  return false;
1118
1119
  }
@@ -1161,7 +1162,7 @@ function createOrUpdateWranglerConfig(cwd, projectName, force) {
1161
1162
  }
1162
1163
  if (!config.assets) {
1163
1164
  const edits = modify(result, ["assets"], {
1164
- directory: "dist",
1165
+ directory: "dist/client",
1165
1166
  not_found_handling: "single-page-application",
1166
1167
  binding: "ASSETS",
1167
1168
  run_worker_first: ["/**"]
@@ -1680,8 +1681,11 @@ export default defineConfig({
1680
1681
  installCmd,
1681
1682
  devFlag,
1682
1683
  "@cloudflare/vite-plugin",
1684
+ "wrangler"
1685
+ ], projectPath);
1686
+ await runCommand(pm, [
1687
+ installCmd,
1683
1688
  `@standardagents/builder${builderVersion}`,
1684
- "wrangler",
1685
1689
  "zod"
1686
1690
  ], projectPath);
1687
1691
  } catch (error) {
@@ -2182,7 +2186,9 @@ async function scaffoldVite(projectPath, chatSourceDir, projectName, serverUrl,
2182
2186
  copyDir(path3.join(chatSourceDir, "src"), path3.join(projectPath, "src"), []);
2183
2187
  logger.success("Copied src/");
2184
2188
  const viteDir = path3.join(chatSourceDir, "vite");
2185
- fs3.copyFileSync(path3.join(viteDir, "index.html"), path3.join(projectPath, "index.html"));
2189
+ let indexHtml = fs3.readFileSync(path3.join(viteDir, "index.html"), "utf-8");
2190
+ indexHtml = indexHtml.replace('src="/main.tsx"', 'src="/src/main.tsx"');
2191
+ fs3.writeFileSync(path3.join(projectPath, "index.html"), indexHtml, "utf-8");
2186
2192
  logger.success("Created index.html");
2187
2193
  fs3.copyFileSync(path3.join(viteDir, "main.tsx"), path3.join(projectPath, "src", "main.tsx"));
2188
2194
  logger.success("Created src/main.tsx");