@fiodos/web-core 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/cjs/adapters/webCredentialAutofillAdapter.d.ts +16 -0
  2. package/dist/cjs/adapters/webCredentialAutofillAdapter.js +47 -0
  3. package/dist/cjs/api/backendClient.js +14 -0
  4. package/dist/cjs/config/types.d.ts +15 -2
  5. package/dist/cjs/controller/AgentController.d.ts +14 -0
  6. package/dist/cjs/controller/AgentController.js +63 -0
  7. package/dist/cjs/dropin/createFiodosAgent.d.ts +27 -1
  8. package/dist/cjs/dropin/createFiodosAgent.js +32 -1
  9. package/dist/cjs/embed/dynamics.d.ts +61 -0
  10. package/dist/cjs/embed/dynamics.js +173 -0
  11. package/dist/cjs/embed/global.d.ts +45 -0
  12. package/dist/cjs/embed/global.js +48 -0
  13. package/dist/cjs/index.d.ts +3 -0
  14. package/dist/cjs/index.js +8 -1
  15. package/dist/cjs/orb/mountOrb.js +111 -18
  16. package/dist/cjs/orb/orbView.js +40 -7
  17. package/dist/cjs/orb/publishedConfig.d.ts +4 -2
  18. package/dist/cjs/orb/publishedConfig.js +56 -7
  19. package/dist/cjs/version.d.ts +1 -1
  20. package/dist/cjs/version.js +1 -1
  21. package/dist/embed/fiodos-embed.js +66 -0
  22. package/dist/esm/adapters/webCredentialAutofillAdapter.d.ts +16 -0
  23. package/dist/esm/adapters/webCredentialAutofillAdapter.js +44 -0
  24. package/dist/esm/api/backendClient.js +14 -0
  25. package/dist/esm/config/types.d.ts +15 -2
  26. package/dist/esm/controller/AgentController.d.ts +14 -0
  27. package/dist/esm/controller/AgentController.js +63 -0
  28. package/dist/esm/dropin/createFiodosAgent.d.ts +27 -1
  29. package/dist/esm/dropin/createFiodosAgent.js +32 -1
  30. package/dist/esm/embed/dynamics.d.ts +61 -0
  31. package/dist/esm/embed/dynamics.js +168 -0
  32. package/dist/esm/embed/global.d.ts +45 -0
  33. package/dist/esm/embed/global.js +46 -0
  34. package/dist/esm/index.d.ts +3 -0
  35. package/dist/esm/index.js +3 -0
  36. package/dist/esm/orb/mountOrb.js +112 -19
  37. package/dist/esm/orb/orbView.js +41 -8
  38. package/dist/esm/orb/publishedConfig.d.ts +4 -2
  39. package/dist/esm/orb/publishedConfig.js +56 -7
  40. package/dist/esm/version.d.ts +1 -1
  41. package/dist/esm/version.js +1 -1
  42. package/package.json +5 -3
@@ -16,6 +16,7 @@
16
16
  * - The agent only ever executes actions declared in the manifest.
17
17
  */
18
18
  import { combineContexts, createActionExecutor, createConsentManager, createSafeTelemetry, createSanitizer, buildBubbleExchangeWindow, BUBBLE_PAGE_EXCHANGES, clearPersistedConversation, conversationIdentityKey, conversationRetentionOptions, createConversationSession, persistConversationSession, restoreConversationSession, defaultRouteContextText, formatMessage, prepareConversationForTurn, recordConversationExchange, resolveConfirmationLexicon, resolveMessages, validateManifest, } from '@fiodos/core';
19
+ import { createWebCredentialAutofillAdapter } from '../adapters/webCredentialAutofillAdapter.js';
19
20
  import { AgentApiError } from '../api/errors.js';
20
21
  import { formatAgentTurnError } from '../api/formatTurnError.js';
21
22
  import { buildManifestPayload } from '../api/backendClient.js';
@@ -91,12 +92,19 @@ export class AgentController {
91
92
  appId: config.manifest.appId,
92
93
  version: config.consentVersion,
93
94
  });
