@wix/mcp 1.0.94 → 1.0.95

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 (79) hide show
  1. package/README.md +2 -2
  2. package/build/bin-standalone.js +1116 -321
  3. package/build/cjs/index.cjs +2813 -1147
  4. package/build/cjs/toolkit.cjs +1788 -362
  5. package/build/dts/api-call/headless-release.d.ts +56 -0
  6. package/build/dts/api-call/headless-release.js +135 -0
  7. package/build/dts/api-call/index.d.ts +9 -1
  8. package/build/dts/api-call/index.js +13 -7
  9. package/build/dts/api-call/site-files.d.ts +14 -0
  10. package/build/dts/api-call/site-files.js +106 -10
  11. package/build/dts/api-call/upload-headless-website-files.d.ts +88 -5
  12. package/build/dts/api-call/upload-headless-website-files.js +473 -20
  13. package/build/dts/api-call/upload-image-tool.d.ts +2 -0
  14. package/build/dts/api-call/upload-image-tool.js +8 -4
  15. package/build/dts/bin.d.ts +1 -1
  16. package/build/dts/bin.js +3 -1
  17. package/build/dts/code-mode/index.d.ts +6 -1
  18. package/build/dts/code-mode/index.js +30 -10
  19. package/build/dts/code-mode/truncate-response.js +5 -1
  20. package/build/dts/config/default-config.d.ts +35 -5
  21. package/build/dts/config/default-config.js +334 -178
  22. package/build/dts/config/file-params.d.ts +22 -0
  23. package/build/dts/config/file-params.js +24 -0
  24. package/build/dts/config/param-descriptions.d.ts +14 -2
  25. package/build/dts/config/param-descriptions.js +33 -14
  26. package/build/dts/constants.d.ts +1 -0
  27. package/build/dts/constants.js +1 -0
  28. package/build/dts/docs/docs.d.ts +12 -1
  29. package/build/dts/docs/docs.js +210 -42
  30. package/build/dts/docs/fetch-article.d.ts +21 -0
  31. package/build/dts/docs/fetch-article.js +66 -4
  32. package/build/dts/docs/get-to-know.d.ts +7 -2
  33. package/build/dts/docs/get-to-know.js +36 -14
  34. package/build/dts/docs/mintlify-docs.d.ts +121 -0
  35. package/build/dts/docs/mintlify-docs.js +391 -0
  36. package/build/dts/docs/semanticSearch.d.ts +2 -1
  37. package/build/dts/docs/semanticSearch.js +14 -7
  38. package/build/dts/docs/start-deploy-website.d.ts +7 -6
  39. package/build/dts/docs/start-deploy-website.js +13 -8
  40. package/build/dts/docs/start-headless-build.d.ts +8 -10
  41. package/build/dts/docs/start-headless-build.js +14 -28
  42. package/build/dts/index.d.ts +2 -2
  43. package/build/dts/index.js +2 -2
  44. package/build/dts/infra/redact-personal-data.d.ts +4 -0
  45. package/build/dts/infra/redact-personal-data.js +79 -0
  46. package/build/dts/site-widget-tools/constants.d.ts +49 -1
  47. package/build/dts/site-widget-tools/constants.js +64 -7
  48. package/build/dts/site-widget-tools/index.d.ts +1 -0
  49. package/build/dts/site-widget-tools/index.js +1 -0
  50. package/build/dts/site-widget-tools/pick-images-tool/index.d.ts +14 -0
  51. package/build/dts/site-widget-tools/pick-images-tool/index.js +138 -0
  52. package/build/dts/site-widget-tools/search-site-templates-tool/index.js +16 -2
  53. package/build/dts/site-widget-tools/site-builder-tool/index.js +22 -2
  54. package/build/dts/site-widget-tools/site-creation-tool/index.d.ts +7 -1
  55. package/build/dts/site-widget-tools/site-creation-tool/index.js +22 -51
  56. package/build/dts/site-widget-tools/suggested-domain-tool/index.js +6 -3
  57. package/build/dts/support/index.d.ts +4 -0
  58. package/build/dts/support/index.js +13 -7
  59. package/build/dts/toolkit-entry.d.cts +15 -10
  60. package/build/dts/toolkit-entry.d.ts +15 -10
  61. package/build/dts/toolkit.d.ts +2 -2
  62. package/build/dts/toolkit.js +14 -7
  63. package/build/dts/wix-mcp-server.d.ts +10 -1
  64. package/build/dts/wix-mcp-server.js +25 -7
  65. package/build/dts/wixel/constants.d.ts +8 -1
  66. package/build/dts/wixel/constants.js +8 -1
  67. package/build/dts/wixel/index.d.ts +1 -1
  68. package/build/dts/wixel/index.js +2 -2
  69. package/build/dts/wixel/wixel-a2a-client.d.ts +83 -0
  70. package/build/dts/wixel/wixel-a2a-client.js +166 -0
  71. package/build/dts/wixel/wixel-bi.d.ts +2 -1
  72. package/build/dts/wixel/wixel-bi.js +2 -1
  73. package/build/dts/wixel/{external-agent-api.d.ts → wixel-session-entries.d.ts} +11 -33
  74. package/build/dts/wixel/{external-agent-api.js → wixel-session-entries.js} +33 -54
  75. package/build/dts/wixel/wixel-session-tools.d.ts +21 -26
  76. package/build/dts/wixel/wixel-session-tools.js +494 -599
  77. package/build/esm/index.js +2824 -1170
  78. package/build/esm/toolkit.js +1786 -360
  79. package/package.json +4 -4
