Agent / foldkit-agent-native

Sixty seconds: generate actions

Start with the Agent contract and host guide. The integration below assumes AssistantAgent is your declared contract and AgentBuilder is its application-specialized builder. The host-specific runtimeFor(context) below resolves the caller to that live application.

Agent Native needs a static action registry, but the live Model and principal belong to the caller. Register the contract once and resolve the bound runtime per invocation:

ts
import { AgentNative } from 'foldkit-agent-native'
import { registerPackageActions } from '@agent-native/core/server'

registerPackageActions(
  AgentNative.actions({
    definition: AssistantAgent,
    resolveRuntime: context => runtimeFor(context),
  }),
)

runtimeFor(context) returns an AgentRuntime already bound to the correct live application and principal:

ts
const runtimeFor = (context: HostContext) =>
  AgentBuilder.bind({
    definition: AssistantAgent,
    // The principal is part of the host, beside `model` and `dispatch`.
    host: { ...hostFor(context), principal: () => principalFor(context) },
  })

That distinction is the heart of this adapter:

static
AssistantAgent
      |
      v
Agent Native action descriptions

per invocation
verified host caller/context
      |
      v
resolveRuntime(ctx)
      |
      v
AgentRuntime
      |
      v
availability -> authorization -> Message -> update

The registry describes capabilities. The bound runtime decides whether a particular caller may use one right now.

Verify one action before adding the registry

Start with one capability and a runtime bound to a known caller. Invoke the generated action with valid input, then with a value its schema rejects. The first must reach your existing Message handler; the second must leave the Model unchanged. Next switch to a principal your contract refuses. Registration is static, so an action's presence never implies that this caller may execute it.

actions builds descriptors. registerPackageActions installs them in the host. resolveRuntime runs for an invocation, so resolve the verified caller there rather than capturing one user's runtime in a process-wide registry.