@gravity-rail/sdk 0.22.0 → 0.33.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.
Files changed (55) hide show
  1. package/README.md +57 -8
  2. package/dist/agui.d.cts +1 -1
  3. package/dist/agui.d.ts +1 -1
  4. package/dist/audio.d.cts +1 -1
  5. package/dist/audio.d.ts +1 -1
  6. package/dist/{client-C10qSd6b.d.ts → chat-interaction-DJ9-Qtg2.d.cts} +8016 -3571
  7. package/dist/{client-Ct0soeip.d.cts → chat-interaction-dd6F3uT4.d.ts} +8016 -3571
  8. package/dist/{chunk-3HAV5XUJ.js → chunk-HRUMZ46V.js} +1 -1
  9. package/dist/chunk-HRUMZ46V.js.map +1 -0
  10. package/dist/{chunk-7OLBLLV7.js → chunk-P2E6LU7I.js} +57 -7
  11. package/dist/chunk-P2E6LU7I.js.map +1 -0
  12. package/dist/{chunk-WMA6YCAS.js → chunk-WDYHAQDY.js} +1364 -216
  13. package/dist/chunk-WDYHAQDY.js.map +1 -0
  14. package/dist/helpers.cjs +54 -1
  15. package/dist/helpers.cjs.map +1 -1
  16. package/dist/helpers.d.cts +3 -2
  17. package/dist/helpers.d.ts +3 -2
  18. package/dist/helpers.js +11 -3
  19. package/dist/helpers.js.map +1 -1
  20. package/dist/index.cjs +2414 -149
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +550 -6
  23. package/dist/index.d.ts +550 -6
  24. package/dist/index.js +1037 -23
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal.cjs +1456 -235
  27. package/dist/internal.cjs.map +1 -1
  28. package/dist/internal.d.cts +33 -49
  29. package/dist/internal.d.ts +33 -49
  30. package/dist/internal.js +77 -33
  31. package/dist/internal.js.map +1 -1
  32. package/dist/realtime.cjs +279 -14
  33. package/dist/realtime.cjs.map +1 -1
  34. package/dist/realtime.d.cts +169 -17
  35. package/dist/realtime.d.ts +169 -17
  36. package/dist/realtime.js +264 -13
  37. package/dist/realtime.js.map +1 -1
  38. package/dist/{revision-state-C6aM-PHu.d.ts → revision-state-BD39fW5X.d.ts} +236 -5
  39. package/dist/{revision-state-CCPTiW-i.d.cts → revision-state-Cgmy_Cds.d.cts} +236 -5
  40. package/dist/schemas.cjs +35 -10
  41. package/dist/schemas.cjs.map +1 -1
  42. package/dist/schemas.d.cts +54 -33
  43. package/dist/schemas.d.ts +54 -33
  44. package/dist/schemas.js +35 -10
  45. package/dist/schemas.js.map +1 -1
  46. package/dist/{tasks-WH_VfzMv.d.cts → tasks-B-31JPuq.d.cts} +298 -114
  47. package/dist/{tasks-WH_VfzMv.d.ts → tasks-B-31JPuq.d.ts} +298 -114
  48. package/dist/types-0c6_NGU4.d.cts +90 -0
  49. package/dist/types-0c6_NGU4.d.ts +90 -0
  50. package/package.json +3 -3
  51. package/dist/chunk-3HAV5XUJ.js.map +0 -1
  52. package/dist/chunk-7OLBLLV7.js.map +0 -1
  53. package/dist/chunk-WMA6YCAS.js.map +0 -1
  54. package/dist/types-DkYyrvoC.d.cts +0 -19
  55. package/dist/types-DkYyrvoC.d.ts +0 -19
