Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

Merge pull request #9056 from janhq/thinhlpg/request-provenance

Thinh Le5db5c77b13e4
diff --cc docs/src/pages/docs/agent/protocol.mdx
index 01e4a7ba4,99a068014..6e7c197a9
--- a/docs/src/pages/docs/agent/protocol.mdx
+++ b/docs/src/pages/docs/agent/protocol.mdx
@@@ -59,12 -59,30 +59,31 @@@ what **this RPC session** negotiated (`
`stream-json`'s `init` fields into RPC or treat a negotiated response as universal availability.
<Callout type="warning">
-RPC is not in a shipped CLI or SDK release yet. ACP remains planned. JavaScript and Python SDK
-packages are not released ([#367](https://github.com/janhq/jan-internal/issues/367)). Host tools
-exist on both `stream-json` (`--host-tools`) and RPC (below).
+RPC is on `main` but not yet in a nightly or release. ACP remains planned. JavaScript and Python
+SDK packages are not released ([#367](https://github.com/janhq/jan-internal/issues/367)). Host tools
+exist on both `stream-json` (`--host-tools`) and RPC (below). See
+[what your build supports](/docs/agent/sdk#what-your-build-supports).
</Callout>
+ ## RPC stream events
+
+ A turn's events reach the client as notifications named `item/<tag>`, where `<tag>` is the event's
+ own `type` on the `stream-json` surface: one naming rule for both, and no second list to keep in
+ sync. `protocol/rpc-schema.json` publishes the resulting notification names in its `events`
+ section, generated from the same Rust enum that produces them (`src-tauri/src/core/cli/rpc.rs:736`),
+ so a record can be looked up there rather than inferred from this page.
+
+ A `request_provenance` event therefore arrives as `item/request_provenance`, carrying the identity
+ of each outbound provider request (run, session, provider, model, wire API, body and tool-array
+ hashes, image hashes) and none of its content. A subagent's request is reported on its child's
+ stream, so its record arrives nested in `item/subagent` (`{run_id, name, event}`) rather than at the
+ top level. See [Request provenance](/docs/agent/cli#request-provenance) for the record's fields.
+
+ A turn whose provider request fails ends with `item/error` (`{type: "error", code, message}`, the
+ provider's own words where it gave any) and then `turn/completed` with `stopReason: "error"` and the
+ same message. A client must read that as the turn's outcome: the assistant text is whatever arrived
+ before the failure, which is usually nothing, and no further records follow.
+
## RPC host tools
A host declares tools on `session/start`; the model calls them, Jan sends the call to the host,