future-lang 0.3.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/ARCHITECTURE.md +424 -0
- package/MIGRATION.md +365 -0
- package/README.md +370 -0
- package/ROADMAP.md +263 -0
- package/examples/adult.future +8 -0
- package/examples/api.future +11 -0
- package/examples/assistant.future +8 -0
- package/examples/browser-demo.html +164 -0
- package/examples/greet.future +7 -0
- package/examples/hello.future +1 -0
- package/examples/math.future +8 -0
- package/examples/mini-app.html +301 -0
- package/examples/smarthome.future +10 -0
- package/future-browser.js +102 -0
- package/future-playground.html +650 -0
- package/package.json +27 -0
- package/runtime/ai.js +92 -0
- package/runtime/browser.js +458 -0
- package/runtime/device.js +36 -0
- package/runtime/home.js +19 -0
- package/runtime/http.js +32 -0
- package/runtime/index.js +403 -0
- package/runtime/lsp-metadata.js +104 -0
- package/runtime/math.js +16 -0
- package/runtime/memory.js +61 -0
- package/runtime/mqtt.js +49 -0
- package/runtime/providers/anthropic.js +59 -0
- package/runtime/providers/index.js +93 -0
- package/runtime/providers/openai-compat.js +85 -0
- package/runtime/providers/util.js +70 -0
- package/runtime/rag/chunker.js +65 -0
- package/runtime/rag/pipeline.js +86 -0
- package/runtime/rag/vector-store.js +119 -0
- package/runtime/rag.js +94 -0
- package/runtime/schedule.js +77 -0
- package/runtime/system.js +101 -0
- package/runtime/tts.js +38 -0
- package/runtime/vision.js +85 -0
- package/server.js +42 -0
- package/src/ast.js +202 -0
- package/src/cli.js +391 -0
- package/src/errors.js +21 -0
- package/src/formatter.js +48 -0
- package/src/generator.js +457 -0
- package/src/index.js +48 -0
- package/src/lexer.js +248 -0
- package/src/parser.js +469 -0
package/README.md
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# Future
|
|
2
|
+
|
|
3
|
+
**An AI-first, IoT-first programming language that transpiles to JavaScript.**
|
|
4
|
+
|
|
5
|
+
Future reads like plain English, runs on Node.js, and gives every program built-in access to AI, HTTP, MQTT, memory, scheduling, and more β without `async`/`await` boilerplate. It also runs fully in the browser.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install future-lang
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```future
|
|
16
|
+
# hello.future
|
|
17
|
+
name = "World"
|
|
18
|
+
print "Hello, {name}!"
|
|
19
|
+
|
|
20
|
+
scores = [85, 92, 78]
|
|
21
|
+
print "Count: {len(scores)}"
|
|
22
|
+
print "Best: {math.max(85, 92, 78)}"
|
|
23
|
+
|
|
24
|
+
answer = ai.ask("What is the capital of Portugal? One word.")
|
|
25
|
+
print "AI says: {answer}"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx future run hello.future
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Language features
|
|
35
|
+
|
|
36
|
+
### Variables and types
|
|
37
|
+
|
|
38
|
+
```future
|
|
39
|
+
name = "Alice"
|
|
40
|
+
age = 30
|
|
41
|
+
active = true
|
|
42
|
+
data = null # also: none
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### String interpolation
|
|
46
|
+
|
|
47
|
+
```future
|
|
48
|
+
print "Hello, {name}! You are {age} years old."
|
|
49
|
+
print "Pi is approximately {math.pi}"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Any `{identifier}` or `{identifier.prop}` inside a string becomes a JS template literal. Escape a literal brace with `\{`.
|
|
53
|
+
|
|
54
|
+
### Arithmetic and logic
|
|
55
|
+
|
|
56
|
+
```future
|
|
57
|
+
sum = 10 + 3 * 2
|
|
58
|
+
same = sum == 16
|
|
59
|
+
both = true and false
|
|
60
|
+
any = true or false
|
|
61
|
+
neg = not true
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Conditionals
|
|
65
|
+
|
|
66
|
+
```future
|
|
67
|
+
if age >= 18
|
|
68
|
+
print "Adult"
|
|
69
|
+
else
|
|
70
|
+
print "Minor"
|
|
71
|
+
end
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Lists and objects
|
|
75
|
+
|
|
76
|
+
```future
|
|
77
|
+
fruits = ["apple", "banana", "cherry"]
|
|
78
|
+
user = { name: "JoΓ£o" age: 30 city: "Lisbon" }
|
|
79
|
+
|
|
80
|
+
print user.name
|
|
81
|
+
print fruits.length
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Iteration
|
|
85
|
+
|
|
86
|
+
```future
|
|
87
|
+
for fruit in fruits
|
|
88
|
+
print "I like {fruit}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
count = 0
|
|
92
|
+
while count < 5
|
|
93
|
+
count = count + 1
|
|
94
|
+
end
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Functions
|
|
98
|
+
|
|
99
|
+
```future
|
|
100
|
+
function greet(name)
|
|
101
|
+
return "Hello, {name}!"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
msg = greet("Alice")
|
|
105
|
+
print msg
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Error handling
|
|
109
|
+
|
|
110
|
+
```future
|
|
111
|
+
try
|
|
112
|
+
data = http.get("https://api.example.com/data")
|
|
113
|
+
print data.title
|
|
114
|
+
catch err
|
|
115
|
+
print "Request failed: {err}"
|
|
116
|
+
end
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Built-in functions
|
|
122
|
+
|
|
123
|
+
### `len(x)` β length of any value
|
|
124
|
+
|
|
125
|
+
```future
|
|
126
|
+
items = [1, 2, 3, 4, 5]
|
|
127
|
+
text = "hello"
|
|
128
|
+
obj = { a: 1 b: 2 }
|
|
129
|
+
|
|
130
|
+
print len(items) # 5
|
|
131
|
+
print len(text) # 5
|
|
132
|
+
print len(obj) # 2 (number of keys)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### `math` β numeric operations
|
|
136
|
+
|
|
137
|
+
```future
|
|
138
|
+
print math.round(3.7) # 4
|
|
139
|
+
print math.floor(3.9) # 3
|
|
140
|
+
print math.ceil(3.1) # 4
|
|
141
|
+
print math.abs(-5) # 5
|
|
142
|
+
print math.sqrt(16) # 4
|
|
143
|
+
print math.pow(2, 10) # 1024
|
|
144
|
+
print math.max(1, 5, 3) # 5
|
|
145
|
+
print math.min(1, 5, 3) # 1
|
|
146
|
+
print math.random() # random float 0β1
|
|
147
|
+
print math.log(math.e) # 1
|
|
148
|
+
print math.pi # 3.141592...
|
|
149
|
+
print math.e # 2.718281...
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### `input(prompt)` β read user input
|
|
153
|
+
|
|
154
|
+
```future
|
|
155
|
+
name = input("What is your name? ")
|
|
156
|
+
print "Hello, {name}!"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
In the browser this uses `window.prompt()`. In a Node.js CLI program it reads from stdin.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Capabilities & the runtime
|
|
164
|
+
|
|
165
|
+
Future programs talk to the outside world through **namespace calls**. The compiler detects them and automatically switches the program to async mode β you never write `async` or `await`.
|
|
166
|
+
|
|
167
|
+
```future
|
|
168
|
+
# HTTP
|
|
169
|
+
todo = http.get("https://jsonplaceholder.typicode.com/todos/1")
|
|
170
|
+
print "Title: {todo.title}"
|
|
171
|
+
|
|
172
|
+
# AI
|
|
173
|
+
answer = ai.ask("Explain MQTT in one sentence")
|
|
174
|
+
tts.speak(answer)
|
|
175
|
+
|
|
176
|
+
# Home automation
|
|
177
|
+
home.turnOn("livingroom_light")
|
|
178
|
+
mqtt.publish("home/livingroom/light", "on")
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Available namespaces
|
|
182
|
+
|
|
183
|
+
| Namespace | Functions | Notes |
|
|
184
|
+
|------------|-----------|-------|
|
|
185
|
+
| `http` | `get(url)`, `post(url, body)` | Parses JSON automatically |
|
|
186
|
+
| `ai` | `ask(prompt)`, `chat(messages)`, `embed(text)`, `stream(prompt, cb)`, `configure(provider, key)` | Pluggable providers |
|
|
187
|
+
| `tts` | `speak(text)` | System engine (`say` / SAPI / `espeak-ng`) |
|
|
188
|
+
| `mqtt` | `publish(topic, msg)`, `subscribe(topic, handler)` | Real broker or in-process loopback |
|
|
189
|
+
| `memory` | `set(key, v)`, `get(key)`, `delete(key)`, `search(q)`, `forget(pattern?)` | In-process key-value store |
|
|
190
|
+
| `schedule` | `every(interval, cb)`, `once(delay, cb)`, `cron(expr, cb)` | "30m", "5s", or milliseconds |
|
|
191
|
+
| `system` | `exec(cmd)`, `open(target)`, `notify(msg)`, `read(path)`, `write(path, content)` | OS utilities |
|
|
192
|
+
| `rag` | `index(docs)`, `query(question)`, `create(name)`, `indexFile(path)`, `indexUrl(url)` | Vector search + LLM answer |
|
|
193
|
+
| `vision` | `describe(img)`, `detect(img)`, `ocr(img)`, `classify(img)`, `compare(a, b)` | Needs AI provider |
|
|
194
|
+
| `home` | `turnOn(device)`, `turnOff(device)`, `set(device, value)` | Home automation via MQTT |
|
|
195
|
+
| `math` | `round`, `floor`, `ceil`, `abs`, `sqrt`, `pow`, `log`, `random`, `min`, `max`, `pi`, `e` | Full Math wrapper |
|
|
196
|
+
| `device` | `register(config)`, `get(name)`, `list()` | IoT device registry |
|
|
197
|
+
|
|
198
|
+
### Configuration (environment variables)
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
FUTURE_AI_PROVIDER=anthropic # anthropic | openai | gemini | ollama | openrouter | groq
|
|
202
|
+
FUTURE_AI_API_KEY=sk-...
|
|
203
|
+
FUTURE_AI_MODEL=claude-sonnet-4-6
|
|
204
|
+
ANTHROPIC_API_KEY=sk-ant-... # legacy shortcut
|
|
205
|
+
MQTT_URL=mqtt://localhost:1883
|
|
206
|
+
FUTURE_VECTOR_DB=memory # memory | file | qdrant
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## AI configuration
|
|
212
|
+
|
|
213
|
+
```future
|
|
214
|
+
# From code
|
|
215
|
+
ai.configure("openai", "sk-...")
|
|
216
|
+
ai.configure("ollama") # local, no key needed
|
|
217
|
+
|
|
218
|
+
answer = ai.ask("What is 2 + 2?")
|
|
219
|
+
print answer
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Agents
|
|
225
|
+
|
|
226
|
+
Agents are named async tasks with an implicit `goal` parameter. `use` declarations are documentation β they don't generate code.
|
|
227
|
+
|
|
228
|
+
```future
|
|
229
|
+
agent support
|
|
230
|
+
use rag
|
|
231
|
+
use memory
|
|
232
|
+
|
|
233
|
+
docs = rag.query(goal)
|
|
234
|
+
memory.set("last_query", goal)
|
|
235
|
+
return docs
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
answer = support("How do I reset the device?")
|
|
239
|
+
print answer
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Compiles to `async function support(goal) { ... }`.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Streaming
|
|
247
|
+
|
|
248
|
+
```future
|
|
249
|
+
stream ai.ask("Tell me a short story")
|
|
250
|
+
print chunk
|
|
251
|
+
end
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Compiles to `await __rt.ai.stream(prompt, async (chunk) => { ... })`.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Event-driven programming
|
|
259
|
+
|
|
260
|
+
```future
|
|
261
|
+
on mqtt "house/temp"
|
|
262
|
+
print "Temperature: {message}"
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
every "30m"
|
|
266
|
+
data = http.get("https://api.example.com/stats")
|
|
267
|
+
print data.count
|
|
268
|
+
end
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## RAG (Retrieval-Augmented Generation)
|
|
274
|
+
|
|
275
|
+
```future
|
|
276
|
+
# Index documents
|
|
277
|
+
rag.index(["Future is a language.", "It compiles to JavaScript."])
|
|
278
|
+
rag.indexFile("manual.txt")
|
|
279
|
+
rag.indexUrl("https://docs.example.com")
|
|
280
|
+
|
|
281
|
+
# Query
|
|
282
|
+
answer = rag.query("What does Future compile to?")
|
|
283
|
+
print answer
|
|
284
|
+
|
|
285
|
+
# Named knowledge bases
|
|
286
|
+
kb = rag.create("products")
|
|
287
|
+
kb.index(["Product A costs $10."])
|
|
288
|
+
reply = kb.query("How much is Product A?")
|
|
289
|
+
print reply
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Browser runtime
|
|
295
|
+
|
|
296
|
+
Future also runs in the browser β no Node.js required.
|
|
297
|
+
|
|
298
|
+
```html
|
|
299
|
+
<script type="module" src="future-browser.js"></script>
|
|
300
|
+
|
|
301
|
+
<!-- Option A: proxy mode (API key stays on your server) -->
|
|
302
|
+
<script type="module">
|
|
303
|
+
import Future from './future-browser.js'
|
|
304
|
+
Future.configure({ proxy: '/api/ai' })
|
|
305
|
+
Future.runtime.print = (...args) => {
|
|
306
|
+
document.getElementById('output').textContent += args.join(' ') + '\n'
|
|
307
|
+
}
|
|
308
|
+
</script>
|
|
309
|
+
|
|
310
|
+
<!-- Option B: direct key (dev/demos only β key is visible in source) -->
|
|
311
|
+
<script type="module">
|
|
312
|
+
import Future from './future-browser.js'
|
|
313
|
+
Future.configure({ provider: 'openai', apiKey: 'sk-...' })
|
|
314
|
+
</script>
|
|
315
|
+
|
|
316
|
+
<script type="future">
|
|
317
|
+
names = ["Alice", "Bob", "Carlos"]
|
|
318
|
+
for name in names
|
|
319
|
+
print "Hello, {name}!"
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
answer = ai.ask("One fun fact about Lisbon.")
|
|
323
|
+
print answer
|
|
324
|
+
</script>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Open `future-playground.html` in any browser for a live editor with 11 built-in examples.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## CLI
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
future run program.future # compile + run
|
|
335
|
+
future compile program.future # print generated JavaScript
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## How it works
|
|
341
|
+
|
|
342
|
+
The compiler is a three-phase pipeline:
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
Source (.future) β Lexer β Parser β Generator β JavaScript
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**SIMPLE mode** β programs with no capability calls compile to plain, synchronous JS with no imports.
|
|
349
|
+
|
|
350
|
+
**ASYNC mode** β any capability call (`http.get`, `ai.ask`, `math.round`, `input`, β¦) switches the program to async mode. The generator imports `future-lang/runtime` as `__rt` and wraps every function in `async`/`await`. The user writes none of this.
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Package exports
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
{
|
|
358
|
+
".": "./src/index.js",
|
|
359
|
+
"./runtime": "./runtime/index.js",
|
|
360
|
+
"./runtime/lsp-metadata": "./runtime/lsp-metadata.js"
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Documentation
|
|
367
|
+
|
|
368
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md) β compiler pipeline, folder structure, AST node types
|
|
369
|
+
- [ROADMAP.md](ROADMAP.md) β feature status and priorities
|
|
370
|
+
- [MIGRATION.md](MIGRATION.md) β changelog, what changed between versions
|
package/ROADMAP.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# Future β Roadmap
|
|
2
|
+
|
|
3
|
+
**Version:** 0.3.0 Β· **Last updated:** 2026-06-13
|
|
4
|
+
|
|
5
|
+
Status legend: β
Done Β· π In progress Β· π Planned Β· π‘ Idea
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## General-Purpose Programming
|
|
10
|
+
|
|
11
|
+
| Feature | Status | Notes |
|
|
12
|
+
|---------|--------|-------|
|
|
13
|
+
| `len(x)` built-in | β
| Arrays, strings, and objects β no runtime needed (sync) |
|
|
14
|
+
| `math` module | β
| `round`, `floor`, `ceil`, `abs`, `sqrt`, `pow`, `log`, `random`, `min`, `max`, `pi`, `e` |
|
|
15
|
+
| `input(prompt)` built-in | β
| stdin (Node.js) / `window.prompt` (browser) |
|
|
16
|
+
| `while condition ... end` | β
| Condition-based loop |
|
|
17
|
+
| `null` / `none` literals | β
| Both compile to JS `null` |
|
|
18
|
+
| Multi-line strings | π | Strings must be single-line today |
|
|
19
|
+
| String `+` concatenation | β
| Works via binary `+` operator |
|
|
20
|
+
| Integer division / modulo | π | `math.trunc(a / b)` workaround for now |
|
|
21
|
+
| `use "other.future"` imports | π‘ | No cross-file composition yet |
|
|
22
|
+
| REPL (`future repl`) | π‘ | Interactive shell with introspection |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## AI
|
|
27
|
+
|
|
28
|
+
| Feature | Status | Notes |
|
|
29
|
+
|---------|--------|-------|
|
|
30
|
+
| `ai.ask(prompt)` | β
| Single-turn Q&A |
|
|
31
|
+
| `ai.chat(messages)` | β
| Multi-turn conversation |
|
|
32
|
+
| `ai.embed(text)` | β
| Real embeddings (OpenAI/Ollama) + keyword fallback |
|
|
33
|
+
| `ai.stream(prompt, callback)` | β
| Streaming via SSE β runtime implemented |
|
|
34
|
+
| `stream ai.ask() ... end` syntax | β
| Language-level streaming with implicit `chunk` variable |
|
|
35
|
+
| `ai.configure(provider, key, model)` | β
| Pluggable provider from Future code |
|
|
36
|
+
| Provider: Anthropic | β
| Native Messages API |
|
|
37
|
+
| Provider: OpenAI | β
| Via OpenAI-compat layer |
|
|
38
|
+
| Provider: Ollama | β
| Local models, no key needed |
|
|
39
|
+
| Provider: OpenRouter | β
| Multi-model routing |
|
|
40
|
+
| Provider: Gemini | β
| Via Google's OpenAI-compat endpoint |
|
|
41
|
+
| Provider: Venice / Groq / Together | β
| Via OpenAI-compat layer |
|
|
42
|
+
| `FUTURE_AI_PROVIDER` env var | β
| Switch provider without code change |
|
|
43
|
+
| `ai.extract(text, schema)` | π | Structured JSON extraction with a schema |
|
|
44
|
+
| `ai.classify(text, labels)` | π | Zero-shot classification |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## RAG (Retrieval-Augmented Generation)
|
|
49
|
+
|
|
50
|
+
| Feature | Status | Notes |
|
|
51
|
+
|---------|--------|-------|
|
|
52
|
+
| `rag.index(docs)` | β
| Real pipeline: chunk β embed β store |
|
|
53
|
+
| `rag.query(question)` | β
| Similarity search + LLM answer generation |
|
|
54
|
+
| `rag.create(name)` β Knowledge Bases | β
| Isolated pipeline per KB |
|
|
55
|
+
| `kb.index(docs)` / `kb.query(q)` | β
| Fully awaited by compiler in async mode |
|
|
56
|
+
| `rag.stats()` | β
| Chunk count and vector count |
|
|
57
|
+
| `rag.indexFile(path)` | β
| Reads a local file and indexes it |
|
|
58
|
+
| `rag.indexUrl(url)` | β
| Fetches a URL and indexes its text |
|
|
59
|
+
| Chunker (sentence-aware, overlapping) | β
| 512-char chunks, 64-char overlap |
|
|
60
|
+
| Keyword vector fallback (offline RAG) | β
| Works with no embedding API |
|
|
61
|
+
| Vector store: memory | β
| In-process, cosine similarity |
|
|
62
|
+
| Vector store: file (JSON persistence) | β
| No native deps, survives restarts |
|
|
63
|
+
| Vector store: Qdrant | π | Stub exists β implement `runtime/rag/qdrant.js` |
|
|
64
|
+
| Vector store: Pinecone / Weaviate | π | Stubs exist |
|
|
65
|
+
| Source attribution in query results | π | Return which chunks matched and their source |
|
|
66
|
+
| `rag.delete(id)` | π | Remove a document from the index |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## MQTT
|
|
71
|
+
|
|
72
|
+
| Feature | Status | Notes |
|
|
73
|
+
|---------|--------|-------|
|
|
74
|
+
| `mqtt.publish(topic, message)` | β
| Real broker or in-process loopback |
|
|
75
|
+
| `mqtt.subscribe(topic, handler)` | β
| Callback on each message |
|
|
76
|
+
| `on mqtt "topic" ... end` | β
| Event-oriented syntax sugar |
|
|
77
|
+
| TLS/SSL connections (`mqtts://`) | π | Already works via env var URL |
|
|
78
|
+
| QoS levels | π | `mqtt.publish(topic, msg, { qos: 1 })` |
|
|
79
|
+
| Retained messages | π | `mqtt.publish(topic, msg, { retain: true })` |
|
|
80
|
+
| `mqtt.unsubscribe(topic)` | π | Cancel a subscription |
|
|
81
|
+
| `mqtt.disconnect()` | π | Graceful shutdown |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Home Automation
|
|
86
|
+
|
|
87
|
+
| Feature | Status | Notes |
|
|
88
|
+
|---------|--------|-------|
|
|
89
|
+
| `home.turnOn(device)` | β
| Publishes to `home/<device>/set` via MQTT |
|
|
90
|
+
| `home.turnOff(device)` | β
| |
|
|
91
|
+
| `home.set(device, value)` | β
| Arbitrary value (brightness, temperature, β¦) |
|
|
92
|
+
| `home.get(device)` | π | Read current device state |
|
|
93
|
+
| `home.scene(name)` | π | Activate a named scene |
|
|
94
|
+
| Home Assistant REST API backend | π | Swap MQTT for HA long-lived token |
|
|
95
|
+
| Philips Hue direct integration | π‘ | `home.hue.*` sub-namespace |
|
|
96
|
+
| Matter / Thread support | π‘ | Local-network device control without cloud |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Vision AI
|
|
101
|
+
|
|
102
|
+
| Feature | Status | Notes |
|
|
103
|
+
|---------|--------|-------|
|
|
104
|
+
| `vision.describe(image)` | β
| Uses configured AI provider (Claude/GPT-4o) |
|
|
105
|
+
| `vision.detect(image)` | β
| Object / label detection via prompt |
|
|
106
|
+
| `vision.ocr(image)` | β
| Text extraction from image |
|
|
107
|
+
| `vision.classify(image)` | β
| Primary category in 1β2 words |
|
|
108
|
+
| `vision.compare(imageA, imageB)` | β
| Similarity / diff description |
|
|
109
|
+
| Accepts URLs and base64 data-URIs | β
| |
|
|
110
|
+
| Local model (LLaVA via Ollama) | π | Works with `FUTURE_AI_PROVIDER=ollama` + llava model |
|
|
111
|
+
| `vision.watch(cameraUrl, callback)` | π‘ | Continuous RTSP / webcam stream analysis |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Device Management
|
|
116
|
+
|
|
117
|
+
| Feature | Status | Notes |
|
|
118
|
+
|---------|--------|-------|
|
|
119
|
+
| `device.register(config)` | β
| In-process registry |
|
|
120
|
+
| `device.get(name)` | β
| Look up by name |
|
|
121
|
+
| `device.list()` | β
| All registered devices |
|
|
122
|
+
| `device.update(name, changes)` | π | Patch device config |
|
|
123
|
+
| `device.remove(name)` | π | Deregister a device |
|
|
124
|
+
| `device.send(name, command)` | π | Send a command to a registered device |
|
|
125
|
+
| Persistent registry (JSON / SQLite) | π | Survives process restarts |
|
|
126
|
+
| AWS IoT Core / Azure IoT Hub | π‘ | Cloud-managed fleet |
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Memory
|
|
131
|
+
|
|
132
|
+
| Feature | Status | Notes |
|
|
133
|
+
|---------|--------|-------|
|
|
134
|
+
| `memory.set(key, value)` | β
| |
|
|
135
|
+
| `memory.get(key)` | β
| Returns null if not found |
|
|
136
|
+
| `memory.delete(key)` | β
| |
|
|
137
|
+
| `memory.search(query)` | β
| Substring match on key + value |
|
|
138
|
+
| `memory.forget(pattern?)` | β
| Delete by pattern or clear all |
|
|
139
|
+
| Persistent memory (file / Redis) | π | Survives process restarts |
|
|
140
|
+
| Semantic memory search | π | Use `ai.embed()` for similarity-based recall |
|
|
141
|
+
| Memory scoped to agents | π | Namespaced per-agent store |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Scheduling
|
|
146
|
+
|
|
147
|
+
| Feature | Status | Notes |
|
|
148
|
+
|---------|--------|-------|
|
|
149
|
+
| `schedule.every(interval, cb)` | β
| "30m", "5s", ms number |
|
|
150
|
+
| `schedule.once(delay, cb)` | β
| Run once after delay |
|
|
151
|
+
| `schedule.cron(expr, cb)` | β
| Requires optional `node-cron` package |
|
|
152
|
+
| `every "30m" ... end` syntax | β
| Compiles to `schedule.every` |
|
|
153
|
+
| `schedule.cancel(handle)` | π | Stop a recurring task |
|
|
154
|
+
| `schedule.list()` | π | List active tasks |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## System & OS
|
|
159
|
+
|
|
160
|
+
| Feature | Status | Notes |
|
|
161
|
+
|---------|--------|-------|
|
|
162
|
+
| `system.exec(command)` | β
| Run shell commands |
|
|
163
|
+
| `system.open(target)` | β
| OS default handler for files/URLs |
|
|
164
|
+
| `system.notify(message)` | β
| Desktop notification |
|
|
165
|
+
| `system.read(path)` | β
| Read a local file to string |
|
|
166
|
+
| `system.write(path, content)` | β
| Write (create or overwrite) a local file |
|
|
167
|
+
| `system.env(name)` | β
| Read environment variables; browser reads from `window.__env` |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Agents
|
|
172
|
+
|
|
173
|
+
| Feature | Status | Notes |
|
|
174
|
+
|---------|--------|-------|
|
|
175
|
+
| `AgentDeclaration` AST node | β
| Architecture complete |
|
|
176
|
+
| `agent <name> use <cap> ... end` | β
| Compiles to `async function name(goal)` |
|
|
177
|
+
| `use <capability>` declarations | β
| Collected for tooling; no-op in generated JS |
|
|
178
|
+
| Implicit `goal` parameter | β
| Available inside agent body without declaration |
|
|
179
|
+
| Agent memory isolation | π | Per-agent namespaced memory |
|
|
180
|
+
| Agent tools (function binding) | π | Map Future functions to tool calls |
|
|
181
|
+
| Multi-agent orchestration | π‘ | Agents calling other agents |
|
|
182
|
+
| Tool-calling loop (ReAct) | π‘ | AI decides which tool to call each step |
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Language & Compiler
|
|
187
|
+
|
|
188
|
+
| Feature | Status | Notes |
|
|
189
|
+
|---------|--------|-------|
|
|
190
|
+
| Print, variables, if/else, functions | β
| Core language |
|
|
191
|
+
| Capability calls (auto-async, auto-await) | β
| |
|
|
192
|
+
| `on <source> <channel> ... end` | β
| Event subscription |
|
|
193
|
+
| `every <interval> ... end` | β
| Recurring task |
|
|
194
|
+
| Method calls on dynamic objects awaited | β
| Enables `kb.query()` pattern |
|
|
195
|
+
| `for item in list ... end` | β
| List iteration |
|
|
196
|
+
| `while condition ... end` | β
| Condition-based loop |
|
|
197
|
+
| `try ... catch err ... end` | β
| Error handling |
|
|
198
|
+
| Lists `[1, 2, 3]` | β
| Array literals |
|
|
199
|
+
| Object literals `{ key: value }` | β
| No commas required (Future style) |
|
|
200
|
+
| String interpolation `"Hello {name}"` | β
| Template literal output |
|
|
201
|
+
| Namespace refs in strings `"{math.pi}"` | β
| Correctly emits `${__rt.math.pi}` in async mode |
|
|
202
|
+
| `null` / `none` literals | β
| Both spellings compile to JS `null` |
|
|
203
|
+
| `stream <call> ... end` | β
| Streams chunks via implicit `chunk` variable |
|
|
204
|
+
| `agent <name> ... end` | β
| Named async task with implicit `goal` parameter |
|
|
205
|
+
| `len(x)` built-in | β
| Arrays, strings, objects β sync, no runtime needed |
|
|
206
|
+
| `math.*` module | β
| Full JS Math wrapper |
|
|
207
|
+
| `input(prompt)` built-in | β
| stdin (Node.js) / `window.prompt` (browser) |
|
|
208
|
+
| Multi-line strings | π | Strings must be single-line |
|
|
209
|
+
| `use "other.future"` β module imports | π‘ | No cross-file composition |
|
|
210
|
+
| REPL (`future repl`) | π‘ | Interactive shell with introspection |
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Browser Runtime
|
|
215
|
+
|
|
216
|
+
| Feature | Status | Notes |
|
|
217
|
+
|---------|--------|-------|
|
|
218
|
+
| `future-browser.js` β browser entry point | β
| Compiler + runtime bundled, no Node.js required |
|
|
219
|
+
| `<script type="future">` interceptor | β
| Deferred via `setTimeout` so modules run first |
|
|
220
|
+
| `Future.configure({ proxy })` | β
| Proxy mode β API key stays on server |
|
|
221
|
+
| `Future.configure({ provider, apiKey })` | β
| Demo mode β key visible in source |
|
|
222
|
+
| `Future.runtime.print` override | β
| Redirect output to DOM |
|
|
223
|
+
| `Future.run(source)` / `Future.compile(source)` | β
| Programmatic API |
|
|
224
|
+
| `future-playground.html` | β
| Live editor with 11 examples |
|
|
225
|
+
| AI modules (ai, rag, vision) | β
| Require key or proxy |
|
|
226
|
+
| http, memory, schedule, tts, math, device | β
| Fully supported in browser |
|
|
227
|
+
| `input()` in browser | β
| Uses `window.prompt` |
|
|
228
|
+
| MQTT in browser | π | Needs WebSocket broker |
|
|
229
|
+
| `system.exec/read/write` in browser | β | Not available (sandboxed) |
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Tooling
|
|
234
|
+
|
|
235
|
+
| Feature | Status | Notes |
|
|
236
|
+
|---------|--------|-------|
|
|
237
|
+
| CLI: `future run` | β
| |
|
|
238
|
+
| CLI: `future compile` | β
| |
|
|
239
|
+
| Structured manifest | β
| All 12 modules, 50+ functions fully described |
|
|
240
|
+
| Runtime introspection API | β
| `runtime.describe()` / `listModules()` / `listFunctions()` |
|
|
241
|
+
| LSP metadata module | β
| Completions, hover, signatures |
|
|
242
|
+
| Browser playground | β
| `future-playground.html` β 11 examples |
|
|
243
|
+
| VSCode extension | π | Syntax highlighting, completions, hover |
|
|
244
|
+
| Language Server (LSP) | π | Full editor integration |
|
|
245
|
+
| `future fmt` | π | Auto-formatter |
|
|
246
|
+
| `future check` | π | Lint / type check without running |
|
|
247
|
+
| npm publish (`future-lang`) | π | Public package registry |
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Priority Matrix
|
|
252
|
+
|
|
253
|
+
| Priority | Item | Why it matters |
|
|
254
|
+
|----------|------|----------------|
|
|
255
|
+
| π΄ Critical | npm publish (`future-lang`) | Required to ship publicly |
|
|
256
|
+
| π΄ Critical | VSCode extension (syntax highlighting) | First impression for new users |
|
|
257
|
+
| π High | `use "other.future"` imports | Cross-file composition for real projects |
|
|
258
|
+
| π High | `system.env(name)` | Read env vars from Future code |
|
|
259
|
+
| π‘ Medium | Home Assistant REST API | Most HA users don't run MQTT |
|
|
260
|
+
| π‘ Medium | Persistent memory / device registry | Most programs are stateless today |
|
|
261
|
+
| π‘ Medium | Agent tool-calling loop (ReAct) | True autonomous agents |
|
|
262
|
+
| π’ Low | `rag.delete(id)` | Selective document removal |
|
|
263
|
+
| π’ Low | REPL | Nice-to-have for exploration |
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Consumir dados de uma API pΓΊblica (JSONPlaceholder)
|
|
2
|
+
todo = http.get("https://jsonplaceholder.typicode.com/todos/1")
|
|
3
|
+
|
|
4
|
+
print "TΓtulo da tarefa:"
|
|
5
|
+
print todo.title
|
|
6
|
+
|
|
7
|
+
if todo.completed == true
|
|
8
|
+
print "Status: concluΓda"
|
|
9
|
+
else
|
|
10
|
+
print "Status: pendente"
|
|
11
|
+
end
|