package/dist/index.cjs CHANGED
@@ -28,6 +28,16 @@ __export(src_exports, {
28
28
  AccessGrantStatus: () => AccessGrantStatus,
29
29
  AccessGrantTrigger: () => AccessGrantTrigger,
30
30
  AccessLevel: () => AccessLevel2,
31
+ ActivityCapability: () => ActivityCapability,
32
+ ActivityEventFamily: () => ActivityEventFamily,
33
+ ActivityEventType: () => ActivityEventType,
34
+ ActivityGrain: () => ActivityGrain,
35
+ ActivityGroupBy: () => ActivityGroupBy,
36
+ ActivityOpenItemOrder: () => ActivityOpenItemOrder,
37
+ ActivityOutcome: () => ActivityOutcome,
38
+ ActivityVisibility: () => ActivityVisibility,
39
+ ActivityWindowBasis: () => ActivityWindowBasis,
40
+ ActorKind: () => ActorKind,
31
41
  AgentBuilder: () => AgentBuilder,
32
42
  ApiError: () => ApiError,
33
43
  ApplyError: () => ApplyError,
@@ -48,8 +58,16 @@ __export(src_exports, {
48
58
  CalendarScheduleRecurrence: () => CalendarScheduleRecurrence,
49
59
  CalendarSource: () => CalendarSource,
50
60
  CapabilityClass: () => CapabilityClass,
61
+ ChannelMessageDirection: () => ChannelMessageDirection,
62
+ ChannelMessageSource: () => ChannelMessageSource,
63
+ ChannelMessagesUnavailableReason: () => ChannelMessagesUnavailableReason,
64
+ ChatInteractionController: () => ChatInteractionController,
65
+ ChatMuteReason: () => ChatMuteReason,
51
66
  ConsentMethod: () => ConsentMethod,
52
67
  CriterionType: () => CriterionType,
68
+ DEFAULT_AGENT_CHAT_MODEL: () => DEFAULT_AGENT_CHAT_MODEL,
69
+ DEFAULT_AGENT_REALTIME_MODEL: () => DEFAULT_AGENT_REALTIME_MODEL,
70
+ DEFAULT_AGENT_REALTIME_MODEL_CONFIG: () => DEFAULT_AGENT_REALTIME_MODEL_CONFIG,
53
71
  DEFAULT_CHAT_MODEL: () => DEFAULT_CHAT_MODEL,
54
72
  DEFAULT_CUSTOM_VOICE_MODEL: () => DEFAULT_CUSTOM_VOICE_MODEL,
55
73
  DEFAULT_THINKING_SPEECH_PHRASES: () => DEFAULT_THINKING_SPEECH_PHRASES,
@@ -59,8 +77,11 @@ __export(src_exports, {
59
77
  DataRecordRetirementResponseReason: () => DataRecordRetirementResponseReason,
60
78
  DataSensitivity: () => DataSensitivity,
61
79
  DataTypeRecordScope: () => DataTypeRecordScope,
80
+ DigestSlotRole: () => DigestSlotRole,
62
81
  DriverMode: () => DriverMode,
82
+ EhrWritebackOutcomeResponseStatus: () => EhrWritebackOutcomeResponseStatus,
63
83
  EmailDnsRecordType: () => EmailDnsRecordType,
84
+ EntityKind: () => EntityKind,
64
85
  EventRuleActionType: () => EventRuleActionType,
65
86
  EventRuleEventType: () => EventRuleEventType,
66
87
  EventRuleObjectType: () => EventRuleObjectType,
@@ -71,6 +92,11 @@ __export(src_exports, {
71
92
  FhirVendor: () => FhirVendor,
72
93
  FormBuilder: () => FormBuilder,
73
94
  GravityRailClient: () => GravityRailClient,
95
+ ImportSkippedRuleResourceGroupResourceType: () => ImportSkippedRuleResourceGroupResourceType,
96
+ ImportSkippedRuleResponseNeededResourceTypesItem: () => ImportSkippedRuleResponseNeededResourceTypesItem,
97
+ ImportSkippedRuleResponseParentKind: () => ImportSkippedRuleResponseParentKind,
98
+ ImportSkippedRuleResponseReasonCode: () => ImportSkippedRuleResponseReasonCode,
99
+ ImportSkippedRuleResponseStatus: () => ImportSkippedRuleResponseStatus,
74
100
  InboundFaxStatusValues: () => InboundFaxStatus,
75
101
  IndexStatus: () => IndexStatus,
76
102
  InvitationStatus: () => InvitationStatus,
@@ -78,6 +104,7 @@ __export(src_exports, {
78
104
  JourneyBuilder: () => JourneyBuilder,
79
105
  JourneyStepBuilder: () => JourneyStepBuilder,
80
106
  MASKED_SECRET_SENTINEL: () => MASKED_SECRET_SENTINEL,
107
+ MEMBER_RELATIONSHIP_KINDS: () => MEMBER_RELATIONSHIP_KINDS,
81
108
  McpServerState: () => McpServerState,
82
109
  MemberFeature: () => MemberFeature,
83
110
  MemberFilterBuilder: () => MemberFilterBuilder,
@@ -85,6 +112,7 @@ __export(src_exports, {
85
112
  MemberImportPreviewRowAction: () => MemberImportPreviewRowAction,
86
113
  MemberImportValidationError: () => MemberImportValidationError,
87
114
  MemberLabelBuilder: () => MemberLabelBuilder,
115
+ MemberRelationshipKind: () => MemberRelationshipKind,
88
116
  MemberType: () => MemberType,
89
117
  MenuItemResponseItemType: () => MenuItemResponseItemType,
90
118
  MenuItemType: () => MenuItemResponseItemType,
@@ -120,8 +148,11 @@ __export(src_exports, {
120
148
  REALTIME_MODEL_OPENAI: () => REALTIME_MODEL_OPENAI,
121
149
  REALTIME_MODEL_OPENAI_2: () => REALTIME_MODEL_OPENAI_2,
122
150
  REALTIME_MODEL_OPENAI_MINI: () => REALTIME_MODEL_OPENAI_MINI,
151
+ RefResolutionStatus: () => RefResolutionStatus,
123
152
  Region: () => Region,
124
153
  RegistrationIdentifier: () => RegistrationIdentifier,
154
+ RelatedMemberRole: () => RelatedMemberRole,
155
+ RelationshipCardinality: () => RelationshipCardinality,
125
156
  Resource: () => Resource,
126
157
  RoleUpdate: () => RoleUpdate,
127
158
  RoutineBuilder: () => RoutineBuilder,
@@ -146,7 +177,12 @@ __export(src_exports, {
146
177
  TTS_PREVIEW_PROVIDERS: () => TTS_PREVIEW_PROVIDERS,
147
178
  TaskBuilder: () => TaskBuilder,
148
179
  TemplatesApi: () => TemplatesApi,
180
+ TestChatRunLane: () => TestChatRunLane,
181
+ TestChatRunOutcome: () => TestChatRunOutcome,
149
182
  ToolkitState: () => ToolkitState,
183
+ UiPromptPresentedKindValues: () => UiPromptPresentedKind,
184
+ UiPromptResponseKindValues: () => UiPromptResponseKind,
185
+ UiPromptResponseStatusValues: () => UiPromptResponseStatus,
150
186
  WIDGET_SLUGS: () => WIDGET_SLUGS,
151
187
  WORKFLOW_IMPLICIT_USE_SCOPE: () => WORKFLOW_IMPLICIT_USE_SCOPE,
152
188
  WorkflowAccessWarningResourceType: () => WorkflowAccessWarningResourceType,
@@ -221,6 +257,9 @@ function isApiValidationError(value) {
221
257
  const v = value;
222
258
  return typeof v.field === "string" && typeof v.kind === "string" && typeof v.message === "string";
223
259
  }
260
+ function logApiClientError(_error) {
261
+ console.warn("API request failed");
262
+ }
224
263
  var ApiError = class extends Error {
225
264
  statusCode;
226
265
  /** Legacy string-array errors — kept for non-validation callers. */
@@ -239,6 +278,7 @@ var ApiError = class extends Error {
239
278
  errorData;
240
279
  constructor(message, statusCode, errors, validationErrors) {
241
280
  super(message);
281
+ this.name = "ApiError";
242
282
  this.statusCode = statusCode;
243
283
  this.errors = errors;
244
284
  this.validationErrors = validationErrors;
@@ -498,9 +538,10 @@ ${formattedErrors}`, response.status);
498
538
  const message = errorData.detail ? `${errorData.detail}: ${details}` : `Validation failed: ${details}`;
499
539
  throw new ApiError(message, response.status, stringErrors);
500
540
  }
501
- const structuredError = errorData.detail || errorData;
541
+ const detail = errorData.detail;
542
+ const structuredError = detail && typeof detail === "object" ? detail : errorData;
502
543
  if (structuredError && typeof structuredError === "object" && (structuredError.error === true || structuredError.code)) {
503
- const message = structuredError.message || structuredError.code || "Unknown error";
544
+ const message = typeof detail === "string" && detail || structuredError.message || structuredError.code || "Unknown error";
504
545
  const error = new ApiError(message, response.status);
505
546
  error.errorData = structuredError;
506
547
  throw error;
@@ -517,7 +558,7 @@ ${formattedErrors}`, response.status);
517
558
  }
518
559
  return response.json();
519
560
  } catch (error) {
520
- console.warn(error);
561
+ logApiClientError(error);
521
562
  throw error;
522
563
  }
523
564
  }
@@ -624,7 +665,7 @@ ${formattedErrors}`, response.status);
624
665
  }
625
666
  return response;
626
667
  } catch (error) {
627
- console.warn(error);
668
+ logApiClientError(error);
628
669
  throw error;
629
670
  }
630
671
  }
@@ -670,7 +711,7 @@ ${formattedErrors}`, response.status);
670
711
  }
671
712
  return response.json();
672
713
  } catch (error) {
673
- console.warn(error);
714
+ logApiClientError(error);
674
715
  throw error;
675
716
  }
676
717
  }
@@ -1911,17 +1952,6 @@ var CallsApi = class extends BaseApiClient {
1911
1952
  `w/${wid}/calls${params.toString() ? `?${params.toString()}` : ""}`
1912
1953
  );
1913
1954
  }
1914
- /** Initiate a new outbound call. */
1915
- async initiateCall(wid, request) {
1916
- return this.fetch(`w/${wid}/call`, {
1917
- method: "POST",
1918
- body: JSON.stringify(request)
1919
- });
1920
- }
1921
- /** Get a voice authentication token for real-time audio. */
1922
- async getVoiceToken(wid) {
1923
- return this.fetch(`w/${wid}/voice/token`);
1924
- }
1925
1955
  /** Get message timing data for a chat recording. */
1926
1956
  async getMessageTiming(wid, chatId) {
1927
1957
  return this.fetch(`w/${wid}/recordings/chat/${chatId}/message-timing`);
@@ -2047,6 +2077,26 @@ var ChatsApi = class extends BaseApiClient {
2047
2077
  async getChat(wid, id) {
2048
2078
  return this.fetch(`w/${wid}/chats/${id}`);
2049
2079
  }
2080
+ /**
2081
+ * Get a short-lived, interactive AgentCore browser view for this Chat.
2082
+ *
2083
+ * The signed URL is deliberately response-local. Callers must keep it in
2084
+ * memory only and request a fresh value when reopening the view.
2085
+ */
2086
+ async getChatBrowserLiveView(wid, chatId) {
2087
+ const response = await this.fetchRaw(`w/${wid}/chats/${chatId}/browser/live-view`);
2088
+ if (response.status === 204) return null;
2089
+ return response.json();
2090
+ }
2091
+ /**
2092
+ * Which machine resources this Chat is running right now.
2093
+ *
2094
+ * Infrastructure state only — no Chat content — so it is safe to poll while
2095
+ * a Chat is open.
2096
+ */
2097
+ async getChatMachineResources(wid, chatId) {
2098
+ return this.fetch(`w/${wid}/chats/${chatId}/machine-resources`);
2099
+ }
2050
2100
  /**
2051
2101
  * Create-chat preflight for SMS: is a conversation already live between this
2052
2102
  * workspace number and this member?
@@ -2074,6 +2124,23 @@ var ChatsApi = class extends BaseApiClient {
2074
2124
  async getChatCallbacks(wid, chatId) {
2075
2125
  return this.fetch(`w/${wid}/chats/${chatId}/callbacks`);
2076
2126
  }
2127
+ /**
2128
+ * List EHR write-back outcomes for a chat (newest first).
2129
+ *
2130
+ * Operator surface: the endpoint requires `chats:read` in addition to the
2131
+ * chat's own object authorization, so a chat owner reading their own chat
2132
+ * does not reach it. The response carries IDs and closed-vocabulary codes
2133
+ * only — no note body, summary, member fields, or provider messages.
2134
+ */
2135
+ async getChatEhrWritebackOutcomes(wid, chatId, options = {}) {
2136
+ const params = new URLSearchParams();
2137
+ if (options.limit !== void 0) params.append("limit", options.limit.toString());
2138
+ if (options.cursor) params.append("cursor", options.cursor);
2139
+ const queryString = params.toString();
2140
+ return this.fetch(
2141
+ `w/${wid}/chats/${chatId}/ehr-writeback-outcomes${queryString ? `?${queryString}` : ""}`
2142
+ );
2143
+ }
2077
2144
  /** Cancel a pending scheduled callback on a chat. */
2078
2145
  async cancelChatCallback(wid, chatId, callbackId) {
2079
2146
  return this.fetch(
@@ -2085,6 +2152,18 @@ var ChatsApi = class extends BaseApiClient {
2085
2152
  async getChatTodos(wid, chatId) {
2086
2153
  return this.fetch(`w/${wid}/chats/${chatId}/todos`);
2087
2154
  }
2155
+ /**
2156
+ * The caller's own live inline-connect link for a chat.
2157
+ *
2158
+ * An `inline_connect` prompt (`UiPromptPresented.connect`) names the
2159
+ * connection but carries no URL; fetch it here when the member chooses to
2160
+ * connect. 404 when nothing is live for the caller in this chat.
2161
+ */
2162
+ async getInlineConnectLink(wid, chatId, appSlug) {
2163
+ return this.fetch(
2164
+ `w/${wid}/chats/${chatId}/inline-connect/${encodeURIComponent(appSlug)}/link`
2165
+ );
2166
+ }
2088
2167
  /** Get loaded and revealed skills for a chat. */
2089
2168
  async getChatSkills(wid, chatId) {
2090
2169
  return this.fetch(`w/${wid}/chats/${chatId}/skills`);
@@ -2119,6 +2198,23 @@ var ChatsApi = class extends BaseApiClient {
2119
2198
  method: "PUT"
2120
2199
  });
2121
2200
  }
2201
+ /** Start an interaction within an existing Chat without changing its channel. */
2202
+ async createChatInteractionSession(wid, chatId, request) {
2203
+ return this.fetch(
2204
+ `w/${wid}/chats/${chatId}/interaction-sessions`,
2205
+ {
2206
+ method: "POST",
2207
+ body: JSON.stringify(request)
2208
+ }
2209
+ );
2210
+ }
2211
+ /** End one mode session and append its replacement in the same Chat. */
2212
+ async transitionChatInteractionSession(wid, chatId, sessionId, request) {
2213
+ return this.fetch(
2214
+ `w/${wid}/chats/${chatId}/interaction-sessions/${encodeURIComponent(sessionId)}/transition`,
2215
+ { method: "POST", body: JSON.stringify(request) }
2216
+ );
2217
+ }
2122
2218
  /** Create a new chat. */
2123
2219
  async createChat(wid, chat) {
2124
2220
  const { agentMemberId, ...rest } = chat;
@@ -2178,22 +2274,12 @@ var ChatsApi = class extends BaseApiClient {
2178
2274
  });
2179
2275
  }
2180
2276
  /** Update the mute status of a chat. */
2181
- async updateChatMute(wid, id, muted) {
2277
+ async updateChatMute(wid, id, muted, muteReason, muteExpiresOnInbound) {
2182
2278
  return this.fetch(`w/${wid}/chats/${id}/mute`, {
2183
2279
  method: "PUT",
2184
- body: JSON.stringify({ muted })
2280
+ body: JSON.stringify({ muted, muteReason, muteExpiresOnInbound })
2185
2281
  });
2186
2282
  }
2187
- /** Update the needs-response flag on a chat. */
2188
- async updateChatNeedsResponse(wid, id, needsResponse) {
2189
- return this.fetch(
2190
- `w/${wid}/chats/${id}/needs-response`,
2191
- {
2192
- method: "PUT",
2193
- body: JSON.stringify({ needsResponse })
2194
- }
2195
- );
2196
- }
2197
2283
  /** Generate an AI summary for a chat, optionally updating its labels. */
2198
2284
  async summarizeChat(wid, id, updateLabels) {
2199
2285
  const params = new URLSearchParams();
@@ -2209,10 +2295,11 @@ var ChatsApi = class extends BaseApiClient {
2209
2295
  }
2210
2296
  /** List messages in a chat with optional pagination.
2211
2297
  * ``id`` is the numeric chat id (documented) or the chat uuid (accepted). */
2212
- async getChatMessages(wid, id, limit, offset) {
2298
+ async getChatMessages(wid, id, limit, offset, before) {
2213
2299
  const params = new URLSearchParams();
2214
2300
  if (limit) params.append("limit", limit.toString());
2215
2301
  if (offset) params.append("offset", offset.toString());
2302
+ if (before) params.append("before", before);
2216
2303
  return this.fetch(
2217
2304
  `w/${wid}/chats/${id}/messages${params.toString() ? `?${params.toString()}` : ""}`
2218
2305
  );
@@ -2632,6 +2719,35 @@ var DashboardsApi = class extends BaseApiClient {
2632
2719
 
2633
2720
  // src/api/data-types.ts
2634
2721
  var DataTypesApi = class extends BaseApiClient {
2722
+ /** Read the local Form's draft and optimistic publication counters. */
2723
+ async getDataTypeDraft(wid, id) {
2724
+ return this.fetch(`w/${wid}/data-types/${id}/schema-draft`);
2725
+ }
2726
+ /** Save a draft without changing the schema used to validate live records. */
2727
+ async saveDataTypeDraft(wid, id, request) {
2728
+ return this.fetch(`w/${wid}/data-types/${id}/schema-draft`, {
2729
+ method: "PUT",
2730
+ body: JSON.stringify(request)
2731
+ });
2732
+ }
2733
+ /** Publish the expected draft as the next immutable local schema version. */
2734
+ async publishDataTypeDraft(wid, id, request) {
2735
+ return this.fetch(`w/${wid}/data-types/${id}/schema-publish`, {
2736
+ method: "POST",
2737
+ body: JSON.stringify(request)
2738
+ });
2739
+ }
2740
+ /** List schema history newest first; use the last version as the next cursor. */
2741
+ async getDataTypeVersions(wid, id, options) {
2742
+ const params = new URLSearchParams();
2743
+ if (options?.beforeVersion !== void 0)
2744
+ params.set("beforeVersion", String(options.beforeVersion));
2745
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
2746
+ const query = params.toString();
2747
+ return this.fetch(
2748
+ `w/${wid}/data-types/${id}/schema-versions${query ? `?${query}` : ""}`
2749
+ );
2750
+ }
2635
2751
  /** List all data types for a workspace, optionally filtering by archived status. */
2636
2752
  async getDataTypes(wid, options) {
2637
2753
  const params = new URLSearchParams();
@@ -2700,7 +2816,6 @@ var DataTypesApi = class extends BaseApiClient {
2700
2816
  const params = new URLSearchParams();
2701
2817
  if (options?.memberId !== void 0) params.append("member_id", options.memberId.toString());
2702
2818
  if (options?.memberIds?.length) params.append("member_ids", options.memberIds.join(","));
2703
- if (options?.recordId !== void 0) params.append("record_id", options.recordId.toString());
2704
2819
  if (options?.search) params.append("search", options.search);
2705
2820
  if (options?.searchField) params.append("search_field", options.searchField);
2706
2821
  if (options?.dataRecordFilterId != null) {
@@ -2856,36 +2971,35 @@ function isUuid(value) {
2856
2971
 
2857
2972
  // src/api/devices.ts
2858
2973
  var DevicesApi = class extends BaseApiClient {
2859
- /** List devices visible to the caller (own devices, or all with devices:admin). */
2860
- async getDevices(wid, options = {}) {
2861
- const qs = options.mine ? "?mine=true" : "";
2862
- return this.fetch(`w/${wid}/devices${qs}`);
2974
+ /** List devices owned by the current Account. */
2975
+ async getDevices() {
2976
+ return this.fetch("account/devices");
2863
2977
  }
2864
- /** Fetch one device by UUID. Non-owners without devices:admin receive 404. */
2865
- async getDevice(wid, deviceUuid) {
2866
- return this.fetch(`w/${wid}/devices/${deviceUuid}`);
2978
+ /** Fetch one device owned by the current Account. Other devices return 404. */
2979
+ async getDevice(deviceUuid) {
2980
+ return this.fetch(`account/devices/${deviceUuid}`);
2867
2981
  }
2868
2982
  /** List shippable companion-device products (Lantern, later SKUs). */
2869
- async getDeviceKinds(wid) {
2870
- return this.fetch(`w/${wid}/devices/kinds`);
2983
+ async getDeviceKinds() {
2984
+ return this.fetch("account/devices/kinds");
2871
2985
  }
2872
- /** Claim a pairing code shown on a companion device. Requires devices:write. */
2873
- async claimDevicePairing(wid, body) {
2874
- return this.fetch(`w/${wid}/devices/pairing/claim`, {
2986
+ /** Claim a pairing code shown on a companion device for the current Account. */
2987
+ async claimDevicePairing(body) {
2988
+ return this.fetch("account/devices/pairing/claim", {
2875
2989
  method: "POST",
2876
2990
  body: JSON.stringify(body)
2877
2991
  });
2878
2992
  }
2879
- /** Update display name and/or LAN capability flags. Requires devices:write. */
2880
- async updateDevice(wid, deviceUuid, body) {
2881
- return this.fetch(`w/${wid}/devices/${deviceUuid}`, {
2993
+ /** Update display name and/or LAN capability flags on an owned device. */
2994
+ async updateDevice(deviceUuid, body) {
2995
+ return this.fetch(`account/devices/${deviceUuid}`, {
2882
2996
  method: "PATCH",
2883
2997
  body: JSON.stringify(body)
2884
2998
  });
2885
2999
  }
2886
- /** Revoke a device credential. The device must pair again. Requires devices:write. */
2887
- async revokeDevice(wid, deviceUuid) {
2888
- return this.fetch(`w/${wid}/devices/${deviceUuid}/revoke`, {
3000
+ /** Revoke an owned device credential. The device must pair again. */
3001
+ async revokeDevice(deviceUuid) {
3002
+ return this.fetch(`account/devices/${deviceUuid}/revoke`, {
2889
3003
  method: "POST",
2890
3004
  body: JSON.stringify({})
2891
3005
  });
@@ -3314,6 +3428,22 @@ var EventsApi = class extends BaseApiClient {
3314
3428
  }
3315
3429
  );
3316
3430
  }
3431
+ /**
3432
+ * Preview what would stop a draft Routine placing its scheduled outbound
3433
+ * calls — the Member voice opt-out, a missing member phone, or a
3434
+ * workspace number that is stale, archived, or not voice-enabled.
3435
+ * Non-persisting and advisory. The audience is reported as counts only,
3436
+ * never as Member rows.
3437
+ */
3438
+ async previewRoutineVoiceReadiness(wid, request) {
3439
+ return this.fetch(
3440
+ `w/${wid}/routines/preview-voice-readiness`,
3441
+ {
3442
+ method: "POST",
3443
+ body: JSON.stringify(request)
3444
+ }
3445
+ );
3446
+ }
3317
3447
  /** List routines with optional pagination and active status filtering. */
3318
3448
  async getRoutines(wid, options = {}) {
3319
3449
  const params = new URLSearchParams();
@@ -3323,6 +3453,8 @@ var EventsApi = class extends BaseApiClient {
3323
3453
  if (options.sortOrder) params.append("sortOrder", options.sortOrder);
3324
3454
  if (options.owner) params.append("owner", options.owner);
3325
3455
  if (options.ownerId) params.append("ownerId", options.ownerId.toString());
3456
+ if (options.agentId) params.append("agentId", options.agentId.toString());
3457
+ if (options.agentOnly) params.append("agentOnly", "true");
3326
3458
  return this.fetch(
3327
3459
  `w/${wid}/routines${params.toString() ? `?${params.toString()}` : ""}`
3328
3460
  );
@@ -4299,7 +4431,14 @@ var InboxesApi = class extends BaseApiClient {
4299
4431
  async getInboxes(wid) {
4300
4432
  return this.fetch(`w/${wid}/inboxes`);
4301
4433
  }
4302
- /** Get an inbox by ID. */
4434
+ /**
4435
+ * Get an inbox by ID or UUID.
4436
+ *
4437
+ * The route has always taken either (`inbox_id: str = Path(..., description=
4438
+ * "Inbox ID or UUID")`); the signature said `number`, which put the UUID path
4439
+ * out of reach for a caller holding an inbox ref from the activity feed —
4440
+ * where refs are UUID-only by design.
4441
+ */
4303
4442
  async getInbox(wid, id) {
4304
4443
  return this.fetch(`w/${wid}/inboxes/${id}`);
4305
4444
  }
@@ -4838,6 +4977,19 @@ var MembersApi = class extends BaseApiClient {
4838
4977
  async getWorkspaceMember(wid, memberId) {
4839
4978
  return this.fetch(`w/${wid}/members/${memberId}`);
4840
4979
  }
4980
+ /**
4981
+ * Get one member of an org's workspace, under `org:read`.
4982
+ *
4983
+ * The same record and the same shape as `getWorkspaceMember`, for a reader
4984
+ * whose authority is the org rather than a member row in that workspace —
4985
+ * an org Activity pane opening a member it just listed. A workspace outside
4986
+ * the org is a 404, indistinguishable from a member id that does not exist.
4987
+ */
4988
+ async getOrgWorkspaceMember(orgUuid, workspaceUuid, memberId) {
4989
+ return this.fetch(
4990
+ `o/${orgUuid}/activity/workspaces/${workspaceUuid}/members/${memberId}`
4991
+ );
4992
+ }
4841
4993
  /** Create a new workspace member. */
4842
4994
  async createWorkspaceMember(wid, data) {
4843
4995
  return this.fetch(`w/${wid}/members`, {
@@ -5017,17 +5169,11 @@ var MembersApi = class extends BaseApiClient {
5017
5169
  * operator can decide whether to skip or explicitly overwrite before
5018
5170
  * committing. Requires MEMBERS_ADMIN and is bulk-PHI audited server-side.
5019
5171
  */
5020
- async previewImportMembers(wid, file, newMemberRoleId, options) {
5172
+ async previewImportMembers(wid, file, newMemberRoleId) {
5021
5173
  const formData = new FormData();
5022
5174
  formData.append("file", file);
5023
5175
  const params = new URLSearchParams();
5024
5176
  params.append("new_member_role_id", newMemberRoleId.toString());
5025
- if (options?.trustEmailAddresses) {
5026
- params.append("trust_email_addresses", "true");
5027
- }
5028
- if (options?.trustPhoneNumbers) {
5029
- params.append("trust_phone_numbers", "true");
5030
- }
5031
5177
  const response = await this.fetchRaw(
5032
5178
  `w/${wid}/members/import/preview?${params.toString()}`,
5033
5179
  {
@@ -5054,12 +5200,6 @@ var MembersApi = class extends BaseApiClient {
5054
5200
  formData.append("file", file);
5055
5201
  const params = new URLSearchParams();
5056
5202
  params.append("new_member_role_id", newMemberRoleId.toString());
5057
- if (options?.trustEmailAddresses) {
5058
- params.append("trust_email_addresses", "true");
5059
- }
5060
- if (options?.trustPhoneNumbers) {
5061
- params.append("trust_phone_numbers", "true");
5062
- }
5063
5203
  if (options?.identityConflictPolicy) {
5064
5204
  params.append("identity_conflict_policy", options.identityConflictPolicy);
5065
5205
  }
@@ -5308,13 +5448,255 @@ var MembersApi = class extends BaseApiClient {
5308
5448
  async getMemberSyncLinks(wid, memberId) {
5309
5449
  return this.fetch(`w/${wid}/members/${memberId}/sync-links`);
5310
5450
  }
5451
+ async getMemberRelationships(wid, memberId, params) {
5452
+ const search = new URLSearchParams();
5453
+ if (params?.page) search.set("page", String(params.page));
5454
+ if (params?.pageSize) search.set("pageSize", String(params.pageSize));
5455
+ if (params?.kind) search.set("kind", params.kind);
5456
+ const qs = search.toString();
5457
+ return this.fetch(
5458
+ `w/${wid}/members/${memberId}/relationships${qs ? `?${qs}` : ""}`
5459
+ );
5460
+ }
5461
+ async createMemberRelationship(wid, memberId, body) {
5462
+ return this.fetch(`w/${wid}/members/${memberId}/relationships`, {
5463
+ method: "POST",
5464
+ body: JSON.stringify(body)
5465
+ });
5466
+ }
5467
+ async archiveMemberRelationship(wid, memberId, relationshipId) {
5468
+ return this.fetch(
5469
+ `w/${wid}/members/${memberId}/relationships/${relationshipId}`,
5470
+ { method: "DELETE" }
5471
+ );
5472
+ }
5311
5473
  };
5312
5474
 
5313
- // src/api/activity-timeline.ts
5314
- var ActivityTimelineApi = class extends BaseApiClient {
5315
- /** One page of activity. Omit `cursor` for a fresh snapshot. */
5316
- async queryActivityTimeline(wid, request = {}) {
5317
- return this.fetch(`w/${wid}/activity-timeline/query`, {
5475
+ // src/api/activity.ts
5476
+ var ActivityApi = class extends BaseApiClient {
5477
+ /** The account mount: this caller's whole estate, at any grain. */
5478
+ async queryActivity(request) {
5479
+ return this.fetch("activity/query", {
5480
+ method: "POST",
5481
+ body: JSON.stringify(request)
5482
+ });
5483
+ }
5484
+ /**
5485
+ * Latest admitted event for each workspace-qualified Activity subject.
5486
+ * Scope authorization and any event-type leaf authorization are both
5487
+ * applied before a subject is returned.
5488
+ */
5489
+ async queryActivityLatestSubjects(request) {
5490
+ return this.fetch("activity/latest-subjects", {
5491
+ method: "POST",
5492
+ body: JSON.stringify(request)
5493
+ });
5494
+ }
5495
+ /**
5496
+ * The account mount's priority lane — one queue per human. `openedAfter`
5497
+ * may bound the active backlog without changing the priority policy.
5498
+ */
5499
+ async queryActivityOpenItems(request = {}) {
5500
+ return this.fetch("activity/open-items", {
5501
+ method: "POST",
5502
+ body: JSON.stringify(request)
5503
+ });
5504
+ }
5505
+ /**
5506
+ * The account mount's one view: one stream of occurrences, some carrying
5507
+ * open state. The window bounds the event axis; open items older than it
5508
+ * arrive as `olderOpenCount`, never hidden.
5509
+ */
5510
+ async queryActivityOneView(request) {
5511
+ return this.fetch("activity/one-view", {
5512
+ method: "POST",
5513
+ body: JSON.stringify(request)
5514
+ });
5515
+ }
5516
+ /** The account mount's badge numbers. */
5517
+ async getActivityCounts(request = {}) {
5518
+ return this.fetch("activity/counts", {
5519
+ method: "POST",
5520
+ body: JSON.stringify(request)
5521
+ });
5522
+ }
5523
+ /**
5524
+ * What this caller's estate admits, so a client renders honest controls.
5525
+ *
5526
+ * Account mount only, and deliberately so: the org and workspace mounts
5527
+ * answer the same question through the surfaces that already serve their
5528
+ * membership. Not an authorization decision — every read re-derives that.
5529
+ */
5530
+ async getActivityCapabilities() {
5531
+ return this.fetch("activity/capabilities", { method: "GET" });
5532
+ }
5533
+ /** The org mount. `org:info` is the entry gate; `org:read` widens the rows. */
5534
+ async queryOrgActivity(orgUuid, request) {
5535
+ return this.fetch(`o/${orgUuid}/activity/query`, {
5536
+ method: "POST",
5537
+ body: JSON.stringify(request)
5538
+ });
5539
+ }
5540
+ async queryOrgActivityLatestSubjects(orgUuid, request) {
5541
+ return this.fetch(`o/${orgUuid}/activity/latest-subjects`, {
5542
+ method: "POST",
5543
+ body: JSON.stringify(request)
5544
+ });
5545
+ }
5546
+ /** The org mount's priority lane. */
5547
+ async queryOrgActivityOpenItems(orgUuid, request = {}) {
5548
+ return this.fetch(`o/${orgUuid}/activity/open-items`, {
5549
+ method: "POST",
5550
+ body: JSON.stringify(request)
5551
+ });
5552
+ }
5553
+ /** The org mount's one view. */
5554
+ async queryOrgActivityOneView(orgUuid, request) {
5555
+ return this.fetch(`o/${orgUuid}/activity/one-view`, {
5556
+ method: "POST",
5557
+ body: JSON.stringify(request)
5558
+ });
5559
+ }
5560
+ /** The org mount's badge numbers. */
5561
+ async getOrgActivityCounts(orgUuid, request = {}) {
5562
+ return this.fetch(`o/${orgUuid}/activity/counts`, {
5563
+ method: "POST",
5564
+ body: JSON.stringify(request)
5565
+ });
5566
+ }
5567
+ /**
5568
+ * The specifics behind a page of aggregate lines, in one round trip.
5569
+ *
5570
+ * Each entry of `request.lines` is an aggregate line's **own server-issued
5571
+ * drill**, POSTed back verbatim, and the response is positional with it — so
5572
+ * a caller maps groups back to rows without inventing a key and without a
5573
+ * second expression of the slice that could drift from the count above it.
5574
+ *
5575
+ * Aggregate-shaped, never row-level: counts per PHI-silent key. A digest the
5576
+ * server could not finish comes back with `complete: false` and no groups,
5577
+ * which a client renders as the plain count phrase rather than as a slice
5578
+ * presented as the whole.
5579
+ */
5580
+ async queryActivityDigest(request) {
5581
+ return this.fetch("activity/digest", {
5582
+ method: "POST",
5583
+ body: JSON.stringify(request)
5584
+ });
5585
+ }
5586
+ /** The org mount's digest. */
5587
+ async queryOrgActivityDigest(orgUuid, request) {
5588
+ return this.fetch(`o/${orgUuid}/activity/digest`, {
5589
+ method: "POST",
5590
+ body: JSON.stringify(request)
5591
+ });
5592
+ }
5593
+ /** The workspace mount's digest. */
5594
+ async queryWorkspaceActivityDigest(workspaceUuid, request) {
5595
+ return this.fetch(`w/${workspaceUuid}/activity/digest`, {
5596
+ method: "POST",
5597
+ body: JSON.stringify(request)
5598
+ });
5599
+ }
5600
+ /** The workspace mount. The request's own member session carries its scopes. */
5601
+ async queryWorkspaceActivity(workspaceUuid, request) {
5602
+ return this.fetch(`w/${workspaceUuid}/activity/query`, {
5603
+ method: "POST",
5604
+ body: JSON.stringify(request)
5605
+ });
5606
+ }
5607
+ async queryWorkspaceActivityLatestSubjects(workspaceUuid, request) {
5608
+ return this.fetch(`w/${workspaceUuid}/activity/latest-subjects`, {
5609
+ method: "POST",
5610
+ body: JSON.stringify(request)
5611
+ });
5612
+ }
5613
+ /** The workspace mount's priority lane. */
5614
+ async queryWorkspaceActivityOpenItems(workspaceUuid, request = {}) {
5615
+ return this.fetch(`w/${workspaceUuid}/activity/open-items`, {
5616
+ method: "POST",
5617
+ body: JSON.stringify(request)
5618
+ });
5619
+ }
5620
+ /** The workspace mount's one view. */
5621
+ async queryWorkspaceActivityOneView(workspaceUuid, request) {
5622
+ return this.fetch(`w/${workspaceUuid}/activity/one-view`, {
5623
+ method: "POST",
5624
+ body: JSON.stringify(request)
5625
+ });
5626
+ }
5627
+ /** The workspace mount's badge numbers. */
5628
+ async getWorkspaceActivityCounts(workspaceUuid, request = {}) {
5629
+ return this.fetch(`w/${workspaceUuid}/activity/counts`, {
5630
+ method: "POST",
5631
+ body: JSON.stringify(request)
5632
+ });
5633
+ }
5634
+ /**
5635
+ * Hydrate a page of typed refs in one round trip.
5636
+ *
5637
+ * The relief valve the design names for chatty hydration, and the by-UUID
5638
+ * read path most entity kinds otherwise lack: nineteen kinds resolve here,
5639
+ * each through the workspace's own live authorizers under the caller's
5640
+ * session. One request per workspace per listing, instead of one per ref.
5641
+ *
5642
+ * **Every requested ref comes back**, in the order it was sent and
5643
+ * deduplicated on `(kind, uuid)`. A ref the caller may not see is an entry
5644
+ * with `status: 'unresolved'` — never a 404, and never an omission, so a
5645
+ * page's ability to render never depends on what it happens to name.
5646
+ * `status: 'unsupported'` means this build has no by-UUID path for that
5647
+ * kind at all (account, org, workspace, domain, subscription and the
5648
+ * commerce kinds; see the resolve registry for each one's reason) — those
5649
+ * resolve through the mount that owns them, and retrying here will not
5650
+ * help.
5651
+ *
5652
+ * PHI: resolved labels are member-identifying data. They belong in the UI
5653
+ * and nowhere else — never a log line, never an error message.
5654
+ */
5655
+ async resolveEntityRefs(workspaceUuid, request) {
5656
+ return this.fetch(`w/${workspaceUuid}/entity-refs/resolve`, {
5657
+ method: "POST",
5658
+ body: JSON.stringify(request)
5659
+ });
5660
+ }
5661
+ /**
5662
+ * Hydrate a page of typed refs spanning an org's workspaces, in one round
5663
+ * trip. `org:info` is the gate; what it buys differs per workspace, and the
5664
+ * server decides — an `org:read` holder reads every workspace in the org,
5665
+ * an `org:info` holder the ones they belong to.
5666
+ *
5667
+ * The request groups refs by workspace because the same UUID under two
5668
+ * workspaces is two entities. A group naming a workspace this caller cannot
5669
+ * reach comes back entirely `unresolved` — the same answer a denied ref
5670
+ * gets, never an error.
5671
+ *
5672
+ * Caps: at most 500 refs and 25 workspaces across the whole request, and a
5673
+ * workspace may be named at most once in it. Each answered group carries the
5674
+ * same per-entry contract as the workspace mount: every requested ref comes
5675
+ * back, with a marker status rather than an omission.
5676
+ *
5677
+ * PHI: resolved labels are member-identifying data. They belong in the UI
5678
+ * and nowhere else — never a log line, never an error message.
5679
+ */
5680
+ async resolveOrgEntityRefs(orgUuid, request) {
5681
+ return this.fetch(`o/${orgUuid}/activity/entity-refs/resolve`, {
5682
+ method: "POST",
5683
+ body: JSON.stringify(request)
5684
+ });
5685
+ }
5686
+ /**
5687
+ * Hydrate a page of typed refs spanning the caller's whole estate.
5688
+ *
5689
+ * The same grouped body as the org mount, and the same rule that the server
5690
+ * chooses each group's authority: a workspace the caller belongs to resolves
5691
+ * under their own member row, and a workspace they reach by holding
5692
+ * `org:read` on its org resolves under that. A client never states which,
5693
+ * because stating it would mean carrying a copy of the policy.
5694
+ *
5695
+ * PHI: resolved labels are member-identifying data. They belong in the UI
5696
+ * and nowhere else — never a log line, never an error message.
5697
+ */
5698
+ async resolveAccountEntityRefs(request) {
5699
+ return this.fetch(`activity/entity-refs/resolve`, {
5318
5700
  method: "POST",
5319
5701
  body: JSON.stringify(request)
5320
5702
  });
@@ -5508,6 +5890,10 @@ var MondayIntegrationApi = class extends BaseApiClient {
5508
5890
 
5509
5891
  // src/api/intervention-requests.ts
5510
5892
  var InterventionRequestsApi = class extends BaseApiClient {
5893
+ /** List every visible Chat that currently needs attention in Agent Mode. */
5894
+ async getAgentModeAttention(wid) {
5895
+ return this.fetch(`w/${wid}/agent-mode/attention`);
5896
+ }
5511
5897
  /** List intervention requests in a workspace, newest first. */
5512
5898
  async getInterventionRequests(wid, params = {}) {
5513
5899
  const query = new URLSearchParams();
@@ -5521,6 +5907,23 @@ var InterventionRequestsApi = class extends BaseApiClient {
5521
5907
  `w/${wid}/intervention-requests${qs ? `?${qs}` : ""}`
5522
5908
  );
5523
5909
  }
5910
+ /**
5911
+ * Resolve one intervention request. One row, one resolution — whoever takes
5912
+ * it closes it for everyone who was notified. Resolving an already-resolved
5913
+ * request is a 409 conflict; a non-escalation request is a 409 too.
5914
+ *
5915
+ * The JSON body (empty when no note is supplied) is required as a CSRF
5916
+ * barrier (GRA-6284), so a cross-site form POST cannot reach it.
5917
+ */
5918
+ async resolveInterventionRequest(wid, requestId, params = {}) {
5919
+ return this.fetch(
5920
+ `w/${wid}/intervention-requests/${requestId}/resolve`,
5921
+ {
5922
+ method: "POST",
5923
+ body: JSON.stringify(params)
5924
+ }
5925
+ );
5926
+ }
5524
5927
  };
5525
5928
 
5526
5929
  // src/api/notification-rules.ts
@@ -5602,12 +6005,6 @@ var OperatorApi = class extends BaseApiClient {
5602
6005
  async getPresenceStatus(wid) {
5603
6006
  return this.fetch(`w/${wid}/presence/me`);
5604
6007
  }
5605
- /** Disconnect the current member's presence session. */
5606
- async disconnectPresence(wid) {
5607
- return this.fetch(`w/${wid}/presence/disconnect-self`, {
5608
- method: "POST"
5609
- });
5610
- }
5611
6008
  // Operator chat message methods
5612
6009
  /** Get paginated chat messages for an operator chat. */
5613
6010
  async getOperatorChatMessages(wid, chatId, limit = 50, offset = 0) {
@@ -6177,6 +6574,28 @@ var OrgApi = class extends BaseApiClient {
6177
6574
  async getLegalEntity(orgUuid, legalEntityUuid) {
6178
6575
  return this.fetch(`o/${orgUuid}/legal-entities/${legalEntityUuid}`);
6179
6576
  }
6577
+ /**
6578
+ * Read one registration draft for a legal entity.
6579
+ *
6580
+ * A draft is what the operator has typed but not submitted. It exists so
6581
+ * data entry is never gated on a prerequisite: someone can write down the
6582
+ * caller-ID name today and submit it the day the business is verified.
6583
+ */
6584
+ async getRegistrationDraft(orgUuid, legalEntityUuid, kind) {
6585
+ return this.fetch(
6586
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/registration-drafts/${kind}`
6587
+ );
6588
+ }
6589
+ /**
6590
+ * Save one registration draft. Always accepted — the server refuses only
6591
+ * an oversized body, never an unfinished one.
6592
+ */
6593
+ async saveRegistrationDraft(orgUuid, legalEntityUuid, kind, data) {
6594
+ return this.fetch(
6595
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/registration-drafts/${kind}`,
6596
+ { method: "PUT", body: JSON.stringify({ data }) }
6597
+ );
6598
+ }
6180
6599
  /** Cached voice trust product state (CNAM / SHAKEN-STIR / Voice Integrity) for one legal entity. */
6181
6600
  async getVoiceTrustProducts(orgUuid, legalEntityUuid) {
6182
6601
  return this.fetch(
@@ -6350,6 +6769,42 @@ var OrgApi = class extends BaseApiClient {
6350
6769
  }
6351
6770
  );
6352
6771
  }
6772
+ // =========================================================================
6773
+ // Organization webhook endpoints (GRA-8314)
6774
+ // =========================================================================
6775
+ async listOrgWebhookEndpoints(orgIdOrUuid) {
6776
+ return this.fetch(`o/${orgIdOrUuid}/webhooks`);
6777
+ }
6778
+ /**
6779
+ * The subscribable event-type vocabulary for the org UI's event-type
6780
+ * picker — exactly what the create/update validators accept, so the UI
6781
+ * never offers a type the API would reject.
6782
+ */
6783
+ async listOrgWebhookEventTypes(orgIdOrUuid) {
6784
+ return this.fetch(`o/${orgIdOrUuid}/webhooks/event-types`);
6785
+ }
6786
+ async createOrgWebhookEndpoint(orgIdOrUuid, data) {
6787
+ return this.fetch(`o/${orgIdOrUuid}/webhooks`, {
6788
+ method: "POST",
6789
+ body: JSON.stringify(data)
6790
+ });
6791
+ }
6792
+ async updateOrgWebhookEndpoint(orgIdOrUuid, endpointUuid, data) {
6793
+ return this.fetch(`o/${orgIdOrUuid}/webhooks/${endpointUuid}`, {
6794
+ method: "PATCH",
6795
+ body: JSON.stringify(data)
6796
+ });
6797
+ }
6798
+ async deleteOrgWebhookEndpoint(orgIdOrUuid, endpointUuid) {
6799
+ return this.fetch(`o/${orgIdOrUuid}/webhooks/${endpointUuid}`, {
6800
+ method: "DELETE"
6801
+ });
6802
+ }
6803
+ async listOrgWebhookEndpointDeliveries(orgIdOrUuid, endpointUuid, limit = 50) {
6804
+ return this.fetch(
6805
+ `o/${orgIdOrUuid}/webhooks/${endpointUuid}/deliveries?limit=${limit}`
6806
+ );
6807
+ }
6353
6808
  };
6354
6809
  function businessProfilePath(orgUuid, legalEntityUuid) {
6355
6810
  return legalEntityUuid ? `o/${orgUuid}/legal-entities/${legalEntityUuid}/business-profile` : `o/${orgUuid}/business-profile`;
@@ -6770,6 +7225,8 @@ var PersonasApi = class extends BaseApiClient {
6770
7225
  const q = new URLSearchParams();
6771
7226
  if (params?.page !== void 0) q.set("page", String(params.page));
6772
7227
  if (params?.pageSize !== void 0) q.set("pageSize", String(params.pageSize));
7228
+ if (params?.includeArchived !== void 0)
7229
+ q.set("includeArchived", String(params.includeArchived));
6773
7230
  const qs = q.toString() ? `?${q.toString()}` : "";
6774
7231
  return this.fetch(`w/${wid}/personas${qs}`);
6775
7232
  }
@@ -6788,6 +7245,18 @@ var PersonasApi = class extends BaseApiClient {
6788
7245
  body: JSON.stringify(data)
6789
7246
  });
6790
7247
  }
7248
+ async archivePersona(wid, id) {
7249
+ return this.fetch(`w/${wid}/personas/${id}/archive`, {
7250
+ method: "POST",
7251
+ body: JSON.stringify({})
7252
+ });
7253
+ }
7254
+ async unarchivePersona(wid, id) {
7255
+ return this.fetch(`w/${wid}/personas/${id}/unarchive`, {
7256
+ method: "POST",
7257
+ body: JSON.stringify({})
7258
+ });
7259
+ }
6791
7260
  async deletePersona(wid, id) {
6792
7261
  return this.fetch(`w/${wid}/personas/${id}`, { method: "DELETE" });
6793
7262
  }
@@ -8462,14 +8931,74 @@ var JourneysApi = class extends BaseApiClient {
8462
8931
  async getJourneyAuthoring(wid, journeyId) {
8463
8932
  return this.fetch(`w/${wid}/journeys/${journeyId}/authoring`);
8464
8933
  }
8465
- /** Create a new journey. Returns the READ projection (`JourneyRead`). */
8934
+ /**
8935
+ * Atomically replace a v2 Journey's whole definition (Journey v2 plan §3.8).
8936
+ *
8937
+ * ONE request carries the ordered touches, the wait into each touch, the
8938
+ * ordered Endings, action associations, goals, and
8939
+ * `expectedUpdatedAt` for optimistic concurrency. It is a full replacement,
8940
+ * not a patch — omitting `goals` is the one exception and leaves them alone.
8941
+ *
8942
+ * Returns the AUTHORING projection (`Journey`): the caller just wrote the
8943
+ * CEL and holds the `journeys:write` scope that authorizes reading it back.
8944
+ *
8945
+ * Refusals are HTTP 409 with a stable `code`:
8946
+ * * `journey_v2_execution_model_mismatch` — the Journey is legacy; use the
8947
+ * step/connection/goal endpoints.
8948
+ * * `journey_v2_structural_edit_not_allowed` — it is live; pause it first.
8949
+ * * `journey_v2_definition_conflict` — someone saved first; reload.
8950
+ * * `journey_v2_invalid_topology` — the resulting graph is not executable;
8951
+ * the body carries `issues` (codes and resource uuids, never CEL).
8952
+ */
8953
+ async putJourneyV2Definition(wid, journeyId, data) {
8954
+ return this.fetch(`w/${wid}/journeys/${journeyId}/v2-definition`, {
8955
+ method: "PUT",
8956
+ body: JSON.stringify(data)
8957
+ });
8958
+ }
8959
+ /**
8960
+ * Dry-run the v2 publish validator against the STORED definition.
8961
+ *
8962
+ * Answers "could I activate this right now?" without attempting the
8963
+ * transition. Issues carry closed codes and resource uuids only — never CEL
8964
+ * and never member data — so they are safe to render or log.
8965
+ */
8966
+ async getJourneyV2Validation(wid, journeyId) {
8967
+ return this.fetch(
8968
+ `w/${wid}/journeys/${journeyId}/v2-definition/validation`
8969
+ );
8970
+ }
8971
+ /**
8972
+ * MemberFilter ids and names, for the Journey authoring picker.
8973
+ *
8974
+ * A v2 wait, route or Ending may carry a structured MemberFilter predicate
8975
+ * and the author selects it by NAME (rule-filters plan §3.10). This is the
8976
+ * catalogue for that control and the whole of what it needs: two scalars per
8977
+ * filter, no `query` predicate, no rules, no counts.
8978
+ *
8979
+ * Authorized on `journeys:write` alone — deliberately NOT the Members
8980
+ * surface's `MembersApi.getMemberFilters`, which is `members:read`
8981
+ * because it returns each filter's predicate. Journey authoring should not
8982
+ * require Member-read access to name a cohort.
8983
+ */
8984
+ async getJourneyFilterOptions(wid) {
8985
+ return this.fetch(`w/${wid}/journeys/filter-options`);
8986
+ }
8987
+ /** Create a new journey. Returns the READ projection (`JourneyRead`). */
8466
8988
  async createJourney(wid, data) {
8467
8989
  return this.fetch(`w/${wid}/journeys`, {
8468
8990
  method: "POST",
8469
8991
  body: JSON.stringify(data)
8470
8992
  });
8471
8993
  }
8472
- /** Update an existing journey. Returns the READ projection (`JourneyRead`). */
8994
+ /**
8995
+ * Update an existing journey. Returns the READ projection (`JourneyRead`).
8996
+ *
8997
+ * `executionModel` is excluded: it is a CREATE-only field. Flipping a live
8998
+ * Journey's engine is a guarded, audited migration operation (Journey v2
8999
+ * plan §3.11), so the server has no update counterpart and sending one here
9000
+ * would silently do nothing.
9001
+ */
8473
9002
  async updateJourney(wid, journeyId, data) {
8474
9003
  return this.fetch(`w/${wid}/journeys/${journeyId}`, {
8475
9004
  method: "PUT",
@@ -8576,8 +9105,6 @@ var JourneysApi = class extends BaseApiClient {
8576
9105
  qs.set("currentTaskId", String(params.currentTaskId));
8577
9106
  if (params?.runtimeFailureEdgeId !== void 0)
8578
9107
  qs.set("runtimeFailureEdgeId", String(params.runtimeFailureEdgeId));
8579
- if (params?.memberJourneyId !== void 0)
8580
- qs.set("memberJourneyId", String(params.memberJourneyId));
8581
9108
  const query = qs.toString();
8582
9109
  return this.fetch(
8583
9110
  `w/${wid}/journeys/${journeyId}/members${query ? `?${query}` : ""}`
@@ -8731,6 +9258,15 @@ var WorkflowsApi = class extends BaseApiClient {
8731
9258
  async getWorkflow(wid, id) {
8732
9259
  return this.fetch(`w/${wid}/workflows/${id}`);
8733
9260
  }
9261
+ async getWorkflowOpeningTurnConversionReport(wid, id) {
9262
+ return this.fetch(`w/${wid}/workflows/${id}/opening-turn/conversion-report`);
9263
+ }
9264
+ async convertWorkflowStartTaskOpeningMessage(wid, id, expectedRuleId) {
9265
+ return this.fetch(`w/${wid}/workflows/${id}/opening-turn/convert-start-task-message`, {
9266
+ method: "POST",
9267
+ body: JSON.stringify({ expectedRuleId })
9268
+ });
9269
+ }
8734
9270
  /** Get activity metrics for a single workflow. */
8735
9271
  async getWorkflowActivity(wid, id, options) {
8736
9272
  const params = options?.days ? `?days=${options.days}` : "";
@@ -9222,7 +9758,9 @@ var Scope = /* @__PURE__ */ ((Scope2) => {
9222
9758
  var BulkMemberResultStatus = {
9223
9759
  created: "created",
9224
9760
  updated: "updated",
9225
- failed: "failed"
9761
+ failed: "failed",
9762
+ conflict: "conflict",
9763
+ skipped: "skipped"
9226
9764
  };
9227
9765
  var MemberImportMatchInfoMatchType = {
9228
9766
  external_id: "external_id",
@@ -9236,6 +9774,7 @@ var MemberImportPreviewRowAction = {
9236
9774
  update: "update",
9237
9775
  unchanged: "unchanged",
9238
9776
  conflict: "conflict",
9777
+ skipped: "skipped",
9239
9778
  error: "error"
9240
9779
  };
9241
9780
 
@@ -9384,6 +9923,8 @@ var EventRuleActionType = /* @__PURE__ */ ((EventRuleActionType2) => {
9384
9923
  EventRuleActionType2["CONNECTOR_OPERATION"] = "connector:operation";
9385
9924
  EventRuleActionType2["ECW_REFRESH_MEMBER_ENCOUNTERS"] = "ecw:refresh_member_encounters";
9386
9925
  EventRuleActionType2["PLAY_AUDIO"] = "audio:play";
9926
+ EventRuleActionType2["CHARLESTON_SEND_PMD_PAGE"] = "charleston:send_pmd_page";
9927
+ EventRuleActionType2["PATIENTSYNC_TRANSFER"] = "patientsync:transfer";
9387
9928
  return EventRuleActionType2;
9388
9929
  })(EventRuleActionType || {});
9389
9930
  function eventRuleActionParams(params) {
@@ -9405,6 +9946,7 @@ var WorkspaceFeature = /* @__PURE__ */ ((WorkspaceFeature2) => {
9405
9946
  WorkspaceFeature2["BROWSER"] = "browser";
9406
9947
  WorkspaceFeature2["WEB_SEARCH"] = "web_search";
9407
9948
  WorkspaceFeature2["CALENDAR"] = "calendar";
9949
+ WorkspaceFeature2["JOURNEY_V2_EDITOR"] = "journey_v2_editor";
9408
9950
  WorkspaceFeature2["EXPERIMENTS"] = "experiments";
9409
9951
  WorkspaceFeature2["MAILBOX_USER_INPUT"] = "mailbox_user_input";
9410
9952
  WorkspaceFeature2["FORKED_TRAJECTORIES"] = "forked_trajectories";
@@ -9567,6 +10109,7 @@ var ModelProvider = {
9567
10109
  elevenlabs: "elevenlabs",
9568
10110
  deepgram: "deepgram",
9569
10111
  xai: "xai",
10112
+ fireworks: "fireworks",
9570
10113
  custom: "custom"
9571
10114
  };
9572
10115
  var ModelType = {
@@ -9669,6 +10212,24 @@ var FhirClientType = /* @__PURE__ */ ((FhirClientType2) => {
9669
10212
  return FhirClientType2;
9670
10213
  })(FhirClientType || {});
9671
10214
 
10215
+ // src/types/generated/qualification.ts
10216
+ var TestChatRunLane = {
10217
+ text: "text",
10218
+ web_realtime: "web_realtime",
10219
+ core_agent_only: "core_agent_only",
10220
+ unsupported: "unsupported",
10221
+ unknown: "unknown"
10222
+ };
10223
+ var TestChatRunOutcome = {
10224
+ simulator_end: "simulator_end",
10225
+ terminal_tool: "terminal_tool",
10226
+ agent_silent: "agent_silent",
10227
+ max_turns: "max_turns",
10228
+ human_end: "human_end",
10229
+ configuration_failure: "configuration_failure",
10230
+ instrument_failure: "instrument_failure"
10231
+ };
10232
+
9672
10233
  // src/types/qualification-types.ts
9673
10234
  var CriterionType = /* @__PURE__ */ ((CriterionType2) => {
9674
10235
  CriterionType2["EXPRESSION"] = "expression";
@@ -9727,6 +10288,253 @@ var ConsentMethod = /* @__PURE__ */ ((ConsentMethod2) => {
9727
10288
  return ConsentMethod2;
9728
10289
  })(ConsentMethod || {});
9729
10290
 
10291
+ // src/types/generated/member_relationship.ts
10292
+ var MemberRelationshipKind = {
10293
+ parent_of: "parent_of",
10294
+ sibling_of: "sibling_of",
10295
+ spouse_of: "spouse_of",
10296
+ caregiver_of: "caregiver_of",
10297
+ emergency_contact_of: "emergency_contact_of",
10298
+ next_of_kin_of: "next_of_kin_of",
10299
+ legal_guardian_of: "legal_guardian_of",
10300
+ healthcare_agent_of: "healthcare_agent_of",
10301
+ doctor_of: "doctor_of",
10302
+ primary_contact_of: "primary_contact_of"
10303
+ };
10304
+ var RelatedMemberRole = {
10305
+ parent: "parent",
10306
+ child: "child",
10307
+ sibling: "sibling",
10308
+ spouse: "spouse",
10309
+ caregiver: "caregiver",
10310
+ care_recipient: "care_recipient",
10311
+ emergency_contact: "emergency_contact",
10312
+ emergency_contact_for: "emergency_contact_for",
10313
+ next_of_kin: "next_of_kin",
10314
+ next_of_kin_for: "next_of_kin_for",
10315
+ legal_guardian: "legal_guardian",
10316
+ legal_guardian_for: "legal_guardian_for",
10317
+ healthcare_agent: "healthcare_agent",
10318
+ healthcare_agent_for: "healthcare_agent_for",
10319
+ doctor: "doctor",
10320
+ patient: "patient",
10321
+ primary_contact: "primary_contact",
10322
+ primary_contact_for: "primary_contact_for"
10323
+ };
10324
+ var RelationshipCardinality = {
10325
+ many_to_many: "many_to_many",
10326
+ one_to_one: "one_to_one",
10327
+ one_per_target: "one_per_target"
10328
+ };
10329
+
10330
+ // src/types/generated/member_relationship_catalog.ts
10331
+ var MEMBER_RELATIONSHIP_KINDS = [
10332
+ {
10333
+ "kind": "parent_of",
10334
+ "cardinality": "many_to_many",
10335
+ "symmetric": false,
10336
+ "grantsChartAccess": false,
10337
+ "roles": [
10338
+ {
10339
+ "role": "parent",
10340
+ "label": "Parent",
10341
+ "inverseLabel": "Child",
10342
+ "description": "This person is a parent of the member. For a minor, also add Legal guardian if they should read the chart."
10343
+ },
10344
+ {
10345
+ "role": "child",
10346
+ "label": "Child",
10347
+ "inverseLabel": "Parent",
10348
+ "description": "This person is a child of the member."
10349
+ }
10350
+ ]
10351
+ },
10352
+ {
10353
+ "kind": "sibling_of",
10354
+ "cardinality": "many_to_many",
10355
+ "symmetric": true,
10356
+ "grantsChartAccess": false,
10357
+ "roles": [
10358
+ {
10359
+ "role": "sibling",
10360
+ "label": "Sibling",
10361
+ "inverseLabel": "Sibling",
10362
+ "description": "These members are siblings."
10363
+ }
10364
+ ]
10365
+ },
10366
+ {
10367
+ "kind": "spouse_of",
10368
+ "cardinality": "one_to_one",
10369
+ "symmetric": true,
10370
+ "grantsChartAccess": false,
10371
+ "roles": [
10372
+ {
10373
+ "role": "spouse",
10374
+ "label": "Spouse",
10375
+ "inverseLabel": "Spouse",
10376
+ "description": "These members are spouses or partners."
10377
+ }
10378
+ ]
10379
+ },
10380
+ {
10381
+ "kind": "caregiver_of",
10382
+ "cardinality": "many_to_many",
10383
+ "symmetric": false,
10384
+ "grantsChartAccess": false,
10385
+ "roles": [
10386
+ {
10387
+ "role": "caregiver",
10388
+ "label": "Caregiver",
10389
+ "inverseLabel": "Care recipient",
10390
+ "description": "This person provides care for the member at home."
10391
+ },
10392
+ {
10393
+ "role": "care_recipient",
10394
+ "label": "Care recipient",
10395
+ "inverseLabel": "Caregiver",
10396
+ "description": "This person receives care from the member."
10397
+ }
10398
+ ]
10399
+ },
10400
+ {
10401
+ "kind": "emergency_contact_of",
10402
+ "cardinality": "many_to_many",
10403
+ "symmetric": false,
10404
+ "grantsChartAccess": false,
10405
+ "roles": [
10406
+ {
10407
+ "role": "emergency_contact",
10408
+ "label": "Emergency contact",
10409
+ "inverseLabel": "Emergency contact for",
10410
+ "description": "This person is the member's emergency contact."
10411
+ },
10412
+ {
10413
+ "role": "emergency_contact_for",
10414
+ "label": "Emergency contact for",
10415
+ "inverseLabel": "Emergency contact",
10416
+ "description": "The member is listed as this person's emergency contact."
10417
+ }
10418
+ ]
10419
+ },
10420
+ {
10421
+ "kind": "next_of_kin_of",
10422
+ "cardinality": "one_per_target",
10423
+ "symmetric": false,
10424
+ "grantsChartAccess": false,
10425
+ "roles": [
10426
+ {
10427
+ "role": "next_of_kin",
10428
+ "label": "Next of kin",
10429
+ "inverseLabel": "Next of kin for",
10430
+ "description": "This person is the member's designated next of kin. A member has at most one."
10431
+ },
10432
+ {
10433
+ "role": "next_of_kin_for",
10434
+ "label": "Next of kin for",
10435
+ "inverseLabel": "Next of kin",
10436
+ "description": "The member is this person's designated next of kin."
10437
+ }
10438
+ ]
10439
+ },
10440
+ {
10441
+ "kind": "legal_guardian_of",
10442
+ "cardinality": "many_to_many",
10443
+ "symmetric": false,
10444
+ "grantsChartAccess": true,
10445
+ "roles": [
10446
+ {
10447
+ "role": "legal_guardian",
10448
+ "label": "Legal guardian",
10449
+ "inverseLabel": "Legal guardian for",
10450
+ "description": "Court-appointed guardian, or parent/person with parental responsibility for a minor."
10451
+ },
10452
+ {
10453
+ "role": "legal_guardian_for",
10454
+ "label": "Legal guardian for",
10455
+ "inverseLabel": "Legal guardian",
10456
+ "description": "The member is this person's legal guardian."
10457
+ }
10458
+ ]
10459
+ },
10460
+ {
10461
+ "kind": "healthcare_agent_of",
10462
+ "cardinality": "many_to_many",
10463
+ "symmetric": false,
10464
+ "grantsChartAccess": true,
10465
+ "roles": [
10466
+ {
10467
+ "role": "healthcare_agent",
10468
+ "label": "Healthcare agent",
10469
+ "inverseLabel": "Healthcare agent for",
10470
+ "description": "Healthcare power of attorney or health proxy."
10471
+ },
10472
+ {
10473
+ "role": "healthcare_agent_for",
10474
+ "label": "Healthcare agent for",
10475
+ "inverseLabel": "Healthcare agent",
10476
+ "description": "The member is this person's healthcare agent (healthcare power of attorney or health proxy)."
10477
+ }
10478
+ ]
10479
+ },
10480
+ {
10481
+ "kind": "doctor_of",
10482
+ "cardinality": "many_to_many",
10483
+ "symmetric": false,
10484
+ "grantsChartAccess": true,
10485
+ "roles": [
10486
+ {
10487
+ "role": "doctor",
10488
+ "label": "Doctor",
10489
+ "inverseLabel": "Patient",
10490
+ "description": "This person is a treating clinician for the member."
10491
+ },
10492
+ {
10493
+ "role": "patient",
10494
+ "label": "Patient",
10495
+ "inverseLabel": "Doctor",
10496
+ "description": "This person is a patient of the member."
10497
+ }
10498
+ ]
10499
+ },
10500
+ {
10501
+ "kind": "primary_contact_of",
10502
+ "cardinality": "one_per_target",
10503
+ "symmetric": false,
10504
+ "grantsChartAccess": true,
10505
+ "roles": [
10506
+ {
10507
+ "role": "primary_contact",
10508
+ "label": "Primary contact",
10509
+ "inverseLabel": "Primary contact for",
10510
+ "description": "This person is the organization's primary contact for the member. A member has at most one."
10511
+ },
10512
+ {
10513
+ "role": "primary_contact_for",
10514
+ "label": "Primary contact for",
10515
+ "inverseLabel": "Primary contact",
10516
+ "description": "The member is this person's assigned primary contact inside the organization."
10517
+ }
10518
+ ]
10519
+ }
10520
+ ];
10521
+
10522
+ // src/types/generated/ui_prompt.ts
10523
+ var UiPromptPresentedKind = {
10524
+ render_ui: "render_ui",
10525
+ present_choice_list: "present_choice_list",
10526
+ inline_connect: "inline_connect"
10527
+ };
10528
+ var UiPromptResponseKind = {
10529
+ render_ui: "render_ui",
10530
+ present_choice_list: "present_choice_list",
10531
+ inline_connect: "inline_connect"
10532
+ };
10533
+ var UiPromptResponseStatus = {
10534
+ submitted: "submitted",
10535
+ declined: "declined"
10536
+ };
10537
+
9730
10538
  // src/api/workspace-invitations.ts
9731
10539
  var WorkspaceInvitationsApi = class extends BaseApiClient {
9732
10540
  /**
@@ -9862,11 +10670,31 @@ var WorkspaceInvitationsApi = class extends BaseApiClient {
9862
10670
  };
9863
10671
 
9864
10672
  // src/api/workspaces.ts
10673
+ function planFields(options) {
10674
+ if (!options) return {};
10675
+ const fields = {};
10676
+ if (options.intent !== void 0) fields.intent = options.intent;
10677
+ if (options.expectedPlanFingerprint !== void 0) {
10678
+ fields.expectedPlanFingerprint = options.expectedPlanFingerprint;
10679
+ }
10680
+ if (options.bindings !== void 0 && options.bindings.length > 0) {
10681
+ fields.bindings = options.bindings;
10682
+ }
10683
+ return fields;
10684
+ }
9865
10685
  var WorkspacesApi = class extends BaseApiClient {
9866
10686
  /** List all workspaces accessible to the current user. */
9867
10687
  async getWorkspaces() {
9868
10688
  return this.fetch("w/");
9869
10689
  }
10690
+ /**
10691
+ * Compact rows for the workspaces a companion device could enter — the
10692
+ * Lantern picker. Filtered by the same admission policy a device
10693
+ * credential is gated by, without needing the device credential.
10694
+ */
10695
+ async getDeviceAdmissibleWorkspaces() {
10696
+ return this.fetch("w/?can_use_device=1");
10697
+ }
9870
10698
  /** List all publicly visible workspaces. */
9871
10699
  async getPublicWorkspaces() {
9872
10700
  return this.fetch("w/public");
@@ -10160,18 +10988,62 @@ var WorkspacesApi = class extends BaseApiClient {
10160
10988
  const qs = searchParams.toString();
10161
10989
  return this.fetch(`w/${wid}/export${qs ? `?${qs}` : ""}`);
10162
10990
  }
10163
- /** Preview the result of importing workspace configuration without applying changes. */
10164
- async previewWorkspaceImport(wid, exportData, importMappings, createNew, autoMap) {
10991
+ /** Preview the result of importing workspace configuration without applying changes.
10992
+ *
10993
+ * Pass `options.intent = 'template_reapply'` to get the deterministic
10994
+ * re-apply plan: `planRows`, `sourceFingerprint` and `planFingerprint` come
10995
+ * back beside the legacy preview items, and the fingerprint is what
10996
+ * `importWorkspace` must be given to apply exactly that projection.
10997
+ */
10998
+ async previewWorkspaceImport(wid, exportData, importMappings, createNew, autoMap, options) {
10165
10999
  return this.fetch(`w/${wid}/preview-import`, {
10166
11000
  method: "POST",
10167
11001
  body: JSON.stringify({
10168
11002
  exportData,
10169
11003
  importMappings,
10170
11004
  createNew,
10171
- autoMap
11005
+ autoMap,
11006
+ ...planFields(options)
10172
11007
  })
10173
11008
  });
10174
11009
  }
11010
+ /**
11011
+ * Plan a workspace export ZIP against this workspace without importing it.
11012
+ *
11013
+ * The sibling of `previewWorkspaceImport`, and it exists for one reason: a
11014
+ * JSON preview has no archive, so it cannot decide whether File BYTES would
11015
+ * be replaced — that decision compares the archive's blob digest against the
11016
+ * destination's current content digest.
11017
+ */
11018
+ async previewWorkspaceImportZip(wid, archive, options) {
11019
+ const { exportData, importMappings, createNew, autoMap, ...planOptions } = options ?? {};
11020
+ const payload = {
11021
+ importMappings: importMappings ?? {},
11022
+ createNew: createNew ?? {},
11023
+ ...planFields(planOptions)
11024
+ };
11025
+ if (exportData) payload.exportData = exportData;
11026
+ if (autoMap) payload.autoMap = autoMap;
11027
+ const form = new FormData();
11028
+ form.append(
11029
+ "request",
11030
+ new Blob([JSON.stringify(payload)], { type: "application/json" }),
11031
+ "import.json"
11032
+ );
11033
+ form.append("archive", archive, "workspace-export.zip");
11034
+ return this.fetch(`w/${wid}/preview-import.zip`, {
11035
+ method: "POST",
11036
+ body: form
11037
+ });
11038
+ }
11039
+ /**
11040
+ * Everything a template re-apply adds to an import or a preview.
11041
+ *
11042
+ * `bindings` values are sent in the request body only. They are never
11043
+ * projected from a response and must never be logged: the point of a
11044
+ * binding is that a webhook endpoint and a signing secret belong to ONE
11045
+ * target workspace.
11046
+ */
10175
11047
  /** Download a workspace export ZIP (``export.json`` + file blobs). */
10176
11048
  async exportWorkspaceZip(wid, workflowId, scope, exclude) {
10177
11049
  const searchParams = new URLSearchParams();
@@ -10185,46 +11057,138 @@ var WorkspacesApi = class extends BaseApiClient {
10185
11057
  /** Import workspace configuration from exported JSON, or from a ZIP archive.
10186
11058
  * Pass ``archive`` (the ZIP from ``exportWorkspaceZip``) to restore file
10187
11059
  * contents. ``exportData`` may be omitted when the ZIP contains it.
10188
- */
10189
- async importWorkspace(wid, exportData, importMappings, createNew, archive) {
10190
- const payload = {
10191
- importMappings,
10192
- createNew
10193
- };
10194
- if (exportData) {
10195
- payload.exportData = exportData;
10196
- }
11060
+ *
11061
+ * ``activateWebhookRules`` is safety-default false: imported
11062
+ * ``webhook:send`` EventRules are force-disabled unless the operator
11063
+ * opts in. An exported-inactive rule stays inactive either way.
11064
+ *
11065
+ * With ``options.intent = 'template_reapply'`` this is the GUARDED apply.
11066
+ * It requires ``options.expectedPlanFingerprint`` — the digest a preview
11067
+ * returned — and answers 200 ``success``, 200 ``noop`` (the target already
11068
+ * matched the template, so nothing at all was recorded), 409
11069
+ * ``stale_import_plan`` or 409 ``import_plan_refused``. Both 409s commit
11070
+ * nothing and carry the complete values-free ``planRows``.
11071
+ */
11072
+ async importWorkspace(wid, exportData, importMappings, createNew, archive, activateWebhookRules, autoMap, options) {
10197
11073
  if (archive) {
10198
- const form = new FormData();
10199
- form.append(
10200
- "request",
10201
- new Blob([JSON.stringify(payload)], { type: "application/json" }),
10202
- "import.json"
10203
- );
10204
- form.append("archive", archive, "workspace-export.zip");
10205
- return this.fetch(`w/${wid}/import.zip`, {
10206
- method: "POST",
10207
- body: form
11074
+ return this.importWorkspaceZip(wid, archive, {
11075
+ ...options,
11076
+ exportData,
11077
+ importMappings,
11078
+ createNew,
11079
+ autoMap,
11080
+ activateWebhookRules
10208
11081
  });
10209
11082
  }
10210
11083
  if (!exportData) {
10211
11084
  throw new Error("exportData is required for JSON import");
10212
11085
  }
11086
+ const payload = {
11087
+ exportData,
11088
+ importMappings,
11089
+ createNew,
11090
+ ...planFields(options)
11091
+ };
11092
+ if (activateWebhookRules) {
11093
+ payload.activateWebhookRules = activateWebhookRules;
11094
+ }
11095
+ if (autoMap) {
11096
+ payload.autoMap = autoMap;
11097
+ }
10213
11098
  return this.fetch(`w/${wid}/import`, {
10214
11099
  method: "POST",
10215
11100
  body: JSON.stringify(payload)
10216
11101
  });
10217
11102
  }
11103
+ /**
11104
+ * Apply a workspace export ZIP to this workspace.
11105
+ *
11106
+ * The apply sibling of `previewWorkspaceImportZip`, and the same multipart
11107
+ * shape: the archive travels as `archive`, everything else as one JSON
11108
+ * `request` part. `exportData` defaults to `export.json` inside the ZIP, so
11109
+ * it is sent only to override it.
11110
+ *
11111
+ * With `options.intent = 'template_reapply'` this is the GUARDED apply. It
11112
+ * requires `options.expectedPlanFingerprint` — the digest a preview
11113
+ * returned — and answers 200 `success`, 200 `noop` (the target already
11114
+ * matched the template, so nothing at all was recorded), 409
11115
+ * `stale_import_plan` or 409 `import_plan_refused`. Both 409s commit
11116
+ * nothing and carry the complete values-free `planRows`.
11117
+ *
11118
+ * `options.bindings` values are sent in the request body only. They are
11119
+ * never projected from a response and must never be logged: the point of a
11120
+ * binding is that a webhook endpoint and a signing secret belong to ONE
11121
+ * target workspace.
11122
+ */
11123
+ async importWorkspaceZip(wid, archive, options) {
11124
+ const {
11125
+ exportData,
11126
+ importMappings,
11127
+ createNew,
11128
+ autoMap,
11129
+ activateWebhookRules,
11130
+ ...planOptions
11131
+ } = options ?? {};
11132
+ const payload = {
11133
+ importMappings: importMappings ?? {},
11134
+ createNew: createNew ?? {},
11135
+ ...planFields(planOptions)
11136
+ };
11137
+ if (exportData) payload.exportData = exportData;
11138
+ if (activateWebhookRules) payload.activateWebhookRules = activateWebhookRules;
11139
+ if (autoMap) payload.autoMap = autoMap;
11140
+ const form = new FormData();
11141
+ form.append(
11142
+ "request",
11143
+ new Blob([JSON.stringify(payload)], { type: "application/json" }),
11144
+ "import.json"
11145
+ );
11146
+ form.append("archive", archive, "workspace-export.zip");
11147
+ return this.fetch(`w/${wid}/import.zip`, {
11148
+ method: "POST",
11149
+ body: form
11150
+ });
11151
+ }
11152
+ /**
11153
+ * Reconnectable EventRules skipped by the latest workspace import, grouped
11154
+ * by the missing phone / inbox / member. Templates and action params are
11155
+ * not returned.
11156
+ */
11157
+ async getImportSkippedRules(wid, status) {
11158
+ const params = new URLSearchParams();
11159
+ if (status !== void 0) {
11160
+ params.set("status", status);
11161
+ }
11162
+ const qs = params.toString();
11163
+ return this.fetch(
11164
+ `w/${wid}/import/skipped-rules${qs ? `?${qs}` : ""}`
11165
+ );
11166
+ }
11167
+ /** Current bounded phone, inbox, and phone-chat binding gaps after an import. */
11168
+ async getImportReadiness(wid) {
11169
+ return this.fetch(`w/${wid}/import/readiness`);
11170
+ }
11171
+ /**
11172
+ * Re-point every outstanding skipped EventRule that needed the same source
11173
+ * resource onto a re-provisioned one, recreating each rule from its
11174
+ * preserved definition. Repeat calls no-op on already-reconnected rows.
11175
+ */
11176
+ async rebuildImportSkippedRules(wid, body) {
11177
+ return this.fetch(
11178
+ `w/${wid}/import/skipped-rules/rebuild`,
11179
+ { method: "POST", body: JSON.stringify(body) }
11180
+ );
11181
+ }
10218
11182
  /** Preview a workspace import using the legacy untyped interface. */
10219
11183
  // Legacy method for backward compatibility
10220
- async previewImportWorkspace(wid, exportData, importMappings = {}, createNew = {}) {
11184
+ async previewImportWorkspace(wid, exportData, importMappings = {}, createNew = {}, autoMap) {
11185
+ const payload = { exportData, importMappings, createNew };
11186
+ if (autoMap) {
11187
+ payload.autoMap = autoMap;
11188
+ }
10221
11189
  return this.fetch(`w/${wid}/preview-import`, {
10222
11190
  method: "POST",
10223
- body: JSON.stringify({
10224
- exportData,
10225
- importMappings,
10226
- createNew
10227
- })
11191
+ body: JSON.stringify(payload)
10228
11192
  });
10229
11193
  }
10230
11194
  /** List available themes for a workspace. */
@@ -10372,7 +11336,7 @@ function createApiModules(apiKey, baseUrl, customFetch) {
10372
11336
  connectionSync: new ConnectionSyncApi(apiKey, baseUrl, customFetch),
10373
11337
  mcpServers: new McpServersApi(apiKey, baseUrl, customFetch),
10374
11338
  members: new MembersApi(apiKey, baseUrl, customFetch),
10375
- activityTimeline: new ActivityTimelineApi(apiKey, baseUrl, customFetch),
11339
+ activity: new ActivityApi(apiKey, baseUrl, customFetch),
10376
11340
  motd: new MotdApi(apiKey, baseUrl, customFetch),
10377
11341
  trackedLinks: new TrackedLinksApi(apiKey, baseUrl, customFetch),
10378
11342
  confluence: new ConfluenceApi(apiKey, baseUrl, customFetch),
@@ -10419,6 +11383,8 @@ var WORKSPACE_METHOD_NAMES = [
10419
11383
  "archiveDataType",
10420
11384
  "archiveJourney",
10421
11385
  "archiveMember",
11386
+ "archiveMemberRelationship",
11387
+ "archivePersona",
10422
11388
  "archivePhoneNumber",
10423
11389
  "archiveStep",
10424
11390
  "archiveTask",
@@ -10471,6 +11437,8 @@ var WORKSPACE_METHOD_NAMES = [
10471
11437
  "createCalendarEventType",
10472
11438
  "createCalendarSchedule",
10473
11439
  "createChat",
11440
+ "createChatInteractionSession",
11441
+ "transitionChatInteractionSession",
10474
11442
  "createChatCompletion",
10475
11443
  "createChatFilter",
10476
11444
  "createChatLabel",
@@ -10500,6 +11468,7 @@ var WORKSPACE_METHOD_NAMES = [
10500
11468
  "createMemberFilter",
10501
11469
  "createMemberLabel",
10502
11470
  "createMemberMemory",
11471
+ "createMemberRelationship",
10503
11472
  "createMemberRole",
10504
11473
  "createMenuItem",
10505
11474
  "createNotificationRule",
@@ -10602,7 +11571,6 @@ var WORKSPACE_METHOD_NAMES = [
10602
11571
  "disconnectConfluence",
10603
11572
  "disconnectHubspot",
10604
11573
  "disconnectMondayConnection",
10605
- "disconnectPresence",
10606
11574
  "disconnectSalesforce",
10607
11575
  "discordLinkPreflight",
10608
11576
  "discoverOAuthMetadata",
@@ -10665,6 +11633,7 @@ var WORKSPACE_METHOD_NAMES = [
10665
11633
  "getAccessGrant",
10666
11634
  "getAccessGrants",
10667
11635
  "getAgent",
11636
+ "getAgentModeAttention",
10668
11637
  "getAgentTask",
10669
11638
  "getAgentTaskMessages",
10670
11639
  "getAgentTasks",
@@ -10696,7 +11665,9 @@ var WORKSPACE_METHOD_NAMES = [
10696
11665
  "getCharlestonTestDeliveryRecipients",
10697
11666
  "getChat",
10698
11667
  "getChatAssignmentTasks",
11668
+ "getChatBrowserLiveView",
10699
11669
  "getChatCallbacks",
11670
+ "getChatEhrWritebackOutcomes",
10700
11671
  "getChatEmails",
10701
11672
  "getChatFilter",
10702
11673
  "getChatFilterByUuid",
@@ -10705,6 +11676,7 @@ var WORKSPACE_METHOD_NAMES = [
10705
11676
  "getChatLabel",
10706
11677
  "getChatLabelByUuid",
10707
11678
  "getChatLabels",
11679
+ "getChatMachineResources",
10708
11680
  "getChatMessages",
10709
11681
  "getChatModelOverride",
10710
11682
  "getChatPhoneCalls",
@@ -10745,6 +11717,8 @@ var WORKSPACE_METHOD_NAMES = [
10745
11717
  "getDataRecordFilters",
10746
11718
  "getDataRecords",
10747
11719
  "getDataType",
11720
+ "getDataTypeDraft",
11721
+ "getDataTypeVersions",
10748
11722
  "getDataTypeByUuid",
10749
11723
  "getDataTypeBySlug",
10750
11724
  "getDataTypes",
@@ -10788,9 +11762,16 @@ var WORKSPACE_METHOD_NAMES = [
10788
11762
  "listChatRecordings",
10789
11763
  "previewQuery",
10790
11764
  "publishSiteSource",
10791
- "queryActivityTimeline",
11765
+ "publishDataTypeDraft",
11766
+ "saveDataTypeDraft",
11767
+ "queryWorkspaceActivity",
11768
+ "queryWorkspaceActivityLatestSubjects",
11769
+ "queryWorkspaceActivityOpenItems",
11770
+ "queryWorkspaceActivityOneView",
11771
+ "queryWorkspaceActivityDigest",
10792
11772
  "registerDiscordSlashCommands",
10793
11773
  "reopenWorkspaceSupportRequest",
11774
+ "resolveEntityRefs",
10794
11775
  "resetSiteSource",
10795
11776
  "resolveFilePath",
10796
11777
  "getFileLabel",
@@ -10818,16 +11799,22 @@ var WORKSPACE_METHOD_NAMES = [
10818
11799
  "getHubspotSyncLogs",
10819
11800
  "getHubspotTransformPresets",
10820
11801
  "getICalFeedUrl",
11802
+ "getImportSkippedRules",
11803
+ "getImportReadiness",
11804
+ "rebuildImportSkippedRules",
10821
11805
  "getInbox",
10822
11806
  "getInboxEmail",
10823
11807
  "getInboxEmails",
10824
11808
  "getInboxThreads",
10825
11809
  "getInboxes",
11810
+ "getInterventionRequests",
10826
11811
  "getJourney",
10827
11812
  "getJourneyAuthoring",
11813
+ "getJourneyFilterOptions",
10828
11814
  "getJourneyHealth",
10829
11815
  "getJourneyMembers",
10830
11816
  "getJourneyNotes",
11817
+ "getJourneyV2Validation",
10831
11818
  "getJourneys",
10832
11819
  "getLinkablePhones",
10833
11820
  "getLinkedHealthieMembers",
@@ -10855,6 +11842,7 @@ var WORKSPACE_METHOD_NAMES = [
10855
11842
  "getMemberMemories",
10856
11843
  "getMemberMemory",
10857
11844
  "getMemberRecordCounts",
11845
+ "getMemberRelationships",
10858
11846
  "getMemberRole",
10859
11847
  "getMemberRoleCleanupPlan",
10860
11848
  "getMemberRoleByUuid",
@@ -10903,8 +11891,6 @@ var WORKSPACE_METHOD_NAMES = [
10903
11891
  "getPublicFolder",
10904
11892
  "getPublicFolderFiles",
10905
11893
  "getPublicProducts",
10906
- "previewPromoCode",
10907
- "startPromoPlanTrial",
10908
11894
  "getQualification",
10909
11895
  "getQualifications",
10910
11896
  "getRecordingInfo",
@@ -10959,10 +11945,10 @@ var WORKSPACE_METHOD_NAMES = [
10959
11945
  "getUnreadNotificationCount",
10960
11946
  "getUsageDashboard",
10961
11947
  "getVariableRegistry",
10962
- "getVoiceToken",
10963
11948
  "getVoiceUsageReport",
10964
11949
  "getWebhookLogs",
10965
11950
  "getWorkflow",
11951
+ "getWorkflowOpeningTurnConversionReport",
10966
11952
  "getWorkflowAccessValidation",
10967
11953
  "getWorkflowActivity",
10968
11954
  "getWorkflowConfigValidation",
@@ -10979,6 +11965,7 @@ var WORKSPACE_METHOD_NAMES = [
10979
11965
  "getWorkflows",
10980
11966
  "getWorkflowsActivityBatch",
10981
11967
  "getWorkspace",
11968
+ "getWorkspaceActivityCounts",
10982
11969
  "getWorkspaceBuilder",
10983
11970
  "getWorkspaceBuilders",
10984
11971
  "getWorkspaceCounts",
@@ -10998,7 +11985,7 @@ var WORKSPACE_METHOD_NAMES = [
10998
11985
  "importMembers",
10999
11986
  "importSalesforceMembers",
11000
11987
  "importWorkspace",
11001
- "initiateCall",
11988
+ "importWorkspaceZip",
11002
11989
  "initiateOutboundCall",
11003
11990
  "inspectPrompt",
11004
11991
  "installHubspot",
@@ -11055,14 +12042,17 @@ var WORKSPACE_METHOD_NAMES = [
11055
12042
  "previewMemberWorkflowVoice",
11056
12043
  "previewRenameFieldSlug",
11057
12044
  "previewImportWorkspace",
12045
+ "previewRoutineVoiceReadiness",
11058
12046
  "previewRoutineWorkflowAccess",
11059
12047
  "previewSchedule",
11060
12048
  "previewTTS",
11061
12049
  "previewTemplate",
11062
12050
  "previewThinkingSound",
11063
12051
  "previewWorkspaceImport",
12052
+ "previewWorkspaceImportZip",
11064
12053
  "provisionClientWorkspace",
11065
12054
  "publishWorkflowRevision",
12055
+ "putJourneyV2Definition",
11066
12056
  "rateMessage",
11067
12057
  "getChatFeedback",
11068
12058
  "reenrollMember",
@@ -11083,6 +12073,7 @@ var WORKSPACE_METHOD_NAMES = [
11083
12073
  "resetRoutineRuns",
11084
12074
  "resolveAccessGrant",
11085
12075
  "resolveAnonymousMember",
12076
+ "resolveInterventionRequest",
11086
12077
  "restoreFileVersion",
11087
12078
  "revokeAccessGrant",
11088
12079
  "revokeApiKey",
@@ -11123,6 +12114,7 @@ var WORKSPACE_METHOD_NAMES = [
11123
12114
  "unarchiveChat",
11124
12115
  "unarchiveDataType",
11125
12116
  "unarchiveMember",
12117
+ "unarchivePersona",
11126
12118
  "unarchiveStep",
11127
12119
  "unarchiveTask",
11128
12120
  "unarchiveWorkflow",
@@ -11147,7 +12139,6 @@ var WORKSPACE_METHOD_NAMES = [
11147
12139
  "updateChatLabel",
11148
12140
  "updateChatModelOverride",
11149
12141
  "updateChatMute",
11150
- "updateChatNeedsResponse",
11151
12142
  "updateClientWorkspace",
11152
12143
  "updateConnection",
11153
12144
  "updateConnectionSyncConfig",
@@ -11211,6 +12202,7 @@ var WORKSPACE_METHOD_NAMES = [
11211
12202
  "uploadFile",
11212
12203
  "updateVoicemailStatus",
11213
12204
  "updateWorkflow",
12205
+ "convertWorkflowStartTaskOpeningMessage",
11214
12206
  "updateWorkflowContributor",
11215
12207
  "updateWorkflowNote",
11216
12208
  "updateWorkflowRevisionMetadata",
@@ -11257,6 +12249,13 @@ function bindAccessGrantsMethods(target, accessGrants) {
11257
12249
  target.getGranteeGrants = accessGrants.getGranteeGrants.bind(accessGrants);
11258
12250
  }
11259
12251
 
12252
+ // src/client/bindings/intervention-requests.ts
12253
+ function bindInterventionRequestsMethods(target, interventionRequests) {
12254
+ target.getAgentModeAttention = interventionRequests.getAgentModeAttention.bind(interventionRequests);
12255
+ target.getInterventionRequests = interventionRequests.getInterventionRequests.bind(interventionRequests);
12256
+ target.resolveInterventionRequest = interventionRequests.resolveInterventionRequest.bind(interventionRequests);
12257
+ }
12258
+
11260
12259
  // src/client/bindings/agent-tasks.ts
11261
12260
  function bindAgentTasksMethods(target, api) {
11262
12261
  target.getAgentTasks = api.getAgentTasks.bind(api);
@@ -11297,10 +12296,15 @@ function bindTasksMethods(target, tasks, abilities) {
11297
12296
 
11298
12297
  // src/client/bindings/chats.ts
11299
12298
  function bindChatsMethods(target, chats) {
12299
+ target.createChatInteractionSession = chats.createChatInteractionSession.bind(chats);
12300
+ target.transitionChatInteractionSession = chats.transitionChatInteractionSession.bind(chats);
11300
12301
  target.getChats = chats.getChats.bind(chats);
11301
12302
  target.getChat = chats.getChat.bind(chats);
12303
+ target.getChatBrowserLiveView = chats.getChatBrowserLiveView.bind(chats);
12304
+ target.getChatMachineResources = chats.getChatMachineResources.bind(chats);
11302
12305
  target.getCurrentSmsChat = chats.getCurrentSmsChat.bind(chats);
11303
12306
  target.getChatCallbacks = chats.getChatCallbacks.bind(chats);
12307
+ target.getChatEhrWritebackOutcomes = chats.getChatEhrWritebackOutcomes.bind(chats);
11304
12308
  target.cancelChatCallback = chats.cancelChatCallback.bind(chats);
11305
12309
  target.getChatTokenUsage = chats.getChatTokenUsage.bind(chats);
11306
12310
  target.getChatTodos = chats.getChatTodos.bind(chats);
@@ -11318,7 +12322,6 @@ function bindChatsMethods(target, chats) {
11318
12322
  target.getChatModelOverride = chats.getChatModelOverride.bind(chats);
11319
12323
  target.updateChatModelOverride = chats.updateChatModelOverride.bind(chats);
11320
12324
  target.updateChatMute = chats.updateChatMute.bind(chats);
11321
- target.updateChatNeedsResponse = chats.updateChatNeedsResponse.bind(chats);
11322
12325
  target.summarizeChat = chats.summarizeChat.bind(chats);
11323
12326
  target.getChatMessages = chats.getChatMessages.bind(chats);
11324
12327
  target.getChildThreadMessages = chats.getChildThreadMessages.bind(chats);
@@ -11353,8 +12356,6 @@ function bindChatsMethods(target, chats) {
11353
12356
  // src/client/bindings/calls.ts
11354
12357
  function bindCallsMethods(target, calls, cel) {
11355
12358
  target.getPhoneCalls = calls.getPhoneCalls.bind(calls);
11356
- target.initiateCall = calls.initiateCall.bind(calls);
11357
- target.getVoiceToken = calls.getVoiceToken.bind(calls);
11358
12359
  target.getMessageTiming = calls.getMessageTiming.bind(calls);
11359
12360
  target.getRecordingInfo = calls.getRecordingInfo.bind(calls);
11360
12361
  target.listChatRecordings = calls.listChatRecordings.bind(calls);
@@ -11375,9 +12376,30 @@ function bindDashboardsMethods(target, dashboards) {
11375
12376
  target.getConfigurationHealth = dashboards.getConfigurationHealth.bind(dashboards);
11376
12377
  }
11377
12378
 
11378
- // src/client/bindings/activity-timeline.ts
11379
- function bindActivityTimelineMethods(target, activityTimeline) {
11380
- target.queryActivityTimeline = activityTimeline.queryActivityTimeline.bind(activityTimeline);
12379
+ // src/client/bindings/activity.ts
12380
+ function bindActivityMethods(target, activity) {
12381
+ target.queryActivity = activity.queryActivity.bind(activity);
12382
+ target.queryActivityLatestSubjects = activity.queryActivityLatestSubjects.bind(activity);
12383
+ target.queryActivityOpenItems = activity.queryActivityOpenItems.bind(activity);
12384
+ target.queryActivityOneView = activity.queryActivityOneView.bind(activity);
12385
+ target.queryActivityDigest = activity.queryActivityDigest.bind(activity);
12386
+ target.getActivityCounts = activity.getActivityCounts.bind(activity);
12387
+ target.getActivityCapabilities = activity.getActivityCapabilities.bind(activity);
12388
+ target.queryOrgActivity = activity.queryOrgActivity.bind(activity);
12389
+ target.queryOrgActivityLatestSubjects = activity.queryOrgActivityLatestSubjects.bind(activity);
12390
+ target.queryOrgActivityOpenItems = activity.queryOrgActivityOpenItems.bind(activity);
12391
+ target.queryOrgActivityOneView = activity.queryOrgActivityOneView.bind(activity);
12392
+ target.queryOrgActivityDigest = activity.queryOrgActivityDigest.bind(activity);
12393
+ target.getOrgActivityCounts = activity.getOrgActivityCounts.bind(activity);
12394
+ target.queryWorkspaceActivity = activity.queryWorkspaceActivity.bind(activity);
12395
+ target.queryWorkspaceActivityLatestSubjects = activity.queryWorkspaceActivityLatestSubjects.bind(activity);
12396
+ target.queryWorkspaceActivityOpenItems = activity.queryWorkspaceActivityOpenItems.bind(activity);
12397
+ target.queryWorkspaceActivityOneView = activity.queryWorkspaceActivityOneView.bind(activity);
12398
+ target.queryWorkspaceActivityDigest = activity.queryWorkspaceActivityDigest.bind(activity);
12399
+ target.getWorkspaceActivityCounts = activity.getWorkspaceActivityCounts.bind(activity);
12400
+ target.resolveEntityRefs = activity.resolveEntityRefs.bind(activity);
12401
+ target.resolveOrgEntityRefs = activity.resolveOrgEntityRefs.bind(activity);
12402
+ target.resolveAccountEntityRefs = activity.resolveAccountEntityRefs.bind(activity);
11381
12403
  }
11382
12404
 
11383
12405
  // src/client/bindings/motd.ts
@@ -11399,6 +12421,10 @@ function bindTrackedLinksMethods(target, trackedLinks) {
11399
12421
 
11400
12422
  // src/client/bindings/data-types.ts
11401
12423
  function bindDataTypesMethods(target, dataTypes) {
12424
+ target.getDataTypeDraft = dataTypes.getDataTypeDraft.bind(dataTypes);
12425
+ target.saveDataTypeDraft = dataTypes.saveDataTypeDraft.bind(dataTypes);
12426
+ target.publishDataTypeDraft = dataTypes.publishDataTypeDraft.bind(dataTypes);
12427
+ target.getDataTypeVersions = dataTypes.getDataTypeVersions.bind(dataTypes);
11402
12428
  target.getDataTypes = dataTypes.getDataTypes.bind(dataTypes);
11403
12429
  target.getDataType = dataTypes.getDataType.bind(dataTypes);
11404
12430
  target.getDataTypeByUuid = dataTypes.getDataTypeByUuid.bind(dataTypes);
@@ -11455,6 +12481,7 @@ function bindMembersMethods(target, members) {
11455
12481
  target.updateCurrentMember = members.updateCurrentMember.bind(members);
11456
12482
  target.getWorkspaceMembers = members.getWorkspaceMembers.bind(members);
11457
12483
  target.getWorkspaceMember = members.getWorkspaceMember.bind(members);
12484
+ target.getOrgWorkspaceMember = members.getOrgWorkspaceMember.bind(members);
11458
12485
  target.createWorkspaceMember = members.createWorkspaceMember.bind(members);
11459
12486
  target.updateMember = members.updateMember.bind(members);
11460
12487
  target.deleteMember = members.deleteMember.bind(members);
@@ -11484,6 +12511,8 @@ function bindMembersMethods(target, members) {
11484
12511
  target.createMemberRole = members.createMemberRole.bind(members);
11485
12512
  target.updateMemberRole = members.updateMemberRole.bind(members);
11486
12513
  target.deleteMemberRole = members.deleteMemberRole.bind(members);
12514
+ target.getMemberRoleCleanupPlan = members.getMemberRoleCleanupPlan.bind(members);
12515
+ target.mergeMemberRoles = members.mergeMemberRoles.bind(members);
11487
12516
  target.getMemberFields = members.getMemberFields.bind(members);
11488
12517
  target.getMemberFieldDefinitions = members.getMemberFieldDefinitions.bind(members);
11489
12518
  target.createMemberField = members.createMemberField.bind(members);
@@ -11501,11 +12530,15 @@ function bindMembersMethods(target, members) {
11501
12530
  target.createMemberMemory = members.createMemberMemory.bind(members);
11502
12531
  target.deleteMemberMemory = members.deleteMemberMemory.bind(members);
11503
12532
  target.getMemberSyncLinks = members.getMemberSyncLinks.bind(members);
12533
+ target.getMemberRelationships = members.getMemberRelationships.bind(members);
12534
+ target.createMemberRelationship = members.createMemberRelationship.bind(members);
12535
+ target.archiveMemberRelationship = members.archiveMemberRelationship.bind(members);
11504
12536
  }
11505
12537
 
11506
12538
  // src/client/bindings/workspaces.ts
11507
12539
  function bindWorkspacesMethods(target, workspaces, signupRequests) {
11508
12540
  target.getWorkspaces = workspaces.getWorkspaces.bind(workspaces);
12541
+ target.getDeviceAdmissibleWorkspaces = workspaces.getDeviceAdmissibleWorkspaces.bind(workspaces);
11509
12542
  target.getPublicWorkspaces = workspaces.getPublicWorkspaces.bind(workspaces);
11510
12543
  target.getWorkspace = workspaces.getWorkspace.bind(workspaces);
11511
12544
  target.createWorkspace = workspaces.createWorkspace.bind(workspaces);
@@ -11536,6 +12569,8 @@ function bindWorkspacesMethods(target, workspaces, signupRequests) {
11536
12569
  target.getProduct = workspaces.getProduct.bind(workspaces);
11537
12570
  target.getWorkspaceProduct = workspaces.getWorkspaceProduct.bind(workspaces);
11538
12571
  target.getPublicProducts = workspaces.getPublicProducts.bind(workspaces);
12572
+ target.previewPromoCode = workspaces.previewPromoCode.bind(workspaces);
12573
+ target.startPromoPlanTrial = workspaces.startPromoPlanTrial.bind(workspaces);
11539
12574
  target.getPublicProduct = workspaces.getPublicProduct.bind(workspaces);
11540
12575
  target.createProduct = workspaces.createProduct.bind(workspaces);
11541
12576
  target.updateProduct = workspaces.updateProduct.bind(workspaces);
@@ -11543,7 +12578,12 @@ function bindWorkspacesMethods(target, workspaces, signupRequests) {
11543
12578
  target.exportWorkspace = workspaces.exportWorkspace.bind(workspaces);
11544
12579
  target.exportWorkspaceZip = workspaces.exportWorkspaceZip.bind(workspaces);
11545
12580
  target.previewWorkspaceImport = workspaces.previewWorkspaceImport.bind(workspaces);
12581
+ target.previewWorkspaceImportZip = workspaces.previewWorkspaceImportZip.bind(workspaces);
11546
12582
  target.importWorkspace = workspaces.importWorkspace.bind(workspaces);
12583
+ target.importWorkspaceZip = workspaces.importWorkspaceZip.bind(workspaces);
12584
+ target.getImportSkippedRules = workspaces.getImportSkippedRules.bind(workspaces);
12585
+ target.getImportReadiness = workspaces.getImportReadiness.bind(workspaces);
12586
+ target.rebuildImportSkippedRules = workspaces.rebuildImportSkippedRules.bind(workspaces);
11547
12587
  target.previewImportWorkspace = workspaces.previewImportWorkspace.bind(workspaces);
11548
12588
  target.getWorkspaceThemes = workspaces.getWorkspaceThemes.bind(workspaces);
11549
12589
  target.updateWorkspaceThemes = workspaces.updateWorkspaceThemes.bind(workspaces);
@@ -11751,9 +12791,11 @@ function bindEventsMethods(target, events) {
11751
12791
  target.updateRoutine = events.updateRoutine.bind(events);
11752
12792
  target.deleteRoutine = events.deleteRoutine.bind(events);
11753
12793
  target.runRoutine = events.runRoutine.bind(events);
12794
+ target.getRoutineConfigEvents = events.getRoutineConfigEvents.bind(events);
11754
12795
  target.getRoutineRuns = events.getRoutineRuns.bind(events);
11755
12796
  target.resetRoutineRuns = events.resetRoutineRuns.bind(events);
11756
12797
  target.previewSchedule = events.previewSchedule.bind(events);
12798
+ target.previewRoutineVoiceReadiness = events.previewRoutineVoiceReadiness.bind(events);
11757
12799
  target.previewRoutineWorkflowAccess = events.previewRoutineWorkflowAccess.bind(events);
11758
12800
  }
11759
12801
 
@@ -11778,6 +12820,8 @@ function bindExperimentsMethods(target, experiments) {
11778
12820
  function bindWorkflowsMethods(target, workflows, workflowNotes, voice, supervisors) {
11779
12821
  target.getWorkflows = workflows.getWorkflows.bind(workflows);
11780
12822
  target.getWorkflow = workflows.getWorkflow.bind(workflows);
12823
+ target.getWorkflowOpeningTurnConversionReport = workflows.getWorkflowOpeningTurnConversionReport.bind(workflows);
12824
+ target.convertWorkflowStartTaskOpeningMessage = workflows.convertWorkflowStartTaskOpeningMessage.bind(workflows);
11781
12825
  target.getWorkflowActivity = workflows.getWorkflowActivity.bind(workflows);
11782
12826
  target.getWorkflowsActivityBatch = workflows.getWorkflowsActivityBatch.bind(workflows);
11783
12827
  target.getWorkflowDiagram = workflows.getWorkflowDiagram.bind(workflows);
@@ -12198,7 +13242,6 @@ function bindOperatorMethods(target, operatorGroups) {
12198
13242
  target.removeGroupMember = operatorGroups.removeGroupMember.bind(operatorGroups);
12199
13243
  target.getLiveOperators = operatorGroups.getLiveOperators.bind(operatorGroups);
12200
13244
  target.getPresenceStatus = operatorGroups.getPresenceStatus.bind(operatorGroups);
12201
- target.disconnectPresence = operatorGroups.disconnectPresence.bind(operatorGroups);
12202
13245
  target.getOperatorChatMessages = operatorGroups.getOperatorChatMessages.bind(operatorGroups);
12203
13246
  target.sendOperatorMessage = operatorGroups.sendOperatorMessage.bind(operatorGroups);
12204
13247
  }
@@ -12226,6 +13269,8 @@ function bindOrgMethods(target, org) {
12226
13269
  target.listLegalEntities = org.listLegalEntities.bind(org);
12227
13270
  target.getLegalEntity = org.getLegalEntity.bind(org);
12228
13271
  target.createLegalEntity = org.createLegalEntity.bind(org);
13272
+ target.getRegistrationDraft = org.getRegistrationDraft.bind(org);
13273
+ target.saveRegistrationDraft = org.saveRegistrationDraft.bind(org);
12229
13274
  target.getVoiceTrustProducts = org.getVoiceTrustProducts.bind(org);
12230
13275
  target.syncVoiceTrustProducts = org.syncVoiceTrustProducts.bind(org);
12231
13276
  target.createOrganizationWorkspace = org.createOrganizationWorkspace.bind(org);
@@ -12257,6 +13302,9 @@ function bindJourneysMethods(target, journeys) {
12257
13302
  target.getJourneys = journeys.getJourneys.bind(journeys);
12258
13303
  target.getJourney = journeys.getJourney.bind(journeys);
12259
13304
  target.getJourneyAuthoring = journeys.getJourneyAuthoring.bind(journeys);
13305
+ target.putJourneyV2Definition = journeys.putJourneyV2Definition.bind(journeys);
13306
+ target.getJourneyV2Validation = journeys.getJourneyV2Validation.bind(journeys);
13307
+ target.getJourneyFilterOptions = journeys.getJourneyFilterOptions.bind(journeys);
12260
13308
  target.getJourneyHealth = journeys.getJourneyHealth.bind(journeys);
12261
13309
  target.createJourney = journeys.createJourney.bind(journeys);
12262
13310
  target.updateJourney = journeys.updateJourney.bind(journeys);
@@ -12312,6 +13360,8 @@ function bindPersonasMethods(target, personas) {
12312
13360
  target.getPersona = personas.getPersona.bind(personas);
12313
13361
  target.createPersona = personas.createPersona.bind(personas);
12314
13362
  target.updatePersona = personas.updatePersona.bind(personas);
13363
+ target.archivePersona = personas.archivePersona.bind(personas);
13364
+ target.unarchivePersona = personas.unarchivePersona.bind(personas);
12315
13365
  target.deletePersona = personas.deletePersona.bind(personas);
12316
13366
  }
12317
13367
 
@@ -12411,8 +13461,11 @@ var GravityRailClient = class {
12411
13461
  // Chats API
12412
13462
  getChats;
12413
13463
  getChat;
13464
+ getChatBrowserLiveView;
13465
+ getChatMachineResources;
12414
13466
  getCurrentSmsChat;
12415
13467
  getChatCallbacks;
13468
+ getChatEhrWritebackOutcomes;
12416
13469
  cancelChatCallback;
12417
13470
  getChatTokenUsage;
12418
13471
  getChatTodos;
@@ -12424,13 +13477,14 @@ var GravityRailClient = class {
12424
13477
  archiveChat;
12425
13478
  unarchiveChat;
12426
13479
  createChat;
13480
+ createChatInteractionSession;
13481
+ transitionChatInteractionSession;
12427
13482
  createWorkflowOutboundVoiceChat;
12428
13483
  deleteChat;
12429
13484
  updateChat;
12430
13485
  getChatModelOverride;
12431
13486
  updateChatModelOverride;
12432
13487
  updateChatMute;
12433
- updateChatNeedsResponse;
12434
13488
  summarizeChat;
12435
13489
  getChatMessages;
12436
13490
  getChildThreadMessages;
@@ -12462,8 +13516,6 @@ var GravityRailClient = class {
12462
13516
  getChatFilterCount;
12463
13517
  // Calls API
12464
13518
  getPhoneCalls;
12465
- initiateCall;
12466
- getVoiceToken;
12467
13519
  getMessageTiming;
12468
13520
  getRecordingInfo;
12469
13521
  listChatRecordings;
@@ -12472,6 +13524,10 @@ var GravityRailClient = class {
12472
13524
  validateCelExpression;
12473
13525
  // Data Types API
12474
13526
  getDataTypes;
13527
+ getDataTypeDraft;
13528
+ saveDataTypeDraft;
13529
+ publishDataTypeDraft;
13530
+ getDataTypeVersions;
12475
13531
  getDataType;
12476
13532
  getDataTypeByUuid;
12477
13533
  getDataTypeBySlug;
@@ -12514,6 +13570,9 @@ var GravityRailClient = class {
12514
13570
  updateCurrentMember;
12515
13571
  getWorkspaceMembers;
12516
13572
  getWorkspaceMember;
13573
+ // Org-scoped, so deliberately absent from WORKSPACE_METHOD_NAMES: that proxy
13574
+ // passes a workspace uuid as the first argument.
13575
+ getOrgWorkspaceMember;
12517
13576
  createWorkspaceMember;
12518
13577
  updateMember;
12519
13578
  deleteMember;
@@ -12567,6 +13626,10 @@ var GravityRailClient = class {
12567
13626
  deleteMemberMemory;
12568
13627
  // Member Sync Links
12569
13628
  getMemberSyncLinks;
13629
+ // Member Relationships
13630
+ getMemberRelationships;
13631
+ createMemberRelationship;
13632
+ archiveMemberRelationship;
12570
13633
  // Agent Tasks API (operator-facing async sub-agent inspection/cancel)
12571
13634
  getAgentTasks;
12572
13635
  getAgentTask;
@@ -12604,6 +13667,8 @@ var GravityRailClient = class {
12604
13667
  getPersona;
12605
13668
  createPersona;
12606
13669
  updatePersona;
13670
+ archivePersona;
13671
+ unarchivePersona;
12607
13672
  deletePersona;
12608
13673
  // Metrics API (customer-defined outcome metrics)
12609
13674
  listMetrics;
@@ -12623,8 +13688,32 @@ var GravityRailClient = class {
12623
13688
  getDashboardChannelStats;
12624
13689
  getDashboardWorkflowAssignmentStats;
12625
13690
  getConfigurationHealth;
12626
- // Activity Timeline API
12627
- queryActivityTimeline;
13691
+ // Activity Spine serving API — one query shape, three mounts
13692
+ // (docs/projects/active/activity-spine.md).
13693
+ queryActivity;
13694
+ queryActivityLatestSubjects;
13695
+ queryActivityOpenItems;
13696
+ queryActivityOneView;
13697
+ queryActivityDigest;
13698
+ getActivityCounts;
13699
+ getActivityCapabilities;
13700
+ queryOrgActivity;
13701
+ queryOrgActivityLatestSubjects;
13702
+ queryOrgActivityOpenItems;
13703
+ queryOrgActivityOneView;
13704
+ queryOrgActivityDigest;
13705
+ getOrgActivityCounts;
13706
+ queryWorkspaceActivity;
13707
+ queryWorkspaceActivityLatestSubjects;
13708
+ queryWorkspaceActivityOpenItems;
13709
+ queryWorkspaceActivityOneView;
13710
+ queryWorkspaceActivityDigest;
13711
+ getWorkspaceActivityCounts;
13712
+ // Hydration: typed refs in, display summaries out, one round trip. The org
13713
+ // variant carries several workspaces' groups in that one trip.
13714
+ resolveEntityRefs;
13715
+ resolveOrgEntityRefs;
13716
+ resolveAccountEntityRefs;
12628
13717
  // MOTD API
12629
13718
  getMotd;
12630
13719
  // Tracked Links analytics (#10934)
@@ -12640,6 +13729,9 @@ var GravityRailClient = class {
12640
13729
  getJourneys;
12641
13730
  getJourney;
12642
13731
  getJourneyAuthoring;
13732
+ putJourneyV2Definition;
13733
+ getJourneyV2Validation;
13734
+ getJourneyFilterOptions;
12643
13735
  getJourneyHealth;
12644
13736
  createJourney;
12645
13737
  updateJourney;
@@ -12694,7 +13786,6 @@ var GravityRailClient = class {
12694
13786
  removeGroupMember;
12695
13787
  getLiveOperators;
12696
13788
  getPresenceStatus;
12697
- disconnectPresence;
12698
13789
  getOperatorChatMessages;
12699
13790
  sendOperatorMessage;
12700
13791
  // Access Grants API
@@ -12707,10 +13798,15 @@ var GravityRailClient = class {
12707
13798
  getAccessGrants;
12708
13799
  getMemberGrants;
12709
13800
  getGranteeGrants;
13801
+ // Intervention Requests API
13802
+ getAgentModeAttention;
13803
+ getInterventionRequests;
13804
+ resolveInterventionRequest;
12710
13805
  // Prompts API
12711
13806
  inspectPrompt;
12712
13807
  // Workspaces API
12713
13808
  getWorkspaces;
13809
+ getDeviceAdmissibleWorkspaces;
12714
13810
  getPublicWorkspaces;
12715
13811
  getWorkspace;
12716
13812
  createWorkspace;
@@ -12750,7 +13846,12 @@ var GravityRailClient = class {
12750
13846
  exportWorkspace;
12751
13847
  exportWorkspaceZip;
12752
13848
  previewWorkspaceImport;
13849
+ previewWorkspaceImportZip;
12753
13850
  importWorkspace;
13851
+ importWorkspaceZip;
13852
+ getImportSkippedRules;
13853
+ getImportReadiness;
13854
+ rebuildImportSkippedRules;
12754
13855
  previewImportWorkspace;
12755
13856
  getWorkspaceThemes;
12756
13857
  updateWorkspaceThemes;
@@ -12785,6 +13886,8 @@ var GravityRailClient = class {
12785
13886
  listLegalEntities;
12786
13887
  getLegalEntity;
12787
13888
  createLegalEntity;
13889
+ getRegistrationDraft;
13890
+ saveRegistrationDraft;
12788
13891
  getVoiceTrustProducts;
12789
13892
  syncVoiceTrustProducts;
12790
13893
  createOrganizationWorkspace;
@@ -12976,10 +14079,13 @@ var GravityRailClient = class {
12976
14079
  getRoutineRuns;
12977
14080
  resetRoutineRuns;
12978
14081
  previewSchedule;
14082
+ previewRoutineVoiceReadiness;
12979
14083
  previewRoutineWorkflowAccess;
12980
14084
  // Workflows API
12981
14085
  getWorkflows;
12982
14086
  getWorkflow;
14087
+ getWorkflowOpeningTurnConversionReport;
14088
+ convertWorkflowStartTaskOpeningMessage;
12983
14089
  getWorkflowActivity;
12984
14090
  getWorkflowsActivityBatch;
12985
14091
  getWorkflowDiagram;
@@ -13455,7 +14561,7 @@ var GravityRailClient = class {
13455
14561
  bindMetricsMethods(this, apis.metrics);
13456
14562
  bindQueriesMethods(this, apis.queries);
13457
14563
  bindDashboardsMethods(this, apis.dashboards);
13458
- bindActivityTimelineMethods(this, apis.activityTimeline);
14564
+ bindActivityMethods(this, apis.activity);
13459
14565
  bindMotdMethods(this, apis.motd);
13460
14566
  bindTrackedLinksMethods(this, apis.trackedLinks);
13461
14567
  bindJourneysMethods(this, apis.journeys);
@@ -13463,6 +14569,7 @@ var GravityRailClient = class {
13463
14569
  bindOperatorMethods(this, apis.operatorGroups);
13464
14570
  bindOrgMethods(this, apis.org);
13465
14571
  bindAccessGrantsMethods(this, apis.accessGrants);
14572
+ bindInterventionRequestsMethods(this, apis.interventionRequests);
13466
14573
  bindPromptsMethods(this, apis.prompts);
13467
14574
  bindWorkspacesMethods(this, apis.workspaces, apis.workspaceInvitations);
13468
14575
  bindAuthMethods(this, apis.auth, apis.assignments);
@@ -13659,6 +14766,19 @@ var WorkspaceBuilderResource = class {
13659
14766
  get isImplicit() {
13660
14767
  return false;
13661
14768
  }
14769
+ /**
14770
+ * True when `apply()` is safe — and required — to run against a resource
14771
+ * that was ADOPTED rather than created.
14772
+ *
14773
+ * False by default because most builders create only: re-running their
14774
+ * `apply()` on an existing resource would make a duplicate. Override it
14775
+ * when `apply()` is an idempotent full write keyed on stable identities,
14776
+ * which is the only way a re-run can express an EDIT (a removed goal, a
14777
+ * reordered timeline) rather than just an addition.
14778
+ */
14779
+ get appliesWhenExisting() {
14780
+ return false;
14781
+ }
13662
14782
  matchKey() {
13663
14783
  return void 0;
13664
14784
  }
@@ -14337,6 +15457,755 @@ function buildJourneyGoalPayload(goal) {
14337
15457
  ...goal.value !== void 0 ? { value: goal.value } : {}
14338
15458
  };
14339
15459
  }
15460
+ var V2RouteBuilder = class {
15461
+ constructor(name, options = {}) {
15462
+ this.name = name;
15463
+ this.options = options;
15464
+ }
15465
+ name;
15466
+ options;
15467
+ touches = [];
15468
+ /**
15469
+ * The DECISION RULE uuid. Adopted for the same reason an Ending's is:
15470
+ * `MemberJourneyStep.entry_decision_rule_id` points at this row with
15471
+ * `ON DELETE SET NULL`, so recreating it on a re-run would erase which arm
15472
+ * every already-routed enrollment is on — invisibly, since both rules
15473
+ * "exist" afterwards.
15474
+ */
15475
+ _ruleUuid;
15476
+ /** Append a touch to this arm. Order is call order. */
15477
+ touch(name, options = {}) {
15478
+ const touch = new V2TouchBuilder(name, options);
15479
+ this.touches.push(touch);
15480
+ return touch;
15481
+ }
15482
+ };
15483
+ var V2BranchBuilder = class {
15484
+ routes = [];
15485
+ /** Append a route. Declaration order is evaluation order. */
15486
+ route(name, options = {}) {
15487
+ const route = new V2RouteBuilder(name, options);
15488
+ this.routes.push(route);
15489
+ return route;
15490
+ }
15491
+ };
15492
+ var V2TouchBuilder = class {
15493
+ /**
15494
+ * The name is CANONICALIZED here, once, and everything downstream reads it:
15495
+ * the `key:<name>` address, the payload, adoption's name lookup, and the
15496
+ * uniqueness gate. The API trims it before storing
15497
+ * (`JourneyV2TouchInput`/`JourneyV2EndingInput` name validators), so a
15498
+ * builder holding `" Welcome "` would send an address for a name the server
15499
+ * does not have, fail to find its own step on the way back, and treat it as
15500
+ * new on the next run — archiving the live step and its history. One
15501
+ * representation at the boundary is the only way that cannot happen; a
15502
+ * second trim anywhere downstream would be a place for the two to drift.
15503
+ */
15504
+ constructor(name, options = {}) {
15505
+ this.options = options;
15506
+ this.name = name.trim();
15507
+ }
15508
+ options;
15509
+ rules = [];
15510
+ /** Filled in from the server's response so a re-run keeps this touch. */
15511
+ _uuid;
15512
+ /**
15513
+ * The exclusive branch that follows this touch, when it has one. A touch
15514
+ * carrying a branch gets NO ordinary outgoing connection: its routes are
15515
+ * the only way out, so touches declared after it are reached only by an arm
15516
+ * naming them in `continueAt`.
15517
+ */
15518
+ _branch;
15519
+ name;
15520
+ /**
15521
+ * Attach an exclusive branch after this touch, or return the existing one.
15522
+ *
15523
+ * Idempotent so a script can add routes in stages without accidentally
15524
+ * declaring two branches on one touch — which the server has no shape for,
15525
+ * since a touch owns exactly one ordered route set.
15526
+ */
15527
+ branch() {
15528
+ this._branch ??= new V2BranchBuilder();
15529
+ return this._branch;
15530
+ }
15531
+ /**
15532
+ * The request-local address this step answers to (plan §3.8 / phase 6).
15533
+ *
15534
+ * A saved step is addressed by its uuid; an unsaved one by a `key` derived
15535
+ * from its authored name. Deriving from the NAME rather than minting a
15536
+ * uuid4 keeps the payload stable across re-runs of the same script — a
15537
+ * fresh random key on every run would make the request differ from itself
15538
+ * for no reason, and the server's EventRule sync matches on the uuids the
15539
+ * payload carries. Names are already asserted unique within a journey,
15540
+ * which is what makes a name-derived key unique.
15541
+ *
15542
+ * {@link V2EndingBuilder} INHERITS this rather than deriving its own: an
15543
+ * Ending's anchor key and a touch's key land in one server-side namespace
15544
+ * (`stepKey` is one field), so two derivations that drifted would produce
15545
+ * two spellings of the same address and a goal would 404 on the one its
15546
+ * step was not sent under.
15547
+ *
15548
+ * Two steps of one name therefore answer to one address. {@link preflight}
15549
+ * is the first enforcement point and refuses it before any write, counting
15550
+ * touches and Endings together and comparing names trimmed, as the API
15551
+ * stores them. Without that gate the collision surfaces twice and both
15552
+ * times too late: the server rejects the definition PUT after `apply()` has
15553
+ * created the Journey, and {@link indexStoredByName} rejects the SECOND run
15554
+ * of a script whose two stored steps make `adopt()` a coin flip.
15555
+ */
15556
+ get _address() {
15557
+ return this._uuid ?? `key:${this.name}`;
15558
+ }
15559
+ /**
15560
+ * Re-attach the EventRule uuids the server already stores for this touch.
15561
+ *
15562
+ * Identity is the operator-set rule NAME. `.sendsSms(...)` does not require
15563
+ * one, so an unnamed rule falls back to its actionType — but ONLY when that
15564
+ * answer is 1:1: exactly one unnamed draft of that actionType here, and
15565
+ * exactly one stored rule of it left unclaimed there. Anything else throws.
15566
+ *
15567
+ * The ordinal-within-actionType fallback this replaces was not a weaker
15568
+ * identity, it was the wrong one. Inserting a new unnamed rule ABOVE an
15569
+ * existing same-type rule shifts every position by one, so the new rule
15570
+ * adopted the existing rule's uuid — taking over its delivery bookkeeping —
15571
+ * and the existing rule was written as brand new and archived. Nothing in
15572
+ * the payload showed it: both rules "exist" afterwards. When the script
15573
+ * cannot say which rule is which, the honest answer is to ask the author to
15574
+ * name them, not to guess by position.
15575
+ */
15576
+ adoptRuleUuids(serverRules) {
15577
+ const namedDrafts = this.rules.filter((draft) => !!draft.options.name);
15578
+ const storedByName = indexStoredByName(
15579
+ serverRules,
15580
+ new Set(namedDrafts.map((draft) => draft.options.name)),
15581
+ `touch '${this.name}'`,
15582
+ "action"
15583
+ );
15584
+ const claimed = /* @__PURE__ */ new Set();
15585
+ for (const draft of namedDrafts) {
15586
+ const match = storedByName.get(draft.options.name);
15587
+ if (!match) continue;
15588
+ draft.adoptedUuid = match.uuid;
15589
+ claimed.add(match);
15590
+ }
15591
+ const unnamedByActionType = /* @__PURE__ */ new Map();
15592
+ for (const draft of this.rules) {
15593
+ if (draft.options.name) continue;
15594
+ const actionType = String(draft.actionType);
15595
+ unnamedByActionType.set(actionType, [
15596
+ ...unnamedByActionType.get(actionType) ?? [],
15597
+ draft
15598
+ ]);
15599
+ }
15600
+ for (const [actionType, drafts] of unnamedByActionType) {
15601
+ const candidates = serverRules.filter(
15602
+ (rule) => String(rule.actionType) === actionType && !claimed.has(rule)
15603
+ );
15604
+ if (!candidates.length) continue;
15605
+ if (drafts.length === 1 && candidates.length === 1) {
15606
+ drafts[0].adoptedUuid = candidates[0].uuid;
15607
+ continue;
15608
+ }
15609
+ throw new Error(
15610
+ `touch '${this.name}' has ${drafts.length} unnamed ${actionType} action(s) and the server has ${candidates.length} \u2014 so there is no way to tell which stored action each one is. Adopting by position swaps their identities the moment an action is inserted or removed, which moves one action's delivery history onto another. Give these actions names (\`{ name: ... }\`) so each one can be matched to the right rule.`
15611
+ );
15612
+ }
15613
+ }
15614
+ /** Attach a `JOURNEY_STEP_EXECUTE` action. Same contract as legacy. */
15615
+ onExecute(actionType, params = {}, options = {}) {
15616
+ this.rules.push({
15617
+ uuid: crypto.randomUUID(),
15618
+ actionType,
15619
+ actionParams: params,
15620
+ options
15621
+ });
15622
+ return this;
15623
+ }
15624
+ sendsSms(params, options = {}) {
15625
+ return this.onExecute("sms:send" /* SMS_SEND */, params, options);
15626
+ }
15627
+ callsMember(params, options = {}) {
15628
+ return this.onExecute("phone:call" /* PHONE_CALL */, params, options);
15629
+ }
15630
+ sendsEmail(params, options = {}) {
15631
+ return this.onExecute("email:send" /* EMAIL_SEND */, params, options);
15632
+ }
15633
+ get hasOutreach() {
15634
+ return this.rules.length > 0;
15635
+ }
15636
+ eventRuleInputs() {
15637
+ return this.rules.map((rule) => ({
15638
+ uuid: rule.adoptedUuid ?? rule.uuid,
15639
+ eventType: "journey_step:execute" /* JOURNEY_STEP_EXECUTE */,
15640
+ actionType: rule.actionType,
15641
+ actionParams: resolveRefs(rule.actionParams),
15642
+ ...rule.options.name ? { name: rule.options.name } : {},
15643
+ ...rule.options.when ? { conditions: rule.options.when } : {},
15644
+ ...rule.options.delaySeconds ? { delay: rule.options.delaySeconds } : {},
15645
+ active: rule.options.active ?? true
15646
+ }));
15647
+ }
15648
+ };
15649
+ var V2EndingBuilder = class extends V2TouchBuilder {
15650
+ constructor(name, when, filterId) {
15651
+ super(name);
15652
+ this.when = when;
15653
+ this.filterId = filterId;
15654
+ }
15655
+ when;
15656
+ filterId;
15657
+ /**
15658
+ * The DECISION RULE uuid, distinct from `_uuid` (the anchor step's).
15659
+ *
15660
+ * An Ending is two rows: a `JourneyDecisionRule` carrying the condition and
15661
+ * precedence, and a `JourneyStep` anchor carrying its actions, goals, and
15662
+ * status history. Adopting only the anchor left the rule to be recreated on
15663
+ * every re-run — and `MemberJourney.latched_ending_rule_id` /
15664
+ * `JourneyStatusLog.journey_decision_rule_id` point at the RULE with
15665
+ * `ON DELETE SET NULL`, so every completed enrollment silently forgot which
15666
+ * Ending it took.
15667
+ */
15668
+ _ruleUuid;
15669
+ /**
15670
+ * An Ending cannot carry a branch, and saying so is the whole override.
15671
+ *
15672
+ * `V2EndingBuilder extends V2TouchBuilder` for the identity and addressing
15673
+ * an Ending's anchor shares with a touch, which also inherits every touch
15674
+ * method — `branch()` among them. Inherited unchanged it would set
15675
+ * `_branch` on an object nothing ever reads it from: the Ending serializer
15676
+ * writes `{uuid|key, name, celCondition, filterId, eventRules}` and no
15677
+ * `branch`, and `allTouches()` walks only the timeline, so the routes are
15678
+ * never numbered, validated, adopted or sent. The author gets no error and
15679
+ * a definition quietly missing what they asked for.
15680
+ *
15681
+ * An Ending is terminal by construction — it is the rule that ENDS an
15682
+ * enrollment — so there is no shape to serialize even if the payload had a
15683
+ * field for it. Refusing at the call is the only point where the author is
15684
+ * still holding the mistake.
15685
+ *
15686
+ * @see foreignAnchorProblem for why this names no Ending.
15687
+ */
15688
+ branch() {
15689
+ throw new Error(
15690
+ "an Ending cannot carry a branch. An Ending terminates an enrollment, so there is nothing after it to route to, and the atomic definition has no field to send one under \u2014 the routes would be silently dropped. Put the branch on the touch that leads to this Ending instead, and give each arm its own Ending."
15691
+ );
15692
+ }
15693
+ };
15694
+ var JourneyV2Builder = class extends WorkspaceBuilderResource {
15695
+ constructor(name, options = {}) {
15696
+ super();
15697
+ this.name = name;
15698
+ this.description = options.description ?? "";
15699
+ this.activate = options.activate ?? false;
15700
+ }
15701
+ name;
15702
+ description;
15703
+ touches = [];
15704
+ endings = [];
15705
+ goals = [];
15706
+ /** Activate after the definition is written and validated. */
15707
+ activate;
15708
+ /** Optimistic-concurrency token, from create or adoption. */
15709
+ _expectedUpdatedAt;
15710
+ /** Server status at adoption — decides whether a re-run must pause first. */
15711
+ _status;
15712
+ /**
15713
+ * A v2 definition write is idempotent, so an ADOPTED journey is written
15714
+ * too. That is the whole point of adopting one: the PUT is a full,
15715
+ * uuid-keyed replacement, so re-running a script is how an author expresses
15716
+ * an edit. The legacy builder stays create-only — its `apply()` only knows
15717
+ * how to create, and re-running it would duplicate.
15718
+ */
15719
+ get appliesWhenExisting() {
15720
+ return true;
15721
+ }
15722
+ /** Append a touch to the timeline. Order is call order. */
15723
+ touch(name, options = {}) {
15724
+ const touch = new V2TouchBuilder(name, options);
15725
+ this.touches.push(touch);
15726
+ return touch;
15727
+ }
15728
+ /**
15729
+ * Every touch in the timeline, arms included, depth first.
15730
+ *
15731
+ * Identity adoption, name-uniqueness and validation all have to see arm
15732
+ * touches — a walk over the top level alone would leave every arm touch
15733
+ * recreated on each re-run, silently archiving its member history.
15734
+ */
15735
+ allTouches() {
15736
+ const out = [];
15737
+ const walk = (touches) => {
15738
+ for (const touch of touches) {
15739
+ out.push(touch);
15740
+ for (const route of touch._branch?.routes ?? []) walk(route.touches);
15741
+ }
15742
+ };
15743
+ walk(this.touches);
15744
+ return out;
15745
+ }
15746
+ /** Every route in the timeline, at every nesting depth, depth first. */
15747
+ allRoutes() {
15748
+ const out = [];
15749
+ for (const touch of this.allTouches()) {
15750
+ for (const route of touch._branch?.routes ?? []) out.push(route);
15751
+ }
15752
+ return out;
15753
+ }
15754
+ /** Append an Ending. Call order is evaluation order. */
15755
+ ending(name, options) {
15756
+ const ending = new V2EndingBuilder(name, options.when, options.filterId);
15757
+ this.endings.push(ending);
15758
+ return ending;
15759
+ }
15760
+ goal(name, options = {}) {
15761
+ this.goals.push({
15762
+ name,
15763
+ description: options.description,
15764
+ step: options.step,
15765
+ completionCel: options.completionCel,
15766
+ value: options.value
15767
+ });
15768
+ return this;
15769
+ }
15770
+ /**
15771
+ * Authoring problems the server's publish validator would reject.
15772
+ *
15773
+ * A different rule set from the legacy builder's on purpose. "No incoming
15774
+ * edge" has no meaning in a timeline — position is the order — and the v2
15775
+ * failure modes are different ones: an action-less touch that is not an
15776
+ * explicit wait, and an Ending with no condition.
15777
+ */
15778
+ validate() {
15779
+ const problems = [];
15780
+ if (!this.touches.length) {
15781
+ problems.push(
15782
+ `journey '${this.name}' has no touches \u2014 an empty timeline has nothing to execute.`
15783
+ );
15784
+ }
15785
+ const armHeads = new Set(
15786
+ this.allRoutes().map((route) => route.touches[0]).filter(Boolean)
15787
+ );
15788
+ this.allTouches().forEach((touch) => {
15789
+ if (touch.hasOutreach) return;
15790
+ const wait = touch.options.wait;
15791
+ const isFirst = this.touches[0] === touch;
15792
+ const isExplicitWait = !isFirst && !armHeads.has(touch) && (wait?.afterDays !== void 0 || !!wait?.when || wait?.filterId !== void 0);
15793
+ if (isExplicitWait) return;
15794
+ problems.push(
15795
+ `touch '${touch.name}' has no JOURNEY_STEP_EXECUTE action \u2014 a member reaching it gets nothing. Add one, or give it a wait so it is an explicit grace period.`
15796
+ );
15797
+ });
15798
+ for (const touch of this.allTouches()) {
15799
+ const branch = touch._branch;
15800
+ if (!branch) continue;
15801
+ const fallbacks = branch.routes.filter(
15802
+ (route) => !route.options.when?.trim() && route.options.filterId === void 0
15803
+ );
15804
+ if (branch.routes.length - fallbacks.length < 1) {
15805
+ problems.push(
15806
+ `branch after touch '${touch.name}' needs at least one conditional route \u2014 one declared with a \`when\`, a \`filterId\`, or both. Members wait at the branch until a route matches, so an Otherwise is optional.`
15807
+ );
15808
+ }
15809
+ if (fallbacks.length > 1) {
15810
+ problems.push(
15811
+ `branch after touch '${touch.name}' declares ${fallbacks.length} Otherwise routes; a branch has at most one unconditional fallback.`
15812
+ );
15813
+ }
15814
+ if (fallbacks.length === 1 && branch.routes[branch.routes.length - 1] !== fallbacks[0]) {
15815
+ problems.push(
15816
+ `the Otherwise route of the branch after touch '${touch.name}' is not last; it is taken immediately, so any route after it can never be reached.`
15817
+ );
15818
+ }
15819
+ for (const route of branch.routes) {
15820
+ if (!route.touches.length && !route.options.continueAt) {
15821
+ problems.push(
15822
+ `route '${route.name}' has no target \u2014 give it at least one touch, or a \`continueAt\` naming the touch it continues to.`
15823
+ );
15824
+ }
15825
+ }
15826
+ }
15827
+ for (const ending of this.endings) {
15828
+ if (!ending.when?.trim() && ending.filterId === void 0) {
15829
+ problems.push(
15830
+ `ending '${ending.name}' has no condition \u2014 an Ending that always matches terminates every enrolment on evaluation order alone. Give it a \`when\` expression, a \`filterId\`, or both.`
15831
+ );
15832
+ }
15833
+ }
15834
+ return problems;
15835
+ }
15836
+ /**
15837
+ * Shapes this definition cannot express, found BEFORE anything is written.
15838
+ *
15839
+ * A different list from {@link validate}, and a different consequence:
15840
+ * those are warnings the orchestrator prints and then writes anyway, these
15841
+ * are refusals. For each one the payload has no way to say what the script
15842
+ * asked for, so serializing past it would write a DIFFERENT program from
15843
+ * the one the script wrote, with nothing afterwards to say so.
15844
+ *
15845
+ * It has to run before the first write rather than during serialization,
15846
+ * because {@link apply} creates the Journey — or pauses a live one — before
15847
+ * it builds the payload. A refusal raised from `definitionPayload()` has
15848
+ * therefore already left an empty journey shell behind, or taken a
15849
+ * production program off the air.
15850
+ *
15851
+ * PURE: reads only what the script declared, never what the server holds,
15852
+ * so it is correct at any point — before adoption included — and
15853
+ * `WorkspaceBuilder.preflight()` can stay a synchronous, side-effect-free
15854
+ * check a caller may run directly. Nothing here needs adoption to have run:
15855
+ * an anchor the server has not seen is addressed by its request-local key,
15856
+ * so "has this Ending been saved" is no longer a question a refusal
15857
+ * depends on.
15858
+ */
15859
+ preflight() {
15860
+ const problems = [];
15861
+ this.allTouches().forEach((touch, index) => {
15862
+ const wait = touch.options.wait;
15863
+ if (wait?.afterDays !== void 0 && wait.when) {
15864
+ problems.push(waitExclusivityProblem(index));
15865
+ }
15866
+ });
15867
+ const owned = this.ownedAnchors();
15868
+ this.goals.forEach((goal, index) => {
15869
+ const step = goal.step;
15870
+ if (step && !owned.has(step)) {
15871
+ problems.push(foreignAnchorProblem(index, anchorKind(step)));
15872
+ }
15873
+ });
15874
+ const stepNames = [
15875
+ ...this.allTouches().map((touch) => touch.name),
15876
+ ...this.endings.map((ending) => ending.name)
15877
+ ];
15878
+ const claims = /* @__PURE__ */ new Map();
15879
+ for (const name of stepNames) claims.set(name, (claims.get(name) ?? 0) + 1);
15880
+ const repeated = [...claims.values()].filter((count) => count > 1).length;
15881
+ if (repeated) problems.push(sharedStepNameProblem(repeated));
15882
+ const nameless = stepNames.filter((name) => !name).length;
15883
+ if (nameless) problems.push(namelessStepProblem(nameless));
15884
+ return problems;
15885
+ }
15886
+ /**
15887
+ * Every step a goal in THIS journey can anchor to, compared by object
15888
+ * identity — touches AND Endings, which is why the element type names both
15889
+ * rather than leaning on `V2EndingBuilder extends V2TouchBuilder` to smuggle
15890
+ * Endings in under a touch-only annotation.
15891
+ *
15892
+ * A goal anchored to some other journey's builder is not a near miss the
15893
+ * server can catch: an unsaved one sends a `stepKey` this definition never
15894
+ * declares (a 404 whose cause is invisible), and a SAVED one sends a real
15895
+ * `stepUuid` belonging to a live step somewhere else.
15896
+ */
15897
+ ownedAnchors() {
15898
+ return /* @__PURE__ */ new Set([...this.allTouches(), ...this.endings]);
15899
+ }
15900
+ planLine() {
15901
+ const parts = [];
15902
+ const touchCount = this.allTouches().length;
15903
+ const routeCount = this.allRoutes().length;
15904
+ if (touchCount) parts.push(`${touchCount} touches`);
15905
+ if (routeCount) parts.push(`${routeCount} routes`);
15906
+ if (this.endings.length) parts.push(`${this.endings.length} endings`);
15907
+ if (this.goals.length) parts.push(`${this.goals.length} goals`);
15908
+ return `Journey (v2): ${this.name}${parts.length ? ` (${parts.join(", ")})` : ""}`;
15909
+ }
15910
+ /**
15911
+ * Re-attach every stable child identity the server already holds.
15912
+ *
15913
+ * The atomic endpoint is a FULL REPLACEMENT keyed on uuids: an omitted
15914
+ * uuid does not mean "unchanged", it means "create a new one and archive
15915
+ * whatever the old one was". So anything this misses is silently recreated
15916
+ * on every re-run of the same script — and a script is normally re-run,
15917
+ * because a program is built in stages. Each identity has a different thing
15918
+ * hanging off it, and losing it costs something specific:
15919
+ *
15920
+ * | identity | what re-creating it destroys |
15921
+ * |---|---|
15922
+ * | touch step uuid | the touch's `MemberJourneyStep` history |
15923
+ * | EventRule uuid | that action's delivery bookkeeping |
15924
+ * | Ending RULE uuid | which Ending completed enrollments latched |
15925
+ * | Ending anchor uuid | the Ending's status history and goal anchor |
15926
+ * | goal uuid | every member's satisfaction row for that goal |
15927
+ *
15928
+ * `existing` is the journey DETAIL or AUTHORING projection. Both carry
15929
+ * `steps[].eventRules`, `goals`, and `decisionRules` —
15930
+ * the read projection redacts CEL, not identity — so one fetch is enough
15931
+ * and no second round trip is needed. (The orchestrator asks for the
15932
+ * authoring projection anyway: this builder holds `journeys:write` because
15933
+ * it is about to PUT, and the superset costs nothing.)
15934
+ *
15935
+ * Names are the only key available on a FIRST adoption, and a duplicate
15936
+ * name makes adoption a coin flip between two live resources. That throws
15937
+ * rather than guessing: silently attaching a touch to the wrong step
15938
+ * archives real member history.
15939
+ */
15940
+ adopt(existing) {
15941
+ super.adopt(existing);
15942
+ this._expectedUpdatedAt = existing.updatedAt;
15943
+ this._status = existing.status;
15944
+ this.assertUnambiguousNames();
15945
+ this.adoptChildIdentities(existing);
15946
+ }
15947
+ /** Reject a script whose own names cannot identify a resource. */
15948
+ assertUnambiguousNames() {
15949
+ assertUniqueNames(
15950
+ this.allTouches().map((touch) => touch.name),
15951
+ `journey '${this.name}'`,
15952
+ "touch"
15953
+ );
15954
+ assertUniqueNames(
15955
+ this.allRoutes().map((route) => route.name),
15956
+ `journey '${this.name}'`,
15957
+ "route"
15958
+ );
15959
+ assertUniqueNames(
15960
+ this.endings.map((ending) => ending.name),
15961
+ `journey '${this.name}'`,
15962
+ "ending"
15963
+ );
15964
+ assertUniqueNames(
15965
+ this.goals.map((goal) => goal.name),
15966
+ `journey '${this.name}'`,
15967
+ "goal"
15968
+ );
15969
+ for (const touch of [...this.allTouches(), ...this.endings]) {
15970
+ const names = touch.rules.map((rule) => rule.options.name).filter(Boolean);
15971
+ assertUniqueNames(names, `touch '${touch.name}'`, "action name");
15972
+ }
15973
+ }
15974
+ adoptChildIdentities(payload) {
15975
+ const steps = payload.steps ?? [];
15976
+ const referencedStepNames = /* @__PURE__ */ new Set([
15977
+ ...this.allTouches().map((touch) => touch.name),
15978
+ ...this.endings.map((ending) => ending.name)
15979
+ ]);
15980
+ const stepsByName = indexStoredByName(
15981
+ steps,
15982
+ referencedStepNames,
15983
+ `journey '${this.name}'`,
15984
+ "step"
15985
+ );
15986
+ const stepsById = new Map(steps.map((step) => [step.id, step]));
15987
+ for (const touch of this.allTouches()) {
15988
+ const match = stepsByName.get(touch.name);
15989
+ if (!match) continue;
15990
+ touch._uuid = match.uuid;
15991
+ touch.adoptRuleUuids(match.eventRules ?? []);
15992
+ }
15993
+ const routeRules = (payload.decisionRules ?? []).filter(
15994
+ (rule) => rule.sourceStepId !== null && rule.sourceStepId !== void 0
15995
+ );
15996
+ const declaredRoutes = this.allRoutes();
15997
+ const routesByName = indexStoredByName(
15998
+ routeRules,
15999
+ new Set(declaredRoutes.map((route) => route.name)),
16000
+ `journey '${this.name}'`,
16001
+ "route"
16002
+ );
16003
+ for (const route of declaredRoutes) {
16004
+ const stored = routesByName.get(route.name);
16005
+ if (stored) route._ruleUuid = stored.uuid;
16006
+ }
16007
+ const endingRules = (payload.decisionRules ?? []).filter(
16008
+ (rule) => rule.sourceStepId === null || rule.sourceStepId === void 0
16009
+ );
16010
+ const rulesByName = indexStoredByName(
16011
+ endingRules,
16012
+ new Set(this.endings.map((ending) => ending.name)),
16013
+ `journey '${this.name}'`,
16014
+ "ending"
16015
+ );
16016
+ for (const ending of this.endings) {
16017
+ const rule = rulesByName.get(ending.name);
16018
+ const anchor = rule ? stepsById.get(rule.targetStepId) : stepsByName.get(ending.name);
16019
+ if (rule) ending._ruleUuid = rule.uuid;
16020
+ if (!anchor) continue;
16021
+ ending._uuid = anchor.uuid;
16022
+ ending.adoptRuleUuids(anchor.eventRules ?? []);
16023
+ }
16024
+ const goalsByName = indexStoredByName(
16025
+ payload.goals ?? [],
16026
+ new Set(this.goals.map((goal) => goal.name)),
16027
+ `journey '${this.name}'`,
16028
+ "goal"
16029
+ );
16030
+ for (const goal of this.goals) {
16031
+ const match = goalsByName.get(goal.name);
16032
+ if (match) goal._uuid = match.uuid;
16033
+ }
16034
+ }
16035
+ /** The atomic request body. Exposed so a test can assert it without HTTP. */
16036
+ definitionPayload() {
16037
+ const owned = this.ownedAnchors();
16038
+ const positions = new Map(
16039
+ this.allTouches().map((touch, index) => [touch, index])
16040
+ );
16041
+ return {
16042
+ expectedUpdatedAt: this._expectedUpdatedAt ?? "",
16043
+ touches: this.touches.map((touch) => serializeV2Touch(touch, positions)),
16044
+ endings: this.endings.map((ending) => ({
16045
+ ...ending._ruleUuid ? { uuid: ending._ruleUuid } : {},
16046
+ // Anchor address, exactly as `serializeV2Touch` sends a touch's:
16047
+ // the saved anchor's uuid, or the request-local `key` a goal in
16048
+ // this same save names it by. Both come from `_address`, so the
16049
+ // Ending and the goal cannot be sent under two spellings.
16050
+ ...ending._uuid ? { anchorUuid: ending._uuid } : { key: ending._address },
16051
+ name: ending.name,
16052
+ // The two predicates are sent INDEPENDENTLY (rule-filters plan
16053
+ // §3.2). A filter-only Ending carries no `celCondition` at all
16054
+ // rather than an empty one the server would have to normalize.
16055
+ ...ending.when ? { celCondition: ending.when } : {},
16056
+ ...ending.filterId !== void 0 ? { filterId: ending.filterId } : {},
16057
+ eventRules: ending.eventRuleInputs()
16058
+ })),
16059
+ // ALWAYS sent, `[]` included. The field distinguishes omitted (leave
16060
+ // goals alone) from empty (delete them), and this builder owns the
16061
+ // goal list — so omitting an empty list would make goal REMOVAL the
16062
+ // one edit a script cannot express: delete the `.goal(...)` call, re-run,
16063
+ // and the goal stays live forever.
16064
+ goals: this.goals.map((goal, index) => ({
16065
+ ...goal._uuid ? { uuid: goal._uuid } : {},
16066
+ name: goal.name,
16067
+ ...goal.description ? { description: goal.description } : {},
16068
+ ...serializeV2GoalAnchor(goal.step, index, owned),
16069
+ ...goal.completionCel ? { completionCel: goal.completionCel } : {},
16070
+ ...goal.value !== void 0 ? { value: goal.value } : {}
16071
+ }))
16072
+ };
16073
+ }
16074
+ async apply(client) {
16075
+ const problems = this.preflight();
16076
+ if (problems.length) {
16077
+ throw new Error(
16078
+ `Journey (v2) has ${problems.length} problem(s) and was not applied:
16079
+ ` + problems.map((problem) => ` - ${problem}`).join("\n")
16080
+ );
16081
+ }
16082
+ if (!this._existed) {
16083
+ const created = await client.createJourney({
16084
+ name: this.name,
16085
+ description: this.description,
16086
+ // Explicit, always. An omitted executionModel means `legacy` on the
16087
+ // server, so a v2 builder that forgot it would quietly author a
16088
+ // legacy Journey that happens to look like a timeline.
16089
+ executionModel: "v2"
16090
+ });
16091
+ this._id = created.id;
16092
+ this._uuid = created.uuid;
16093
+ this._created = true;
16094
+ this._expectedUpdatedAt = created.updatedAt;
16095
+ } else if (this._status === "active" && this.activate) {
16096
+ const paused = await client.updateJourney(this.id, { status: "paused" });
16097
+ this._expectedUpdatedAt = paused.updatedAt;
16098
+ }
16099
+ const saved = await client.putJourneyV2Definition(this.id, this.definitionPayload());
16100
+ this._expectedUpdatedAt = saved.updatedAt;
16101
+ this.adoptWrittenUuids(saved);
16102
+ if (this.activate) {
16103
+ await client.updateJourney(this.id, { status: "active" });
16104
+ }
16105
+ }
16106
+ /**
16107
+ * Re-attach the uuids the server assigned, so a follow-up write matches.
16108
+ *
16109
+ * The PUT returns the AUTHORING projection, which is the same shape
16110
+ * `adopt` reads — so this is the same operation against a payload we just
16111
+ * caused, and it uses the same code path rather than a second, thinner
16112
+ * copy that would drift.
16113
+ */
16114
+ adoptWrittenUuids(saved) {
16115
+ this.adoptChildIdentities(saved);
16116
+ }
16117
+ };
16118
+ function indexStoredByName(rows, referenced, owner, kind) {
16119
+ const byName = /* @__PURE__ */ new Map();
16120
+ const counts = /* @__PURE__ */ new Map();
16121
+ for (const row of rows) {
16122
+ const name = row.name;
16123
+ if (typeof name !== "string" || !name) continue;
16124
+ counts.set(name, (counts.get(name) ?? 0) + 1);
16125
+ if (!byName.has(name)) byName.set(name, row);
16126
+ }
16127
+ for (const [name, count] of counts) {
16128
+ if (count < 2 || !referenced.has(name)) continue;
16129
+ throw new Error(
16130
+ `${owner} already has ${count} ${kind}s named '${name}'. This script adopts by name, so it cannot tell which ${kind} it owns \u2014 and the one it does not pick is archived on the next save, taking its history with it. Rename them so each name identifies one ${kind}.`
16131
+ );
16132
+ }
16133
+ return byName;
16134
+ }
16135
+ function assertUniqueNames(names, owner, kind) {
16136
+ const seen = /* @__PURE__ */ new Set();
16137
+ for (const name of names) {
16138
+ if (seen.has(name)) {
16139
+ throw new Error(
16140
+ `${owner} has two ${kind}s named '${name}'. The v2 builder adopts an existing journey by name, so duplicates would attach a builder to either one at random \u2014 archiving the other's history on the next save. Rename one.`
16141
+ );
16142
+ }
16143
+ seen.add(name);
16144
+ }
16145
+ }
16146
+ function serializeV2Touch(touch, positions) {
16147
+ return {
16148
+ ...touch._uuid ? { uuid: touch._uuid } : { key: touch._address },
16149
+ name: touch.name,
16150
+ ...touch.options.description ? { description: touch.options.description } : {},
16151
+ ...touch.options.wait ? { wait: buildV2Wait(touch.options.wait, positions.get(touch)) } : {},
16152
+ eventRules: touch.eventRuleInputs(),
16153
+ ...touch._branch ? {
16154
+ branch: {
16155
+ routes: touch._branch.routes.map((route) => ({
16156
+ ...route._ruleUuid ? { uuid: route._ruleUuid } : {},
16157
+ name: route.name,
16158
+ // Omitted, not null, and INDEPENDENT of each other: a route
16159
+ // with neither predicate IS the Otherwise marker, one with
16160
+ // either is conditional, and one with both is ANDed
16161
+ // (rule-filters plan §3.2). The server normalizes "" to the
16162
+ // same thing as omitted.
16163
+ ...route.options.when ? { celCondition: route.options.when } : {},
16164
+ ...route.options.filterId !== void 0 ? { filterId: route.options.filterId } : {},
16165
+ touches: route.touches.map((armTouch) => serializeV2Touch(armTouch, positions)),
16166
+ ...route.options.continueAt ? { continueAt: route.options.continueAt._address } : {}
16167
+ }))
16168
+ }
16169
+ } : {}
16170
+ };
16171
+ }
16172
+ function serializeV2GoalAnchor(step, goalIndex, owned) {
16173
+ if (!step) return {};
16174
+ if (!owned.has(step)) throw new Error(foreignAnchorProblem(goalIndex, anchorKind(step)));
16175
+ if (step._uuid) return { stepUuid: step._uuid };
16176
+ return { stepKey: step._address };
16177
+ }
16178
+ function foreignAnchorProblem(goalIndex, kind) {
16179
+ return `goal at index ${goalIndex} is anchored to ${kind === "Ending" ? "an" : "a"} ${kind} that belongs to a different journey builder. A goal anchor is part of the same atomic definition as its step, so it can only name a touch or Ending this journey declares.`;
16180
+ }
16181
+ function waitExclusivityProblem(touchIndex) {
16182
+ const where = touchIndex === void 0 ? "this touch" : `touch at index ${touchIndex}`;
16183
+ return `${where} sets both afterDays and when; fold the day count into \`when\`. A v2 wait is either a whole-day count or Advanced CEL, not both.`;
16184
+ }
16185
+ function sharedStepNameProblem(count) {
16186
+ return `${count} step name(s) are claimed more than once. Touches and Endings are one namespace: until a save mints their uuids they address themselves by name and the definition resolves those keys through one field, and once saved they are stored steps the next run cannot tell apart. Names are canonical (trimmed), as the API stores them. Rename one.`;
16187
+ }
16188
+ function namelessStepProblem(count) {
16189
+ return `${count} step(s) have an empty name once trimmed. A step's name is its request-local address until a save mints its uuid, so a nameless one has nothing to be addressed by, and the API refuses it. Name them.`;
16190
+ }
16191
+ function anchorKind(step) {
16192
+ return step instanceof V2EndingBuilder ? "Ending" : "touch";
16193
+ }
16194
+ function buildV2Wait(wait, touchIndex) {
16195
+ if (wait.afterDays !== void 0 && wait.when) {
16196
+ throw new Error(waitExclusivityProblem(touchIndex));
16197
+ }
16198
+ const extras = {
16199
+ ...wait.filterId !== void 0 ? { filterId: wait.filterId } : {}
16200
+ };
16201
+ if (wait.afterDays !== void 0) {
16202
+ return { kind: "wholeDays", days: wait.afterDays, ...extras };
16203
+ }
16204
+ if (wait.when) {
16205
+ return { kind: "advanced", cel: wait.when, ...extras };
16206
+ }
16207
+ return { kind: "none", ...extras };
16208
+ }
14340
16209
 
14341
16210
  // src/workspace-builder/role-update.ts
14342
16211
  var RoleUpdate = class extends WorkspaceBuilderResource {
@@ -14572,6 +16441,7 @@ var AgentBuilder = class extends WorkspaceBuilderResource {
14572
16441
  this.memberRoleId = options.roleId ?? options.role_id;
14573
16442
  this.tools = options.tools ?? [];
14574
16443
  this.codeInterpreterEnabled = options.codeInterpreterEnabled ?? options.code_interpreter_enabled ?? false;
16444
+ this.webBrowserEnabled = options.webBrowserEnabled ?? options.web_browser_enabled ?? false;
14575
16445
  }
14576
16446
  name;
14577
16447
  chatModelId;
@@ -14579,6 +16449,7 @@ var AgentBuilder = class extends WorkspaceBuilderResource {
14579
16449
  memberRoleId;
14580
16450
  tools;
14581
16451
  codeInterpreterEnabled;
16452
+ webBrowserEnabled;
14582
16453
  planLine() {
14583
16454
  const parts = [];
14584
16455
  if (this.chatModelId) parts.push(`model=${this.chatModelId}`);
@@ -14599,7 +16470,8 @@ var AgentBuilder = class extends WorkspaceBuilderResource {
14599
16470
  chatModelId: this.chatModelId,
14600
16471
  systemPrompt: this.systemPrompt,
14601
16472
  ...this.tools.length ? { tools: this.tools } : {},
14602
- ...this.codeInterpreterEnabled ? { codeInterpreterEnabled: true } : {}
16473
+ ...this.codeInterpreterEnabled ? { codeInterpreterEnabled: true } : {},
16474
+ ...this.webBrowserEnabled ? { webBrowserEnabled: true } : {}
14603
16475
  };
14604
16476
  const result = await client.createAgent(payload);
14605
16477
  this._id = result.id;
@@ -14620,6 +16492,9 @@ var PHASES = /* @__PURE__ */ new Map([
14620
16492
  [RoutineBuilder, 6],
14621
16493
  [NotificationRuleBuilder, 6],
14622
16494
  [JourneyBuilder, 7],
16495
+ // Same phase as the legacy builder: a v2 Journey is written whole by its
16496
+ // own apply(), so it has no child resources to sequence after it.
16497
+ [JourneyV2Builder, 7],
14623
16498
  [JourneyStepBuilder, 8]
14624
16499
  ]);
14625
16500
  var LIST_PAGE_SIZE = 100;
@@ -14681,6 +16556,21 @@ var WorkspaceBuilder = class {
14681
16556
  this.resources.push(journey);
14682
16557
  return journey;
14683
16558
  }
16559
+ /**
16560
+ * A Journey v2 timeline (plan §3.8): ordered touches, structured waits, and
16561
+ * ordered Endings, written through the atomic definition endpoint.
16562
+ *
16563
+ * A separate factory rather than an option on {@link journey}, because the
16564
+ * two return different builders with different vocabularies — `.touch()`
16565
+ * and `.ending()` versus `.step()` and `.connectsTo()`. The legacy builder
16566
+ * keeps its current behaviour untouched, which is the plan's explicit
16567
+ * compatibility requirement.
16568
+ */
16569
+ journeyV2(name, options = {}) {
16570
+ const journey = new JourneyV2Builder(name, options);
16571
+ this.resources.push(journey);
16572
+ return journey;
16573
+ }
14684
16574
  agent(name, options = {}) {
14685
16575
  const agent = new AgentBuilder(name, options);
14686
16576
  this.resources.push(agent);
@@ -14764,7 +16654,9 @@ ${"=".repeat(50)}`);
14764
16654
  * surfaced before the write rather than discovered from a member's phone.
14765
16655
  */
14766
16656
  reportJourneyWarnings() {
14767
- const problems = this.resources.filter((resource) => resource instanceof JourneyBuilder).flatMap((journey) => journey.validate());
16657
+ const problems = this.resources.filter(
16658
+ (resource) => resource instanceof JourneyBuilder || resource instanceof JourneyV2Builder
16659
+ ).flatMap((journey) => journey.validate());
14768
16660
  if (!problems.length) return;
14769
16661
  writeLine("\n Journey warnings:");
14770
16662
  for (const problem of problems) writeLine(` ! ${problem}`);
@@ -14781,6 +16673,12 @@ ${"=".repeat(50)}`);
14781
16673
  * Deliberately narrow: only cross-resource facts the builder can see with
14782
16674
  * certainty. Per-field CEL schema checking stays server-side, where the
14783
16675
  * real validator lives — duplicating it here would drift.
16676
+ *
16677
+ * Pure: reads only what the plan declares, never what the server holds, so
16678
+ * it is correct before adoption and safe for a caller to run directly. It
16679
+ * is also the WHOLE gate: every anchor a v2 definition can name has a
16680
+ * request-local address whether or not the server has seen it, so no
16681
+ * refusal has to wait for adoption to decide it.
14784
16682
  */
14785
16683
  preflight() {
14786
16684
  const problems = [];
@@ -14804,39 +16702,46 @@ ${"=".repeat(50)}`);
14804
16702
  }
14805
16703
  }
14806
16704
  }
16705
+ for (const resource of this.resources) {
16706
+ if (resource instanceof JourneyV2Builder) problems.push(...resource.preflight());
16707
+ }
14807
16708
  return [...new Set(problems)];
14808
16709
  }
14809
- async apply() {
14810
- const problems = this.preflight();
14811
- if (problems.length) {
14812
- writeLine("\nPlan rejected \u2014 nothing was created:");
14813
- for (const problem of problems) writeLine(` ! ${problem}`);
14814
- throw new Error(
14815
- `Plan has ${problems.length} problem(s) and was not applied:
16710
+ /** The plan-rejection shape: every problem printed, nothing written. */
16711
+ rejectIfProblems(problems) {
16712
+ if (!problems.length) return;
16713
+ writeLine("\nPlan rejected \u2014 nothing was created:");
16714
+ for (const problem of problems) writeLine(` ! ${problem}`);
16715
+ throw new Error(
16716
+ `Plan has ${problems.length} problem(s) and was not applied:
14816
16717
  ` + problems.map((problem) => ` - ${problem}`).join("\n")
14817
- );
14818
- }
16718
+ );
16719
+ }
16720
+ async apply() {
14819
16721
  const resources = this.sortedResources();
16722
+ this.rejectIfProblems(this.preflight());
14820
16723
  await this.resolveExisting(resources);
14821
16724
  const summary = {};
14822
16725
  writeLine("Applying...");
14823
16726
  for (const resource of resources) {
14824
16727
  try {
14825
16728
  if (resource.isImplicit) continue;
14826
- if (resource._existed) {
16729
+ if (resource._existed && !resource.appliesWhenExisting) {
14827
16730
  const key = resourceKey(resource);
14828
16731
  summary[key] ??= [];
14829
16732
  summary[key].push(resource._id);
14830
16733
  writeLine(` Exists ${resource.planLine()} -> id=${resource._id}`);
14831
16734
  continue;
14832
16735
  }
16736
+ const updating = resource._existed;
14833
16737
  await resource.apply(this.client);
14834
16738
  if (resource._created || resource._id !== void 0) {
14835
16739
  const key = resourceKey(resource);
14836
16740
  summary[key] ??= [];
14837
16741
  summary[key].push(resource._id);
14838
16742
  const startTag = resource instanceof TaskBuilder && resource.start ? " [start]" : "";
14839
- writeLine(` Created ${resource.planLine()}${startTag} -> id=${resource._id}`);
16743
+ const verb = updating ? "Updated" : "Created";
16744
+ writeLine(` ${verb} ${resource.planLine()}${startTag} -> id=${resource._id}`);
14840
16745
  } else {
14841
16746
  writeLine(` Skipped: ${resource.planLine()}`);
14842
16747
  }
@@ -14855,6 +16760,11 @@ Done! Created ${count} resources.`);
14855
16760
  return summary;
14856
16761
  }
14857
16762
  async resolveExisting(resources) {
16763
+ assertUniqueJourneyNames(
16764
+ resources.filter(
16765
+ (resource) => resource instanceof JourneyBuilder || resource instanceof JourneyV2Builder
16766
+ )
16767
+ );
14858
16768
  const formSlugs = new Map(
14859
16769
  resources.filter((resource) => resource instanceof FormBuilder).map((resource) => [resource.slug, resource])
14860
16770
  );
@@ -14893,14 +16803,33 @@ Done! Created ${count} resources.`);
14893
16803
  }
14894
16804
  }
14895
16805
  const journeyNames = new Map(
14896
- resources.filter((resource) => resource instanceof JourneyBuilder).map((resource) => [resource.name, resource])
16806
+ resources.filter(
16807
+ (resource) => resource instanceof JourneyBuilder || resource instanceof JourneyV2Builder
16808
+ ).map((resource) => [resource.name, resource])
14897
16809
  );
14898
16810
  if (journeyNames.size) {
14899
- const existingJourneys = await this.client.getJourneys();
14900
- for (const existing of existingJourneys.items) {
16811
+ const pageSize = 500;
16812
+ const firstPage = await this.client.getJourneys(false, { page: 1, pageSize });
16813
+ const allJourneys = [...firstPage.items];
16814
+ for (let page = 2; page <= firstPage.totalPages; page++) {
16815
+ const nextPage = await this.client.getJourneys(false, { page, pageSize });
16816
+ allJourneys.push(...nextPage.items);
16817
+ }
16818
+ const storedByName = /* @__PURE__ */ new Map();
16819
+ for (const existing of allJourneys) {
14901
16820
  if (!existing.name || !journeyNames.has(existing.name)) continue;
14902
- const detail = await this.client.getJourney(existing.id);
14903
- journeyNames.get(existing.name).adopt(detail);
16821
+ storedByName.set(existing.name, [...storedByName.get(existing.name) ?? [], existing]);
16822
+ }
16823
+ for (const [name, matches] of storedByName) {
16824
+ if (matches.length > 1) {
16825
+ throw new Error(
16826
+ `This workspace has ${matches.length} journeys named '${name}', and the script adopts an existing journey by name \u2014 so it cannot tell which one it owns. Adopting the wrong one replaces that journey whole on the next save. Rename the others in the app, or rename the journey in the script.`
16827
+ );
16828
+ }
16829
+ const existing = matches[0];
16830
+ const builder = journeyNames.get(name);
16831
+ const detail = builder instanceof JourneyV2Builder ? await this.client.getJourneyAuthoring(existing.id) : await this.client.getJourney(existing.id);
16832
+ builder.adopt(detail);
14904
16833
  }
14905
16834
  }
14906
16835
  const agentNames = new Map(
@@ -15079,6 +17008,12 @@ Done! Created ${count} resources.`);
15079
17008
  }
15080
17009
  } else if (resource instanceof JourneyBuilder) {
15081
17010
  for (const goal of resource.goals) lines.push(`Goal: ${goal.name}`);
17011
+ } else if (resource instanceof JourneyV2Builder) {
17012
+ resource.touches.forEach((touch, index) => {
17013
+ lines.push(`${index + 1}. ${touch.name}`);
17014
+ });
17015
+ for (const ending of resource.endings) lines.push(`Ending: ${ending.name}`);
17016
+ for (const goal of resource.goals) lines.push(`Goal: ${goal.name}`);
15082
17017
  }
15083
17018
  }
15084
17019
  return lines;
@@ -15237,6 +17172,17 @@ var ApplyError = class extends Error {
15237
17172
  return this.#cause;
15238
17173
  }
15239
17174
  };
17175
+ function assertUniqueJourneyNames(journeys) {
17176
+ const seen = /* @__PURE__ */ new Set();
17177
+ for (const journey of journeys) {
17178
+ if (seen.has(journey.name)) {
17179
+ throw new Error(
17180
+ `This script declares two journeys named '${journey.name}'. A journey is adopted and re-applied by name, so only one of them could ever be written \u2014 and a v2 apply replaces the journey it adopted whole. Rename one.`
17181
+ );
17182
+ }
17183
+ seen.add(journey.name);
17184
+ }
17185
+ }
15240
17186
  function resourceKey(resource) {
15241
17187
  if (resource instanceof RoleUpdate) return "roleUpdates";
15242
17188
  if (resource instanceof FormBuilder) return "forms";
@@ -15246,7 +17192,9 @@ function resourceKey(resource) {
15246
17192
  if (resource instanceof MemberFilterBuilder) return "memberFilters";
15247
17193
  if (resource instanceof RoutineBuilder) return "routines";
15248
17194
  if (resource instanceof NotificationRuleBuilder) return "notificationRules";
15249
- if (resource instanceof JourneyBuilder) return "journeys";
17195
+ if (resource instanceof JourneyBuilder || resource instanceof JourneyV2Builder) {
17196
+ return "journeys";
17197
+ }
15250
17198
  if (resource instanceof JourneyStepBuilder) return "journeySteps";
15251
17199
  if (resource instanceof AgentBuilder) return "agents";
15252
17200
  return "resources";
@@ -15357,7 +17305,7 @@ function writeScopeForResource(resource) {
15357
17305
  if (resource instanceof RoutineBuilder || resource instanceof NotificationRuleBuilder) {
15358
17306
  return "automations:admin";
15359
17307
  }
15360
- if (resource instanceof JourneyBuilder || resource instanceof JourneyStepBuilder) {
17308
+ if (resource instanceof JourneyBuilder || resource instanceof JourneyStepBuilder || resource instanceof JourneyV2Builder) {
15361
17309
  return "journeys:write";
15362
17310
  }
15363
17311
  if (resource instanceof RoleUpdate) return "member_roles:write";
@@ -15501,6 +17449,36 @@ var QUERY_VALUELESS_OPS = /* @__PURE__ */ new Set([
15501
17449
  "exists"
15502
17450
  ]);
15503
17451
 
17452
+ // src/types/generated/channel_message.ts
17453
+ var ChannelMessageDirection = {
17454
+ inbound: "inbound",
17455
+ outbound: "outbound"
17456
+ };
17457
+ var ChannelMessageSource = {
17458
+ sms_record: "sms_record",
17459
+ other_chat: "other_chat"
17460
+ };
17461
+
17462
+ // src/types/generated/chat.ts
17463
+ var ChannelMessagesUnavailableReason = {
17464
+ not_single_channel: "not_single_channel",
17465
+ no_phone_number: "no_phone_number",
17466
+ no_counterpart_phone: "no_counterpart_phone"
17467
+ };
17468
+ var ChatMuteReason = {
17469
+ working: "working",
17470
+ waiting_on_person: "waiting_on_person",
17471
+ resolved_elsewhere: "resolved_elsewhere",
17472
+ not_mine: "not_mine"
17473
+ };
17474
+
17475
+ // src/types/generated/ehr_writeback.ts
17476
+ var EhrWritebackOutcomeResponseStatus = {
17477
+ accepted: "accepted",
17478
+ skipped: "skipped",
17479
+ failed: "failed"
17480
+ };
17481
+
15504
17482
  // src/types/chat-types.ts
15505
17483
  var SMS_DELIVERY_FAILURE_STATUSES = /* @__PURE__ */ new Set([
15506
17484
  "failed",
@@ -15657,6 +17635,35 @@ var PromoCodeStatus = {
15657
17635
  exhausted: "exhausted"
15658
17636
  };
15659
17637
 
17638
+ // src/types/generated/import_skipped_rule.ts
17639
+ var ImportSkippedRuleResourceGroupResourceType = {
17640
+ phone: "phone",
17641
+ inbox: "inbox",
17642
+ member: "member"
17643
+ };
17644
+ var ImportSkippedRuleResponseNeededResourceTypesItem = {
17645
+ phone: "phone",
17646
+ inbox: "inbox",
17647
+ member: "member"
17648
+ };
17649
+ var ImportSkippedRuleResponseParentKind = {
17650
+ routine: "routine",
17651
+ journey_step: "journey_step",
17652
+ task: "task",
17653
+ workflow: "workflow",
17654
+ other: "other"
17655
+ };
17656
+ var ImportSkippedRuleResponseReasonCode = {
17657
+ missing_binding: "missing_binding",
17658
+ invalid_event_rule_cel: "invalid_event_rule_cel",
17659
+ unresolved_journey_scope: "unresolved_journey_scope"
17660
+ };
17661
+ var ImportSkippedRuleResponseStatus = {
17662
+ outstanding: "outstanding",
17663
+ reconnected: "reconnected",
17664
+ dismissed: "dismissed"
17665
+ };
17666
+
15660
17667
  // src/features/registry.ts
15661
17668
  var FeatureCategory = /* @__PURE__ */ ((FeatureCategory2) => {
15662
17669
  FeatureCategory2["COMMUNICATION"] = "communication";
@@ -15782,6 +17789,12 @@ function isChatType(value) {
15782
17789
 
15783
17790
  // src/constants/models.ts
15784
17791
  var DEFAULT_CHAT_MODEL = "aws:bedrock:claude-4-5-haiku";
17792
+ var DEFAULT_AGENT_CHAT_MODEL = "openai:chat:gpt-5.6-luna";
17793
+ var DEFAULT_AGENT_REALTIME_MODEL = "xai:realtime:voice-agent-2";
17794
+ var DEFAULT_AGENT_REALTIME_MODEL_CONFIG = {
17795
+ ttsModel: "native",
17796
+ voiceModel: "xai:voice:cosmo"
17797
+ };
15785
17798
  var DEFAULT_VOICE_INFERENCE_MODEL = "openai:chat:gpt-5.6-luna";
15786
17799
  var DEFAULT_CUSTOM_VOICE_MODEL = "elevenlabs:voice:river";
15787
17800
 
@@ -15873,6 +17886,176 @@ function getAllResourceSlugs() {
15873
17886
  return Object.keys(RESOURCE_METADATA);
15874
17887
  }
15875
17888
 
17889
+ // src/types/generated/digest.ts
17890
+ var DigestSlotRole = {
17891
+ people: "people",
17892
+ subject: "subject",
17893
+ actor: "actor",
17894
+ workflow: "workflow",
17895
+ journey: "journey",
17896
+ phone_number: "phone_number",
17897
+ data_type: "data_type",
17898
+ operator_group: "operator_group",
17899
+ channel: "channel",
17900
+ origin: "origin",
17901
+ source: "source",
17902
+ reason: "reason",
17903
+ direction: "direction",
17904
+ area: "area",
17905
+ conclusion: "conclusion"
17906
+ };
17907
+
17908
+ // src/types/generated/activity_feed.ts
17909
+ var ActivityGrain = {
17910
+ month: "month",
17911
+ week: "week",
17912
+ day: "day",
17913
+ hour: "hour",
17914
+ event: "event"
17915
+ };
17916
+ var ActivityGroupBy = {
17917
+ workspace: "workspace",
17918
+ event_type: "event_type",
17919
+ family: "family",
17920
+ workspace_family: "workspace_family"
17921
+ };
17922
+ var ActivityOpenItemOrder = {
17923
+ priority: "priority",
17924
+ recency: "recency"
17925
+ };
17926
+ var ActivityWindowBasis = {
17927
+ absolute: "absolute",
17928
+ workspace_local: "workspace_local"
17929
+ };
17930
+
17931
+ // src/types/generated/family.ts
17932
+ var ActivityEventFamily = {
17933
+ people: "people",
17934
+ conversations: "conversations",
17935
+ journeys: "journeys",
17936
+ automation: "automation",
17937
+ operators: "operators",
17938
+ administration: "administration"
17939
+ };
17940
+ var ActivityOutcome = {
17941
+ ok: "ok",
17942
+ attention: "attention",
17943
+ failed: "failed"
17944
+ };
17945
+
17946
+ // src/types/generated/entity_ref.ts
17947
+ var RefResolutionStatus = {
17948
+ resolved: "resolved",
17949
+ unresolved: "unresolved",
17950
+ unsupported: "unsupported"
17951
+ };
17952
+
17953
+ // src/types/generated/event_type.ts
17954
+ var ActivityCapability = {
17955
+ "assignments:read": "assignments:read",
17956
+ "chats:read": "chats:read",
17957
+ "journeys:read": "journeys:read",
17958
+ "members:read": "members:read",
17959
+ "operator:read": "operator:read",
17960
+ "org:read": "org:read",
17961
+ "phones:read": "phones:read",
17962
+ "workflows:read": "workflows:read",
17963
+ "workspace:read": "workspace:read"
17964
+ };
17965
+ var ActivityEventType = {
17966
+ membercreated: "member.created",
17967
+ memberremoved: "member.removed",
17968
+ memberrole_changed: "member.role_changed",
17969
+ memberlabels_changed: "member.labels_changed",
17970
+ memberattributes_changed: "member.attributes_changed",
17971
+ importstarted: "import.started",
17972
+ importcompleted: "import.completed",
17973
+ assignmentstarted: "assignment.started",
17974
+ assignmentconcluded: "assignment.concluded",
17975
+ journeyenrolled: "journey.enrolled",
17976
+ journeyunenrolled: "journey.unenrolled",
17977
+ journeycompleted: "journey.completed",
17978
+ journeystep_transitioned: "journey.step_transitioned",
17979
+ journeyactivated: "journey.activated",
17980
+ chatstarted: "chat.started",
17981
+ chatawaiting_human: "chat.awaiting_human",
17982
+ chathuman_replied: "chat.human_replied",
17983
+ chatcall_ended: "chat.call_ended",
17984
+ escalationopened: "escalation.opened",
17985
+ escalationresolved: "escalation.resolved",
17986
+ callstarted: "call.started",
17987
+ callcompleted: "call.completed",
17988
+ callmissed: "call.missed",
17989
+ presencewent_online: "presence.went_online",
17990
+ presencewent_offline: "presence.went_offline",
17991
+ operator_groupmember_added: "operator_group.member_added",
17992
+ operator_groupmember_removed: "operator_group.member_removed",
17993
+ voicemailreceived: "voicemail.received",
17994
+ voicemaillistened: "voicemail.listened",
17995
+ routinestarted: "routine.started",
17996
+ routinecompleted: "routine.completed",
17997
+ routinefailed: "routine.failed",
17998
+ workflowpublished: "workflow.published",
17999
+ subscriptionstarted: "subscription.started",
18000
+ subscriptionupdated: "subscription.updated",
18001
+ subscriptioncanceled: "subscription.canceled",
18002
+ member_subscriptionstarted: "member_subscription.started",
18003
+ member_subscriptioncanceled: "member_subscription.canceled",
18004
+ purchasecompleted: "purchase.completed",
18005
+ phone_numberprovisioned: "phone_number.provisioned",
18006
+ phone_numberarchived: "phone_number.archived",
18007
+ domainlinked: "domain.linked",
18008
+ domainverified: "domain.verified",
18009
+ configupdated: "config.updated"
18010
+ };
18011
+ var ActivityVisibility = {
18012
+ workspace: "workspace",
18013
+ org: "org",
18014
+ account_private: "account_private"
18015
+ };
18016
+
18017
+ // src/types/generated/ref.ts
18018
+ var ActorKind = {
18019
+ account: "account",
18020
+ agent: "agent",
18021
+ connection: "connection",
18022
+ member: "member",
18023
+ org_account: "org_account",
18024
+ system: "system"
18025
+ };
18026
+ var EntityKind = {
18027
+ account: "account",
18028
+ org: "org",
18029
+ org_account: "org_account",
18030
+ workspace: "workspace",
18031
+ agent: "agent",
18032
+ connection: "connection",
18033
+ member: "member",
18034
+ assignment: "assignment",
18035
+ journey: "journey",
18036
+ journey_step: "journey_step",
18037
+ routine: "routine",
18038
+ task: "task",
18039
+ workflow: "workflow",
18040
+ workflow_revision: "workflow_revision",
18041
+ call: "call",
18042
+ chat: "chat",
18043
+ escalation: "escalation",
18044
+ inbox: "inbox",
18045
+ phone_number: "phone_number",
18046
+ voicemail: "voicemail",
18047
+ domain: "domain",
18048
+ import: "import",
18049
+ invoice: "invoice",
18050
+ member_label: "member_label",
18051
+ member_subscription: "member_subscription",
18052
+ operator_group: "operator_group",
18053
+ purchase: "purchase",
18054
+ subscription: "subscription",
18055
+ data_type: "data_type",
18056
+ workspace_config: "workspace_config"
18057
+ };
18058
+
15876
18059
  // src/scopes.ts
15877
18060
  var ScopeCategory = /* @__PURE__ */ ((ScopeCategory2) => {
15878
18061
  ScopeCategory2["WORKSPACE"] = "workspace";
@@ -15978,7 +18161,9 @@ var SCOPES = {
15978
18161
  "chats:write": {
15979
18162
  name: "chats:write",
15980
18163
  category: "chats" /* CHATS */,
15981
- description: "Send messages in conversations",
18164
+ // Cross-member: acting in a conversation that is not yours. Sending in
18165
+ // your own needs no scope (see the chats:read note on "all").
18166
+ description: "Modify other members' conversations",
15982
18167
  implies: ["chats:read"]
15983
18168
  },
15984
18169
  "chats:admin": {
@@ -16546,6 +18731,50 @@ function getRevisionState(workflow, revision) {
16546
18731
  state: revision?.publishedAt != null ? "published" : "draft"
16547
18732
  };
16548
18733
  }
18734
+
18735
+ // src/helpers/chat-interaction.ts
18736
+ var ChatInteractionController = class {
18737
+ constructor(api, workspaceId, chatId) {
18738
+ this.api = api;
18739
+ this.workspaceId = workspaceId;
18740
+ this.chatId = chatId;
18741
+ }
18742
+ api;
18743
+ workspaceId;
18744
+ chatId;
18745
+ current;
18746
+ pending;
18747
+ tail = Promise.resolve();
18748
+ clientSessionId = crypto.randomUUID();
18749
+ /** Serialize switches and reuse request IDs when a response is lost. */
18750
+ ensure(mode) {
18751
+ const operation = this.tail.then(async () => {
18752
+ if (this.pending) await this.applyPending();
18753
+ if (this.current?.mode !== mode) {
18754
+ this.pending = { mode, requestId: crypto.randomUUID() };
18755
+ await this.applyPending();
18756
+ }
18757
+ if (!this.current) throw new Error("Interaction session unavailable");
18758
+ return this.current;
18759
+ });
18760
+ this.tail = operation.catch(() => void 0);
18761
+ return operation;
18762
+ }
18763
+ async applyPending() {
18764
+ const pending = this.pending;
18765
+ if (!pending) return;
18766
+ this.current = this.current ? await this.api.transitionChatInteractionSession(
18767
+ this.workspaceId,
18768
+ this.chatId,
18769
+ this.current.id,
18770
+ pending
18771
+ ) : await this.api.createChatInteractionSession(this.workspaceId, this.chatId, {
18772
+ ...pending,
18773
+ clientSessionId: this.clientSessionId
18774
+ });
18775
+ this.pending = void 0;
18776
+ }
18777
+ };
16549
18778
  // Annotate the CommonJS export names for ESM import in node:
16550
18779
  0 && (module.exports = {
16551
18780
  AGENT_NOTE_ORIGINS,
@@ -16556,6 +18785,16 @@ function getRevisionState(workflow, revision) {
16556
18785
  AccessGrantStatus,
16557
18786
  AccessGrantTrigger,
16558
18787
  AccessLevel,
18788
+ ActivityCapability,
18789
+ ActivityEventFamily,
18790
+ ActivityEventType,
18791
+ ActivityGrain,
18792
+ ActivityGroupBy,
18793
+ ActivityOpenItemOrder,
18794
+ ActivityOutcome,
18795
+ ActivityVisibility,
18796
+ ActivityWindowBasis,
18797
+ ActorKind,
16559
18798
  AgentBuilder,
16560
18799
  ApiError,
16561
18800
  ApplyError,
@@ -16576,8 +18815,16 @@ function getRevisionState(workflow, revision) {
16576
18815
  CalendarScheduleRecurrence,
16577
18816
  CalendarSource,
16578
18817
  CapabilityClass,
18818
+ ChannelMessageDirection,
18819
+ ChannelMessageSource,
18820
+ ChannelMessagesUnavailableReason,
18821
+ ChatInteractionController,
18822
+ ChatMuteReason,
16579
18823
  ConsentMethod,
16580
18824
  CriterionType,
18825
+ DEFAULT_AGENT_CHAT_MODEL,
18826
+ DEFAULT_AGENT_REALTIME_MODEL,
18827
+ DEFAULT_AGENT_REALTIME_MODEL_CONFIG,
16581
18828
  DEFAULT_CHAT_MODEL,
16582
18829
  DEFAULT_CUSTOM_VOICE_MODEL,
16583
18830
  DEFAULT_THINKING_SPEECH_PHRASES,
@@ -16587,8 +18834,11 @@ function getRevisionState(workflow, revision) {
16587
18834
  DataRecordRetirementResponseReason,
16588
18835
  DataSensitivity,
16589
18836
  DataTypeRecordScope,
18837
+ DigestSlotRole,
16590
18838
  DriverMode,
18839
+ EhrWritebackOutcomeResponseStatus,
16591
18840
  EmailDnsRecordType,
18841
+ EntityKind,
16592
18842
  EventRuleActionType,
16593
18843
  EventRuleEventType,
16594
18844
  EventRuleObjectType,
@@ -16599,6 +18849,11 @@ function getRevisionState(workflow, revision) {
16599
18849
  FhirVendor,
16600
18850
  FormBuilder,
16601
18851
  GravityRailClient,
18852
+ ImportSkippedRuleResourceGroupResourceType,
18853
+ ImportSkippedRuleResponseNeededResourceTypesItem,
18854
+ ImportSkippedRuleResponseParentKind,
18855
+ ImportSkippedRuleResponseReasonCode,
18856
+ ImportSkippedRuleResponseStatus,
16602
18857
  InboundFaxStatusValues,
16603
18858
  IndexStatus,
16604
18859
  InvitationStatus,
@@ -16606,6 +18861,7 @@ function getRevisionState(workflow, revision) {
16606
18861
  JourneyBuilder,
16607
18862
  JourneyStepBuilder,
16608
18863
  MASKED_SECRET_SENTINEL,
18864
+ MEMBER_RELATIONSHIP_KINDS,
16609
18865
  McpServerState,
16610
18866
  MemberFeature,
16611
18867
  MemberFilterBuilder,
@@ -16613,6 +18869,7 @@ function getRevisionState(workflow, revision) {
16613
18869
  MemberImportPreviewRowAction,
16614
18870
  MemberImportValidationError,
16615
18871
  MemberLabelBuilder,
18872
+ MemberRelationshipKind,
16616
18873
  MemberType,
16617
18874
  MenuItemResponseItemType,
16618
18875
  MenuItemType,
@@ -16648,8 +18905,11 @@ function getRevisionState(workflow, revision) {
16648
18905
  REALTIME_MODEL_OPENAI,
16649
18906
  REALTIME_MODEL_OPENAI_2,
16650
18907
  REALTIME_MODEL_OPENAI_MINI,
18908
+ RefResolutionStatus,
16651
18909
  Region,
16652
18910
  RegistrationIdentifier,
18911
+ RelatedMemberRole,
18912
+ RelationshipCardinality,
16653
18913
  Resource,
16654
18914
  RoleUpdate,
16655
18915
  RoutineBuilder,
@@ -16674,7 +18934,12 @@ function getRevisionState(workflow, revision) {
16674
18934
  TTS_PREVIEW_PROVIDERS,
16675
18935
  TaskBuilder,
16676
18936
  TemplatesApi,
18937
+ TestChatRunLane,
18938
+ TestChatRunOutcome,
16677
18939
  ToolkitState,
18940
+ UiPromptPresentedKindValues,
18941
+ UiPromptResponseKindValues,
18942
+ UiPromptResponseStatusValues,
16678
18943
  WIDGET_SLUGS,
16679
18944
  WORKFLOW_IMPLICIT_USE_SCOPE,
16680
18945
  WorkflowAccessWarningResourceType,