@telorun/sdk 0.6.0 → 0.7.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/dist/index.d.ts CHANGED
@@ -15,5 +15,6 @@ export * from "./invoke-error.js";
15
15
  export * from "./runtime-error.js";
16
16
  export * from "./runtime-event.js";
17
17
  export * from "./runtime-resource.js";
18
+ export * from "./stream.js";
18
19
  export * from "./types.js";
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -15,4 +15,5 @@ export * from "./invoke-error.js";
15
15
  export * from "./runtime-error.js";
16
16
  export * from "./runtime-event.js";
17
17
  export * from "./runtime-resource.js";
18
+ export * from "./stream.js";
18
19
  export * from "./types.js";
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Stream — a thin wrapper around an `AsyncIterable` that gives stream-typed
3
+ * values a stable, recognized constructor.
4
+ *
5
+ * Why this exists: cel-js's runtime type-checker rejects values whose
6
+ * constructor isn't one of `Object/Map/Array/Set` or a registered object type.
7
+ * AsyncGenerator instances (the native shape of `async function*` results) hit
8
+ * that rejection because their `.constructor` is an `AsyncGeneratorFunction`
9
+ * object — typeof `"object"`, not `"function"` — which `Environment.registerType`
10
+ * refuses to accept. Wrapping an iterable in a `new Stream(...)` gives the
11
+ * resulting value a real-class constructor that cel-js can register and
12
+ * recognize, so `${{ steps.X.result.output }}` evaluations pass through cleanly.
13
+ *
14
+ * The companion analyzer registers `Stream` as a CEL object type with no
15
+ * fields — terminal access (passing the value through) succeeds, member access
16
+ * (`result.output.text`, `result.output[0]`) raises a CEL error at runtime,
17
+ * mirroring the analyzer's static check on `x-telo-stream` properties.
18
+ *
19
+ * Producers that yield streams (encoder controllers, `Ai.TextStream`, file
20
+ * read sources, etc.) construct `new Stream(asyncIterable)` for any value
21
+ * exposed on a stream-typed property. Consumers iterate via `for await`.
22
+ *
23
+ * The class implements `AsyncIterable<T>`, so all standard JS iteration
24
+ * patterns work without unwrapping. Internally it forwards `Symbol.asyncIterator`
25
+ * to the underlying iterable.
26
+ */
27
+ export declare class Stream<T = unknown> implements AsyncIterable<T> {
28
+ private readonly source;
29
+ constructor(source: AsyncIterable<T>);
30
+ [Symbol.asyncIterator](): AsyncIterator<T>;
31
+ }
32
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +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"}
package/dist/stream.js ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Stream — a thin wrapper around an `AsyncIterable` that gives stream-typed
3
+ * values a stable, recognized constructor.
4
+ *
5
+ * Why this exists: cel-js's runtime type-checker rejects values whose
6
+ * constructor isn't one of `Object/Map/Array/Set` or a registered object type.
7
+ * AsyncGenerator instances (the native shape of `async function*` results) hit
8
+ * that rejection because their `.constructor` is an `AsyncGeneratorFunction`
9
+ * object — typeof `"object"`, not `"function"` — which `Environment.registerType`
10
+ * refuses to accept. Wrapping an iterable in a `new Stream(...)` gives the
11
+ * resulting value a real-class constructor that cel-js can register and
12
+ * recognize, so `${{ steps.X.result.output }}` evaluations pass through cleanly.
13
+ *
14
+ * The companion analyzer registers `Stream` as a CEL object type with no
15
+ * fields — terminal access (passing the value through) succeeds, member access
16
+ * (`result.output.text`, `result.output[0]`) raises a CEL error at runtime,
17
+ * mirroring the analyzer's static check on `x-telo-stream` properties.
18
+ *
19
+ * Producers that yield streams (encoder controllers, `Ai.TextStream`, file
20
+ * read sources, etc.) construct `new Stream(asyncIterable)` for any value
21
+ * exposed on a stream-typed property. Consumers iterate via `for await`.
22
+ *
23
+ * The class implements `AsyncIterable<T>`, so all standard JS iteration
24
+ * patterns work without unwrapping. Internally it forwards `Symbol.asyncIterator`
25
+ * to the underlying iterable.
26
+ */
27
+ export class Stream {
28
+ source;
29
+ constructor(source) {
30
+ this.source = source;
31
+ }
32
+ [Symbol.asyncIterator]() {
33
+ return this.source[Symbol.asyncIterator]();
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Telo SDK - Public API for Telo module authors.",
5
5
  "keywords": [
6
6
  "telo",
package/src/index.ts CHANGED
@@ -15,5 +15,6 @@ export * from "./invoke-error.js";
15
15
  export * from "./runtime-error.js";
16
16
  export * from "./runtime-event.js";
17
17
  export * from "./runtime-resource.js";
18
+ export * from "./stream.js";
18
19
  export * from "./types.js";
19
20
 
package/src/stream.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Stream — a thin wrapper around an `AsyncIterable` that gives stream-typed
3
+ * values a stable, recognized constructor.
4
+ *
5
+ * Why this exists: cel-js's runtime type-checker rejects values whose
6
+ * constructor isn't one of `Object/Map/Array/Set` or a registered object type.
7
+ * AsyncGenerator instances (the native shape of `async function*` results) hit
8
+ * that rejection because their `.constructor` is an `AsyncGeneratorFunction`
9
+ * object — typeof `"object"`, not `"function"` — which `Environment.registerType`
10
+ * refuses to accept. Wrapping an iterable in a `new Stream(...)` gives the
11
+ * resulting value a real-class constructor that cel-js can register and
12
+ * recognize, so `${{ steps.X.result.output }}` evaluations pass through cleanly.
13
+ *
14
+ * The companion analyzer registers `Stream` as a CEL object type with no
15
+ * fields — terminal access (passing the value through) succeeds, member access
16
+ * (`result.output.text`, `result.output[0]`) raises a CEL error at runtime,
17
+ * mirroring the analyzer's static check on `x-telo-stream` properties.
18
+ *
19
+ * Producers that yield streams (encoder controllers, `Ai.TextStream`, file
20
+ * read sources, etc.) construct `new Stream(asyncIterable)` for any value
21
+ * exposed on a stream-typed property. Consumers iterate via `for await`.
22
+ *
23
+ * The class implements `AsyncIterable<T>`, so all standard JS iteration
24
+ * patterns work without unwrapping. Internally it forwards `Symbol.asyncIterator`
25
+ * to the underlying iterable.
26
+ */
27
+ export class Stream<T = unknown> implements AsyncIterable<T> {
28
+ constructor(private readonly source: AsyncIterable<T>) {}
29
+
30
+ [Symbol.asyncIterator](): AsyncIterator<T> {
31
+ return this.source[Symbol.asyncIterator]();
32
+ }
33
+ }