@telorun/stream 0.2.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/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ # SUSTAINABLE USE LICENSE (Fair-code)
2
+
3
+ Copyright (c) 2026 CodeNet Sp. z o.o.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, and distribute the Software for any purpose—including commercial purposes—subject to the following conditions:
6
+
7
+ 1. ANTI-COMPETITION RESTRICTION: The Software may not be provided to third parties as a managed service, commercial SaaS (Software-as-a-Service), PaaS (Platform-as-a-Service), BaaS (Backend-as-a-Service), or similar offering where the primary value provided to the user is the functionality of the Software itself, without a separate commercial license from the copyright holder.
8
+
9
+ 2. PERMITTED COMMERCIAL USE: You are free to use the Software to build, host, and monetize your own commercial applications, products, and services, provided such use does not violate Clause 1.
10
+
11
+ 3. ATTRIBUTION: This copyright notice and license must be included in all copies or substantial portions of the Software.
12
+
13
+ 4. CONTRIBUTIONS: Contributions to the Software are welcome and encouraged. By contributing, you agree that your contributions may be incorporated into the Software and distributed under this license.
14
+
15
+ 5. DISCLAIMER: The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.
16
+
17
+ For commercial licensing, managed hosting exemptions, or enterprise inquiries, please contact <contact@codenet.pl>.
package/README.md ADDED
@@ -0,0 +1,239 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/telorun/telo/main/assets/telo.png" alt="Telo" width="200" />
3
+ </p>
4
+
5
+ <h1 align="center">Telo</h1>
6
+
7
+ <p align="center">Runtime for declarative backends.</p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/telorun/telo/actions/workflows/test.yml"><img alt="Tests" src="https://github.com/telorun/telo/actions/workflows/test.yml/badge.svg" /></a>
11
+ <a href="https://www.npmjs.com/package/@telorun/cli"><img alt="node" src="https://img.shields.io/node/v/@telorun/cli" /></a>
12
+ <br />
13
+ <a href="https://github.com/telorun/telo/commits/main"><img alt="Last commit" src="https://img.shields.io/github/last-commit/telorun/telo" /></a>
14
+ <a href="https://github.com/telorun/telo/issues"><img alt="Issues" src="https://img.shields.io/github/issues/telorun/telo" /></a>
15
+ <a href="https://github.com/telorun/telo/pulls"><img alt="Pull requests" src="https://img.shields.io/github/issues-pr/telorun/telo" /></a>
16
+ <br />
17
+ <img alt="Changesets" src="https://img.shields.io/badge/maintained%20with-changesets-176de3" />
18
+ </p>
19
+
20
+ Telo is an execution engine (Micro-Kernel) that runs logic defined entirely in YAML manifests. Instead of writing imperative backend code, you define your routes, databases, schemas, and AI workflows as atomic, interconnected YAML documents. Telo takes those manifests and runs them.
21
+
22
+ Built to be language-agnostic and infinitely extensible.
23
+
24
+ ```bash
25
+ # Reconcile your manifest into a running backend
26
+ $ telo ./examples/hello-api.yaml
27
+
28
+ {"level":30,"time":1771610393008,"pid":1310178,"hostname":"dev","msg":"Server listening at http://127.0.0.1:8844"}
29
+ ```
30
+
31
+ ## Why use Telo?
32
+
33
+ - **Open Standards:** Built on YAML, JSON Schema, and CEL — no proprietary DSL.
34
+ - **Static Analysis:** CEL type checking, reference validation, and IDE diagnostics catch errors before runtime.
35
+ - **Micro-Kernel Architecture:** Telo itself knows nothing about HTTP or SQL. Everything is a module you import, scope, and compose with typed variable and secret contracts.
36
+ - **Language Agnostic:** Available as a Node.js runtime today, with a shared YAML runtime contract that allows for future Rust or Go implementations without changing your manifests.
37
+
38
+ ## What It Does
39
+
40
+ - **Loads** YAML resources and compiles CEL expressions (`${{ }}`) into an in-memory registry.
41
+ - **Resolves** resource dependencies via a multi-pass init loop, handling ordering automatically.
42
+ - **Indexes** resources by Kind and Name for constant-time lookup.
43
+ - **Dispatches** execution to the controller that owns each Kind.
44
+
45
+ ## Example manifest
46
+
47
+ Here is an example Telo application that defines a simple HTTP API:
48
+
49
+ ```yaml
50
+ kind: Telo.Application
51
+ metadata:
52
+ name: feedback
53
+ version: 1.0.0
54
+ description: |
55
+ A complete feedback collection REST API — no code, pure YAML.
56
+ Persists entries to SQLite and serves them over HTTP.
57
+ imports:
58
+ Http: std/http-server@0.6.1
59
+ Sql: std/sql@0.5.1
60
+ targets:
61
+ - Migrations
62
+ - Server
63
+ ---
64
+ # SQLite database — swap driver/host/database for PostgreSQL with zero YAML changes
65
+ kind: Sql.Connection
66
+ metadata:
67
+ name: Db
68
+ driver: sqlite
69
+ file: ./tmp/feedback.db
70
+ ---
71
+ # Migrations: applied automatically before the server starts
72
+ kind: Sql.Migrations
73
+ metadata:
74
+ name: Migrations
75
+ connection:
76
+ kind: Sql.Connection
77
+ name: Db
78
+ ---
79
+ kind: Sql.Migration
80
+ metadata:
81
+ name: Migration_20260413_182154_CreateFeedback
82
+ version: 20260413_182154_CreateFeedback
83
+ sql: |
84
+ CREATE TABLE IF NOT EXISTS feedback (
85
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
86
+ text TEXT NOT NULL,
87
+ source TEXT,
88
+ score INTEGER NOT NULL DEFAULT 0,
89
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
90
+ )
91
+ ---
92
+ kind: Http.Server
93
+ metadata:
94
+ name: Server
95
+ baseUrl: http://localhost:8844
96
+ port: 8844
97
+ logger: true
98
+ openapi:
99
+ info:
100
+ title: Feedback API
101
+ version: 1.0.0
102
+ mounts:
103
+ - path: /v1
104
+ type: Http.Api.FeedbackRoutes
105
+ ---
106
+ kind: Http.Api
107
+ metadata:
108
+ name: FeedbackRoutes
109
+ routes:
110
+ # POST /v1/feedback — insert a new entry, score derived from body length heuristic
111
+ - request:
112
+ path: /feedback
113
+ method: POST
114
+ schema:
115
+ body:
116
+ type: object
117
+ properties:
118
+ text:
119
+ type: string
120
+ minLength: 1
121
+ source:
122
+ type: string
123
+ required: [ text ]
124
+ handler:
125
+ kind: Sql.Exec
126
+ connection:
127
+ kind: Sql.Connection
128
+ name: Db
129
+ inputs:
130
+ sql: "INSERT INTO feedback (text, source, score) VALUES (?, ?, ?)"
131
+ bindings:
132
+ - "${{ request.body.text }}"
133
+ - "${{ request.body.source }}"
134
+ - "${{ size(request.body.text) }}"
135
+ response:
136
+ - status: 201
137
+ headers:
138
+ Content-Type: application/json
139
+ body:
140
+ ok: true
141
+ message: Feedback received
142
+
143
+ # GET /v1/feedback — list all entries, newest first
144
+ - request:
145
+ path: /feedback
146
+ method: GET
147
+ handler:
148
+ kind: Sql.Select
149
+ connection:
150
+ kind: Sql.Connection
151
+ name: Db
152
+ from: feedback
153
+ columns: [ id, text, source, score, created_at ]
154
+ orderBy:
155
+ - { column: created_at, direction: desc }
156
+ response:
157
+ - status: 200
158
+ headers:
159
+ Content-Type: application/json
160
+ body: "${{ result.rows }}"
161
+
162
+ # GET /v1/feedback/{id} — fetch a single entry
163
+ - request:
164
+ path: /feedback/{id}
165
+ method: GET
166
+ schema:
167
+ params:
168
+ type: object
169
+ properties:
170
+ id:
171
+ type: integer
172
+ required: [ id ]
173
+ handler:
174
+ kind: Sql.Select
175
+ connection:
176
+ kind: Sql.Connection
177
+ name: Db
178
+ from: feedback
179
+ columns: [ id, text, source, score, created_at ]
180
+ where:
181
+ - { column: id, op: "=", value: "${{ request.params.id }}" }
182
+ response:
183
+ - status: 200
184
+ when: "size(result.rows) > 0"
185
+ headers:
186
+ Content-Type: application/json
187
+ body: "${{ result.rows[0] }}"
188
+ - status: 404
189
+ headers:
190
+ Content-Type: application/json
191
+ body:
192
+ ok: false
193
+ message: Not found
194
+ ```
195
+
196
+ ## Status
197
+
198
+ Telo is under **active development**. The core runtime, module system, and standard library are functional, but the API surface — including YAML shapes — may change without notice. Not yet recommended for production use.
199
+
200
+ ## The Meaning of Telo
201
+
202
+ The name Telo is derived from the Greek root Telos - meaning the "end goal", "purpose", or "final state". That is exactly the philosophy behind this runtime. In standard imperative programming, you have to write thousands of lines of code to tell a server exactly how to start. With Telo, you simply declare your desired final state.
203
+
204
+ You define the end state. Telo makes it real.
205
+
206
+ ## Philosophy
207
+
208
+ Modern platforms often spend disproportionate effort on technical mechanics-wiring frameworks, managing infrastructure, and negotiating toolchains-while the original business problem gets delayed or diluted. Telo pushes in the opposite direction: it treats kernel execution as a stable, predictable host so teams can concentrate on the **business logic and outcomes** instead of the plumbing.
209
+
210
+ By separating "what the system should do" from "how it is hosted", the runtime reduces friction for domain‑level changes. Teams can move faster on product requirements, experiment more safely, and keep conversations centered on value delivered rather than implementation trivia.
211
+
212
+ Telo also aims to **join forces across all programming language communities**, so the best ideas, patterns, and implementations can converge into a shared kernel truth without forcing everyone into a single stack.
213
+
214
+ YAML also makes the system more **AI‑friendly** than traditional programming languages: it is explicit, structured, and easier for tools to generate, review, and transform without losing intent.
215
+
216
+ ## Modularity
217
+
218
+ Telo is built around **modules** that own specific resource kinds. A module is loaded from a manifest, declares which kinds it implements, and then receives only the resources of those kinds. This keeps concerns isolated and lets teams compose systems from focused building blocks rather than monolithic services.
219
+
220
+ At kernel execution time, execution is always routed by **Kind.Name**. The kernel resolves the Kind to its owning module and hands off execution. Modules can call back into the kernel to execute other resources, enabling composition without tight coupling.
221
+
222
+ ## Architecture
223
+
224
+ The architecture is inspired by Kubernetes-style manifests: declarative resources, explicit kinds, and a control plane that routes work based on those definitions.
225
+ Those manifests were taken to the next level by allowing them to run inside a standalone runtime host.
226
+
227
+ ## See more at
228
+
229
+ - [Telo Kernel](./kernel/README.md)
230
+ - [Telo SDK for module authors](sdk/README.md)
231
+ - [Modules](modules/README.md)
232
+
233
+ ## License
234
+
235
+ See [LICENSE](https://github.com/telorun/telo/blob/main/LICENSE).
236
+
237
+ ## Contribution Note
238
+
239
+ By contributing, you agree that code and examples in this repository may be translated or re‑implemented in other programming languages (including by AI systems) to support the project’s polyglot goals.
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ * Generic stream substrate. `Stream.Of` emits a declared list of literal items
4
+ * as a `Stream`, value-agnostic.
5
+ */
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ * Generic stream substrate. `Stream.Of` emits a declared list of literal items
4
+ * as a `Stream`, value-agnostic.
5
+ */
@@ -0,0 +1,31 @@
1
+ import type { ControllerContext, ResourceContext, ResourceInstance } from "@telorun/sdk";
2
+ import { Stream } from "@telorun/sdk";
3
+ interface OfResource {
4
+ metadata: {
5
+ name: string;
6
+ module?: string;
7
+ };
8
+ items?: unknown[];
9
+ }
10
+ interface OfOutputs {
11
+ output: Stream<unknown>;
12
+ }
13
+ /**
14
+ * Literal stream source. Emits the declared `items` array as a stream, in
15
+ * order. Value-agnostic — items pass through verbatim, so the element type is
16
+ * whatever the manifest declares (string, object, number). The output is an
17
+ * opaque stream; downstream consumers validate element shapes at runtime.
18
+ */
19
+ declare class StreamOf implements ResourceInstance<Record<string, unknown>, OfOutputs> {
20
+ private readonly resource;
21
+ constructor(resource: OfResource);
22
+ invoke(): Promise<OfOutputs>;
23
+ snapshot(): Record<string, unknown>;
24
+ }
25
+ export declare function register(_ctx: ControllerContext): void;
26
+ export declare function create(resource: OfResource, _ctx: ResourceContext): Promise<StreamOf>;
27
+ export declare const schema: {
28
+ type: string;
29
+ additionalProperties: boolean;
30
+ };
31
+ export {};
@@ -0,0 +1,33 @@
1
+ import { Stream } from "@telorun/sdk";
2
+ /**
3
+ * Literal stream source. Emits the declared `items` array as a stream, in
4
+ * order. Value-agnostic — items pass through verbatim, so the element type is
5
+ * whatever the manifest declares (string, object, number). The output is an
6
+ * opaque stream; downstream consumers validate element shapes at runtime.
7
+ */
8
+ class StreamOf {
9
+ resource;
10
+ constructor(resource) {
11
+ this.resource = resource;
12
+ }
13
+ async invoke() {
14
+ const items = Array.isArray(this.resource.items) ? this.resource.items : [];
15
+ return { output: new Stream(emit(items)) };
16
+ }
17
+ snapshot() {
18
+ return {};
19
+ }
20
+ }
21
+ async function* emit(items) {
22
+ for (const item of items) {
23
+ yield item;
24
+ }
25
+ }
26
+ export function register(_ctx) { }
27
+ export async function create(resource, _ctx) {
28
+ return new StreamOf(resource);
29
+ }
30
+ export const schema = {
31
+ type: "object",
32
+ additionalProperties: true,
33
+ };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@telorun/stream",
3
+ "version": "0.2.0",
4
+ "description": "Generic stream substrate — value-agnostic stream construction (Stream.Of).",
5
+ "keywords": [
6
+ "telo",
7
+ "stream",
8
+ "source"
9
+ ],
10
+ "author": "Bartosz Pasiński <bartosz.pasinski@codenet.pl>",
11
+ "license": "SEE LICENSE IN LICENSE",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/telorun/telo.git",
15
+ "directory": "modules/stream/nodejs"
16
+ },
17
+ "homepage": "https://github.com/telorun/telo#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/telorun/telo/issues"
20
+ },
21
+ "type": "module",
22
+ "main": "./dist/index.js",
23
+ "module": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "bun": "./src/index.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./of": {
32
+ "types": "./dist/of-controller.d.ts",
33
+ "bun": "./src/of-controller.ts",
34
+ "import": "./dist/of-controller.js"
35
+ }
36
+ },
37
+ "files": [
38
+ "dist/**",
39
+ "src/**"
40
+ ],
41
+ "devDependencies": {
42
+ "@types/node": "^20.0.0",
43
+ "typescript": "^5.0.0",
44
+ "@telorun/sdk": "0.18.0"
45
+ },
46
+ "peerDependencies": {
47
+ "@telorun/sdk": "*"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc -p tsconfig.lib.json"
51
+ }
52
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generic stream substrate. `Stream.Of` emits a declared list of literal items
3
+ * as a `Stream`, value-agnostic.
4
+ */
@@ -0,0 +1,50 @@
1
+ import type { ControllerContext, ResourceContext, ResourceInstance } from "@telorun/sdk";
2
+ import { Stream } from "@telorun/sdk";
3
+
4
+ interface OfResource {
5
+ metadata: { name: string; module?: string };
6
+ items?: unknown[];
7
+ }
8
+
9
+ interface OfOutputs {
10
+ output: Stream<unknown>;
11
+ }
12
+
13
+ /**
14
+ * Literal stream source. Emits the declared `items` array as a stream, in
15
+ * order. Value-agnostic — items pass through verbatim, so the element type is
16
+ * whatever the manifest declares (string, object, number). The output is an
17
+ * opaque stream; downstream consumers validate element shapes at runtime.
18
+ */
19
+ class StreamOf implements ResourceInstance<Record<string, unknown>, OfOutputs> {
20
+ constructor(private readonly resource: OfResource) {}
21
+
22
+ async invoke(): Promise<OfOutputs> {
23
+ const items = Array.isArray(this.resource.items) ? this.resource.items : [];
24
+ return { output: new Stream(emit(items)) };
25
+ }
26
+
27
+ snapshot(): Record<string, unknown> {
28
+ return {};
29
+ }
30
+ }
31
+
32
+ async function* emit(items: unknown[]): AsyncIterable<unknown> {
33
+ for (const item of items) {
34
+ yield item;
35
+ }
36
+ }
37
+
38
+ export function register(_ctx: ControllerContext): void {}
39
+
40
+ export async function create(
41
+ resource: OfResource,
42
+ _ctx: ResourceContext,
43
+ ): Promise<StreamOf> {
44
+ return new StreamOf(resource);
45
+ }
46
+
47
+ export const schema = {
48
+ type: "object",
49
+ additionalProperties: true,
50
+ };