# Live website language, voice and versioned context

ASDK can translate **owner-marked public interface text** and keep a bounded,
current map of approved pages, fields and marked screen controls. These features
are opt-in per application in **Dashboard → SDK knowledge**, within the package
assigned by the platform administrator.

```mermaid
flowchart LR
  U[User speaks or types a goal] --> SDK[Client ASDK]
  DOM[Live fields, navigation and marked screen controls] --> SDK
  SDK --> P[Application, session and owner policy checks]
  P --> K[Latest context and structural revision history]
  K --> G[Smart365Guide guidance and configured model]
  G --> R[Explain or propose a reviewed workflow]
  R --> A[Host permissions and required approval]
  A --> V[Authorized action and saved-state verification]
```

## Enable it in the portal

1. The platform owner enables **Website translation**, **SDK knowledge** and,
   for spoken input, **Voice** in the company/application package.
2. The site administrator adds allowed route templates, for example `/billing`
   and `/projects/:id`. Enable collection, marked screen context and use of
   observations in guidance as needed.
3. Enable **Translate marked website text** and choose allowed language codes.
   The default list covers the twelve built-in interface languages. Additional
   BCP-47 languages can be enabled, subject to dictionary/model/voice availability.
4. Mark only public UI copy and give important controls stable knowledge IDs.
   Review private regions and workflow contracts before production.

```html
<section data-smart365-translate>
  <h1 data-smart365-knowledge="billing-title">Billing</h1>
  <label for="project-name">Project name</label>
  <input id="project-name" name="projectName" required maxlength="120">
  <button data-smart365-knowledge="create-project">Create project</button>
</section>
<section data-smart365-private><!-- account records or private content --></section>
```

Existing field discovery does not require adding a knowledge ID to every input.
Stable `data-smart365-knowledge` IDs add screen landmarks, headings, buttons and
links; they are not capabilities or execution grants. Use unique ASCII IDs.

## Install and control language

These APIs require **ASDK 1.1.0 or the current hosted browser bundle**. Older npm
versions do not include them; check registry availability before upgrading. The
hosted HTML integration in the SDK integration manual can be used immediately,
with `Smart365Guide.translatePage()` after initialization. For a compatible npm
version, initialize once after the application mounts:

```js
import { init } from '@smart365guide/asdk';
const guide = init({
  licenseKey: 'YOUR_BROWSER_SDK_LICENSE',
  pageTranslations: {
    fr: { Billing: 'Facturation', 'Project name': 'Nom du projet',
          'Create project': 'Créer un projet' }
  }
});
await guide.ready;
const result = await guide.translatePage('fr');
// result.translated / result.missing describe partial coverage.
```

Host-supplied dictionaries are optional. Missing phrases can be translated by the
company's configured AI provider through the authenticated service. No provider
credential goes into the browser. The server checks the active application/session,
feature package, allowed route/language, input bounds, placeholders and numeric
literals. Provider failures preserve original phrases. Generated translations need
linguistic review, especially for financial, medical and legal UI.

React/Next.js can pass `pageTranslations` to the existing `Smart365Guide` component.
Dictionary/language prop updates do not remount the conversation. With page
translation enabled, `guide.setLanguage('fr')` updates the SDK and eligible website
text; otherwise it changes only the SDK interface as before. An application can
listen to `smart365:pagetranslation` for coverage status. `guide.destroy()` restores
eligible text still owned by the translator and removes its observers.

The visitor can say or type **“Translate this website into French”** or
**“Change website language to Hindi.”** Explicit translation commands are also
recognized in the twelve built-in interface languages. Voice uses the same command
and guidance path; microphone permission and browser recognition/voice support are
still required. Typing remains available. Ordinary action requests continue through
review and existing authorization; a language command does not submit a form.

Translation preserves DOM node identity, input values, selectors, routes, links,
option values and event handlers. Editable content, code, private regions and
`translate="no"` are excluded. Options without explicit `value` attributes are
excluded because translating their text would change the submitted value.
Use one translation owner per region. An external change to the host document
language pauses ASDK page translation so it does not fight native localization.
The current host-page translator changes text nodes; it does not translate every
HTML attribute, image, canvas, PDF, iframe, closed shadow root or native app screen.
Mark public UI carefully: the SDK cannot independently prove that arbitrary text
is non-sensitive. Avoid marking account records or user-authored content.

## Current context and version history

The collector observes structural DOM changes on approved routes, debounces them
and uploads at most six bounded samples per minute. It also refreshes on navigation
and the normal SDK heartbeat. This is best-effort live context, not capture of every
frame or request. UI translation keeps the original label in the knowledge model,
so changing display language does not create a false structural revision.

Field/constraint, navigation and marked control changes create an observed revision.
Request durations, error counts, timestamps and cookie-availability flags update the
latest sample without creating a revision. Returning to an earlier structure creates
a new revision while the retained history exists. Concurrent observations are
serialized. History is capped at twenty revisions per route, two hundred per
application and seven days; latest samples cover up to fifty routes. Clearing data
also clears revision history and the translation cache. Revisions describe observed
layouts, including possible role/A-B variants, rather than verified customer
release versions. A counter can restart after its retained history is removed.

The portal shows current fields, selectors, marked screen context and recent
revisions. The brain receives fresh, filtered context on eligible assistant requests.
`guide.getKnowledge()` reads current allowed DOM context. No screenshots, input
values, cookie contents, request/response bodies or console arguments are uploaded
by this knowledge collector.

Delegated bearer MCP clients can call **`asdk_get_site_context`** with an accessible
`appId` and approved `route`. It returns bounded observations, revision, reception
time and a staleness flag. Owner settings and current package permissions are
checked on every read. Existing `asdk:read` OAuth connections remain limited to
published guidance; this update does not silently expand their consent to unreviewed
observations. Agents must check the live page and host role before acting.

Observations do not automatically rewrite/publish workflows. If the site changes,
review the learned context and update the approved path; never infer that a changed
layout grants a new permission or that an action was saved.

Translation requests are limited to forty phrases and 16 KB per batch, and two
hundred cached batches per application. The cache expires after seven days and is
removed by the existing scheduled cleanup or owner clear action. Service rate limits
are per process; a shared limit/budget service remains necessary for large scale.