95
+ // SMART SIGN-IN ships by default on web (browser password manager);
96
+ // hosts can override the adapter or pass null to opt out entirely.
97
+ this.credentialAutofill =
98
+ config.credentialAutofill === undefined
99
+ ? createWebCredentialAutofillAdapter()
100
+ : config.credentialAutofill;
94
101
  this.executor = createActionExecutor({
95
102
  manifest: config.manifest,
96
103
  registries: config.registries,
97
104
  navigation: config.navigation,
98
105
  messages: this.messages,
99
106
  isAuthenticated: config.isAuthenticated,
107
+ credentialAutofill: this.credentialAutofill,
100
108
  });
101
109
  this.timings = { ...DEFAULT_AGENT_TIMINGS, ...config.timings };
102
110
  // Chaining OFF by default; clamp to the same safe bounds as react/react-native.
@@ -581,6 +589,57 @@ export class AgentController {
581
589
  this.beginConfirmationVoiceWindow();
582
590
  }
583
591
  }
592
+ /**
593
+ * Device capability flags advertised on each turn (never user data). Fresh
594
+ * per turn: cheap, and honest if the environment changes mid-session.
595
+ */
596
+ platformCapabilities() {
597
+ let autofill = false;
598
+ try {
599
+ autofill = this.credentialAutofill?.isSupported() === true;
600
+ }
601
+ catch {
602
+ autofill = false;
603
+ }
604
+ return autofill ? { credentialAutofill: true } : undefined;
605
+ }
606
+ /**
607
+ * Live session verdict advertised on each turn (audience map — never user
608
+ * data): whether the user is signed in plus the app's boolean capability
609
+ * flags. Fresh per turn so login/logout mid-session is honest. Undefined
610
+ * when the host wired neither source (older installs — backend filters
611
+ * nothing, exactly today's behavior).
612
+ */
613
+ sessionContext() {
614
+ const { isAuthenticated, getSessionCapabilities } = this.config;
615
+ if (!isAuthenticated && !getSessionCapabilities)
616
+ return undefined;
617
+ let authenticated = null;
618
+ try {
619
+ const v = isAuthenticated?.();
620
+ authenticated = v == null ? null : Boolean(v);
621
+ }
622
+ catch {
623
+ authenticated = null;
624
+ }
625
+ let capabilities;
626
+ try {
627
+ const raw = getSessionCapabilities?.();
628
+ if (raw && typeof raw === 'object') {
629
+ const clean = {};
630
+ for (const [k, v] of Object.entries(raw)) {
631
+ if (typeof v === 'boolean')
632
+ clean[k] = v;
633
+ }
634
+ if (Object.keys(clean).length > 0)
635
+ capabilities = clean;
636
+ }
637
+ }
638
+ catch {
639
+ capabilities = undefined;
640
+ }
641
+ return { authenticated, ...(capabilities ? { capabilities } : {}) };
642
+ }
584
643
  routeLabel(intent) {
585
644
  return this.config.manifest.routes.find((r) => r.intent === intent)?.label;
586
645
  }
@@ -766,6 +825,8 @@ export class AgentController {
766
825
  isContinuation: true,
767
826
  chainStep: step,
768
827
  lastStep,
828
+ platformCapabilities: this.platformCapabilities(),
829
+ sessionContext: this.sessionContext(),
769
830
  ...buildManifestPayload(this.config.manifest),
770
831
  }, { signal: controller.signal });
771
832
  oc = await this.applyOutcome(turn, routeNow, snap?.context ?? {}, state.userMessage);
@@ -923,6 +984,8 @@ export class AgentController {
923
984
  conversationHistory: conv.history,
924
985
  conversationSummary: conv.summary ?? undefined,
925
986
  sessionId: this.sessionId,
987
+ platformCapabilities: this.platformCapabilities(),
988
+ sessionContext: this.sessionContext(),
926
989
  ...buildManifestPayload(this.config.manifest),
927
990
  }, { signal: controller.signal });
928
991
  outcome = await this.applyOutcome(turn, currentRoute, snapshot?.context ?? {}, text);
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { type ActionRegistries, type AppManifest } from '@fiodos/core';
15
15
  import { AgentController } from '../controller/AgentController.js';
