Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/kotlin/agents_engine/runtime/LiveRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ object LiveRunner {

private const val VERSION = "0.3.0"

/**
* #2801 — primary `serve` entry point parameterised on a
* `suspend (String) -> Any?` callable. Every operator type already
* exposes one (`agent::invokeSuspend`, `pipeline::invokeSuspend`, …);
* the six typed overloads below stay for source-compat but they all
* delegate to this one + the matching [LiveShow.from] lambda overload.
* Future operator types just call this without an edit to LiveRunner.
*/
fun serve(
invoke: suspend (String) -> Any?,
args: Array<String>,
configure: LiveShowBuilder.() -> Unit = {},
): Int = run(args, configure, invoke) { LiveShow.from(invoke, it) }

fun serve(
agent: Agent<String, *>,
args: Array<String>,
Expand Down
19 changes: 19 additions & 0 deletions src/main/kotlin/agents_engine/runtime/LiveShow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,25 @@ class LiveShow internal constructor(
// Identity sentinel — distinguishable from any user value.
private val SENTINEL_FAILURE: Any = Any()

/**
* #2801 — primary `from` entry point. Every operator type
* (`Agent` / `Pipeline` / `Forum` / `Parallel` / `Loop` / `Branch`)
* ultimately exposes a `suspend (String) -> Any?` callable; pass
* it directly via a method reference to avoid the per-operator
* overload fan-out:
*
* ```kotlin
* LiveShow.from(myAgent::invokeSuspend) { theme = LiveShowTheme.NONE }
* ```
*
* The six typed overloads below remain for source-compat and
* IDE-completion ergonomics; they all delegate here. Future
* operator types (Swarm, Stage, …) just call this overload
* directly — no edit to `LiveShow` required.
*/
fun from(invoke: suspend (String) -> Any?, block: LiveShowBuilder.() -> Unit = {}): LiveShow =
buildShow(invoke, block)

fun from(agent: Agent<String, *>, block: LiveShowBuilder.() -> Unit = {}): LiveShow =
buildShow({ agent.invokeSuspend(it) }, block)

Expand Down
Loading