llmz 0.0.12 → 0.0.14
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/CLAUDE.md +363 -0
- package/README.md +61 -34
- package/dist/abort-signal.d.ts +40 -0
- package/dist/chat.d.ts +325 -0
- package/dist/{chunk-PRVFVXT4.js → chunk-2Z5SFF6R.js} +302 -2
- package/dist/{chunk-HJKOSEH2.cjs → chunk-GOJY4GRL.cjs} +307 -7
- package/dist/chunk-KG7DT7WD.cjs +476 -0
- package/dist/chunk-OKTHMXRT.js +476 -0
- package/dist/chunk-WL7ZIMYD.cjs +231 -0
- package/dist/chunk-XAN7HQP5.js +231 -0
- package/dist/context.d.ts +212 -0
- package/dist/{exit-YORW76T3.js → exit-7HDRH27N.js} +1 -1
- package/dist/{exit-TRXEU4OU.cjs → exit-O2WZUEFS.cjs} +2 -2
- package/dist/exit.d.ts +333 -0
- package/dist/index.cjs +206 -9
- package/dist/index.d.ts +62 -0
- package/dist/index.js +204 -7
- package/dist/{llmz-ROOX7RYI.js → llmz-MCHRHRTD.js} +109 -35
- package/dist/{llmz-QLZBDG2Z.cjs → llmz-TR4CQK4F.cjs} +116 -42
- package/dist/llmz.d.ts +142 -5
- package/dist/objects.d.ts +314 -0
- package/dist/result.d.ts +430 -0
- package/dist/snapshots.d.ts +169 -0
- package/dist/{tool-N6ODRRGH.js → tool-4AJIJ3QB.js} +1 -1
- package/dist/{tool-QP4MVRWI.cjs → tool-NS7EGK7Z.cjs} +2 -2
- package/dist/tool.d.ts +441 -0
- package/docs/TODO.md +919 -0
- package/package.json +5 -5
- package/dist/chunk-C6WNNTEV.cjs +0 -212
- package/dist/chunk-GWFYZDUR.cjs +0 -105
- package/dist/chunk-JAGB2AOU.js +0 -212
- package/dist/chunk-JMSZKB4T.js +0 -105
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What is LLMz?
|
|
6
|
+
|
|
7
|
+
LLMz is a revolutionary TypeScript AI agent framework that fundamentally changes how AI agents work. Like other agent frameworks, LLMz calls LLM models in a loop to achieve desired outcomes with access to tools and memory. However, LLMz is **code-first** – meaning it generates and runs TypeScript code in a sandbox rather than using traditional JSON tool calling.
|
|
8
|
+
|
|
9
|
+
**Core Philosophy**: Stop chaining tools. Start generating real code.
|
|
10
|
+
|
|
11
|
+
### Why Code Generation Works Better
|
|
12
|
+
|
|
13
|
+
Traditional agent frameworks rely on JSON tool calling, which has significant limitations:
|
|
14
|
+
|
|
15
|
+
- Hard-to-parse JSON schemas for LLMs
|
|
16
|
+
- Incapable of complex logic, loops, and conditionals
|
|
17
|
+
- Multiple expensive roundtrips for each tool call
|
|
18
|
+
- Unreliable beyond simple scenarios
|
|
19
|
+
|
|
20
|
+
LLMz leverages the fact that models have been trained extensively on millions of TypeScript codebases, making them incredibly reliable at generating working code. This enables:
|
|
21
|
+
|
|
22
|
+
- Complex logic and multi-tool orchestration in **one call**
|
|
23
|
+
- Native LLM thinking via comments and code structure
|
|
24
|
+
- Complete type safety and predictable schemas
|
|
25
|
+
- Seamless scaling in production environments
|
|
26
|
+
|
|
27
|
+
## Core Concepts
|
|
28
|
+
|
|
29
|
+
### Execution Loop
|
|
30
|
+
|
|
31
|
+
LLMz exposes a single method (`execute`) that runs in a loop until one of these conditions:
|
|
32
|
+
|
|
33
|
+
1. **An Exit is returned** - Agent completes with structured result
|
|
34
|
+
2. **Agent waits for user input** (Chat Mode) - Returns control to user
|
|
35
|
+
3. **Maximum iterations reached** - Safety limit to prevent infinite loops
|
|
36
|
+
|
|
37
|
+
The loop automatically handles:
|
|
38
|
+
|
|
39
|
+
- Tool calling and result processing
|
|
40
|
+
- Thinking about outputs and context
|
|
41
|
+
- Error recovery and retry logic
|
|
42
|
+
- Variable state persistence across iterations
|
|
43
|
+
|
|
44
|
+
### Generated Code Structure
|
|
45
|
+
|
|
46
|
+
Every LLMz code block follows a predictable structure:
|
|
47
|
+
|
|
48
|
+
**Return Statement (Required)**:
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
// Chat mode - give turn back to user
|
|
52
|
+
return { action: 'listen' }
|
|
53
|
+
|
|
54
|
+
// Worker mode - complete with result
|
|
55
|
+
return { action: 'done', result: calculatedValue }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Tool Calls with Logic**:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
// Complex logic impossible with JSON tool calling
|
|
62
|
+
const price = await getTicketPrice({ from: 'quebec', to: 'new york' })
|
|
63
|
+
|
|
64
|
+
if (price > 500) {
|
|
65
|
+
throw new Error('Price too high')
|
|
66
|
+
} else {
|
|
67
|
+
const ticketId = await buyTicket({ from: 'quebec', to: 'new york' })
|
|
68
|
+
return { action: 'done', result: ticketId }
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Comments for Planning**:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
// Comments help LLM think step-by-step and plan ahead
|
|
76
|
+
// Check user's budget first before proceeding with purchase
|
|
77
|
+
const budget = await getUserBudget()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Execution Modes
|
|
81
|
+
|
|
82
|
+
**Chat Mode**: Interactive conversational agents
|
|
83
|
+
|
|
84
|
+
- Enabled when `chat` is provided to `execute()`
|
|
85
|
+
- Agents can `yield` React components to user
|
|
86
|
+
- Special `ListenExit` automatically available for user interaction
|
|
87
|
+
- Transcript management for conversation history
|
|
88
|
+
|
|
89
|
+
**Worker Mode**: Automated execution environments
|
|
90
|
+
|
|
91
|
+
- Enabled when `chat` is omitted from `execute()`
|
|
92
|
+
- Focus on computational tasks and data processing
|
|
93
|
+
- Uses `DefaultExit` if no custom exits provided
|
|
94
|
+
- Sandboxed execution with security isolation
|
|
95
|
+
|
|
96
|
+
### Chat Components (Chat Mode Only)
|
|
97
|
+
|
|
98
|
+
Agents can yield React components for rich user interaction:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
// Multi-line text support
|
|
102
|
+
yield <Text>
|
|
103
|
+
Hello, world!
|
|
104
|
+
This is a second line.
|
|
105
|
+
</Text>
|
|
106
|
+
|
|
107
|
+
// Composed/nested components
|
|
108
|
+
yield <Message>
|
|
109
|
+
<Text>What do you prefer?</Text>
|
|
110
|
+
<Button>Cats</Button>
|
|
111
|
+
<Button>Dogs</Button>
|
|
112
|
+
</Message>
|
|
113
|
+
|
|
114
|
+
return { action: 'listen' }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Components map to communication channels (Webchat, SMS, etc.) and can be completely custom.
|
|
118
|
+
|
|
119
|
+
### Tools and Objects
|
|
120
|
+
|
|
121
|
+
**Tools**: Type-safe functions with Zod/Zui schemas
|
|
122
|
+
|
|
123
|
+
- Input/output validation and TypeScript inference
|
|
124
|
+
- Synchronous and asynchronous support
|
|
125
|
+
- Retry logic and error handling
|
|
126
|
+
- Tool aliases for multiple names
|
|
127
|
+
|
|
128
|
+
**Objects**: Namespaced containers for related tools and variables
|
|
129
|
+
|
|
130
|
+
- Group related functionality together
|
|
131
|
+
- Support both readonly and writable variables
|
|
132
|
+
- Variable type validation with schemas
|
|
133
|
+
- Mutation tracking across iterations
|
|
134
|
+
|
|
135
|
+
### Advanced Features
|
|
136
|
+
|
|
137
|
+
**Snapshots**: Pausable/resumable execution
|
|
138
|
+
|
|
139
|
+
- Throw `SnapshotSignal` to halt and serialize execution state
|
|
140
|
+
- Resume later from exact same point
|
|
141
|
+
- Useful for long-running workflows and async operations
|
|
142
|
+
|
|
143
|
+
**Thinking**: Agent reflection and variable inspection
|
|
144
|
+
|
|
145
|
+
- Agent-initiated: `return { action: 'think' }`
|
|
146
|
+
- Tool-initiated: Throw `ThinkSignal` to force reflection
|
|
147
|
+
- Helps agents avoid rushed decisions and process complex information
|
|
148
|
+
|
|
149
|
+
**Hooks**: Custom logic at execution points
|
|
150
|
+
|
|
151
|
+
- `onTrace`: Non-blocking monitoring and logging
|
|
152
|
+
- `onExit`: Validate exits and implement guardrails
|
|
153
|
+
- `onBeforeExecution`: Code mutation and security checks
|
|
154
|
+
- `onIterationEnd`: State augmentation between iterations
|
|
155
|
+
|
|
156
|
+
## Project Overview
|
|
157
|
+
|
|
158
|
+
LLMz operates as an LLM-native TypeScript VM built on top of Zui (Botpress's internal schema library), battle-tested in production powering millions of AI agents worldwide.
|
|
159
|
+
|
|
160
|
+
## Architecture
|
|
161
|
+
|
|
162
|
+
LLMz operates as an LLM-native TypeScript VM built on top of Zui (Botpress's internal schema library). The framework includes two primary execution modes:
|
|
163
|
+
|
|
164
|
+
LLMz operates in two primary modes:
|
|
165
|
+
|
|
166
|
+
- **Chat Mode**: Interactive conversational agents with tools and user interaction. Chat mode is enabled when `chat` is provided to `execute()`
|
|
167
|
+
- **Worker Mode**: Automated execution environments with sandboxing and security. Worker mode is enabled when `chat` is omitted from `execute()`.
|
|
168
|
+
|
|
169
|
+
### Core Components
|
|
170
|
+
|
|
171
|
+
**Main Framework** (`src/`):
|
|
172
|
+
|
|
173
|
+
- `llmz.ts`: Core execution engine and context management
|
|
174
|
+
- `vm.ts`: Virtual machine with isolated-vm and Node.js execution environments
|
|
175
|
+
- `compiler/`: TypeScript compilation pipeline with AST transformations
|
|
176
|
+
- `chat.ts`: Chat interface and message handling
|
|
177
|
+
- `tool.ts`: Tool definition and execution system
|
|
178
|
+
- `component.ts`: UI component system for interactive elements
|
|
179
|
+
|
|
180
|
+
**Execution Pipeline**:
|
|
181
|
+
|
|
182
|
+
- `prompts/`: Dual-mode prompt system (chat-mode/, worker-mode/)
|
|
183
|
+
- `transcript.ts`: Conversation history and context management
|
|
184
|
+
- `context.ts`: Execution context and iteration tracking
|
|
185
|
+
- `result.ts`: Execution result types and error handling
|
|
186
|
+
|
|
187
|
+
**Safety & Security**:
|
|
188
|
+
|
|
189
|
+
- `errors.ts`: Comprehensive error handling and signals
|
|
190
|
+
- `stack-traces.ts`: Stack trace sanitization
|
|
191
|
+
- `snapshots.ts`: Execution state snapshots
|
|
192
|
+
- `truncator.ts`: Content truncation for token limits
|
|
193
|
+
|
|
194
|
+
## Development Commands
|
|
195
|
+
|
|
196
|
+
### Building and Testing
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Build the package (TypeScript compilation + bundling)
|
|
200
|
+
pnpm build
|
|
201
|
+
|
|
202
|
+
# Type checking without emitting files
|
|
203
|
+
pnpm check:type
|
|
204
|
+
|
|
205
|
+
# Development mode with hot reloading
|
|
206
|
+
pnpm watch
|
|
207
|
+
|
|
208
|
+
# Run test suite
|
|
209
|
+
pnpm test
|
|
210
|
+
|
|
211
|
+
# Run tests in watch mode
|
|
212
|
+
pnpm test:watch
|
|
213
|
+
|
|
214
|
+
# Update test snapshots
|
|
215
|
+
pnpm test:update
|
|
216
|
+
|
|
217
|
+
# Generate prompt files (.md.ts) files after changing them
|
|
218
|
+
pnpm generate
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Testing Configuration
|
|
222
|
+
|
|
223
|
+
- Tests use Vitest with custom configuration for LLM testing
|
|
224
|
+
- Retry mechanism (2 retries) due to LLM non-determinism
|
|
225
|
+
- Extended timeout (60s) for LLM response times
|
|
226
|
+
- Custom snapshot serializers for stack traces
|
|
227
|
+
- Markdown and text file loaders for prompt testing
|
|
228
|
+
|
|
229
|
+
## Key Dependencies
|
|
230
|
+
|
|
231
|
+
**Core Runtime**:
|
|
232
|
+
|
|
233
|
+
- `isolated-vm`: Secure JavaScript execution environment
|
|
234
|
+
- `@babel/*`: TypeScript/JSX compilation pipeline
|
|
235
|
+
- `@botpress/client`: Botpress API integration
|
|
236
|
+
- `@bpinternal/zui`: Schema validation and TypeScript generation
|
|
237
|
+
|
|
238
|
+
**Development**:
|
|
239
|
+
|
|
240
|
+
- `tsup`: Fast TypeScript bundler (ESM + CJS output)
|
|
241
|
+
- `vitest`: Modern test framework with TypeScript support
|
|
242
|
+
- `prettier`: Code formatting
|
|
243
|
+
- `handlebars`: Template processing for prompts
|
|
244
|
+
|
|
245
|
+
## Code Architecture Patterns
|
|
246
|
+
|
|
247
|
+
### Execution Flow
|
|
248
|
+
|
|
249
|
+
1. **Prompt Generation**: Dual-mode prompts based on execution type
|
|
250
|
+
2. **Code Generation**: LLM generates TypeScript code with embedded tools
|
|
251
|
+
3. **Compilation**: Babel-based AST transformation with custom plugins
|
|
252
|
+
4. **Execution**: Isolated VM or Node.js execution with monitoring
|
|
253
|
+
5. **Result Processing**: Type-safe result handling and error recovery
|
|
254
|
+
|
|
255
|
+
### Key Plugins (`src/compiler/plugins/`):
|
|
256
|
+
|
|
257
|
+
- `track-tool-calls.ts`: Instrument tool calls for monitoring
|
|
258
|
+
- `variable-extraction.ts`: Extract and track variable usage
|
|
259
|
+
- `line-tracking.ts`: Source map generation and error tracking
|
|
260
|
+
- `jsx-preserve-newlines.ts`: Maintain formatting in JSX components
|
|
261
|
+
|
|
262
|
+
### VM Execution Strategy
|
|
263
|
+
|
|
264
|
+
- **Production**: Uses `isolated-vm` for security isolation
|
|
265
|
+
- **CI/Development**: Falls back to Node.js VM for compatibility
|
|
266
|
+
- **Browser**: Uses standard JavaScript execution
|
|
267
|
+
|
|
268
|
+
## Tool System
|
|
269
|
+
|
|
270
|
+
Tools are defined using Zui schemas and can be:
|
|
271
|
+
|
|
272
|
+
- **Synchronous/Asynchronous**: Both execution types supported
|
|
273
|
+
- **Type-Safe**: Full TypeScript inference and validation
|
|
274
|
+
- **Retryable**: Built-in retry logic with exponential backoff
|
|
275
|
+
- **Traceable**: Comprehensive execution monitoring
|
|
276
|
+
|
|
277
|
+
Example tool definition:
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
const tool = new Tool({
|
|
281
|
+
name: 'exampleTool',
|
|
282
|
+
description: 'Tool description',
|
|
283
|
+
input: z.object({ param: z.string() }),
|
|
284
|
+
output: z.object({ result: z.string() }),
|
|
285
|
+
handler: async ({ param }) => ({ result: `Processed: ${param}` }),
|
|
286
|
+
})
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Component System
|
|
290
|
+
|
|
291
|
+
LLMz includes a React-like component system for building interactive UIs:
|
|
292
|
+
|
|
293
|
+
- **JSX Support**: Full JSX compilation and rendering
|
|
294
|
+
- **Type Safety**: Components are fully typed with Zui schemas
|
|
295
|
+
- **Rendering**: Server-side rendering to various output formats
|
|
296
|
+
|
|
297
|
+
## Security Considerations
|
|
298
|
+
|
|
299
|
+
- **Isolated Execution**: VM isolation prevents access to host system
|
|
300
|
+
- **Stack Trace Cleaning**: Removes internal framework details from errors
|
|
301
|
+
- **Tool Access Control**: Granular permissions for tool execution
|
|
302
|
+
- **Content Truncation**: Automatic handling of token limits
|
|
303
|
+
- **Error Recovery**: Graceful handling of execution failures
|
|
304
|
+
|
|
305
|
+
## File Structure Conventions
|
|
306
|
+
|
|
307
|
+
- Tests co-located with source files (`.test.ts` suffix)
|
|
308
|
+
- Markdown prompts compiled to TypeScript modules
|
|
309
|
+
- Source maps preserved for debugging
|
|
310
|
+
- TypeScript declaration files generated for exports
|
|
311
|
+
|
|
312
|
+
## Environment Variables
|
|
313
|
+
|
|
314
|
+
- `VM_DRIVER`: Choose VM execution environment ('isolated-vm' | 'node')
|
|
315
|
+
- `CI`: Automatically detected, affects VM driver selection
|
|
316
|
+
|
|
317
|
+
## Performance Considerations
|
|
318
|
+
|
|
319
|
+
- Code splitting with dynamic imports for faster startup
|
|
320
|
+
- LRU caching for compiled code and results
|
|
321
|
+
- Lazy loading of heavy dependencies
|
|
322
|
+
- Bundle size optimization with tsup configuration
|
|
323
|
+
|
|
324
|
+
## Exit System
|
|
325
|
+
|
|
326
|
+
LLMz uses a sophisticated exit system for controlling agent termination:
|
|
327
|
+
|
|
328
|
+
- **Built-in Exits**: `ThinkExit`, `ListenExit`, `DefaultExit` for common patterns
|
|
329
|
+
- **Custom Exits**: Domain-specific exits with typed schemas using Zod/Zui
|
|
330
|
+
- **Type Safety**: `result.is(exit)` for compile-time type checking
|
|
331
|
+
- **Agent Usage**: Agents call `return { action: 'exit_name', ...data }` to exit
|
|
332
|
+
|
|
333
|
+
## Prompt System Architecture
|
|
334
|
+
|
|
335
|
+
The dual-mode prompt system (`src/prompts/`) generates different prompts based on execution mode:
|
|
336
|
+
|
|
337
|
+
- **Chat Mode**: Uses prompts from `chat-mode/` for interactive conversations
|
|
338
|
+
- **Worker Mode**: Uses prompts from `worker-mode/` for automated execution
|
|
339
|
+
- **Markdown Templates**: Prompts are written in Markdown and compiled to TypeScript
|
|
340
|
+
- **Dynamic Content**: Tool definitions, schemas, and context injected at runtime
|
|
341
|
+
|
|
342
|
+
## Compiler Pipeline
|
|
343
|
+
|
|
344
|
+
The Babel-based compilation system transforms generated code:
|
|
345
|
+
|
|
346
|
+
1. **AST Parsing**: TypeScript/JSX code parsed into Abstract Syntax Tree
|
|
347
|
+
2. **Plugin Transformation**: Custom plugins modify the AST for execution
|
|
348
|
+
3. **Code Generation**: Modified AST compiled back to executable JavaScript
|
|
349
|
+
4. **Source Maps**: Generated for debugging and error tracking
|
|
350
|
+
|
|
351
|
+
Key transformations:
|
|
352
|
+
|
|
353
|
+
- Tool call instrumentation for monitoring
|
|
354
|
+
- Variable extraction and tracking
|
|
355
|
+
- JSX component handling
|
|
356
|
+
- Line number preservation for stack traces
|
|
357
|
+
|
|
358
|
+
# important-instruction-reminders
|
|
359
|
+
|
|
360
|
+
Do what has been asked; nothing more, nothing less.
|
|
361
|
+
NEVER create files unless they're absolutely necessary for achieving your goal.
|
|
362
|
+
ALWAYS prefer editing an existing file to creating a new one.
|
|
363
|
+
NEVER proactively create documentation files (\*.md) or README files. Only create documentation files if explicitly requested by the User.
|
package/README.md
CHANGED
|
@@ -1,66 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
# 🚀 LLMz: Next-Gen TypeScript AI Agent Framework
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Build AI agents that think, code, and execute like humans—powered by TypeScript and battle-tested at massive scale.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
# The core library
|
|
7
|
-
npm install llmz
|
|
5
|
+
---
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
LLMz is the revolutionary framework behind [Botpress](https://botpress.com), empowering millions of AI agents across thousands of use cases worldwide. Unlike traditional tool-calling frameworks, LLMz leverages the massive body of TypeScript knowledge within LLMs, enabling agents to handle complex logic, loops, conditionals, and multi-tool orchestration seamlessly.
|
|
8
|
+
|
|
9
|
+
**Stop chaining tools. Start generating real code.**
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📦 Quick Start
|
|
14
|
+
|
|
15
|
+
Install and start building agents in seconds:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @botpress/client llmz
|
|
11
19
|
```
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
### ✨ Example
|
|
14
22
|
|
|
15
|
-
```
|
|
16
|
-
import { execute } from 'llmz'
|
|
23
|
+
```typescript
|
|
17
24
|
import { Client } from '@botpress/client'
|
|
25
|
+
import { execute } from 'llmz'
|
|
18
26
|
|
|
19
|
-
const client = new Client({
|
|
20
|
-
botId: process.env.BOTPRESS_BOT_ID,
|
|
21
|
-
token: process.env.BOTPRESS_TOKEN,
|
|
22
|
-
})
|
|
27
|
+
const client = new Client({ botId: '...', token: '...' })
|
|
23
28
|
|
|
24
29
|
const result = await execute({
|
|
30
|
+
instructions: 'What is the sum of integers between 14 and 1078 divisible by 3, 9, or 5?',
|
|
25
31
|
client,
|
|
26
|
-
instructions: 'Return the value of 2 + 4.',
|
|
27
32
|
})
|
|
28
33
|
|
|
29
|
-
console.log(result.output) //
|
|
34
|
+
console.log(result.output) // 271575
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
**Instruction:**
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
```typescript
|
|
40
|
+
'What is the sum of integers between 14 and 1078 divisible by 3, 9, or 5?'
|
|
41
|
+
```
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
**LLMz generates and safely executes real TypeScript:**
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
```typescript
|
|
46
|
+
// Calculating the sum of all integers between 14 and 1078 divisible by 3, 9 or 5
|
|
47
|
+
let sum = 0
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
// Loop through numbers between 14 and 1078 (inclusive)
|
|
50
|
+
for (let i = 14; i <= 1078; i++) {
|
|
51
|
+
if (i % 3 === 0 || i % 9 === 0 || i % 5 === 0) {
|
|
52
|
+
sum += i // Add to sum if divisible by 3, 9, or 5
|
|
53
|
+
}
|
|
54
|
+
}
|
|
41
55
|
|
|
42
|
-
|
|
56
|
+
// Return the final result
|
|
57
|
+
return { action: 'done', value: { success: true, result: sum } }
|
|
58
|
+
```
|
|
43
59
|
|
|
44
|
-
|
|
60
|
+
**Result:**
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
```json
|
|
63
|
+
{ "success": true, "result": 271575 }
|
|
64
|
+
```
|
|
47
65
|
|
|
48
|
-
|
|
66
|
+
---
|
|
49
67
|
|
|
50
|
-
|
|
68
|
+
## ⚡ Why LLMz Beats JSON Tool Calling
|
|
51
69
|
|
|
52
|
-
###
|
|
70
|
+
### Traditional JSON Tool Calling ❌
|
|
53
71
|
|
|
54
|
-
|
|
72
|
+
- Hard-to-parse JSON schemas for LLMs
|
|
73
|
+
- Incapable of complex logic, loops, and conditionals
|
|
74
|
+
- Multiple expensive roundtrips for each tool call
|
|
75
|
+
- Unreliable beyond simple scenarios
|
|
55
76
|
|
|
56
|
-
|
|
77
|
+
### LLMz TypeScript Generation ✅
|
|
57
78
|
|
|
58
|
-
|
|
79
|
+
- **Billions** of lines of TypeScript training data
|
|
80
|
+
- Native LLM thinking via comments and code structure
|
|
81
|
+
- Complex logic and multi-tool orchestration in **one call**
|
|
82
|
+
- Complete type safety and predictable schemas
|
|
83
|
+
- Scales effortlessly in production
|
|
59
84
|
|
|
60
|
-
|
|
85
|
+
---
|
|
61
86
|
|
|
62
|
-
##
|
|
87
|
+
## 🌟 Battle-Tested at Massive Scale
|
|
63
88
|
|
|
64
|
-
|
|
89
|
+
LLMz isn't experimental. It's been driving production workloads globally:
|
|
65
90
|
|
|
66
|
-
|
|
91
|
+
- **1+ year** in production
|
|
92
|
+
- **Millions** of active users
|
|
93
|
+
- **Hundreds of thousands** of deployed agents
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new AbortController that aborts when any of the provided signals abort.
|
|
3
|
+
* This is useful for combining multiple abort conditions (e.g., user cancellation, timeout, parent operation abort).
|
|
4
|
+
*
|
|
5
|
+
* @param signals - Array of AbortSignals to listen to. Undefined/null signals are ignored.
|
|
6
|
+
* @returns A new AbortController that will abort if any input signal aborts
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const userController = new AbortController()
|
|
11
|
+
* const timeoutController = new AbortController()
|
|
12
|
+
*
|
|
13
|
+
* // Create a joined controller that aborts if either signal aborts
|
|
14
|
+
* const joinedController = createJoinedAbortController([
|
|
15
|
+
* userController.signal,
|
|
16
|
+
* timeoutController.signal
|
|
17
|
+
* ])
|
|
18
|
+
*
|
|
19
|
+
* // Use the joined signal in operations
|
|
20
|
+
* await fetch('/api/data', { signal: joinedController.signal })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createJoinedAbortController(signals: (AbortSignal | undefined | null)[]): AbortController;
|
|
24
|
+
/**
|
|
25
|
+
* Convenience function that creates a joined abort signal directly.
|
|
26
|
+
*
|
|
27
|
+
* @param signals - Array of AbortSignals to combine
|
|
28
|
+
* @returns The signal from the joined AbortController
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const joinedSignal = createJoinedAbortSignal([
|
|
33
|
+
* userController.signal,
|
|
34
|
+
* timeoutController.signal
|
|
35
|
+
* ])
|
|
36
|
+
*
|
|
37
|
+
* await someOperation({ signal: joinedSignal })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createJoinedAbortSignal(signals: (AbortSignal | undefined | null)[]): AbortSignal;
|