@salesforce/vite-plugin-lwc-ui-bundle 1.133.2 → 1.134.0

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.
package/README.md CHANGED
@@ -140,6 +140,89 @@ Handles `@salesforce/client/*`. Supports `formFactor` (Small/Medium/Large via CS
140
140
 
141
141
  Handles `lightning/primitiveUtils`. Stubs `normalizeBoolean` and `reflectAttribute`.
142
142
 
143
+ ### `lds(adapters?)`
144
+
145
+ Handles LDS (Lightning Data Service) specifiers such as `lightning/uiRecordApi` by routing registered exports to MCP tools. Unregistered exports pass through to normal `lightning/*` resolution.
146
+
147
+ A single specifier often mixes wire and imperative exports, so all three shapes (`wire`, `imperative-mutation`, `imperative-read`) live in the same registry keyed by module + export name:
148
+
149
+ ```js
150
+ lds({
151
+ "lightning/uiRecordApi": {
152
+ getRecord: {
153
+ type: "wire",
154
+ toolName: "getRecordMcpTool",
155
+ configJsonSchema: {
156
+ type: "object",
157
+ properties: { recordId: { type: "string" } },
158
+ required: ["recordId"],
159
+ additionalProperties: false,
160
+ },
161
+ },
162
+ createRecord: {
163
+ type: "imperative-mutation",
164
+ toolName: "createRecordMcpTool",
165
+ configJsonSchema: {
166
+ type: "object",
167
+ properties: {
168
+ apiName: { type: "string" },
169
+ fields: {
170
+ type: "object",
171
+ properties: {},
172
+ required: [],
173
+ additionalProperties: true,
174
+ },
175
+ },
176
+ required: ["apiName", "fields"],
177
+ additionalProperties: false,
178
+ },
179
+ },
180
+ },
181
+ "lightning/uiObjectInfoApi": {
182
+ getObjectInfo_imperative: {
183
+ type: "imperative-read",
184
+ invokerShape: "legacy",
185
+ toolName: "getObjectInfoMcpTool",
186
+ configJsonSchema: {
187
+ type: "object",
188
+ properties: { objectApiName: { type: "string" } },
189
+ required: ["objectApiName"],
190
+ additionalProperties: false,
191
+ },
192
+ },
193
+ },
194
+ });
195
+ ```
196
+
197
+ `configJsonSchema` is OneStore's [`JSONSchema`](https://www.npmjs.com/package/@conduit-client/jsonschema-validate) — `ObjectType` requires `properties`, `required`, and `additionalProperties` to be declared. Validation is performed at invoke time by the same `assertIsValid` used on-platform.
198
+
199
+ #### Supported invoker shapes
200
+
201
+ | `type` | `invokerShape` | Export signature | Error surface |
202
+ | --------------------- | -------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------ |
203
+ | `wire` | — | `WireAdapter` class consumed by `@wire` | Emits `{ data, error }` to the wire callback. |
204
+ | `imperative-mutation` | — | `(config) => Promise<Data>` | Throws on validation or tool error. |
205
+ | `imperative-read` | `query` | `(config) => Promise<{ data }>` | Throws on validation or tool error. |
206
+ | `imperative-read` | `subscribable` | `(config) => Promise<{ data, subscribe }>` | Throws on validation or tool error. |
207
+ | `imperative-read` | `subscribable-refreshable` | `(config) => Promise<{ data, subscribe, refresh }>` | Throws on validation or tool error. |
208
+ | `imperative-read` | `legacy` | `{ invoke(config, context, callback), subscribe(...): Unsubscribe }` | Callback fires with `{ data, error }`; neither throws. |
209
+
210
+ Each shape is a direct delegation to the matching OneStore service descriptor (`Default`, `Query`, `Subscribable`, or `Legacy` `ImperativeBindingsService`). Consumer code is identical whether the import resolves to native implementation on-platform or to this MCP-backed replacement off-platform — no conditional wrapping, no `{ data, error }` indirection for imperative shapes. Write one `try/catch`, ship both places.
211
+
212
+ Because each shape inherits OneStore's invoker wholesale, successful payloads are **deep-frozen** and Err-branch rejections pass through `toError`. Validation failures throw typed subclasses of `JsonSchemaViolationError` (`MissingRequiredPropertyError`, `IncorrectTypeError`, etc.) — the same classes consumers catch on-platform.
213
+
214
+ `legacy` preserves the older `{ invoke, subscribe }` contract. `context` is accepted but ignored. Callback payloads always use `{ data, error }`; `data` is deep-frozen on success.
215
+
216
+ #### `subscribe()` stance
217
+
218
+ For the `legacy`, `subscribable`, and `subscribable-refreshable` read shapes, `subscribe` is **a deliberate no-op off-platform**: the callback never fires, and the returned unsubscribe is idempotent. `refresh()` (on `subscribable-refreshable`) re-executes the underlying MCP tool.
219
+
220
+ This is deliberate: native `subscribe` is driven by a reactive store, and off-platform there is no store to observe. Pretending otherwise would be dishonest.
221
+
222
+ #### OneStore runtime dependencies
223
+
224
+ `@conduit-client/*` is bundled into the plugin's `runtime.js` artifact at plugin-publish time, not re-imported from the consumer's module graph. Consumers don't need to install or declare any `@conduit-client/*` dependency — component code stays identical to its on-platform form. The only runtime peer the virtual module imports from is `@salesforce/sdk-chat`, which bridges to `window.openai` / MCP Apps.
225
+
143
226
  ## Custom Providers
144
227
 
145
228
  Create custom providers by implementing the provider interface:
@@ -1,10 +1,65 @@
1
+ import { JSONSchema } from '@conduit-client/jsonschema-validate';
1
2
  import { Plugin } from 'vite';
2
- import { JsonSchema } from './types';
3
+ import { ReadInvokerShape } from './types';
3
4
  export interface LdsWireAdapterConfig {
4
5
  type: "wire";
5
6
  toolName: string;
6
- configJsonSchema: JsonSchema;
7
+ configJsonSchema: JSONSchema;
7
8
  }
8
- export type LdsAdapterRegistry = Record<string, Record<string, LdsWireAdapterConfig>>;
9
+ /**
10
+ * Imperative **mutation** adapter. Always an async
11
+ * `(config) => Promise<Data>` that throws on validation or tool error —
12
+ * matching OneStore's `DefaultImperativeBindingsService`, the only service a
13
+ * mutation ever uses on platform. Mutations do not carry an `invokerShape`:
14
+ * `subscribe`/`refresh` make no sense on write, and allowing them here
15
+ * would drift off-platform from on-platform semantics.
16
+ */
17
+ export interface LdsImperativeMutationAdapterConfig {
18
+ type: "imperative-mutation";
19
+ toolName: string;
20
+ configJsonSchema: JSONSchema;
21
+ }
22
+ /**
23
+ * Public alias for the read-shape union defined in `runtime.ts`. Re-exported
24
+ * from this module so consumers don't have to import from the runtime entry
25
+ * point, while keeping the union pinned to one source of truth.
26
+ *
27
+ * Off-platform there is no store, so `subscribe` is a deliberate no-op
28
+ * (callback never fires, returned unsubscribe is idempotent) and `refresh`
29
+ * re-executes the underlying MCP tool. This preserves the OneStore API
30
+ * surface for code ported verbatim.
31
+ */
32
+ export type LdsImperativeReadInvokerShape = ReadInvokerShape;
33
+ export interface LdsImperativeReadAdapterConfig {
34
+ type: "imperative-read";
35
+ invokerShape: LdsImperativeReadInvokerShape;
36
+ toolName: string;
37
+ configJsonSchema: JSONSchema;
38
+ }
39
+ export type LdsAdapterConfig = LdsWireAdapterConfig | LdsImperativeMutationAdapterConfig | LdsImperativeReadAdapterConfig;
40
+ export type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>>;
41
+ /**
42
+ * LDS provider — rewrites registered `lightning/*` imports (e.g.
43
+ * `lightning/uiRecordApi`) to MCP-tool-backed virtual modules. Unregistered
44
+ * exports pass through to the normal `lightning/*` resolution.
45
+ *
46
+ * Three Vite hooks do the work:
47
+ *
48
+ * - **`transform`** — parses each `.js` / `.ts` file with `es-module-lexer`,
49
+ * finds named imports from registered specifiers, and rewrites them to pull
50
+ * registered names from `sf-lds-adapter:<specifier>` while leaving
51
+ * unregistered names pointing at the original specifier.
52
+ *
53
+ * - **`resolveId`** — maps `sf-lds-adapter:<specifier>` to a `\0`-prefixed
54
+ * virtual module ID, preventing Rollup from attempting a filesystem lookup.
55
+ *
56
+ * - **`load`** — generates the virtual module, emitting an MCP-backed
57
+ * `createWireAdapter(...)` class for every `type: 'wire'` entry,
58
+ * `createMutationAdapter(...)` for every `type: 'imperative-mutation'` entry,
59
+ * and `createReadAdapter(...)` for every `type: 'imperative-read'` entry.
60
+ *
61
+ * Only specifiers present in the `adapters` registry are intercepted; imports from
62
+ * unregistered specifiers pass through unchanged.
63
+ */
9
64
  export declare function lds(adapters?: LdsAdapterRegistry): Plugin;
10
65
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,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AACH,wBAAgB,GAAG,CAAC,QAAQ,GAAE,kBAAqC,GAAG,MAAM,CA6F3E"}
@@ -18,9 +18,91 @@ const DEFAULT_ADAPTERS = {
18
18
  type: "object",
19
19
  properties: {
20
20
  recordId: { type: "string" },
21
- fields: { type: "array", items: { type: "string" } }
21
+ layoutTypes: {
22
+ anyOf: [{ type: "array", items: { type: "string" } }, { type: "null" }]
23
+ },
24
+ fields: {
25
+ anyOf: [{ type: "array", items: { type: "string" } }, { type: "null" }]
26
+ }
22
27
  },
23
- required: ["recordId"]
28
+ required: ["recordId"],
29
+ additionalProperties: false,
30
+ anyOf: [
31
+ {
32
+ type: "object",
33
+ properties: {
34
+ fields: { type: "array", items: { type: "string" }, minItems: 1 }
35
+ },
36
+ required: ["fields"],
37
+ additionalProperties: true
38
+ },
39
+ {
40
+ type: "object",
41
+ properties: {
42
+ layoutTypes: {
43
+ type: "array",
44
+ items: { type: "string" },
45
+ minItems: 1
46
+ }
47
+ },
48
+ required: ["layoutTypes"],
49
+ additionalProperties: true
50
+ }
51
+ ]
52
+ }
53
+ },
54
+ createRecord: {
55
+ type: "imperative-mutation",
56
+ toolName: "createRecordMcpTool",
57
+ configJsonSchema: {
58
+ type: "object",
59
+ properties: {
60
+ apiName: { type: "string" },
61
+ fields: {
62
+ type: "object",
63
+ properties: {},
64
+ required: [],
65
+ additionalProperties: true
66
+ }
67
+ },
68
+ required: ["apiName", "fields"],
69
+ additionalProperties: false
70
+ }
71
+ },
72
+ updateRecord: {
73
+ type: "imperative-mutation",
74
+ toolName: "updateRecordMcpTool",
75
+ configJsonSchema: {
76
+ type: "object",
77
+ properties: {
78
+ recordId: { type: "string" },
79
+ fields: {
80
+ type: "object",
81
+ properties: {},
82
+ required: [],
83
+ additionalProperties: true
84
+ }
85
+ },
86
+ required: ["recordId", "fields"],
87
+ additionalProperties: false
88
+ }
89
+ }
90
+ },
91
+ "lightning/uiObjectInfoApi": {
92
+ // On-platform this is a `{ invoke, subscribe }` callback surface
93
+ // emitting `{ data, error }`. The legacy invoker shape preserves that
94
+ // contract verbatim, so ported consumers keep their call sites.
95
+ getObjectInfo_imperative: {
96
+ type: "imperative-read",
97
+ invokerShape: "legacy",
98
+ toolName: "getObjectInfoMcpTool",
99
+ configJsonSchema: {
100
+ type: "object",
101
+ properties: {
102
+ objectApiName: { type: "string" }
103
+ },
104
+ required: ["objectApiName"],
105
+ additionalProperties: false
24
106
  }
25
107
  }
26
108
  }
