Skip to content

sdk: stream a one-shot run's events; CI on Node 18 and Python 3.9 (refs #21) - #47

Merged
blockmandev merged 3 commits into
mainfrom
feat/sdk-stream
Oct 22, 2026
Merged

blockmandev merged 3 commits into
mainfrom
feat/sdk-stream

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Two of #21's code items.

Streaming one-shot runs

Only incode -t … --output-format json was wrapped, so a caller saw nothing until the run ended.

  • Python stream_task(...) takes run_task's arguments and returns a TaskStream.
    • Iterate it for TaskEvent(type, data) as each line arrives: init, text, thinking, notice, tool_use, tool_result, usage.
    • Then .result holds the TaskResult; .wait() drains what's left and returns it.
    • A failed run raises at the end of iteration, with run_task's errors: TaskFailed, IncodeTimeout, IncodeError, ProtocolError for a line that isn't JSON.
    • stderr is read on its own thread. A timeout kills the run. Both pipes are closed when it ends, checked with -W error::ResourceWarning.
  • TypeScript streamTask(task, options) returns a TaskStream: for await yields each TaskEvent, and .result is a promise that resolves or rejects as runTask would. Iterating to the end throws the same error.
  • buildTaskArgv takes the output format.
  • The shared fake (sdk/testing/fake_incode.py) now writes, in stream-json, the events src/task_run.rs writes, before the result.

CI

The SDKs promise Node 18+ and Python 3.9+, but CI ran only Node 22 and Python 3.12. sdk-and-editor is now a matrix: Node 18 with Python 3.9, Node 20, Node 22. The VS Code extension still runs on Node 22 only. main has no required checks, so renaming the job blocks nothing.

Tests

  • Python: StreamTaskTest, 7 tests: events in order with the result kept out of them, wait, a failure raised after its events, a non-JSON line, a crash with stderr, a timeout, and the argv. All 17 task tests pass locally on 3.13.
  • TypeScript:
    • streamTask: 5 tests;
    • test/index.test.ts: what the package entry exports, and a run streamed through it.
    • 44 of 45 tests pass locally on Node 24; the one skipped is presumably the live test, which needs a real binary.

Still open on #21

  • Client-side terminal/* and elicitation requests.
  • A fuller session/list helper.
  • Publishing to PyPI and npm, which needs your accounts.

…Node 18 and Python 3.9 (refs #21)

Only incode -t --output-format json was wrapped, so a caller saw nothing
until the run ended. stream_task (Python) and streamTask (TypeScript)
run stream-json and hand over each event (init, text, thinking, notice,
tool_use, tool_result, usage) as it arrives, then the result, with the
same errors run_task/runTask raise. The SDKs promise Node 18+ and
Python 3.9+ and CI ran only Node 22 and Python 3.12: the SDK job is now
a matrix with the oldest of each.
setup-python failed on ubuntu-latest (24.04) for 3.9, which is past its
end of life and has no build there, so the SDK's promised floor went
untested. That leg now runs on 22.04.
The runner's annotation: "The version '3.9' with architecture 'x64' was
not found for Ubuntu 26.04"; ubuntu-latest began moving to 26.04 on
2026-10-19. The note said 24.04.
@blockmandev
blockmandev merged commit dc5567f into main Oct 22, 2026
9 checks passed
@blockmandev
blockmandev deleted the feat/sdk-stream branch November 15, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant