docs(sdk): add ask-human tool example

Draft
MA
2mo ago
+64-0

What changed

Adds a host-supplied callback recipe for an ask_human tool requested by an integration partner. The example wraps the host callback in a typed SDK tool and shows scoped registration through opencode.tools.register.

Verification

  • bun test test/ask-human-example.test.ts: 1 passed, 0 failed
  • bun run typecheck: passed
  • git diff --check: passed

The public example does not name or quote the private partner conversation.


Summary by cubic

Documents how to register a host callback as an agent tool in @opencode-ai/sdk-next with a new ask_human example. Previously the README described tool registration but gave no concrete callback-based tool; now it shows a complete pattern hosts can copy.

  • Adds makeAskHuman in packages/sdk-next/examples/ask-human.ts, which wraps a (question: string) => Promise<string> callback in a typed Tool and maps failures to a Tool.Failure.
  • Adds packages/sdk-next/test/ask-human-example.test.ts, which settles the tool with a host answer and asserts the callback receives the question.
  • Links the example from the README directly after the tools.register(...) snippet.