Skip to content
Playground(another site)

bynk.capability.provider_agent_cross_context

Error On the Workers target, a context requires a capability whose provider, in another context, constructs that context's agents; the consumer's Worker would build the provider without a binding for those agents' Durable Objects.

On the Workers target, each context is its own Worker with its own env, and a Worker builds the capabilities its handlers are given. If a context requires a capability that another context provides, it builds that provider in its own Worker. When that provider constructs agents of the context it lives in, it needs the Durable Object bindings of that context, which the consumer's env does not have, so the build would fail, or bynk dev would quietly keep the agent's state in the isolate. The compiler refuses the requirement instead. Reach the agents through a service of the providing context, which runs in its own Worker beside its own bindings, or build for --target bundle, where every context shares one process.

Example

registry.bynk
provides Yanks = AgentYanks {
fn set(value: Bool) -> Effect[Bool] {
PackageIndex("x").setYanked(value) // the provider constructs `registry`'s own agent
}
}
// api.bynk
service yank {
on call() -> Effect[Bool] by Caller given registry.Yanks { // ✗ `api`'s Worker would build that provider
registry.Yanks.set(true)
}
}
// api.bynk
service yank {
on call() -> Effect[Bool] by Caller {
registry.yank(true) // ✓ a service of `registry`, run in its own Worker
}
}

In the Book

See also

  • The grammar rule it governs: given_clause.
  • Every code in its category, Capabilities, on the diagnostic index.
  • bynk explain bynk.capability.provider_agent_cross_context shows the same from the installed toolchain, without a network.