@@ -91,9 +173,11 @@ function lds(adapters = DEFAULT_ADAPTERS) {
91
173
  const moduleAdapters = adapters[specifier];
92
174
  if (!moduleAdapters) return null;
93
175
  const lines = [adapterBaseSource];
94
- for (const [name, { type: _type, ...cfg }] of Object.entries(moduleAdapters)) {
176
+ for (const [name, entry] of Object.entries(moduleAdapters)) {
177
+ const { type, ...cfg } = entry;
178
+ const factory = type === "wire" ? "createWireAdapter" : type === "imperative-mutation" ? "createMutationAdapter" : "createReadAdapter";
95
179
  lines.push(
96
- `export const ${name} = createWireAdapter(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`
180
+ `export const ${name} = ${factory}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`
97
181
  );
98
182
  }
99
183
  return lines.join("\n");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/providers/lds/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { init, parse } from \"es-module-lexer\";\nimport MagicString from \"magic-string\";\nimport type { Plugin } from \"vite\";\nimport type { JsonSchema } from \"./types\";\n\nconst ADAPTER_PREFIX = \"sf-lds-adapter:\";\nconst ADAPTER_ID_PREFIX = \"\\0\" + ADAPTER_PREFIX;\n\nconst adapterBaseSource = readFileSync(\n\tjoin(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"),\n\t\"utf-8\",\n);\n\nexport interface LdsWireAdapterConfig {\n\ttype: \"wire\";\n\ttoolName: string;\n\tconfigJsonSchema: JsonSchema;\n}\n\nexport type LdsAdapterRegistry = Record<string, Record<string, LdsWireAdapterConfig>>;\n\nconst DEFAULT_ADAPTERS: LdsAdapterRegistry = {\n\t\"lightning/uiRecordApi\": {\n\t\tgetRecord: {\n\t\t\ttype: \"wire\",\n\t\t\ttoolName: \"getRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tfields: { type: \"array\", items: { type: \"string\" } },\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\"],\n\t\t\t},\n\t\t},\n\t},\n};\n\nfunction parseImportSpecifiers(bracesContent: string): { original: string; full: string }[] {\n\treturn bracesContent\n\t\t.split(\",\")\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst asIdx = entry.indexOf(\" as \");\n\t\t\tconst original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();\n\t\t\treturn { original, full: entry };\n\t\t});\n}\n\nexport function lds(adapters: LdsAdapterRegistry = DEFAULT_ADAPTERS): Plugin {\n\tconst specifierSnippets = Object.keys(adapters).flatMap((s) => [`'${s}'`, `\"${s}\"`]);\n\n\treturn {\n\t\tname: \"vite-plugin-lds\",\n\t\tenforce: \"pre\",\n\n\t\tasync transform(code, id) {\n\t\t\tconst cleanId = id.split(\"?\")[0] ?? id;\n\t\t\tif (!cleanId.endsWith(\".js\") && !cleanId.endsWith(\".ts\")) return null;\n\t\t\tif (cleanId.includes(\"/node_modules/\")) return null;\n\t\t\tif (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;\n\n\t\t\tawait init;\n\n\t\t\tlet imports: ReturnType<typeof parse>[0];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code);\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst relevant = imports.filter(\n\t\t\t\t(imp) => imp.d === -1 && imp.n !== undefined && imp.n in adapters,\n\t\t\t);\n\t\t\tif (relevant.length === 0) return null;\n\n\t\t\tconst s = new MagicString(code);\n\t\t\tlet changed = false;\n\n\t\t\tfor (const imp of relevant) {\n\t\t\t\tconst { ss: start, se: end, n: specifier } = imp;\n\t\t\t\tconst statement = code.slice(start, end);\n\n\t\t\t\tconst openBrace = statement.indexOf(\"{\");\n\t\t\t\tconst closeBrace = statement.indexOf(\"}\");\n\t\t\t\tif (openBrace === -1 || closeBrace === -1) continue;\n\n\t\t\t\tconst bracesContent = statement.slice(openBrace + 1, closeBrace);\n\t\t\t\tconst moduleAdapters = adapters[specifier!]!;\n\t\t\t\tconst parsedImport = parseImportSpecifiers(bracesContent);\n\t\t\t\tconst registered = parsedImport.filter((p) => p.original in moduleAdapters);\n\t\t\t\tconst unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));\n\n\t\t\t\tif (registered.length === 0) continue;\n\n\t\t\t\tconst parts: string[] = [\n\t\t\t\t\t`import { ${registered.map((p) => p.full).join(\", \")} } from '${ADAPTER_PREFIX}${specifier}';`,\n\t\t\t\t];\n\n\t\t\t\tif (unregistered.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`import { ${unregistered.map((p) => p.full).join(\", \")} } from '${specifier}';`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ts.overwrite(start, end, parts.join(\"\\n\"));\n\t\t\t\tchanged = true;\n\t\t\t}\n\n\t\t\tif (!changed) return null;\n\t\t\treturn { code: s.toString(), map: s.generateMap({ hires: true }) };\n\t\t},\n\n\t\tresolveId(id) {\n\t\t\tif (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(ADAPTER_ID_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(ADAPTER_ID_PREFIX.length);\n\t\t\tconst moduleAdapters = adapters[specifier];\n\t\t\tif (!moduleAdapters) return null;\n\n\t\t\tconst lines: string[] = [adapterBaseSource];\n\t\t\tfor (const [name, { type: _type, ...cfg }] of Object.entries(moduleAdapters)) {\n\t\t\t\tlines.push(\n\t\t\t\t\t`export const ${name} = createWireAdapter(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn lines.join(\"\\n\");\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;;;;AAaA,MAAM,iBAAiB;AACvB,MAAM,oBAAoB,OAAO;AAEjC,MAAM,oBAAoB;AAAA,EACzB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,YAAY;AAAA,EAC1D;AACD;AAUA,MAAM,mBAAuC;AAAA,EAC5C,yBAAyB;AAAA,IACxB,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,kBAAkB;AAAA,QACjB,MAAM;AAAA,QACN,YAAY;AAAA,UACX,UAAU,EAAE,MAAM,SAAA;AAAA,UAClB,QAAQ,EAAE,MAAM,SAAS,OAAO,EAAE,MAAM,WAAS;AAAA,QAAE;AAAA,QAEpD,UAAU,CAAC,UAAU;AAAA,MAAA;AAAA,IACtB;AAAA,EACD;AAEF;AAEA,SAAS,sBAAsB,eAA6D;AAC3F,SAAO,cACL,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAA,CAAM,EACnB,OAAO,OAAO,EACd,IAAI,CAAC,UAAU;AACf,UAAM,QAAQ,MAAM,QAAQ,MAAM;AAClC,UAAM,WAAW,UAAU,KAAK,MAAM,MAAM,GAAG,KAAK,EAAE,SAAS,MAAM,KAAA;AACrE,WAAO,EAAE,UAAU,MAAM,MAAA;AAAA,EAC1B,CAAC;AACH;AAEO,SAAS,IAAI,WAA+B,kBAA0B;AAC5E,QAAM,oBAAoB,OAAO,KAAK,QAAQ,EAAE,QAAQ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AAG;AAE7B,cAAM,QAAkB;AAAA,UACvB,YAAY,WAAW,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,YAAY,cAAc,GAAG,SAAS;AAAA,QAAA;AAG3F,YAAI,aAAa,SAAS,GAAG;AAC5B,gBAAM;AAAA,YACL,YAAY,aAAa,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,YAAY,SAAS;AAAA,UAAA;AAAA,QAE7E;AAEA,UAAE,UAAU,OAAO,KAAK,MAAM,KAAK,IAAI,CAAC;AACxC,kBAAU;AAAA,MACX;AAEA,UAAI,CAAC,QAAS,QAAO;AACrB,aAAO,EAAE,MAAM,EAAE,YAAY,KAAK,EAAE,YAAY,EAAE,OAAO,KAAA,CAAM,EAAA;AAAA,IAChE;AAAA,IAEA,UAAU,IAAI;AACb,UAAI,GAAG,WAAW,cAAc,UAAU,oBAAoB,GAAG,MAAM,eAAe,MAAM;AAC5F,aAAO;AAAA,IACR;AAAA,IAEA,KAAK,IAAI;AACR,UAAI,CAAC,GAAG,WAAW,iBAAiB,EAAG,QAAO;AAE9C,YAAM,YAAY,GAAG,MAAM,kBAAkB,MAAM;AACnD,YAAM,iBAAiB,SAAS,SAAS;AACzC,UAAI,CAAC,eAAgB,QAAO;AAE5B,YAAM,QAAkB,CAAC,iBAAiB;AAC1C,iBAAW,CAAC,MAAM,EAAE,MAAM,OAAO,GAAG,IAAA,CAAK,KAAK,OAAO,QAAQ,cAAc,GAAG;AAC7E,cAAM;AAAA,UACL,gBAAgB,IAAI,wBAAwB,KAAK,UAAU,IAAI,CAAC,KAAK,KAAK,UAAU,GAAG,CAAC;AAAA,QAAA;AAAA,MAE1F;AACA,aAAO,MAAM,KAAK,IAAI;AAAA,IACvB;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/providers/lds/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { JSONSchema } from \"@conduit-client/jsonschema-validate\";\nimport { init, parse } from \"es-module-lexer\";\nimport MagicString from \"magic-string\";\nimport type { Plugin } from \"vite\";\nimport type { ReadInvokerShape } from \"./types\";\n\n// prefix to write into transformed source code\nconst ADAPTER_PREFIX = \"sf-lds-adapter:\";\n// prefix used to ID the adapter when loading the virtual module\nconst ADAPTER_ID_PREFIX = \"\\0\" + ADAPTER_PREFIX;\n\n// the source of the adapter base module — reused across virtual modules so\n// each generated specifier emits the createWireAdapter / createMutationAdapter /\n// createReadAdapter factories once\nconst adapterBaseSource = readFileSync(\n\tjoin(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"),\n\t\"utf-8\",\n);\n\nexport interface LdsWireAdapterConfig {\n\ttype: \"wire\";\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\n/**\n * Imperative **mutation** adapter. Always an async\n * `(config) => Promise<Data>` that throws on validation or tool error —\n * matching OneStore's `DefaultImperativeBindingsService`, the only service a\n * mutation ever uses on platform. Mutations do not carry an `invokerShape`:\n * `subscribe`/`refresh` make no sense on write, and allowing them here\n * would drift off-platform from on-platform semantics.\n */\nexport interface LdsImperativeMutationAdapterConfig {\n\ttype: \"imperative-mutation\";\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\n/**\n * Public alias for the read-shape union defined in `runtime.ts`. Re-exported\n * from this module so consumers don't have to import from the runtime entry\n * point, while keeping the union pinned to one source of truth.\n *\n * Off-platform there is no store, so `subscribe` is a deliberate no-op\n * (callback never fires, returned unsubscribe is idempotent) and `refresh`\n * re-executes the underlying MCP tool. This preserves the OneStore API\n * surface for code ported verbatim.\n */\nexport type LdsImperativeReadInvokerShape = ReadInvokerShape;\n\nexport interface LdsImperativeReadAdapterConfig {\n\ttype: \"imperative-read\";\n\tinvokerShape: LdsImperativeReadInvokerShape;\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\nexport type LdsAdapterConfig =\n\t| LdsWireAdapterConfig\n\t| LdsImperativeMutationAdapterConfig\n\t| LdsImperativeReadAdapterConfig;\n\nexport type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>>;\n\n/**\n * Default adapter registry.\n * Maps LDS module specifiers to MCP tool-backed implementations. Entries can be\n * wire adapters (`type: 'wire'`), imperative mutations (`type: 'imperative-mutation'`),\n * or imperative reads (`type: 'imperative-read'` + `invokerShape`).\n * Add entries here to support additional lightning/* exports.\n */\nconst DEFAULT_ADAPTERS: LdsAdapterRegistry = {\n\t\"lightning/uiRecordApi\": {\n\t\tgetRecord: {\n\t\t\ttype: \"wire\",\n\t\t\ttoolName: \"getRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tanyOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tfields: { type: \"array\", items: { type: \"string\" }, minItems: 1 },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"fields\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\t\t\ttype: \"array\",\n\t\t\t\t\t\t\t\titems: { type: \"string\" },\n\t\t\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"layoutTypes\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tcreateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\ttoolName: \"createRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tapiName: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"apiName\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t\tupdateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\ttoolName: \"updateRecordMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t\"lightning/uiObjectInfoApi\": {\n\t\t// On-platform this is a `{ invoke, subscribe }` callback surface\n\t\t// emitting `{ data, error }`. The legacy invoker shape preserves that\n\t\t// contract verbatim, so ported consumers keep their call sites.\n\t\tgetObjectInfo_imperative: {\n\t\t\ttype: \"imperative-read\",\n\t\t\tinvokerShape: \"legacy\",\n\t\t\ttoolName: \"getObjectInfoMcpTool\",\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tobjectApiName: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"objectApiName\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n};\n\nfunction parseImportSpecifiers(bracesContent: string): { original: string; full: string }[] {\n\treturn bracesContent\n\t\t.split(\",\")\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst asIdx = entry.indexOf(\" as \");\n\t\t\tconst original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();\n\t\t\treturn { original, full: entry };\n\t\t});\n}\n\n/**\n * LDS provider — rewrites registered `lightning/*` imports (e.g.\n * `lightning/uiRecordApi`) to MCP-tool-backed virtual modules. Unregistered\n * exports pass through to the normal `lightning/*` resolution.\n *\n * Three Vite hooks do the work:\n *\n * - **`transform`** — parses each `.js` / `.ts` file with `es-module-lexer`,\n * finds named imports from registered specifiers, and rewrites them to pull\n * registered names from `sf-lds-adapter:<specifier>` while leaving\n * unregistered names pointing at the original specifier.\n *\n * - **`resolveId`** — maps `sf-lds-adapter:<specifier>` to a `\\0`-prefixed\n * virtual module ID, preventing Rollup from attempting a filesystem lookup.\n *\n * - **`load`** — generates the virtual module, emitting an MCP-backed\n * `createWireAdapter(...)` class for every `type: 'wire'` entry,\n * `createMutationAdapter(...)` for every `type: 'imperative-mutation'` entry,\n * and `createReadAdapter(...)` for every `type: 'imperative-read'` entry.\n *\n * Only specifiers present in the `adapters` registry are intercepted; imports from\n * unregistered specifiers pass through unchanged.\n */\nexport function lds(adapters: LdsAdapterRegistry = DEFAULT_ADAPTERS): Plugin {\n\tconst specifierSnippets = Object.keys(adapters).flatMap((s) => [`'${s}'`, `\"${s}\"`]);\n\n\treturn {\n\t\tname: \"vite-plugin-lds\",\n\t\tenforce: \"pre\",\n\n\t\tasync transform(code, id) {\n\t\t\tconst cleanId = id.split(\"?\")[0] ?? id;\n\t\t\tif (!cleanId.endsWith(\".js\") && !cleanId.endsWith(\".ts\")) return null;\n\t\t\tif (cleanId.includes(\"/node_modules/\")) return null;\n\t\t\tif (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;\n\n\t\t\tawait init;\n\n\t\t\tlet imports: ReturnType<typeof parse>[0];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code);\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst relevant = imports.filter(\n\t\t\t\t(imp) => imp.d === -1 && imp.n !== undefined && imp.n in adapters,\n\t\t\t);\n\t\t\tif (relevant.length === 0) return null;\n\n\t\t\tconst s = new MagicString(code);\n\t\t\tlet changed = false;\n\n\t\t\tfor (const imp of relevant) {\n\t\t\t\tconst { ss: start, se: end, n: specifier } = imp;\n\t\t\t\tconst statement = code.slice(start, end);\n\n\t\t\t\tconst openBrace = statement.indexOf(\"{\");\n\t\t\t\tconst closeBrace = statement.indexOf(\"}\");\n\t\t\t\tif (openBrace === -1 || closeBrace === -1) continue;\n\n\t\t\t\tconst bracesContent = statement.slice(openBrace + 1, closeBrace);\n\t\t\t\tconst moduleAdapters = adapters[specifier!]!;\n\t\t\t\tconst parsedImport = parseImportSpecifiers(bracesContent);\n\t\t\t\tconst registered = parsedImport.filter((p) => p.original in moduleAdapters);\n\t\t\t\tconst unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));\n\n\t\t\t\tif (registered.length === 0) continue;\n\n\t\t\t\tconst parts: string[] = [\n\t\t\t\t\t`import { ${registered.map((p) => p.full).join(\", \")} } from '${ADAPTER_PREFIX}${specifier}';`,\n\t\t\t\t];\n\n\t\t\t\tif (unregistered.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`import { ${unregistered.map((p) => p.full).join(\", \")} } from '${specifier}';`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ts.overwrite(start, end, parts.join(\"\\n\"));\n\t\t\t\tchanged = true;\n\t\t\t}\n\n\t\t\tif (!changed) return null;\n\t\t\treturn { code: s.toString(), map: s.generateMap({ hires: true }) };\n\t\t},\n\n\t\tresolveId(id) {\n\t\t\tif (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(ADAPTER_ID_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(ADAPTER_ID_PREFIX.length);\n\t\t\tconst moduleAdapters = adapters[specifier];\n\t\t\tif (!moduleAdapters) return null;\n\n\t\t\t// create lines of code used to create MCP tool based adapters\n\t\t\tconst lines: string[] = [adapterBaseSource];\n\t\t\tfor (const [name, entry] of Object.entries(moduleAdapters)) {\n\t\t\t\tconst { type, ...cfg } = entry;\n\t\t\t\tconst factory =\n\t\t\t\t\ttype === \"wire\"\n\t\t\t\t\t\t? \"createWireAdapter\"\n\t\t\t\t\t\t: type === \"imperative-mutation\"\n\t\t\t\t\t\t\t? \"createMutationAdapter\"\n\t\t\t\t\t\t\t: \"createReadAdapter\";\n\t\t\t\tlines.push(\n\t\t\t\t\t`export const ${name} = ${factory}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn lines.join(\"\\n\");\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;;;;AAeA,MAAM,iBAAiB;AAEvB,MAAM,oBAAoB,OAAO;AAKjC,MAAM,oBAAoB;AAAA,EACzB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,YAAY;AAAA,EAC1D;AACD;AAuDA,MAAM,mBAAuC;AAAA,EAC5C,yBAAyB;AAAA,IACxB,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,kBAAkB;AAAA,QACjB,MAAM;AAAA,QACN,YAAY;AAAA,UACX,UAAU,EAAE,MAAM,SAAA;AAAA,UAClB,a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,UAAA;AAAA,QAE7E;AAEA,UAAE,UAAU,OAAO,KAAK,MAAM,KAAK,IAAI,CAAC;AACxC,kBAAU;AAAA,MACX;AAEA,UAAI,CAAC,QAAS,QAAO;AACrB,aAAO,EAAE,MAAM,EAAE,YAAY,KAAK,EAAE,YAAY,EAAE,OAAO,KAAA,CAAM,EAAA;AAAA,IAChE;AAAA,IAEA,UAAU,IAAI;AACb,UAAI,GAAG,WAAW,cAAc,UAAU,oBAAoB,GAAG,MAAM,eAAe,MAAM;AAC5F,aAAO;AAAA,IACR;AAAA,IAEA,KAAK,IAAI;AACR,UAAI,CAAC,GAAG,WAAW,iBAAiB,EAAG,QAAO;AAE9C,YAAM,YAAY,GAAG,MAAM,kBAAkB,MAAM;AACnD,YAAM,iBAAiB,SAAS,SAAS;AACzC,UAAI,CAAC,eAAgB,QAAO;AAG5B,YAAM,QAAkB,CAAC,iBAAiB;AAC1C,iBAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,cAAc,GAAG;AAC3D,cAAM,EAAE,MAAM,GAAG,IAAA,IAAQ;AACzB,cAAM,UACL,SAAS,SACN,sBACA,SAAS,wBACR,0BACA;AACL,cAAM;AAAA,UACL,gBAAgB,IAAI,MAAM,OAAO,IAAI,KAAK,UAAU,IAAI,CAAC,KAAK,KAAK,UAAU,GAAG,CAAC;AAAA,QAAA;AAAA,MAEnF;AACA,aAAO,MAAM,KAAK,IAAI;AAAA,IACvB;AAAA,EAAA;AAEF;"}
@@ -1,5 +1,7 @@
1
+ import { buildDefaultImperativeBindingsServiceDescriptor, buildQueryImperativeBindingsServiceDescriptor, buildSubscribableImperativeBindingsServiceDescriptor, buildLegacyImperativeBindingsServiceDescriptor } from "@conduit-client/service-bindings-imperative/v1";
2
+ import { buildLWCWireBindingsServiceDescriptor } from "@conduit-client/service-bindings-lwc/v1";
3
+ import { err, ok, toError, buildSubscribableResult } from "@conduit-client/utils";
1
4
  import { getChatSDK } from "@salesforce/sdk-chat";
2
- import { z } from "zod";
3
5
  function normalizeMcpResponse(raw) {
4
6
  if (raw && typeof raw === "object" && "structuredContent" in raw) {
5
7
  return raw.structuredContent;
@@ -20,77 +22,147 @@ function normalizeMcpResponse(raw) {
20
22
  }
21
23
  return raw ?? {};
22
24
  }
23
- function buildSchema(schema) {
24
- switch (schema.type) {
25
- case "string":
26
- return z.string();
27
- case "number":
28
- return z.number();
29
- case "integer":
30
- return z.number().int();
31
- case "boolean":
32
- return z.boolean();
33
- case "array":
34
- return z.array(buildSchema(schema.items));
35
- case "object": {
36
- const required = new Set(schema.required ?? []);
37
- const shape = Object.fromEntries(
38
- Object.entries(schema.properties ?? {}).map(
39
- ([key, val]) => [key, required.has(key) ? buildSchema(val) : buildSchema(val).optional()]
40
- )
41
- );
42
- return z.object(shape);
25
+ function extractToolErrorText(raw) {
26
+ const content = raw.content;
27
+ if (!Array.isArray(content)) return "";
28
+ return content.map((c) => {
29
+ if (c && typeof c === "object" && c.type === "text") {
30
+ return c.text ?? "";
43
31
  }
44
- default:
45
- return z.unknown();
46
- }
32
+ return "";
33
+ }).join(" ").trim();
47
34
  }
48
- function createWireAdapter(name, cfg) {
49
- const toolName = cfg.toolName;
50
- const schema = buildSchema(cfg.configJsonSchema);
51
- class McpToolBackedWireAdapter {
52
- callback;
53
- config = null;
54
- constructor(callback) {
55
- this.callback = callback;
56
- this.config = null;
35
+ class McpToolCommand {
36
+ constructor(adapterName, toolName, params, unwrap) {
37
+ this.adapterName = adapterName;
38
+ this.toolName = toolName;
39
+ this.params = params;
40
+ this.unwrap = unwrap;
41
+ }
42
+ async execute() {
43
+ try {
44
+ const app = await getChatSDK();
45
+ if (!app.callTool) {
46
+ return err(
47
+ new Error(
48
+ `[${this.adapterName}] sdk.callTool is not available on this surface. Make sure window.openai is configured or the component is running in an MCP Apps / OpenAI chat context.`
49
+ )
50
+ );
51
+ }
52
+ const raw = await app.callTool({
53
+ toolName: this.toolName,
54
+ params: this.params ?? void 0
55
+ });
56
+ if (raw && typeof raw === "object" && raw.isError) {
57
+ return err(new Error(extractToolErrorText(raw) || "MCP tool error"));
58
+ }
59
+ const payload = normalizeMcpResponse(raw);
60
+ return this.unwrap ? this.unwrap(payload) : ok(payload);
61
+ } catch (e) {
62
+ return err(e instanceof Error ? e : new Error(String(e)));
57
63
  }
58
- connect() {
59
- this.run();
64
+ }
65
+ }
66
+ const noopUnsubscribe = () => {
67
+ };
68
+ const noopSubscribe = (_cb) => noopUnsubscribe;
69
+ class McpToolSubscribableCommand {
70
+ constructor(adapterName, toolName, params, unwrap) {
71
+ this.adapterName = adapterName;
72
+ this.toolName = toolName;
73
+ this.params = params;
74
+ this.unwrap = unwrap;
75
+ }
76
+ async execute() {
77
+ const base = new McpToolCommand(
78
+ this.adapterName,
79
+ this.toolName,
80
+ this.params,
81
+ this.unwrap
82
+ );
83
+ const result = await base.execute();
84
+ const refresh = async () => {
85
+ const next = await new McpToolCommand(
86
+ this.adapterName,
87
+ this.toolName,
88
+ this.params,
89
+ this.unwrap
90
+ ).execute();
91
+ return next.isOk() ? ok(void 0) : err(next.error);
92
+ };
93
+ return buildSubscribableResult(result, noopSubscribe, refresh);
94
+ }
95
+ }
96
+ const defaultImperativeService = buildDefaultImperativeBindingsServiceDescriptor().service;
97
+ const queryImperativeService = buildQueryImperativeBindingsServiceDescriptor().service;
98
+ const subscribableImperativeService = buildSubscribableImperativeBindingsServiceDescriptor().service;
99
+ const legacyImperativeService = buildLegacyImperativeBindingsServiceDescriptor().service;
100
+ function createMutationAdapter(name, cfg) {
101
+ const getCommand = (options) => {
102
+ options.assertIsValid(options.params[0], cfg.configJsonSchema);
103
+ return new McpToolCommand(name, cfg.toolName, options.params[0]);
104
+ };
105
+ const invoker = defaultImperativeService.bind(getCommand);
106
+ return (...params) => Promise.resolve(invoker(...params));
107
+ }
108
+ function createReadAdapter(name, cfg) {
109
+ const getSubscribableCommand = (options) => {
110
+ options.assertIsValid(options.params[0], cfg.configJsonSchema);
111
+ return new McpToolSubscribableCommand(name, cfg.toolName, options.params[0]);
112
+ };
113
+ switch (cfg.invokerShape) {
114
+ case "query": {
115
+ const getCommand = (options) => {
116
+ options.assertIsValid(options.params[0], cfg.configJsonSchema);
117
+ return new McpToolCommand(name, cfg.toolName, options.params[0]);
118
+ };
119
+ const invoker = queryImperativeService.bind(getCommand);
120
+ return (...params) => Promise.resolve(invoker(...params));
60
121
  }
61
- // eslint-disable-next-line @typescript-eslint/no-empty-function
62
- disconnect() {
122
+ case "subscribable": {
123
+ const invoker = subscribableImperativeService.bind(
124
+ getSubscribableCommand,
125
+ false
126
+ );
127
+ return (...params) => Promise.resolve(invoker(...params));
63
128
  }
64
- update(config) {
65
- this.config = config;
66
- this.run();
129
+ case "subscribable-refreshable": {
130
+ const invoker = subscribableImperativeService.bind(
131
+ getSubscribableCommand,
132
+ true
133
+ );
134
+ return (...params) => Promise.resolve(invoker(...params));
67
135
  }
68
- async run() {
69
- if (!schema.safeParse(this.config).success) {
70
- this.callback({ data: void 0, error: void 0 });
71
- return;
72
- }
73
- try {
74
- const app = await getChatSDK();
75
- if (!app.callTool) {
76
- throw new Error(
77
- `[${name}] sdk.callTool is not available on this surface. Make sure window.openai is configured or the component is running in an MCP Apps / OpenAI chat context.`
78
- );
79
- }
80
- const raw = await app.callTool({
81
- toolName,
82
- params: this.config ?? void 0
83
- });
84
- const result = normalizeMcpResponse(raw);
85
- this.callback({ data: result?.data, error: result?.error });
86
- } catch (e) {
87
- this.callback({ data: void 0, error: e });
88
- }
136
+ case "legacy": {
137
+ const getLegacyCommand = (options) => {
138
+ options.assertIsValid(options.config, cfg.configJsonSchema);
139
+ return new McpToolSubscribableCommand(name, cfg.toolName, options.config);
140
+ };
141
+ return legacyImperativeService.bind(getLegacyCommand);
89
142
  }
143
+ default:
144
+ throw new Error(
145
+ `[${name}] unsupported invokerShape: ${String(cfg.invokerShape)}. Expected 'legacy' | 'query' | 'subscribable' | 'subscribable-refreshable'.`
146
+ );
147
+ }
148
+ }
149
+ const lwcWireBindingsService = buildLWCWireBindingsServiceDescriptor().service;
150
+ function unwrapWireEnvelope(payload) {
151
+ const envelope = payload;
152
+ if (envelope && envelope.error !== void 0 && envelope.error !== null) {
153
+ return err(toError(envelope.error));
90
154
  }
91
- return McpToolBackedWireAdapter;
155
+ return ok(envelope?.data);
156
+ }
157
+ function createWireAdapter(name, cfg) {
158
+ return lwcWireBindingsService.bind(
159
+ (config) => new McpToolCommand(name, cfg.toolName, config, unwrapWireEnvelope),
160
+ cfg.configJsonSchema
161
+ );
92
162
  }
93
163
  export {
164
+ createMutationAdapter,
165
+ createReadAdapter,
94
166
  createWireAdapter
95
167
  };
96
168
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sources":["../../../src/providers/shared/normalize-mcp-response.ts","../../../src/providers/lds/runtime.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\n/**\n * Unwraps the MCP tool transport envelope and returns the tool's payload as-is.\n *\n * Handles the three surface shapes `sdk.callTool()` can resolve with:\n * - MCP Apps surface: `{ structuredContent, content }`\n * - OpenAI surface: `{ result: \"<JSON string>\" }`, where the JSON may itself be\n * an MCP content array (`[{ type: 'text', text: \"<JSON string>\" }, ...]`)\n * - Fallback: the raw value returned by `callTool`\n *\n * The shape of the unwrapped payload is the tool's responsibility — this helper\n * does not project out `data` / `error` / `errors`. Callers read whichever keys\n * their tool contract defines.\n */\nexport function normalizeMcpResponse(raw: unknown): unknown {\n\tif (raw && typeof raw === \"object\" && \"structuredContent\" in raw) {\n\t\treturn (raw as { structuredContent: unknown }).structuredContent;\n\t}\n\n\tif (raw && typeof raw === \"object\" && typeof (raw as { result?: unknown }).result === \"string\") {\n\t\tconst parsed = JSON.parse((raw as { result: string }).result);\n\t\tif (Array.isArray(parsed)) {\n\t\t\tconst textBlock = parsed.find(\n\t\t\t\t(b: { type?: string; text?: string }) =>\n\t\t\t\t\tb && b.type === \"text\" && typeof b.text === \"string\",\n\t\t\t);\n\t\t\tconst text = textBlock ? textBlock.text : null;\n\t\t\tif (text) {\n\t\t\t\treturn JSON.parse(text);\n\t\t\t}\n\t\t\treturn {};\n\t\t}\n\t\treturn parsed;\n\t}\n\n\treturn raw ?? {};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { getChatSDK } from \"@salesforce/sdk-chat\";\nimport { z, type ZodType } from \"zod\";\nimport type { JsonSchema } from \"./types\";\nimport { normalizeMcpResponse } from \"../shared/normalize-mcp-response\";\n\nexport type { JsonSchema };\n\ntype WireCallback = (result: { data: unknown; error: unknown }) => void;\n\nfunction buildSchema(schema: JsonSchema): ZodType {\n\tswitch (schema.type) {\n\t\tcase \"string\":\n\t\t\treturn z.string();\n\t\tcase \"number\":\n\t\t\treturn z.number();\n\t\tcase \"integer\":\n\t\t\treturn z.number().int();\n\t\tcase \"boolean\":\n\t\t\treturn z.boolean();\n\t\tcase \"array\":\n\t\t\treturn z.array(buildSchema(schema.items as JsonSchema));\n\t\tcase \"object\": {\n\t\t\tconst required = new Set<string>((schema.required as string[]) ?? []);\n\t\t\tconst shape = Object.fromEntries(\n\t\t\t\tObject.entries((schema.properties as Record<string, JsonSchema>) ?? {}).map(\n\t\t\t\t\t([key, val]) => [key, required.has(key) ? buildSchema(val) : buildSchema(val).optional()],\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn z.object(shape);\n\t\t}\n\t\tdefault:\n\t\t\treturn z.unknown();\n\t}\n}\n\ninterface AdapterConfig {\n\ttoolName: string;\n\tconfigJsonSchema: JsonSchema;\n}\n\nexport function createWireAdapter(name: string, cfg: AdapterConfig) {\n\tconst toolName = cfg.toolName;\n\tconst schema = buildSchema(cfg.configJsonSchema);\n\tclass McpToolBackedWireAdapter {\n\t\tcallback: WireCallback;\n\t\tconfig: Record<string, unknown> | null = null;\n\n\t\tconstructor(callback: WireCallback) {\n\t\t\tthis.callback = callback;\n\t\t\tthis.config = null;\n\t\t}\n\n\t\tconnect() {\n\t\t\tthis.run();\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\t\tdisconnect() {}\n\n\t\tupdate(config: Record<string, unknown> | null) {\n\t\t\tthis.config = config;\n\t\t\tthis.run();\n\t\t}\n\n\t\tasync run() {\n\t\t\tif (!schema.safeParse(this.config).success) {\n\t\t\t\tthis.callback({ data: undefined, error: undefined });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst app = await getChatSDK();\n\n\t\t\t\tif (!app.callTool) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[${name}] sdk.callTool is not available on this surface. ` +\n\t\t\t\t\t\t\t\"Make sure window.openai is configured or the component is running in \" +\n\t\t\t\t\t\t\t\"an MCP Apps / OpenAI chat context.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst raw = await app.callTool({\n\t\t\t\t\ttoolName,\n\t\t\t\t\tparams: this.config ?? undefined,\n\t\t\t\t});\n\n\t\t\t\tconst result = normalizeMcpResponse(raw) as { data?: unknown; error?: unknown };\n\n\t\t\t\tthis.callback({ data: result?.data, error: result?.error });\n\t\t\t} catch (e) {\n\t\t\t\tthis.callback({ data: undefined, error: e });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn McpToolBackedWireAdapter;\n}\n"],"names":[],"mappings":";;AAmBO,SAAS,qBAAqB,KAAuB;AAC3D,MAAI,OAAO,OAAO,QAAQ,YAAY,uBAAuB,KAAK;AACjE,WAAQ,IAAuC;AAAA,EAChD;AAEA,MAAI,OAAO,OAAO,QAAQ,YAAY,OAAQ,IAA6B,WAAW,UAAU;AAC/F,UAAM,SAAS,KAAK,MAAO,IAA2B,MAAM;AAC5D,QAAI,MAAM,QAAQ,MAAM,GAAG;AAC1B,YAAM,YAAY,OAAO;AAAA,QACxB,CAAC,MACA,KAAK,EAAE,SAAS,UAAU,OAAO,EAAE,SAAS;AAAA,M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,WAAK,IAAA;AAAA,IACN;AAAA,IAEA,MAAM,MAAM;AACX,UAAI,CAAC,OAAO,UAAU,KAAK,MAAM,EAAE,SAAS;AAC3C,aAAK,SAAS,EAAE,MAAM,QAAW,OAAO,QAAW;AACnD;AAAA,MACD;AACA,UAAI;AACH,cAAM,MAAM,MAAM,WAAA;AAElB,YAAI,CAAC,IAAI,UAAU;AAClB,gBAAM,IAAI;AAAA,YACT,IAAI,IAAI;AAAA,UAAA;AAAA,QAIV;AAEA,cAAM,MAAM,MAAM,IAAI,SAAS;AAAA,UAC9B;AAAA,UACA,QAAQ,KAAK,UAAU;AAAA,QAAA,CACvB;AAED,cAAM,SAAS,qBAAqB,GAAG;AAEvC,aAAK,SAAS,EAAE,MAAM,QAAQ,MAAM,OAAO,QAAQ,OAAO;AAAA,MAC3D,SAAS,GAAG;AACX,aAAK,SAAS,EAAE,MAAM,QAAW,OAAO,GAAG;AAAA,MAC5C;AAAA,IACD;AAAA,EAAA;AAGD,SAAO;AACR;"}
1
+ {"version":3,"file":"runtime.js","sources":["../../../src/providers/shared/normalize-mcp-response.ts","../../../src/providers/lds/runtime.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\n/**\n * Unwraps the MCP tool transport envelope and returns the tool's payload as-is.\n *\n * Handles the three surface shapes `sdk.callTool()` can resolve with:\n * - MCP Apps surface: `{ structuredContent, content }`\n * - OpenAI surface: `{ result: \"<JSON string>\" }`, where the JSON may itself be\n * an MCP content array (`[{ type: 'text', text: \"<JSON string>\" }, ...]`)\n * - Fallback: the raw value returned by `callTool`\n *\n * The shape of the unwrapped payload is the tool's responsibility — this helper\n * does not project out `data` / `error` / `errors`. Callers read whichever keys\n * their tool contract defines.\n */\nexport function normalizeMcpResponse(raw: unknown): unknown {\n\tif (raw && typeof raw === \"object\" && \"structuredContent\" in raw) {\n\t\treturn (raw as { structuredContent: unknown }).structuredContent;\n\t}\n\n\tif (raw && typeof raw === \"object\" && typeof (raw as { result?: unknown }).result === \"string\") {\n\t\tconst parsed = JSON.parse((raw as { result: string }).result);\n\t\tif (Array.isArray(parsed)) {\n\t\t\tconst textBlock = parsed.find(\n\t\t\t\t(b: { type?: string; text?: string }) =>\n\t\t\t\t\tb && b.type === \"text\" && typeof b.text === \"string\",\n\t\t\t);\n\t\t\tconst text = textBlock ? textBlock.text : null;\n\t\t\tif (text) {\n\t\t\t\treturn JSON.parse(text);\n\t\t\t}\n\t\t\treturn {};\n\t\t}\n\t\treturn parsed;\n\t}\n\n\treturn raw ?? {};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { ResultCommand, SubscribableResultCommand } from \"@conduit-client/bindings-utils/v1\";\nimport type { assertIsValid, JSONSchema } from \"@conduit-client/jsonschema-validate\";\nimport {\n\tbuildDefaultImperativeBindingsServiceDescriptor,\n\tbuildLegacyImperativeBindingsServiceDescriptor,\n\tbuildQueryImperativeBindingsServiceDescriptor,\n\tbuildSubscribableImperativeBindingsServiceDescriptor,\n} from \"@conduit-client/service-bindings-imperative/v1\";\nimport { buildLWCWireBindingsServiceDescriptor } from \"@conduit-client/service-bindings-lwc/v1\";\nimport {\n\tbuildSubscribableResult,\n\terr,\n\tok,\n\ttoError,\n\ttype Callback,\n\ttype Result,\n\ttype Unsubscribe,\n} from \"@conduit-client/utils\";\nimport { getChatSDK } from \"@salesforce/sdk-chat\";\nimport type { ReadInvokerShape } from \"./types\";\nimport { normalizeMcpResponse } from \"../shared/normalize-mcp-response\";\n\ninterface WireAdapterConfig {\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\ninterface MutationAdapterConfig {\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\ninterface ReadAdapterConfig {\n\tinvokerShape: ReadInvokerShape;\n\ttoolName: string;\n\tconfigJsonSchema: JSONSchema;\n}\n\n/**\n * Optional envelope splitter. Converts the normalized MCP payload into a\n * `Result<Data, Error>` — used by the wire adapter so tools that return\n * `{ data, error }` land on OneStore's Err branch when `error` is set.\n * Imperative callers leave this unset and get the raw payload wrapped in\n * `ok(...)`.\n */\ntype UnwrapEnvelope<Data> = (payload: unknown) => Result<Data, Error>;\n\n/**\n * Pulls a human-readable message out of an MCP error response\n * (`{ isError: true, content: [{ type: 'text', text: ... }, ...] }`).\n * Returns an empty string if no text content is present so the caller can\n * supply a fallback.\n */\nfunction extractToolErrorText(raw: unknown): string {\n\tconst content = (raw as { content?: unknown }).content;\n\tif (!Array.isArray(content)) return \"\";\n\treturn content\n\t\t.map((c) => {\n\t\t\tif (c && typeof c === \"object\" && (c as { type?: string }).type === \"text\") {\n\t\t\t\treturn (c as { text?: string }).text ?? \"\";\n\t\t\t}\n\t\t\treturn \"\";\n\t\t})\n\t\t.join(\" \")\n\t\t.trim();\n}\n\n/**\n * `Command` implementation that calls the configured MCP tool. One class,\n * reused across imperative and wire adapters.\n *\n * `execute()` returns a `Result<Data, unknown>`:\n * - `ok(data)` when the tool resolves — `data` is the unwrapped payload from\n * `normalizeMcpResponse` (or the result of the optional `unwrap` hook).\n * - `err(error)` when the tool rejects, when `sdk.callTool` is unavailable,\n * or when the `unwrap` hook returns `err(...)`.\n *\n * OneStore's `DefaultImperativeBindingsService` wraps this: on `ok(v)` it\n * deep-freezes and returns `v`; on `err(e)` it re-throws via `toError`. Sync\n * throws from `assertIsValid` in the `getCommand` factory are funneled through\n * `throwUserlandError`. `LWCWireBindingsService` wraps the same command\n * differently — it emits `{ data, error }` to the wire callback and attaches\n * freeze / race-guard / incomplete-config behavior.\n */\nclass McpToolCommand<Data> implements ResultCommand<Data, Error> {\n\tconstructor(\n\t\tprivate readonly adapterName: string,\n\t\tprivate readonly toolName: string,\n\t\tprivate readonly params: unknown,\n\t\tprivate readonly unwrap?: UnwrapEnvelope<Data>,\n\t) {}\n\n\tasync execute(): Promise<Result<Data, Error>> {\n\t\ttry {\n\t\t\tconst app = await getChatSDK();\n\t\t\tif (!app.callTool) {\n\t\t\t\treturn err(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t`[${this.adapterName}] sdk.callTool is not available on this surface. ` +\n\t\t\t\t\t\t\t\"Make sure window.openai is configured or the component is running \" +\n\t\t\t\t\t\t\t\"in an MCP Apps / OpenAI chat context.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst raw = await app.callTool({\n\t\t\t\ttoolName: this.toolName,\n\t\t\t\tparams: (this.params as Record<string, unknown>) ?? undefined,\n\t\t\t});\n\t\t\t// The MCP SDK converts handler throws into a resolved tool response\n\t\t\t// with `{ isError: true, content: [...] }` — not a transport\n\t\t\t// rejection. Surface it as an Err here so the default invoker\n\t\t\t// re-throws and the wire/legacy adapters route it through their\n\t\t\t// error channel.\n\t\t\tif (raw && typeof raw === \"object\" && (raw as { isError?: boolean }).isError) {\n\t\t\t\treturn err(new Error(extractToolErrorText(raw) || \"MCP tool error\"));\n\t\t\t}\n\t\t\tconst payload = normalizeMcpResponse(raw);\n\t\t\treturn this.unwrap ? this.unwrap(payload) : ok(payload as Data);\n\t\t} catch (e) {\n\t\t\treturn err(e instanceof Error ? e : new Error(String(e)));\n\t\t}\n\t}\n}\n\n// Off-platform has no store to observe. `subscribe` never fires the callback;\n// the returned unsubscribe is a safe no-op. Module-level so `refresh()`\n// doesn't re-allocate.\nconst noopUnsubscribe: Unsubscribe = () => {\n\t// no store to unsubscribe from off-platform\n};\nconst noopSubscribe = (_cb: Callback<Result<unknown, unknown>>): Unsubscribe => noopUnsubscribe;\n\n/**\n * Adapts `McpToolCommand` into a `SubscribableResultCommand`. Wraps the\n * command's `Result` with `buildSubscribableResult`, supplying:\n * - `subscribe`: no-op — off-platform has no store, so the callback never\n * fires. Returned unsubscribe is idempotent.\n * - `refresh`: builds a fresh `McpToolCommand` and re-executes it so each\n * refresh issues a new MCP tool call. Returns `Result<void, Error>`\n * (ok → undefined; err → the error from the fresh execute).\n *\n * This shim is what lets OneStore's Subscribable and Legacy services run\n * verbatim against MCP: their invokers gate on `isSubscribableResult`, which\n * requires the command's `execute()` to resolve a `SubscribableResult` (not\n * a plain `Result`). The deliberate \"subscribe that doesn't subscribe\"\n * preserves the OneStore API surface so ported code keeps its call sites.\n */\nclass McpToolSubscribableCommand<Data> implements SubscribableResultCommand<Data, Error> {\n\tconstructor(\n\t\tprivate readonly adapterName: string,\n\t\tprivate readonly toolName: string,\n\t\tprivate readonly params: unknown,\n\t\tprivate readonly unwrap?: UnwrapEnvelope<Data>,\n\t) {}\n\n\tasync execute() {\n\t\tconst base = new McpToolCommand<Data>(\n\t\t\tthis.adapterName,\n\t\t\tthis.toolName,\n\t\t\tthis.params,\n\t\t\tthis.unwrap,\n\t\t);\n\t\tconst result = await base.execute();\n\t\tconst refresh = async () => {\n\t\t\tconst next = await new McpToolCommand<Data>(\n\t\t\t\tthis.adapterName,\n\t\t\t\tthis.toolName,\n\t\t\t\tthis.params,\n\t\t\t\tthis.unwrap,\n\t\t\t).execute();\n\t\t\treturn next.isOk() ? ok<void, Error>(undefined) : err(next.error);\n\t\t};\n\t\treturn buildSubscribableResult(result, noopSubscribe, refresh);\n\t}\n}\n\nconst defaultImperativeService = buildDefaultImperativeBindingsServiceDescriptor().service;\nconst queryImperativeService = buildQueryImperativeBindingsServiceDescriptor().service;\nconst subscribableImperativeService =\n\tbuildSubscribableImperativeBindingsServiceDescriptor().service;\nconst legacyImperativeService = buildLegacyImperativeBindingsServiceDescriptor().service;\n\n/**\n * Mutation-shape factory. Builds an async `(config) => Promise<Data>` via\n * OneStore's `DefaultImperativeBindingsService`. Throws on validation error\n * (`throwUserlandError`) or tool error (`toError`). This is the only shape a\n * mutation ever takes on platform — mutation adapters do not carry an\n * `invokerShape` at all.\n */\nexport function createMutationAdapter(name: string, cfg: MutationAdapterConfig) {\n\tconst getCommand = (options: { params: unknown[]; assertIsValid: typeof assertIsValid }) => {\n\t\toptions.assertIsValid(options.params[0], cfg.configJsonSchema);\n\t\treturn new McpToolCommand<unknown>(name, cfg.toolName, options.params[0]);\n\t};\n\tconst invoker = defaultImperativeService.bind<unknown[], unknown>(getCommand);\n\treturn (...params: unknown[]) => Promise.resolve(invoker(...params));\n}\n\n/**\n * Read-shape factory. Dispatches on `cfg.invokerShape`:\n *\n * - `legacy` — `{ invoke, subscribe }` callback surface with `{ data, error }`.\n * `subscribe` fires the callback once from the initial execute's `data`,\n * returns a no-op unsubscribe, and never fires again off-platform.\n * - `query` — `(config) => Promise<{ data }>`; one-shot read.\n * - `subscribable` — `(config) => Promise<{ data, subscribe }>`. Callback\n * passed to `subscribe` never fires; unsubscribe is a no-op.\n * - `subscribable-refreshable` — `(config) => Promise<{ data, subscribe, refresh }>`.\n * `refresh()` re-executes the MCP tool; `subscribe` is still a no-op.\n *\n * All four delegate to an OneStore service (Query / Subscribable / Legacy)\n * over `McpToolSubscribableCommand`, which preserves OneStore's deep-freeze\n * and error-funnel semantics end-to-end.\n */\nexport function createReadAdapter(name: string, cfg: ReadAdapterConfig) {\n\tconst getSubscribableCommand = (options: {\n\t\tparams: unknown[];\n\t\tassertIsValid: typeof assertIsValid;\n\t}) => {\n\t\toptions.assertIsValid(options.params[0], cfg.configJsonSchema);\n\t\treturn new McpToolSubscribableCommand<unknown>(name, cfg.toolName, options.params[0]);\n\t};\n\n\tswitch (cfg.invokerShape) {\n\t\tcase \"query\": {\n\t\t\tconst getCommand = (options: { params: unknown[]; assertIsValid: typeof assertIsValid }) => {\n\t\t\t\toptions.assertIsValid(options.params[0], cfg.configJsonSchema);\n\t\t\t\treturn new McpToolCommand<unknown>(name, cfg.toolName, options.params[0]);\n\t\t\t};\n\t\t\tconst invoker = queryImperativeService.bind<unknown[], unknown>(getCommand);\n\t\t\treturn (...params: unknown[]) => Promise.resolve(invoker(...params));\n\t\t}\n\t\tcase \"subscribable\": {\n\t\t\tconst invoker = subscribableImperativeService.bind<unknown[], unknown>(\n\t\t\t\tgetSubscribableCommand,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\treturn (...params: unknown[]) => Promise.resolve(invoker(...params));\n\t\t}\n\t\tcase \"subscribable-refreshable\": {\n\t\t\tconst invoker = subscribableImperativeService.bind<unknown[], unknown>(\n\t\t\t\tgetSubscribableCommand,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\treturn (...params: unknown[]) => Promise.resolve(invoker(...params));\n\t\t}\n\t\tcase \"legacy\": {\n\t\t\t// Legacy service passes `{ config, assertIsValid }`, not `{ params, ... }`.\n\t\t\tconst getLegacyCommand = (options: {\n\t\t\t\tconfig: unknown;\n\t\t\t\tassertIsValid: typeof assertIsValid;\n\t\t\t}) => {\n\t\t\t\toptions.assertIsValid(options.config, cfg.configJsonSchema);\n\t\t\t\treturn new McpToolSubscribableCommand<unknown>(name, cfg.toolName, options.config);\n\t\t\t};\n\t\t\treturn legacyImperativeService.bind<unknown, unknown>(getLegacyCommand);\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`[${name}] unsupported invokerShape: ${String((cfg as { invokerShape: unknown }).invokerShape)}. ` +\n\t\t\t\t\t`Expected 'legacy' | 'query' | 'subscribable' | 'subscribable-refreshable'.`,\n\t\t\t);\n\t}\n}\n\nconst lwcWireBindingsService = buildLWCWireBindingsServiceDescriptor().service;\n\n/**\n * Splits the MCP tool's `{ data, error }` envelope into a `Result`. Used as\n * the `unwrap` hook on `McpToolCommand` so OneStore's wire invoker sees the\n * error branch directly instead of receiving an envelope wrapped in `ok(...)`.\n *\n * Tools that don't emit the envelope (e.g. imperative) never go through this\n * path — the default imperative invoker doesn't pass `unwrap`.\n */\nfunction unwrapWireEnvelope<Data>(payload: unknown): Result<Data, Error> {\n\tconst envelope = payload as { data?: unknown; error?: unknown } | null | undefined;\n\tif (envelope && envelope.error !== undefined && envelope.error !== null) {\n\t\treturn err(toError(envelope.error));\n\t}\n\treturn ok(envelope?.data as Data);\n}\n\n/**\n * Creates an LWC wire adapter class that calls an MCP tool. Delegates to\n * OneStore's `LWCWireBindingsService`, so the returned class inherits the\n * full `CommandWireAdapterConstructor` contract: initial empty emit, config\n * `sanitize()`, `MissingRequiredPropertyError` → wait-for-next-config gating,\n * deep-freeze on success, race guard on stale resolves, and unsubscriber\n * management on disconnect.\n *\n * The `McpToolCommand` class is reused verbatim — the wire call-site only\n * supplies an `unwrap` hook so the tool's `{ data, error }` envelope lands\n * on OneStore's Err branch rather than being leaked through as an `ok(...)`\n * envelope.\n *\n * @param name - Wire adapter export name, used in MCP error messages.\n * @param cfg - MCP tool name and JSON Schema for valid wire configs.\n */\nexport function createWireAdapter(name: string, cfg: WireAdapterConfig) {\n\treturn lwcWireBindingsService.bind<unknown>(\n\t\t(config) => new McpToolCommand(name, cfg.toolName, config, unwrapWireEnvelope),\n\t\tcfg.configJsonSchema,\n\t);\n}\n"],"names":[],"mappings":";;;;AAmBO,SAAS,qBAAqB,KAAuB;AAC3D,MAAI,OAAO,OAAO,QAAQ,YAAY,uBAAuB,KAAK;AACjE,WAAQ,IAAuC;AAAA,EAChD;AAEA,MAAI,OAAO,OAAO,QAAQ,YAAY,OAAQ,IAA6B,WAAW,UAAU;AAC/F,UAAM,SAAS,KAAK,MAAO,IAA2B,MAAM;AAC5D,QAAI,MAAM,QAAQ,MAAM,GAAG;AAC1B,YAAM,YAAY,OAAO;AAAA,QACxB,CAAC,MACA,KAAK,EAAE,SAAS,UAAU,OAAO,EAAE,SAAS;AAAA,MAAA;AAE9C,YAAM,OAAO,YAAY,UAAU,OAAO;AAC1C,UAAI,MAAM;AACT,eAAO,KAAK,MAAM,IAAI;AAAA,MACvB;AACA,aAAO,CAAA;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAEA,SAAO,OAAO,CAAA;AACf;ACiBA,SAAS,qBAAqB,KAAsB;AACnD,QAAM,UAAW,IAA8B;AAC/C,MAAI,CAAC,MAAM,QAAQ,OAAO,EAAG,QAAO;AACpC,SAAO,QACL,IAAI,CAAC,MAAM;AACX,QAAI,KAAK,OAAO,MAAM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string";
8
- } | {
9
- type: "number";
10
- } | {
11
- type: "integer";
12
- } | {
13
- type: "boolean";
14
- } | {
15
- type: "array";
16
- items: JsonSchema;
17
- } | {
18
- type: "object";
19
- properties?: Record<string, JsonSchema>;
20
- required?: string[];
21
- } | Record<string, unknown>;
6
+ export type ReadInvokerShape = "legacy" | "query" | "subscribable" | "subscribable-refreshable";
22
7
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,UAAU,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAChF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/lds/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,GAAG,cAAc,GAAG,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/vite-plugin-lwc-ui-bundle",
3
- "version": "1.133.2",
3
+ "version": "1.134.0",
4
4
  "description": "Vite plugin for compiling LWC components into static bundles for off-platform and MCP use",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Salesforce",
@@ -73,7 +73,13 @@
73
73
  "magic-string": "^0.30.17"
74
74
  },
75
75
  "devDependencies": {
76
- "@salesforce/sdk-chat": "^1.133.2",
76
+ "@conduit-client/bindings-utils": "3.19.3",
77
+ "@conduit-client/command-base": "3.19.3",
78
+ "@conduit-client/jsonschema-validate": "3.19.3",
79
+ "@conduit-client/service-bindings-imperative": "3.19.3",
80
+ "@conduit-client/service-bindings-lwc": "3.19.3",
81
+ "@conduit-client/utils": "3.19.3",
82
+ "@salesforce/sdk-chat": "^1.134.0",
77
83
  "typescript": "^5.9.3",
78
84
  "vite": "^7.0.0",
79
85
  "vite-plugin-dts": "^4.5.4",