# Goal-scoped guidance for an agent using the existing UI

The core ASDK browser path is: arrive on the customer domain, discover the guide,
request a short goal, receive one currently published route step plus fresh local
fields, use normal authorized browser controls, then check the actual saved result.
The SDK does not execute the task or return success on behalf of the host.

Use the current hosted bundle / source build. This new interface is not claimed
available in an older npm registry version. Register the application and allowed
origin, enable Guide and Agent integration, demonstrate/review/publish the path,
then initialize the SDK once per document as described in SDK-INTEGRATION.md.
Expose the shipped discovery files in the customer's initial HTML/server routes.
A supported browser adapter must follow them; a URL alone does not connect an agent.

```js
// Runs inside the user's existing authorized browser session.
const context = await Smart365Guide.getAgentStep({goal: 'purchase a daypack'});
// context.status === 'ready': one reviewed step, current controls and marked context.
// Use your ordinary browser actions, then read again on the new/current route.
const next = await Smart365Guide.getAgentStep();
```

The first query selects only a unique matching published workflow. Ambiguous
matches return candidates and require an explicit workflowId; nothing is guessed.
Subsequent reads reuse its ID while rechecking the licensed session, current package,
application and published workflow on the server. Route selection stays server-side:
only one matching step is returned. Parameterized routes match one segment per
parameter. Repeated route steps require currentStepOrder. Unmapped/changed routes,
missing primary selectors and owner-disabled automation return a non-ready status.
The host continues to enforce user roles, validation, user consent and approvals.

Live control metadata is scoped to the reviewed target's form and explicitly
referenced control IDs. It includes required/type/length/pattern rules, disabled
controls and fresh dropdown choices. No input values, cookies, stored credentials,
network bodies or console arguments are sent to this guidance service. Private
regions/passwords/hidden inputs/widget controls are excluded. A new read reflects
conditional fields without assuming recorded options are still current.

Dropdowns return ten choices plus explicit pagination metadata. Read live options:

```js
await Smart365Guide.getAgentFieldOptions({selector: '#region', offset: 10});
```

This reauthorizes the current step first; arbitrary selectors and navigation to
another route invalidate the previous option selection. Disabled choices remain
marked. A context exceeding 8 KB returns context_too_large without truncating a
business value or pretending to give a complete contract. Owners should simplify
oversized forms/steps. Workflow route indexes currently support 200 recorded steps.

Owners can mark relevant non-input readback/summary elements with
`data-smart365-knowledge="order-summary"`. Their bounded text stays local until
the authorized browser adapter reads it. Mark only appropriate content: the SDK
cannot prove arbitrary marked text is nonsensitive. Private descendants and input
controls are removed. The result is untrusted DOM observation, not proof of a save.
Use an actual receipt/host saved-state read before claiming completion.

MCP clients can request a current published step with asdk_get_workflow using
appId, workflowId, currentRoute and optionally currentStepOrder. That server tool
returns the reviewed step; the browser SDK additionally joins fresh DOM context.
An MCP connection alone provides no browser control or current host login.

## Evaluation

The separate Juniper experiment compares the same model, goals, account budget,
UI controls and browser tool schema, changing only observation content. Both arms
receive fresh observations after act; no backend execution shortcuts are exposed.
Discovery, SDK initialization and guidance reads are inside the timer. Every saved
order is independently checked. Results and failures must remain in the separate
report; neither equal accuracy nor improved latency is presumed from implementation.

This is one reviewed workflow and adapter, not complete autonomous knowledge of
any SaaS. Existing observation/version history and owner review remain necessary
as the customer app changes. The optional Capability Network backend executor is
separate from this UI-guidance test.