16
+ import type { AgentScreenSnapshot } from '../context/screenContextStore.js';
16
17
  import { type MountOrbOptions, type MountedOrb } from '../orb/mountOrb.js';
17
18
  import type { FiodosWebAgentConfig } from '../config/types.js';
18
19
  export interface CreateFiodosAgentOptions {
@@ -37,8 +38,22 @@ export interface CreateFiodosAgentOptions {
37
38
  sttLocale?: string;
38
39
  /** Host router navigate delegate. Defaults to location.assign. */
39
40
  navigate?: (route: string) => void;
41
+ /**
42
+ * Current route/screen resolver for the agent's screen awareness. Defaults
43
+ * to location.pathname + search. Apps whose screens are CLIENT STATE (no URL
44
+ * change) pass the generated `fyodosGetCurrentRoute` here so the orb knows
45
+ * which screen the user is on (see screen-truth wiring).
46
+ */
47
+ getCurrentRoute?: () => string | null;
40
48
  /** Host auth check for actions requiring auth. */
41
- isAuthenticated?: () => boolean;
49
+ isAuthenticated?: () => boolean | null | undefined;
50
+ /**
51
+ * Fine-grained session capability flags (audience map, e.g.
52
+ * { has_payment_method: true }) from the generated session wiring. Boolean
53
+ * flags only; sent with each turn so the orb shows this user only THEIR
54
+ * available actions.
55
+ */
56
+ getSessionCapabilities?: () => Record<string, boolean> | null | undefined;
42
57
  /** Voice id forwarded to the backend TTS. */
43
58
  ttsVoice?: string | (() => string | undefined);
44
59
  /** End-user id for rate limiting / telemetry correlation. */
@@ -64,6 +79,17 @@ export interface FiodosAgentHandle {
64
79
  * Call it from the app's logout for a hard wipe; no-op until ready.
65
80
  */
66
81
  resetConversation(): void;
82
+ /**
83
+ * Publishes WHAT THE USER IS SEEING so 'execute' actions can target it —
84
+ * the embed-host equivalent of the React `useAgentScreenContext` hook.
85
+ * Hosts without our SDK on screens (Dynamics web resources, WinCC CWCs)
86
+ * call this whenever their form/record/view changes. On the auto-fetch
87
+ * path, calls made before the controller is ready are kept and applied on
88
+ * ready, so hosts don't need to await `ready` themselves.
89
+ */
90
+ setScreenContext(snapshot: AgentScreenSnapshot): void;
91
+ /** Clears a previously published snapshot (e.g. the record was closed). */
92
+ clearScreenContext(): void;
67
93
  destroy(): void;
68
94
  }
69
95
  export declare function createFiodosAgent(options: CreateFiodosAgentOptions): FiodosAgentHandle;
@@ -65,13 +65,17 @@ function assemble(options, manifest, baseUrl) {
65
65
  manifest,
66
66
  locale,
67
67
  sttLocale,
68
- navigation: createWebNavigationAdapter({ navigate: options.navigate ?? defaultNavigate }),
68
+ navigation: createWebNavigationAdapter({
69
+ navigate: options.navigate ?? defaultNavigate,
70
+ getCurrentRoute: options.getCurrentRoute,
71
+ }),
69
72
  registries: options.registries ?? { handlers: {}, idempotencyCheckers: {} },
70
73
  backend,
71
74
  voice: createWebVoiceAdapter(),
72
75
  storage: createWebStorageAdapter(),
73
76
  telemetry,
74
77
  isAuthenticated: options.isAuthenticated,
78
+ getSessionCapabilities: options.getSessionCapabilities,
75
79
  getUserId: options.getUserId,
76
80
  ttsVoice: options.ttsVoice,
77
81
  ...options.configOverrides,
@@ -83,6 +87,9 @@ function assemble(options, manifest, baseUrl) {
83
87
  export function createFiodosAgent(options) {
84
88
  const baseUrl = (options.baseUrl ?? DEFAULT_WEB_API_URL).replace(/\/$/, '');
85
89
  const shouldMount = options.mount !== false;
90
+ // One stable owner id per handle: the host is "one screen" from the store's
91
+ // point of view, so consecutive setScreenContext calls replace each other.
92
+ const contextOwner = Symbol('fiodos-embed-host');
86
93
  // ── Manual path: manifest provided → fully synchronous (back-compat). ───────
87
94
  if (options.manifest) {
88
95
  const controller = assemble(options, options.manifest, baseUrl);
@@ -98,6 +105,12 @@ export function createFiodosAgent(options) {
98
105
  resetConversation() {
99
106
  controller.resetConversation();
100
107
  },
108
+ setScreenContext(snapshot) {
109
+ controller.screenStore.set(contextOwner, snapshot);
110
+ },
111
+ clearScreenContext() {
112
+ controller.screenStore.clear(contextOwner);
113
+ },
101
114
  destroy() {
102
115
  orb?.unmount();
103
116
  controller.dispose();
@@ -106,6 +119,9 @@ export function createFiodosAgent(options) {
106
119
  return handle;
107
120
  }
108
121
  // ── Auto path (React parity): fetch manifest by apiKey, then assemble. ──────
122
+ // Context published before the controller resolves is buffered (last one
123
+ // wins) and applied on ready — hosts fire form events without awaiting us.
124
+ let pendingSnapshot;
109
125
  const handle = {
110
126
  controller: null,
111
127
  orb: null,
@@ -113,6 +129,18 @@ export function createFiodosAgent(options) {
113
129
  resetConversation() {
114
130
  handle.controller?.resetConversation();
115
131
  },
132
+ setScreenContext(snapshot) {
133
+ if (handle.controller)
134
+ handle.controller.screenStore.set(contextOwner, snapshot);
135
+ else
136
+ pendingSnapshot = snapshot;
137
+ },
138
+ clearScreenContext() {
139
+ if (handle.controller)
140
+ handle.controller.screenStore.clear(contextOwner);
141
+ else
142
+ pendingSnapshot = null;
143
+ },
116
144
  destroy() {
117
145
  cancelled = true;
118
146
  handle.orb?.unmount();
@@ -148,6 +176,9 @@ export function createFiodosAgent(options) {
148
176
  return null;
149
177
  }
150
178
  handle.controller = controller;
179
+ if (pendingSnapshot)
180
+ controller.screenStore.set(contextOwner, pendingSnapshot);
181
+ pendingSnapshot = undefined;
151
182
  handle.orb = shouldMount ? mountOrb(controller, options.orb) : null;
152
183
  if (shouldMount && options.apiKey) {
153
184
  void sendOrbSeen({ baseUrl, apiKey: options.apiKey });
@@ -0,0 +1,61 @@
1
+ import type { AgentScreenSnapshot } from '../context/screenContextStore.js';
2
+ interface XrmAttributeLike {
3
+ getName(): string;
4
+ getValue(): unknown;
5
+ /** Present on optionset/lookup attributes; preferred over raw values. */
6
+ getText?(): string | string[] | null;
7
+ }
8
+ interface XrmEntityLike {
9
+ getEntityName(): string;
10
+ /** Record GUID, usually brace-wrapped: "{1D2C...}". Empty on create forms. */
11
+ getId(): string;
12
+ getPrimaryAttributeValue?(): string | null;
13
+ attributes?: {
14
+ forEach(cb: (attribute: XrmAttributeLike) => void): void;
15
+ };
16
+ /** Model-driven apps expose save events here (Xrm ≥ 9.x). */
17
+ addOnPostSave?(handler: () => void): void;
18
+ removeOnPostSave?(handler: () => void): void;
19
+ }
20
+ export interface DynamicsFormContextLike {
21
+ data: {
22
+ entity: XrmEntityLike;
23
+ };
24
+ ui?: {
25
+ getFormType?(): number;
26
+ };
27
+ }
28
+ /** The subset of FiodosAgentHandle the bridge needs (keeps this module cheap to test). */
29
+ export interface ScreenContextSink {
30
+ setScreenContext(snapshot: AgentScreenSnapshot): void;
31
+ clearScreenContext(): void;
32
+ }
33
+ export interface DynamicsSnapshotOptions {
34
+ /**
35
+ * Logical names of the attributes to expose to the agent. When omitted, the
36
+ * first `maxAttributes` non-empty scalar attributes are included.
37
+ */
38
+ attributes?: string[];
39
+ /** Cap when no allowlist is given. Default 12. */
40
+ maxAttributes?: number;
41
+ }
42
+ /** "{1D2C…}" → "1d2c…" (Web API URLs want bare lowercase GUIDs). */
43
+ export declare function normalizeDynamicsId(rawId: string): string;
44
+ /**
45
+ * Builds the AgentScreenSnapshot for the current form state, or null when
46
+ * there is nothing referenceable yet (create form: no record id).
47
+ */
48
+ export declare function dynamicsFormSnapshot(formContext: DynamicsFormContextLike, options?: DynamicsSnapshotOptions): AgentScreenSnapshot | null;
49
+ export interface DynamicsContextBridge {
50
+ /** Re-reads the form and republishes the snapshot (wire to OnChange/OnSave). */
51
+ refresh(): void;
52
+ /** Stops publishing and clears the agent's screen context. */
53
+ disconnect(): void;
54
+ }
55
+ /**
56
+ * Publishes the form snapshot now, republishes after every save (when the
57
+ * form exposes OnPostSave), and clears the context on disconnect. Call it from
58
+ * the form's OnLoad handler.
59
+ */
60
+ export declare function connectDynamicsFormContext(agent: ScreenContextSink, formContext: DynamicsFormContextLike, options?: DynamicsSnapshotOptions): DynamicsContextBridge;
61
+ export {};
@@ -0,0 +1,168 @@
1
+ // ── Value normalization ──────────────────────────────────────────────────────
2
+ const MAX_VALUE_CHARS = 120;
3
+ function clip(text) {
4
+ const t = text.trim();
5
+ return t.length > MAX_VALUE_CHARS ? `${t.slice(0, MAX_VALUE_CHARS - 1)}…` : t;
6
+ }
7
+ /** Lookup values arrive as [{ id, name, entityType }] — show the names. */
8
+ function lookupNames(value) {
9
+ const names = value
10
+ .map((v) => v && typeof v === 'object' && typeof v.name === 'string'
11
+ ? (v.name)
12
+ : null)
13
+ .filter((n) => !!n);
14
+ return names.length ? names.join(', ') : null;
15
+ }
16
+ function normalizeAttributeValue(attribute) {
17
+ // Optionset / lookup / boolean attributes carry a human label — prefer it.
18
+ try {
19
+ const text = attribute.getText?.();
20
+ if (typeof text === 'string' && text.trim())
21
+ return clip(text);
22
+ if (Array.isArray(text) && text.length)
23
+ return clip(text.join(', '));
24
+ }
25
+ catch {
26
+ /* some attribute types throw on getText — fall through to raw value */
27
+ }
28
+ let value;
29
+ try {
30
+ value = attribute.getValue();
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ if (value == null)
36
+ return null;
37
+ if (typeof value === 'string')
38
+ return value.trim() ? clip(value) : null;
39
+ if (typeof value === 'number' || typeof value === 'boolean')
40
+ return value;
41
+ if (value instanceof Date)
42
+ return value.toISOString();
43
+ if (Array.isArray(value)) {
44
+ const names = lookupNames(value);
45
+ return names ? clip(names) : null;
46
+ }
47
+ return null; // collections / unknown object shapes are skipped, never guessed
48
+ }
49
+ /** "{1D2C…}" → "1d2c…" (Web API URLs want bare lowercase GUIDs). */
50
+ export function normalizeDynamicsId(rawId) {
51
+ return rawId.replace(/[{}]/g, '').trim().toLowerCase();
52
+ }
53
+ // ── Snapshot builder ─────────────────────────────────────────────────────────
54
+ /**
55
+ * Builds the AgentScreenSnapshot for the current form state, or null when
56
+ * there is nothing referenceable yet (create form: no record id).
57
+ */
58
+ export function dynamicsFormSnapshot(formContext, options = {}) {
59
+ const entity = formContext.data?.entity;
60
+ if (!entity)
61
+ return null;
62
+ const entityName = entity.getEntityName();
63
+ const recordId = normalizeDynamicsId(entity.getId() ?? '');
64
+ const allowlist = options.attributes?.length
65
+ ? new Set(options.attributes.map((a) => a.trim().toLowerCase()).filter(Boolean))
66
+ : null;
67
+ const maxAttributes = options.maxAttributes ?? 12;
68
+ const fields = {};
69
+ let count = 0;
70
+ entity.attributes?.forEach((attribute) => {
71
+ let name;
72
+ try {
73
+ name = attribute.getName();
74
+ }
75
+ catch {
76
+ return;
77
+ }
78
+ if (!name)
79
+ return;
80
+ if (allowlist) {
81
+ if (!allowlist.has(name.toLowerCase()))
82
+ return;
83
+ }
84
+ else if (count >= maxAttributes) {
85
+ return;
86
+ }
87
+ const value = normalizeAttributeValue(attribute);
88
+ if (value == null)
89
+ return;
90
+ fields[name] = value;
91
+ count += 1;
92
+ });
93
+ let title;
94
+ try {
95
+ title = entity.getPrimaryAttributeValue?.() ?? undefined;
96
+ }
97
+ catch {
98
+ title = undefined;
99
+ }
100
+ // Create forms have no id yet: the agent can still SEE the fields, but there
101
+ // is no target for execute actions, so we publish text-only context.
102
+ const item = recordId
103
+ ? { id: recordId, kind: entityName, title, metadata: fields }
104
+ : null;
105
+ const fieldSummary = Object.entries(fields)
106
+ .map(([k, v]) => `${k}: ${v}`)
107
+ .join('; ');
108
+ const textParts = [
109
+ `Dynamics 365 form — entity "${entityName}"`,
110
+ recordId ? `record "${title ?? recordId}" (id ${recordId})` : 'new record (not saved yet)',
111
+ ];
112
+ if (fieldSummary)
113
+ textParts.push(`Fields: ${fieldSummary}`);
114
+ const context = {
115
+ ...(item ? { visibleContent: { items: [item], focusedIndex: 0 } } : {}),
116
+ custom: {
117
+ platform: 'dynamics365',
118
+ entityName,
119
+ ...(recordId ? { recordId } : {}),
120
+ ...(typeof formContext.ui?.getFormType === 'function'
121
+ ? { formType: formContext.ui.getFormType() }
122
+ : {}),
123
+ },
124
+ };
125
+ return { kind: `dynamics-form:${entityName}`, text: textParts.join('. '), context };
126
+ }
127
+ /**
128
+ * Publishes the form snapshot now, republishes after every save (when the
129
+ * form exposes OnPostSave), and clears the context on disconnect. Call it from
130
+ * the form's OnLoad handler.
131
+ */
132
+ export function connectDynamicsFormContext(agent, formContext, options = {}) {
133
+ let disconnected = false;
134
+ const publish = () => {
135
+ if (disconnected)
136
+ return;
137
+ const snapshot = dynamicsFormSnapshot(formContext, options);
138
+ if (snapshot)
139
+ agent.setScreenContext(snapshot);
140
+ else
141
+ agent.clearScreenContext();
142
+ };
143
+ publish();
144
+ const entity = formContext.data?.entity;
145
+ if (entity?.addOnPostSave) {
146
+ try {
147
+ entity.addOnPostSave(publish);
148
+ }
149
+ catch {
150
+ /* older clients — the host can still call refresh() manually */
151
+ }
152
+ }
153
+ return {
154
+ refresh: publish,
155
+ disconnect() {
156
+ if (disconnected)
157
+ return;
158
+ disconnected = true;
159
+ try {
160
+ entity?.removeOnPostSave?.(publish);
161
+ }
162
+ catch {
163
+ /* best-effort unsubscribe */
164
+ }
165
+ agent.clearScreenContext();
166
+ },
167
+ };
168
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Embed entrypoint — single-file IIFE bundle for CLOSED third-party hosts
3
+ * where npm/ESM is not available: Dynamics 365 web resources, WinCC Unified
4
+ * Custom Web Controls, Salesforce LWC iframes, plain <script> tags.
5
+ *
6
+ * Built by `npm run build:embed` into dist/embed/fiodos-embed.js and exposed
7
+ * as the `Fiodos` global:
8
+ *
9
+ * <script src="fiodos-embed.js"></script>
10
+ * <script>
11
+ * const agent = Fiodos.createFiodosAgent({
12
+ * manifest, // e.g. from `fiodos from-odata`
13
+ * registries: Fiodos.buildApiActionRegistries(manifest, {
14
+ * baseUrl: 'https://org.crm.dynamics.com/api/data/v9.2',
15
+ * authProviders: { dataverse: () => ({ Authorization: `Bearer ${token}` }) },
16
+ * }),
17
+ * });
18
+ * </script>
19
+ *
20
+ * The bundle is self-contained (core + web-core inlined) and side-effect-free
21
+ * beyond assigning the global — it never auto-mounts; the host decides when.
22
+ */
23
+ import { createFiodosAgent } from '../dropin/createFiodosAgent.js';
24
+ import { mountOrb } from '../orb/mountOrb.js';
25
+ import { AgentController } from '../controller/AgentController.js';
26
+ import { createScreenContextStore } from '../context/screenContextStore.js';
27
+ import { connectDynamicsFormContext, dynamicsFormSnapshot, normalizeDynamicsId } from './dynamics.js';
28
+ import { buildApiActionRegistries, validateManifest } from '@fiodos/core';
29
+ declare const api: {
30
+ readonly version: "0.1.14";
31
+ readonly createFiodosAgent: typeof createFiodosAgent;
32
+ readonly mountOrb: typeof mountOrb;
33
+ readonly AgentController: typeof AgentController;
34
+ readonly createScreenContextStore: typeof createScreenContextStore;
35
+ readonly buildApiActionRegistries: typeof buildApiActionRegistries;
36
+ readonly validateManifest: typeof validateManifest;
37
+ readonly connectDynamicsFormContext: typeof connectDynamicsFormContext;
38
+ readonly dynamicsFormSnapshot: typeof dynamicsFormSnapshot;
39
+ readonly normalizeDynamicsId: typeof normalizeDynamicsId;
40
+ };
41
+ declare global {
42
+ var Fiodos: typeof api | undefined;
43
+ }
44
+ export type FiodosEmbedApi = typeof api;
45
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Embed entrypoint — single-file IIFE bundle for CLOSED third-party hosts
3
+ * where npm/ESM is not available: Dynamics 365 web resources, WinCC Unified
4
+ * Custom Web Controls, Salesforce LWC iframes, plain <script> tags.
5
+ *
6
+ * Built by `npm run build:embed` into dist/embed/fiodos-embed.js and exposed
7
+ * as the `Fiodos` global:
8
+ *
9
+ * <script src="fiodos-embed.js"></script>
10
+ * <script>
11
+ * const agent = Fiodos.createFiodosAgent({
12
+ * manifest, // e.g. from `fiodos from-odata`
13
+ * registries: Fiodos.buildApiActionRegistries(manifest, {
14
+ * baseUrl: 'https://org.crm.dynamics.com/api/data/v9.2',
15
+ * authProviders: { dataverse: () => ({ Authorization: `Bearer ${token}` }) },
16
+ * }),
17
+ * });
18
+ * </script>
19
+ *
20
+ * The bundle is self-contained (core + web-core inlined) and side-effect-free
21
+ * beyond assigning the global — it never auto-mounts; the host decides when.
22
+ */
23
+ import { createFiodosAgent } from '../dropin/createFiodosAgent.js';
24
+ import { mountOrb } from '../orb/mountOrb.js';
25
+ import { AgentController } from '../controller/AgentController.js';
26
+ import { createScreenContextStore } from '../context/screenContextStore.js';
27
+ import { connectDynamicsFormContext, dynamicsFormSnapshot, normalizeDynamicsId, } from './dynamics.js';
28
+ import { SDK_VERSION } from '../version.js';
29
+ import { buildApiActionRegistries, validateManifest } from '@fiodos/core';
30
+ const api = {
31
+ version: SDK_VERSION,
32
+ createFiodosAgent,
33
+ mountOrb,
34
+ AgentController,
35
+ createScreenContextStore,
36
+ // Closed-software mode: turn ApiExecutionSpec manifests into live handlers,
37
+ // and validate hand-written / from-odata manifests before mounting.
38
+ buildApiActionRegistries,
39
+ validateManifest,
40
+ // Context bridges: tell the orb what the host is showing. Dynamics gets a
41
+ // dedicated mapper (formContext); any other host calls agent.setScreenContext.
42
+ connectDynamicsFormContext,
43
+ dynamicsFormSnapshot,
44
+ normalizeDynamicsId,
45
+ };
46
+ globalThis.Fiodos = api;
@@ -26,6 +26,7 @@ export { createWebNavigationAdapter, BACK_ROUTE, } from './adapters/webNavigatio
26
26
  export type { WebNavigationAdapter, WebNavigationAdapterOptions, } from './adapters/webNavigationAdapter.js';
27
27
  export { createWebVoiceAdapter } from './adapters/webVoiceAdapter.js';
28
28
  export type { WebVoiceAdapterOptions } from './adapters/webVoiceAdapter.js';
29
+ export { createWebCredentialAutofillAdapter } from './adapters/webCredentialAutofillAdapter.js';
29
30
  export { createFiodosBackendClient, buildManifestPayload } from './api/backendClient.js';
30
31
  export type { FiodosBackendClientOptions } from './api/backendClient.js';
31
32
  export { createFiodosTelemetry } from './api/backendTelemetry.js';
@@ -36,6 +37,8 @@ export { createBridge } from './bridge/createBridge.js';
36
37
  export type { Bridge } from './bridge/createBridge.js';
37
38
  export { createScreenContextStore } from './context/screenContextStore.js';
38
39
  export type { ScreenContextStore, AgentScreenSnapshot } from './context/screenContextStore.js';
40
+ export { connectDynamicsFormContext, dynamicsFormSnapshot, normalizeDynamicsId, } from './embed/dynamics.js';
41
+ export type { DynamicsFormContextLike, DynamicsSnapshotOptions, DynamicsContextBridge, ScreenContextSink, } from './embed/dynamics.js';
39
42
  export { createSpeechSession } from './speech/speechSession.js';
40
43
  export type { SpeechSession, SpeechSessionOptions, SpeechSessionState, SpeechSessionSnapshot, } from './speech/speechSession.js';
41
44
  export { DEFAULT_AGENT_TIMINGS, DEFAULT_AGENT_CHAINING } from './config/types.js';
package/dist/esm/index.js CHANGED
@@ -23,6 +23,7 @@ export { watchPublishedConfig } from './orb/publishedConfig.js';
23
23
  export { createWebStorageAdapter } from './adapters/webStorageAdapter.js';
24
24
  export { createWebNavigationAdapter, BACK_ROUTE, } from './adapters/webNavigationAdapter.js';
25
25
  export { createWebVoiceAdapter } from './adapters/webVoiceAdapter.js';
26
+ export { createWebCredentialAutofillAdapter } from './adapters/webCredentialAutofillAdapter.js';
26
27
  // ── Backend + telemetry (same wire contract as every platform) ────────────────
27
28
  export { createFiodosBackendClient, buildManifestPayload } from './api/backendClient.js';
28
29
  export { createFiodosTelemetry } from './api/backendTelemetry.js';
@@ -31,6 +32,8 @@ export { AgentApiError, isAgentApiError } from './api/errors.js';
31
32
  export { createBridge } from './bridge/createBridge.js';
32
33
  // ── Screen context ────────────────────────────────────────────────────────────
33
34
  export { createScreenContextStore } from './context/screenContextStore.js';
35
+ // ── Closed-host context adapters (embed mode) ─────────────────────────────────
36
+ export { connectDynamicsFormContext, dynamicsFormSnapshot, normalizeDynamicsId, } from './embed/dynamics.js';
34
37
  // ── Speech session ──────────────────────────────────────────────────────────────
35
38
  export { createSpeechSession } from './speech/speechSession.js';
36
39
  // ── Config / i18n ─────────────────────────────────────────────────────────────