-
Notifications
You must be signed in to change notification settings - Fork 0
feat(runtime): add synchronous useAgent() over the request store (#95) #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0ab8374
eafe997
d2cfd47
99fb862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@agent-bundle/runtime": patch | ||
| --- | ||
|
|
||
| Add `useAgent()` to `@agent-bundle/runtime`, the synchronous convenience over `await agent()` for Server Components and server utilities that cannot await. It returns the identical request handle from the same realm-singleton store under the same lease rules — `outside-invocation` when no request is in the async context, `request-closed` on a handle captured from a completed request — and never suspends, because the handle is already resolved in the request's async context. (#402) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,10 @@ returns the invocation plus `Observed` `host`, `session`, `actor`, and | |
| progress, the request signal, and the `state`, `notices`, and `providers` | ||
| slots. The handle is request-scoped: it survives `await`, two concurrent | ||
| requests never observe each other, and reading a captured handle after the | ||
| request closes throws a typed `AgentRequestError`. | ||
| request closes throws a typed `AgentRequestError`. A synchronous Server | ||
| Component or utility that cannot `await` calls `useAgent()` instead; it | ||
| returns the identical handle under the same lease rules and never suspends. | ||
|
Comment on lines
+75
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The package README still states that Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in bf7c0ab: the package README now documents the shipped
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged — the runtime README still says |
||
| Async components should still prefer `await agent()`. | ||
|
|
||
| A **context provider** contributes one request-scoped value without touching | ||
| the compiler. Each `src/providers/<name>.{ts,tsx}` module default-exports a | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Changesets produces the release, this declares only a patch even though the commit adds and documents a new public
useAgent()export. That ships an additive API without the expected minor-version signal for consumers and release tooling; the existing request-store API introduction is also classified as minor in.changeset/request-store-agent.md, so this entry should useminoras well.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a defect:
patchis the repository's pre-1.0 convention, adopted on main in #403.AGENTS.md("Pre-1.0 semver:minor= breaking,patch= everything else (features included). Nomajorbefore 1.0.") and.changeset/README.md("Semver before 1.0:minor= breaking change …;patch= everything else") both classify an additive export such asuseAgent()aspatch. The olderrequest-store-agent.mdentry predates that convention; the changeset here was deliberately switched fromminortopatchin d2cfd47 to follow it.