@@ -1,15 +1,14 @@
1
1
  import { createHttpClient } from '@wix/http-client';
2
- import { startSession, sendMessage, listEvents } from '@wix/ambassador-www-wixel-agent-v1-external-agent/http';
3
- import { InboxHistoryMode, ProjectWorkspace } from '@wix/ambassador-www-wixel-agent-v1-external-agent/types';
4
- import { WIXEL_AGENT_EXTERNAL_API_BASE_URL } from './constants.js';
5
- export { InboxHistoryMode, ProjectWorkspace };
6
- // wixel-agent-service ExternalAgentService — the agent-to-agent session API
7
- // (StartSession / SendMessage / ListEvents). Replaces driving the Wixel
8
- // conversation through the genie chat service directly.
2
+ import { WIXEL_AGENT_SESSIONS_API_BASE_URL } from './constants.js';
3
+ // Reads of the Wixel agent's internal sessions API (wixel-agent-service):
4
+ // the durable entries log of a session and the sessions listing. A2A tasks
5
+ // report a turn's state and reply, but a parked ask_user question — the
6
+ // structured outline / style / choice payload the widgets render — lives only
7
+ // in the entries log. The session id comes from a task's metadata.
9
8
  const CONDUCTOR_OVERRIDE_HEADERS = {
10
9
  Cookie: 'petri_ovr=specs.wixel-slides.enableInWixel#true|specs.wixel-assistant.sidePanelEnabled#true|creditTransactionsPremiumIntegration#A'
11
10
  };
