@telorun/sdk 0.10.0 → 1.0.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/README.md CHANGED
@@ -8,10 +8,6 @@ The Node.js SDK provides the authoring surface for Telo modules. It defines the
8
8
  - **Context types** for accessing the kernel, registry, and events.
9
9
  - **Shared primitives** used by Telo modules and tooling.
10
10
 
11
- ## Status
12
-
13
- Early prototype. APIs and contracts are still evolving. The API surface - including YAML shapes - may change at any time without notice.
14
-
15
11
  ## When to Use It
16
12
 
17
13
  Use the SDK when building or extending Telo modules. It is not the kernel itself; it is the contract layer that keeps module behavior consistent and predictable.
@@ -73,5 +69,5 @@ throws:
73
69
  ## Related Docs
74
70
 
75
71
  - Kernel overview: [kernel/README.md](../../kernel/README.md)
76
- - Built‑in modules: [modules/](../../modules/)
72
+ - Built‑in modules: [Standard Library](../../modules/README.md)
77
73
  - SDKs index: [sdk/README.md](../README.md)
@@ -1,4 +1,4 @@
1
- export interface Provider {
2
- init(): Promise<void>;
1
+ export interface Provider<TOutput = unknown> {
2
+ provide(): Promise<TOutput>;
3
3
  }
4
4
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ,CAAC,OAAO,GAAG,OAAO;IACzC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7B"}
@@ -1,7 +1,8 @@
1
1
  import type { Invocable } from "./capabilities/invokable.js";
2
+ import type { Provider } from "./capabilities/provider.js";
2
3
  import type { Runnable } from "./capabilities/runnable.js";
3
4
  import type { ResourceContext } from "./resource-context.js";
4
- export type ResourceInstance<TInput = Record<string, any>, TOutput = any> = Partial<Invocable<TInput, TOutput>> & Partial<Runnable> & {
5
+ export type ResourceInstance<TInput = Record<string, any>, TOutput = any> = Partial<Invocable<TInput, TOutput>> & Partial<Runnable> & Partial<Provider<TOutput>> & {
5
6
  init?(ctx?: ResourceContext): Promise<void>;
6
7
  teardown?(): void | Promise<void>;
7
8
  snapshot?(): Record<string, any> | Promise<Record<string, any>>;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-instance.d.ts","sourceRoot":"","sources":["../src/resource-instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CACjF,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3B,GACC,OAAO,CAAC,QAAQ,CAAC,GAAG;IAClB,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CACjE,CAAC"}
1
+ {"version":3,"file":"resource-instance.d.ts","sourceRoot":"","sources":["../src/resource-instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CACjF,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3B,GACC,OAAO,CAAC,QAAQ,CAAC,GACjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG;IAC3B,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CACjE,CAAC"}
package/dist/stream.d.ts CHANGED
@@ -11,6 +11,18 @@
11
11
  * resulting value a real-class constructor that cel-js can register and
12
12
  * recognize, so `${{ steps.X.result.output }}` evaluations pass through cleanly.
13
13
  *
14
+ * Singleton across sdk copies: cel-js identifies registered types by
15
+ * constructor identity (`v.constructor === RegisteredCtor`). The kernel and
16
+ * any npm-loaded controller can — and routinely do — resolve `@telorun/sdk`
17
+ * to different installs (workspace vs `.telo/npm/<hash>/...`), so two `Stream`
18
+ * classes with the same shape but different identity would silently break
19
+ * stream-typed CEL evaluations with "Unsupported type: Stream". The first
20
+ * `@telorun/sdk` copy to load registers its `Stream` class on `globalThis`
21
+ * under a stable `Symbol.for("@telorun/sdk:Stream")` key; later copies discard
22
+ * their local declaration at export time and re-export the registered one.
23
+ * Every Stream value in the process shares one constructor regardless of
24
+ * install topology — no build artifact or `file:` symlink required.
25
+ *
14
26
  * The companion analyzer registers `Stream` as a CEL object type with no
15
27
  * fields — terminal access (passing the value through) succeeds, member access
16
28
  * (`result.output.text`, `result.output[0]`) raises a CEL error at runtime,
@@ -24,9 +36,14 @@
24
36
  * patterns work without unwrapping. Internally it forwards `Symbol.asyncIterator`
25
37
  * to the underlying iterable.
26
38
  */
27
- export declare class Stream<T = unknown> implements AsyncIterable<T> {
28
- private readonly source;
29
- constructor(source: AsyncIterable<T>);
30
- [Symbol.asyncIterator](): AsyncIterator<T>;
39
+ interface Stream<T = unknown> extends AsyncIterable<T> {
31
40
  }
41
+ declare const LocalStream: {
42
+ new <T = unknown>(source: AsyncIterable<T>): {
43
+ "__#private@#source": AsyncIterable<T>;
44
+ [Symbol.asyncIterator](): AsyncIterator<T>;
45
+ };
46
+ };
47
+ declare const Stream: typeof LocalStream;
48
+ export { Stream };
32
49
  //# sourceMappingURL=stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,MAAM,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IAErD,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAG3C"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,UAAU,MAAM,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;CAAG;AAOzD,QAAA,MAAM,WAAW;SAAgB,CAAC,oBAMZ,aAAa,CAAC,CAAC,CAAC;8BAF3B,aAAa,CAAC,CAAC,CAAC;kCAMC,aAAa,CAAC,CAAC,CAAC;;CAG3C,CAAC;AAUF,QAAA,MAAM,MAAM,EAAE,OAAO,WAA0D,CAAC;AAMhF,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/stream.js CHANGED
@@ -11,6 +11,18 @@
11
11
  * resulting value a real-class constructor that cel-js can register and
12
12
  * recognize, so `${{ steps.X.result.output }}` evaluations pass through cleanly.
13
13
  *
14
+ * Singleton across sdk copies: cel-js identifies registered types by
15
+ * constructor identity (`v.constructor === RegisteredCtor`). The kernel and
16
+ * any npm-loaded controller can — and routinely do — resolve `@telorun/sdk`
17
+ * to different installs (workspace vs `.telo/npm/<hash>/...`), so two `Stream`
18
+ * classes with the same shape but different identity would silently break
19
+ * stream-typed CEL evaluations with "Unsupported type: Stream". The first
20
+ * `@telorun/sdk` copy to load registers its `Stream` class on `globalThis`
21
+ * under a stable `Symbol.for("@telorun/sdk:Stream")` key; later copies discard
22
+ * their local declaration at export time and re-export the registered one.
23
+ * Every Stream value in the process shares one constructor regardless of
24
+ * install topology — no build artifact or `file:` symlink required.
25
+ *
14
26
  * The companion analyzer registers `Stream` as a CEL object type with no
15
27
  * fields — terminal access (passing the value through) succeeds, member access
16
28
  * (`result.output.text`, `result.output[0]`) raises a CEL error at runtime,
@@ -24,12 +36,34 @@
24
36
  * patterns work without unwrapping. Internally it forwards `Symbol.asyncIterator`
25
37
  * to the underlying iterable.
26
38
  */
27
- export class Stream {
28
- source;
39
+ // Value binding (private): the class declaration that supplies the runtime
40
+ // implementation. Written as a named class expression so `.name === "Stream"`
41
+ // — debuggers, stack traces, and `Object.prototype.toString` all see "Stream",
42
+ // not the const name. The inner `Stream` identifier is only visible inside
43
+ // the class body (for self-reference); it does not shadow the outer interface.
44
+ const LocalStream = class Stream {
45
+ // ECMAScript private field rather than TS `private readonly` — the latter
46
+ // shows up in the inferred type signature, which TS then refuses to export
47
+ // through an anonymous class expression (TS4094).
48
+ #source;
29
49
  constructor(source) {
30
- this.source = source;
50
+ this.#source = source;
31
51
  }
32
52
  [Symbol.asyncIterator]() {
33
- return this.source[Symbol.asyncIterator]();
53
+ return this.#source[Symbol.asyncIterator]();
34
54
  }
35
- }
55
+ };
56
+ const STREAM_KEY = Symbol.for("@telorun/sdk:Stream");
57
+ const globalSlot = globalThis;
58
+ if (!(STREAM_KEY in globalSlot))
59
+ globalSlot[STREAM_KEY] = LocalStream;
60
+ // The exported value: whichever Stream class won the globalThis race (first
61
+ // sdk copy to import this module). Later copies discard their `LocalStream`
62
+ // at export time and route through the winner — keeping constructor identity
63
+ // stable across the kernel/controller realm boundary.
64
+ const Stream = globalSlot[STREAM_KEY];
65
+ // `export { Stream }` re-exports the value binding (the const above) and the
66
+ // type binding (the interface above) under the same name — TypeScript treats
67
+ // value/type as separate namespaces, so a consumer's `import { Stream }`
68
+ // receives both `new Stream(...)` and `Stream<T>`.
69
+ export { Stream };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/sdk",
3
- "version": "0.10.0",
3
+ "version": "1.0.0",
4
4
  "description": "Telo SDK - Public API for Telo module authors.",
5
5
  "keywords": [
6
6
  "telo",
@@ -1,3 +1,3 @@
1
- export interface Provider {
2
- init(): Promise<void>;
1
+ export interface Provider<TOutput = unknown> {
2
+ provide(): Promise<TOutput>;
3
3
  }
@@ -1,11 +1,13 @@
1
1
  import type { Invocable } from "./capabilities/invokable.js";
2
+ import type { Provider } from "./capabilities/provider.js";
2
3
  import type { Runnable } from "./capabilities/runnable.js";
3
4
  import type { ResourceContext } from "./resource-context.js";
4
5
 
5
6
  export type ResourceInstance<TInput = Record<string, any>, TOutput = any> = Partial<
6
7
  Invocable<TInput, TOutput>
7
8
  > &
8
- Partial<Runnable> & {
9
+ Partial<Runnable> &
10
+ Partial<Provider<TOutput>> & {
9
11
  init?(ctx?: ResourceContext): Promise<void>;
10
12
  teardown?(): void | Promise<void>;
11
13
  snapshot?(): Record<string, any> | Promise<Record<string, any>>;
package/src/stream.ts CHANGED
@@ -11,6 +11,18 @@
11
11
  * resulting value a real-class constructor that cel-js can register and
12
12
  * recognize, so `${{ steps.X.result.output }}` evaluations pass through cleanly.
13
13
  *
14
+ * Singleton across sdk copies: cel-js identifies registered types by
15
+ * constructor identity (`v.constructor === RegisteredCtor`). The kernel and
16
+ * any npm-loaded controller can — and routinely do — resolve `@telorun/sdk`
17
+ * to different installs (workspace vs `.telo/npm/<hash>/...`), so two `Stream`
18
+ * classes with the same shape but different identity would silently break
19
+ * stream-typed CEL evaluations with "Unsupported type: Stream". The first
20
+ * `@telorun/sdk` copy to load registers its `Stream` class on `globalThis`
21
+ * under a stable `Symbol.for("@telorun/sdk:Stream")` key; later copies discard
22
+ * their local declaration at export time and re-export the registered one.
23
+ * Every Stream value in the process shares one constructor regardless of
24
+ * install topology — no build artifact or `file:` symlink required.
25
+ *
14
26
  * The companion analyzer registers `Stream` as a CEL object type with no
15
27
  * fields — terminal access (passing the value through) succeeds, member access
16
28
  * (`result.output.text`, `result.output[0]`) raises a CEL error at runtime,
@@ -24,10 +36,43 @@
24
36
  * patterns work without unwrapping. Internally it forwards `Symbol.asyncIterator`
25
37
  * to the underlying iterable.
26
38
  */
27
- export class Stream<T = unknown> implements AsyncIterable<T> {
28
- constructor(private readonly source: AsyncIterable<T>) {}
39
+
40
+ // Type binding: `Stream<T>` as written by consumers (`let s: Stream<number>`)
41
+ // resolves to this interface. The class below also conforms to it.
42
+ interface Stream<T = unknown> extends AsyncIterable<T> {}
43
+
44
+ // Value binding (private): the class declaration that supplies the runtime
45
+ // implementation. Written as a named class expression so `.name === "Stream"`
46
+ // — debuggers, stack traces, and `Object.prototype.toString` all see "Stream",
47
+ // not the const name. The inner `Stream` identifier is only visible inside
48
+ // the class body (for self-reference); it does not shadow the outer interface.
49
+ const LocalStream = class Stream<T = unknown> implements AsyncIterable<T> {
50
+ // ECMAScript private field rather than TS `private readonly` — the latter
51
+ // shows up in the inferred type signature, which TS then refuses to export
52
+ // through an anonymous class expression (TS4094).
53
+ #source: AsyncIterable<T>;
54
+
55
+ constructor(source: AsyncIterable<T>) {
56
+ this.#source = source;
57
+ }
29
58
 
30
59
  [Symbol.asyncIterator](): AsyncIterator<T> {
31
- return this.source[Symbol.asyncIterator]();
60
+ return this.#source[Symbol.asyncIterator]();
32
61
  }
33
- }
62
+ };
63
+
64
+ const STREAM_KEY = Symbol.for("@telorun/sdk:Stream");
65
+ const globalSlot = globalThis as Record<symbol, unknown>;
66
+ if (!(STREAM_KEY in globalSlot)) globalSlot[STREAM_KEY] = LocalStream;
67
+
68
+ // The exported value: whichever Stream class won the globalThis race (first
69
+ // sdk copy to import this module). Later copies discard their `LocalStream`
70
+ // at export time and route through the winner — keeping constructor identity
71
+ // stable across the kernel/controller realm boundary.
72
+ const Stream: typeof LocalStream = globalSlot[STREAM_KEY] as typeof LocalStream;
73
+
74
+ // `export { Stream }` re-exports the value binding (the const above) and the
75
+ // type binding (the interface above) under the same name — TypeScript treats
76
+ // value/type as separate namespaces, so a consumer's `import { Stream }`
77
+ // receives both `new Stream(...)` and `Stream<T>`.
78
+ export { Stream };