12
- function httpClientFor({ authHeaders, apiBaseURL = WIXEL_AGENT_EXTERNAL_API_BASE_URL, conductorOverride }) {
11
+ function httpClientFor({ authHeaders, apiBaseURL = WIXEL_AGENT_SESSIONS_API_BASE_URL, conductorOverride }) {
13
12
  return createHttpClient({
14
13
  headers: {
15
14
  ...authHeaders,
@@ -18,31 +17,8 @@ function httpClientFor({ authHeaders, apiBaseURL = WIXEL_AGENT_EXTERNAL_API_BASE
18
17
  baseURL: apiBaseURL
19
18
  });
20
19
  }
21
- export async function startWixelSession({ sessionId, metaSiteId, callerName = 'Wix MCP', externalId, workspace, callbackUrl, callbackToken, ...base }) {
22
- const httpClient = httpClientFor(base);
23
- const { data } = await httpClient.request(startSession({
24
- sessionId,
25
- metaSiteId,
26
- callerName,
27
- externalId,
28
- workspace,
29
- callbackUrl,
30
- callbackToken
31
- }));
32
- return data;
33
- }
34
- export async function sendWixelSessionMessage({ handle, metaSiteId, text, transactionId, ...base }) {
35
- const httpClient = httpClientFor(base);
36
- const { data } = await httpClient.request(sendMessage({ handle, metaSiteId, text, transactionId }));
37
- return data;
38
- }
39
- export async function listWixelSessionEvents({ handle, metaSiteId, since, historyMode, ...base }) {
40
- const httpClient = httpClientFor(base);
41
- const { data } = await httpClient.request(listEvents({ handle, metaSiteId, since, historyMode }));
42
- return data;
43
- }
44
- // DEBUG: internal wixel-agent sessions API — exposes the full durable session
45
- // entries (incl. parked ask_user questions the external inbox hides).
20
+ // The full durable session entries, including parked ask_user questions,
21
+ // which an A2A task does not carry.
46
22
  export async function getWixelSessionEntries({ sessionId, ...base }) {
47
23
  const httpClient = httpClientFor(base);
48
24
  const { data } = await httpClient.get(`/_api/wixel-agent-server/sessions/${sessionId}/messages`);
@@ -50,16 +26,15 @@ export async function getWixelSessionEntries({ sessionId, ...base }) {
50
26
  }
51
27
  // The sessions listing is scoped to the authenticated caller, so membership
52
28
  // in it is the ownership check for the internal per-session reads below —
53
- // a caller-supplied handle that isn't the caller's own session resolves to
54
- // nothing instead of another tenant's data. The external API returns
55
- // handle === sessionId today; if they ever diverge this fails closed.
29
+ // a session id that isn't the caller's own session resolves to nothing
30
+ // instead of another tenant's data.
56
31
  async function isSessionVisibleToCaller(sessionId, base) {
57
32
  const httpClient = httpClientFor(base);
58
33
  const { data } = await httpClient.get(`/_api/wixel-agent-server/sessions`);
59
34
  return !!data?.sessions?.some((entry) => entry.id === sessionId);
60
35
  }
61
- // The wixel-agent session is bound to the Wixel project it works in; the
62
- // external inbox API doesn't expose it, but the sessions listing does.
36
+ // The wixel-agent session is bound to the Wixel project it works in; an A2A
37
+ // task doesn't expose it, but the sessions listing does.
63
38
  export async function getWixelSessionProjectId({ sessionId, ...base }) {
64
39
  const httpClient = httpClientFor(base);
65
40
  const { data } = await httpClient.get(`/_api/wixel-agent-server/sessions`);
@@ -69,9 +44,9 @@ export async function getWixelSessionProjectId({ sessionId, ...base }) {
69
44
  /**
70
45
  * Classify the session's current state from the durable entries log with a
71
46
  * single read: parked on an ask_user question, actively generating, or idle.
72
- * Empty inbox polls use this to tell callers whether to keep waiting (turn
73
- * running) or to turn to the user (parked question) — an empty inbox alone
74
- * cannot distinguish the two.
47
+ * A task still WORKING uses this to tell callers whether to keep waiting
48
+ * (turn running) or to turn to the user (parked question) — the task state
49
+ * alone cannot distinguish the two.
75
50
  */
76
51
  export async function getWixelSessionActivity({ sessionId, ...base }) {
77
52
  if (!(await isSessionVisibleToCaller(sessionId, base))) {
@@ -128,8 +103,7 @@ export async function getWixelSessionActivity({ sessionId, ...base }) {
128
103
  // The generation job's terminal result carries "conversationEnded": true —
129
104
  // the deliverable was produced and the Wixel flow is complete. Any question
130
105
  // still attached to that turn (e.g. the courtesy "pick a new style?") must
131
- // not resurface as pending until the user speaks again. (The created-assets
132
- // marker only exists on inbox events, not in the entries log.)
106
+ // not resurface as pending until the user speaks again.
133
107
  function flowEndedSinceLastUserMessage(messages) {
134
108
  for (let i = messages.length - 1; i >= 0; i--) {
135
109
  const message = messages[i];
@@ -148,11 +122,11 @@ function flowEndedSinceLastUserMessage(messages) {
148
122
  }
149
123
  return false;
150
124
  }
151
- // The external-session policy intercepts ask_user (client-facing tools are
152
- // disabled) and the agent falls back to plain text — but the structured
153
- // question is still durably persisted as a functionCall entry. Extract the
154
- // most recent one so MCP clients can render it as a widget.
155
- export async function getWixelPendingQuestion({ sessionId, requireParked = false, ...base }) {
125
+ // On API sessions ask_user is intercepted (client-facing tools are disabled)
126
+ // and the agent falls back to plain text — but the structured question is
127
+ // still durably persisted as a functionCall entry. Extract the most recent one
128
+ // so MCP clients can render it as a widget.
129
+ export async function getWixelPendingQuestion({ sessionId, requireParked = false, turnId, ...base }) {
156
130
  if (!(await isSessionVisibleToCaller(sessionId, base)))
157
131
  return null;
158
132
  const data = (await getWixelSessionEntries({
@@ -162,14 +136,17 @@ export async function getWixelPendingQuestion({ sessionId, requireParked = false
162
136
  const messages = data?.messages ?? [];
163
137
  if (flowEndedSinceLastUserMessage(messages))
164
138
  return null;
139
+ const ownTurn = turnId && messages.some((message) => message.turnId === turnId)
140
+ ? turnId
141
+ : null;
165
142
  // Two states carry a question worth surfacing:
166
143
  // - Parked: ask_user is the newest entry — the policy hasn't answered it and
167
- // the turn is suspended waiting for the user (no reply event will come).
168
- // requireParked accepts only this state; empty inbox polls use it so a
169
- // question answered elsewhere (e.g. the Wixel UI) isn't resurfaced while
170
- // the turn keeps generating.
144
+ // the turn is suspended waiting for the user (its task stays WORKING).
145
+ // requireParked accepts only this state; polls of a running task use it
146
+ // so a question answered elsewhere (e.g. the Wixel UI) isn't resurfaced
147
+ // while the turn keeps generating.
171
148
  // - Fallback: the policy auto-responded to ask_user and the agent re-asked
172
- // in plain text (the reply event). The structured payload is still the
149
+ // in plain text (the task's reply). The structured payload is still the
173
150
  // better rendering, so the reply path returns it — until the user's own
174
151
  // text answer supersedes it.
175
152
  let sawNewerEntry = false;
@@ -190,6 +167,8 @@ export async function getWixelPendingQuestion({ sessionId, requireParked = false
190
167
  []);
191
168
  if (!questions.length)
192
169
  continue;
170
+ if (ownTurn && message.turnId !== ownTurn)
171
+ return null;
193
172
  return {
194
173
  toolCallId: call.id,
195
174
  turnId: message.turnId,
@@ -203,4 +182,4 @@ export async function getWixelPendingQuestion({ sessionId, requireParked = false
203
182
  }
204
183
  return null;
205
184
  }
206
- //# sourceMappingURL=external-agent-api.js.map
185
+ //# sourceMappingURL=wixel-session-entries.js.map
@@ -31,43 +31,38 @@ export type WixelDeck = {
31
31
  pageUrls: string[];
32
32
  };
33
33
  export declare function collectDecks(projectAssets: WixelAssetEntity[], deckIds: Set<string>): Map<string, WixelDeck>;
34
- export declare function extractAssetIds(text: string): string[];
35
34
  /**
36
- * Live result cards, per Wixel session handle: the turns a card was rendered
37
- * for (and when), the asset ids / media URLs those cards display, and the
38
- * last turn send_wixel_message opened. The model does not reliably obey "do
39
- * not poll" once a live card is up, so the tools enforce it: list_wixel_events
40
- * refuses while a card is active, get_wixel_asset_result refuses to render
41
- * the same result a second time, and get_wixel_pending_question stays quiet
42
- * for a question the card already shows.
35
+ * Live result cards, per Wixel conversation (contextId): the tasks a card was
36
+ * rendered for (and when), the asset ids / media URLs those cards display, and
37
+ * the last task send_wixel_message returned in the conversation — the card's
38
+ * own answers go through that tool too, so it is the task the card follows.
39
+ * The model does not reliably obey "do not poll" once a live card is up, so
40
+ * the tools enforce it: get_wixel_task refuses while a card follows the
41
+ * conversation's latest task, get_wixel_asset_result refuses to render the
42
+ * same result a second time, and get_wixel_pending_question stays quiet for a
43
+ * question the card already shows.
43
44
  *
44
- * One registry per server instance (like list_wixel_events' cursor memory),
45
- * so sessions never see each other's records. In-memory like that memory
46
- * too: a Durable Object wake-up starts empty, and the intercepts simply
47
- * don't apply until the next send.
45
+ * One registry per server instance, so MCP sessions never see each other's
46
+ * records. In-memory: a Durable Object wake-up starts empty, and the
47
+ * intercepts simply don't apply until the next send.
48
48
  */
49
49
  type LiveCardRecord = {
50
- /** Turn id → when its live card was rendered. */
51
- turns: Map<string, number>;
52
- /** Turns whose card reached done/failed — the agent may poll again. */
53
- finishedTurns: Set<string>;
50
+ /** Task id → when its live card was rendered. */
51
+ tasks: Map<string, number>;
52
+ /** Tasks whose card reached done/failed — the agent may poll again. */
53
+ finishedTasks: Set<string>;
54
54
  shownAssets: Set<string>;
55
- lastSentTurn: string | null;
55
+ lastSentTask: string | null;
56
56
  };
57
57
  export type LiveCardRegistry = ReturnType<typeof createLiveCardRegistry>;
58
58
  export declare function createLiveCardRegistry(): {
59
- get: (handle: string) => LiveCardRecord | undefined;
60
- forHandle: (handle: string) => LiveCardRecord;
61
- isActive: (handle: string, params: {
62
- authHeaders: Record<string, string>;
63
- conductorOverride?: string;
64
- metaSiteId: string;
65
- }) => Promise<boolean>;
59
+ get: (contextId: string) => LiveCardRecord | undefined;
60
+ forContext: (contextId: string) => LiveCardRecord;
61
+ isActive: (contextId: string, isTerminal: (taskId: string) => Promise<boolean>) => Promise<boolean>;
66
62
  };
67
63
  export declare function addGetWixelPendingQuestionTool(server: WixMcpServer, authStrategy: McpAuthenticationStrategy, options?: WixelSessionToolOptions): void;
68
- export declare function addStartWixelSessionTool(server: WixMcpServer, authStrategy: McpAuthenticationStrategy, options?: WixelSessionToolOptions): void;
69
64
  export declare function addSendWixelMessageTool(server: WixMcpServer, authStrategy: McpAuthenticationStrategy, options?: WixelSessionToolOptions): void;
70
- export declare function addListWixelEventsTool(server: WixMcpServer, authStrategy: McpAuthenticationStrategy, options?: WixelSessionToolOptions): void;
65
+ export declare function addGetWixelTaskTool(server: WixMcpServer, authStrategy: McpAuthenticationStrategy, options?: WixelSessionToolOptions): void;
71
66
  export declare function addGetWixelStylePresetsTool(server: WixMcpServer, authStrategy: McpAuthenticationStrategy, options?: WixelSessionToolOptions): void;
72
67
  export type WixelTurnStatus = 'generating' | 'question' | 'done' | 'failed';
73
68
  export declare function addGetWixelTurnResultTool(server: WixMcpServer, authStrategy: McpAuthenticationStrategy, options?: WixelSessionToolOptions): void;