@burdenoff/fe-libs 2026.928.3 → 2026.930.1

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 (129) hide show
  1. package/dist/shared/assistant/adminModeSendGate.d.ts +6 -5
  2. package/dist/shared/assistant/adminModeSendGate.d.ts.map +1 -1
  3. package/dist/shared/assistant/adminModeSendGate.js +11 -11
  4. package/dist/shared/assistant/api.d.ts +313 -28
  5. package/dist/shared/assistant/api.d.ts.map +1 -1
  6. package/dist/shared/assistant/api.js +351 -135
  7. package/dist/shared/assistant/autoRouting.d.ts +11 -3
  8. package/dist/shared/assistant/autoRouting.d.ts.map +1 -1
  9. package/dist/shared/assistant/autoRouting.js +7 -7
  10. package/dist/shared/assistant/capabilities.d.ts +28 -0
  11. package/dist/shared/assistant/capabilities.d.ts.map +1 -1
  12. package/dist/shared/assistant/capabilities.js +19 -10
  13. package/dist/shared/assistant/conversation.d.ts +24 -2
  14. package/dist/shared/assistant/conversation.d.ts.map +1 -1
  15. package/dist/shared/assistant/createSandboxAssistantTransport.d.ts.map +1 -1
  16. package/dist/shared/assistant/createSandboxAssistantTransport.js +67 -54
  17. package/dist/shared/assistant/history/historyList.js +1 -1
  18. package/dist/shared/assistant/history/historyMapping.d.ts.map +1 -1
  19. package/dist/shared/assistant/history/historyMapping.js +5 -1
  20. package/dist/shared/assistant/history/historyResume.js +7 -7
  21. package/dist/shared/assistant/i18nManifest.d.ts +53 -0
  22. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  23. package/dist/shared/assistant/i18nManifest.js +75 -16
  24. package/dist/shared/assistant/index.d.ts +15 -0
  25. package/dist/shared/assistant/index.d.ts.map +1 -1
  26. package/dist/shared/assistant/modeCapabilities.js +1 -1
  27. package/dist/shared/assistant/operations.d.ts +22 -0
  28. package/dist/shared/assistant/operations.d.ts.map +1 -1
  29. package/dist/shared/assistant/operations.js +2 -2
  30. package/dist/shared/assistant/prewarm.d.ts +7 -0
  31. package/dist/shared/assistant/prewarm.d.ts.map +1 -1
  32. package/dist/shared/assistant/prewarm.js +1 -1
  33. package/dist/shared/assistant/product.d.ts +80 -2
  34. package/dist/shared/assistant/product.d.ts.map +1 -1
  35. package/dist/shared/assistant/product.js +10 -6
  36. package/dist/shared/assistant/proposalWriteRules.d.ts +40 -0
  37. package/dist/shared/assistant/proposalWriteRules.d.ts.map +1 -0
  38. package/dist/shared/assistant/proposalWriteRules.js +14 -0
  39. package/dist/shared/assistant/store.d.ts +17 -0
  40. package/dist/shared/assistant/store.d.ts.map +1 -1
  41. package/dist/shared/assistant/store.js +50 -43
  42. package/dist/shared/assistant/turnOutcome.d.ts +34 -2
  43. package/dist/shared/assistant/turnOutcome.d.ts.map +1 -1
  44. package/dist/shared/assistant/turnOutcome.js +28 -17
  45. package/dist/shared/assistant/turnOutcomeCopy.d.ts +29 -7
  46. package/dist/shared/assistant/turnOutcomeCopy.d.ts.map +1 -1
  47. package/dist/shared/assistant/turnOutcomeCopy.js +18 -6
  48. package/dist/shared/assistant/types.d.ts +5 -1
  49. package/dist/shared/assistant/types.d.ts.map +1 -1
  50. package/dist/shared/assistant/ui/AssistantApiCallsConsentDialog.js +4 -4
  51. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  52. package/dist/shared/assistant/ui/AssistantChatArea.js +992 -718
  53. package/dist/shared/assistant/ui/AssistantConversationList.js +6 -6
  54. package/dist/shared/assistant/ui/AssistantLanguageMenu.js +6 -6
  55. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts +8 -1
  56. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts.map +1 -1
  57. package/dist/shared/assistant/ui/AssistantMessageItem.js +77 -76
  58. package/dist/shared/assistant/ui/AssistantMessageList.d.ts +13 -1
  59. package/dist/shared/assistant/ui/AssistantMessageList.d.ts.map +1 -1
  60. package/dist/shared/assistant/ui/AssistantMessageList.js +15 -13
  61. package/dist/shared/assistant/ui/AssistantReplyLanguageSelector.js +5 -5
  62. package/dist/shared/assistant/ui/AssistantSpeechProvider.js +209 -209
  63. package/dist/shared/assistant/ui/AssistantWriteConfirmDialog.d.ts +62 -0
  64. package/dist/shared/assistant/ui/AssistantWriteConfirmDialog.d.ts.map +1 -0
  65. package/dist/shared/assistant/ui/AssistantWriteConfirmDialog.js +253 -0
  66. package/dist/shared/assistant/ui/AssistantWriteProposalCard.d.ts +72 -0
  67. package/dist/shared/assistant/ui/AssistantWriteProposalCard.d.ts.map +1 -0
  68. package/dist/shared/assistant/ui/AssistantWriteProposalCard.js +439 -0
  69. package/dist/shared/assistant/ui/AssistantWriteProposalSlot.d.ts +40 -0
  70. package/dist/shared/assistant/ui/AssistantWriteProposalSlot.d.ts.map +1 -0
  71. package/dist/shared/assistant/ui/AssistantWriteProposalSlot.js +35 -0
  72. package/dist/shared/assistant/ui/composer/AssistantComposer.js +8 -8
  73. package/dist/shared/assistant/ui/useVoiceSession.d.ts +28 -0
  74. package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
  75. package/dist/shared/assistant/ui/useVoiceSession.js +159 -110
  76. package/dist/shared/assistant/ui/useWriteProposalConfirm.d.ts +61 -0
  77. package/dist/shared/assistant/ui/useWriteProposalConfirm.d.ts.map +1 -0
  78. package/dist/shared/assistant/ui/useWriteProposalConfirm.js +109 -0
  79. package/dist/shared/assistant/ui/useWriteProposals.d.ts +128 -0
  80. package/dist/shared/assistant/ui/useWriteProposals.d.ts.map +1 -0
  81. package/dist/shared/assistant/ui/useWriteProposals.js +240 -0
  82. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts +17 -1
  83. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts.map +1 -1
  84. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +141 -109
  85. package/dist/shared/assistant/ui/writeProposalPresentation.d.ts +76 -0
  86. package/dist/shared/assistant/ui/writeProposalPresentation.d.ts.map +1 -0
  87. package/dist/shared/assistant/ui/writeProposalPresentation.js +110 -0
  88. package/dist/shared/assistant/usageReporting.d.ts +108 -0
  89. package/dist/shared/assistant/usageReporting.d.ts.map +1 -0
  90. package/dist/shared/assistant/usageReporting.js +155 -0
  91. package/dist/shared/assistant/useAssistantApiAccess.d.ts +49 -14
  92. package/dist/shared/assistant/useAssistantApiAccess.d.ts.map +1 -1
  93. package/dist/shared/assistant/useAssistantApiAccess.js +43 -25
  94. package/dist/shared/assistant/useAssistantHeartbeat.d.ts.map +1 -1
  95. package/dist/shared/assistant/useAssistantHeartbeat.js +5 -5
  96. package/dist/shared/assistant/useWorkspaceWriteAccess.d.ts +5 -6
  97. package/dist/shared/assistant/useWorkspaceWriteAccess.d.ts.map +1 -1
  98. package/dist/shared/assistant/voice/voiceSession.d.ts +46 -0
  99. package/dist/shared/assistant/voice/voiceSession.d.ts.map +1 -1
  100. package/dist/shared/assistant/voice/voiceSession.js +35 -2
  101. package/dist/shared/assistant/writeConfirmSeam.d.ts +32 -0
  102. package/dist/shared/assistant/writeConfirmSeam.d.ts.map +1 -0
  103. package/dist/shared/assistant/writeConfirmSeam.js +23 -0
  104. package/dist/shared/assistant/writeModeConsent.d.ts +16 -8
  105. package/dist/shared/assistant/writeModeConsent.d.ts.map +1 -1
  106. package/dist/shared/assistant/writeModeConsent.js +2 -2
  107. package/dist/shared/assistant/writeProposalDiscovery.d.ts +187 -0
  108. package/dist/shared/assistant/writeProposalDiscovery.d.ts.map +1 -0
  109. package/dist/shared/assistant/writeProposalDiscovery.js +246 -0
  110. package/dist/shared/assistant/writeProposalErrorCopy.d.ts +135 -0
  111. package/dist/shared/assistant/writeProposalErrorCopy.d.ts.map +1 -0
  112. package/dist/shared/assistant/writeProposalErrorCopy.js +135 -0
  113. package/dist/shared/assistant/writeProposalVoice.d.ts +133 -0
  114. package/dist/shared/assistant/writeProposalVoice.d.ts.map +1 -0
  115. package/dist/shared/assistant/writeProposalVoice.js +66 -0
  116. package/dist/shared/assistant/writeProposals.d.ts +268 -0
  117. package/dist/shared/assistant/writeProposals.d.ts.map +1 -0
  118. package/dist/shared/assistant/writeProposals.js +445 -0
  119. package/dist/shared/assistant/writeReplyBinder.d.ts +166 -0
  120. package/dist/shared/assistant/writeReplyBinder.d.ts.map +1 -0
  121. package/dist/shared/assistant/writeReplyBinder.js +233 -0
  122. package/dist/shared/assistant/writeReplySend.d.ts +110 -0
  123. package/dist/shared/assistant/writeReplySend.d.ts.map +1 -0
  124. package/dist/shared/assistant/writeReplySend.js +93 -0
  125. package/dist/shared-assistant.js +168 -153
  126. package/dist/ui/modal-shell.d.ts +14 -1
  127. package/dist/ui/modal-shell.d.ts.map +1 -1
  128. package/dist/ui/modal-shell.js +8 -6
  129. package/package.json +1 -1
@@ -0,0 +1,445 @@
1
+ import { proxySandboxRaw as e, writeApprovalModeOf as t, writeExecutionOf as n } from "./api.js";
2
+ //#region src/shared/assistant/writeProposals.ts
3
+ var r = [
4
+ "NOT_FOUND",
5
+ "SESSION_MISMATCH",
6
+ "CONVERSATION_MISMATCH",
7
+ "ACTOR_MISMATCH",
8
+ "HASH_MISMATCH",
9
+ "METHOD_NOT_ALLOWED",
10
+ "SUPERSEDED",
11
+ "DECLINED",
12
+ "NOT_PENDING",
13
+ "EXPIRED",
14
+ "EVICTED",
15
+ "EXECUTION_NOT_ENABLED",
16
+ "READ_ONLY",
17
+ "TURN_IN_PROGRESS",
18
+ "CONTEXT_CHANGED",
19
+ "STORE_UNAVAILABLE",
20
+ "APPROVAL_MODE_MISMATCH",
21
+ "PANEL_UPGRADE_REQUIRED",
22
+ "NOT_PROPOSAL_OWNER",
23
+ "INVALID_REQUEST",
24
+ "MALFORMED_RESPONSE",
25
+ "UNKNOWN"
26
+ ], i = class extends Error {
27
+ status;
28
+ code;
29
+ reason;
30
+ current;
31
+ indeterminate;
32
+ constructor(e) {
33
+ super(e.message), this.name = "WriteProposalError", this.status = e.status, this.code = e.code, e.reason !== void 0 && (this.reason = e.reason), e.current !== void 0 && (this.current = e.current), this.indeterminate = e.indeterminate ?? !1;
34
+ }
35
+ };
36
+ function a(e) {
37
+ return e instanceof i;
38
+ }
39
+ var o = "api-calls", s = /^wp_[0-9a-f]{32}$/, c = /^[0-9a-f]{64}$/;
40
+ function l(r) {
41
+ async function a(t, n, a, s, c) {
42
+ let l = r.getWorkspaceId();
43
+ if (!l || !t) throw new i({
44
+ status: 0,
45
+ code: "INVALID_REQUEST",
46
+ message: "No workspace or sandbox to address"
47
+ });
48
+ let u;
49
+ try {
50
+ u = await e(t, l, n, a, s, o, r.getAuthContext());
51
+ } catch (e) {
52
+ throw h(e, c);
53
+ }
54
+ let d = u.status, f = C(u.body) ? u.body : {};
55
+ if (d < 200 || d >= 300) throw m(d, f, c);
56
+ return {
57
+ status: d,
58
+ body: f
59
+ };
60
+ }
61
+ function s(e, t) {
62
+ return new i({
63
+ status: e,
64
+ code: "MALFORMED_RESPONSE",
65
+ message: "The sandbox answered with an unexpected shape",
66
+ indeterminate: t
67
+ });
68
+ }
69
+ function c(e, t, n = !1) {
70
+ let r = q(t.proposal);
71
+ if (!r) throw s(e, n);
72
+ return r;
73
+ }
74
+ return {
75
+ async list(e, r) {
76
+ u(e);
77
+ let i = new URLSearchParams();
78
+ i.set("status", r?.status ?? "live"), r?.since !== void 0 && Number.isFinite(r.since) && r.since >= 0 && i.set("since", String(Math.floor(r.since)));
79
+ let { status: o, body: c } = await a(e.sandboxId, `/sessions/${encodeURIComponent(e.sessionId)}/write-proposals?${i.toString()}`, "GET", void 0, !1);
80
+ if (!w(c.serverNow) || !Array.isArray(c.proposals)) throw s(o, !1);
81
+ let l = [];
82
+ for (let e of c.proposals) {
83
+ let t = q(e);
84
+ if (!t) throw s(o, !1);
85
+ l.push(t);
86
+ }
87
+ return {
88
+ serverNow: c.serverNow,
89
+ mode: t(c.mode),
90
+ execution: n(c.execution, !0),
91
+ proposals: l
92
+ };
93
+ },
94
+ async presented(e, t) {
95
+ d(e);
96
+ let { status: n, body: r } = await a(e.sandboxId, `/write-proposals/${encodeURIComponent(e.proposalId)}/presented`, "POST", {
97
+ sessionId: e.sessionId,
98
+ conversationId: e.conversationId,
99
+ payloadHash: t.payloadHash,
100
+ surface: t.surface,
101
+ clientRequestId: t.clientRequestId
102
+ }, !1);
103
+ return c(n, r);
104
+ },
105
+ async approve(e, t) {
106
+ d(e);
107
+ let { status: n, body: r } = await a(e.sandboxId, `/write-proposals/${encodeURIComponent(e.proposalId)}/approve`, "POST", {
108
+ sessionId: e.sessionId,
109
+ conversationId: e.conversationId,
110
+ payloadHash: t.payloadHash,
111
+ method: "button",
112
+ surface: t.surface,
113
+ clientRequestId: t.clientRequestId
114
+ }, !0);
115
+ if (n === 202) {
116
+ if (r.proposal !== void 0 && r.proposal !== null) {
117
+ let e = q(r.proposal);
118
+ if (!e || e.status !== "executing") throw s(n, !0);
119
+ return {
120
+ kind: "executing",
121
+ proposal: e
122
+ };
123
+ }
124
+ if (r.status !== "executing") throw s(n, !0);
125
+ return {
126
+ kind: "executing",
127
+ proposal: null
128
+ };
129
+ }
130
+ let i = c(n, r, !0), o = r.outcome ?? i.status;
131
+ if (!k(o) || i.status !== o || r.replayed !== void 0 && typeof r.replayed != "boolean") throw s(n, !0);
132
+ return {
133
+ kind: "settled",
134
+ proposal: i,
135
+ outcome: o,
136
+ replayed: r.replayed === !0
137
+ };
138
+ },
139
+ async decline(e, t) {
140
+ d(e);
141
+ let { status: n, body: r } = await a(e.sandboxId, `/write-proposals/${encodeURIComponent(e.proposalId)}/decline`, "POST", {
142
+ sessionId: e.sessionId,
143
+ conversationId: e.conversationId,
144
+ reason: t.reason,
145
+ method: t.method,
146
+ ...t.surface ? { surface: t.surface } : {},
147
+ clientRequestId: t.clientRequestId
148
+ }, !1);
149
+ return c(n, r);
150
+ },
151
+ async declineAll(e, t) {
152
+ u(e);
153
+ let { status: n, body: r } = await a(e.sandboxId, `/sessions/${encodeURIComponent(e.sessionId)}/write-proposals/decline`, "POST", {
154
+ conversationId: e.conversationId,
155
+ reason: t.reason,
156
+ method: t.method,
157
+ clientRequestId: t.clientRequestId
158
+ }, !1), i = A(r.proposalIds ?? [], D);
159
+ if (!T(r.declined) || !i) throw s(n, !1);
160
+ return {
161
+ declined: r.declined,
162
+ proposalIds: i
163
+ };
164
+ }
165
+ };
166
+ }
167
+ function u(e) {
168
+ if (typeof e.sessionId != "string" || !e.sessionId) throw new i({
169
+ status: 0,
170
+ code: "INVALID_REQUEST",
171
+ message: "No session to address"
172
+ });
173
+ }
174
+ function d(e) {
175
+ if (u(e), !s.test(e.proposalId)) throw new i({
176
+ status: 0,
177
+ code: "INVALID_REQUEST",
178
+ message: "Not a write proposal id"
179
+ });
180
+ }
181
+ function f(e) {
182
+ return !(e >= 400 && e < 500 && e !== 408);
183
+ }
184
+ function p(e) {
185
+ if (typeof e != "string") return "UNKNOWN";
186
+ let t = e.trim().toUpperCase();
187
+ return S(r, t) ? t : "UNKNOWN";
188
+ }
189
+ function m(e, t, n) {
190
+ let r = t.current === void 0 ? void 0 : q(t.current) ?? void 0;
191
+ return new i({
192
+ status: e,
193
+ code: p(t.code),
194
+ message: typeof t.error == "string" && t.error ? t.error : `Write proposal request failed (${e})`,
195
+ ...typeof t.reason == "string" ? { reason: t.reason } : {},
196
+ ...r ? { current: r } : {},
197
+ indeterminate: n && f(e)
198
+ });
199
+ }
200
+ function h(e, t) {
201
+ if (e instanceof i) return e;
202
+ let n = C(e) && C(e.extensions) ? e.extensions : {}, r = C(n.http) ? n.http : {}, a = (C(e) ? e.statusCode : void 0) ?? r.status ?? n.statusCode, o = typeof a == "number" && Number.isInteger(a) ? a : 0, s = p(n.code), c = s !== "UNKNOWN" && s !== "STORE_UNAVAILABLE";
203
+ return new i({
204
+ status: o,
205
+ code: s,
206
+ message: e instanceof Error ? e.message : String(e),
207
+ ...typeof n.reason == "string" ? { reason: n.reason } : {},
208
+ indeterminate: t && !c
209
+ });
210
+ }
211
+ var g = [
212
+ "pending",
213
+ "executing",
214
+ "succeeded",
215
+ "failed",
216
+ "outcome_unknown",
217
+ "declined",
218
+ "superseded",
219
+ "expired"
220
+ ], _ = [
221
+ "user_declined",
222
+ "corrected",
223
+ "redirected",
224
+ "not_chosen",
225
+ "user_replied",
226
+ "conversation_closed",
227
+ "mode_switched",
228
+ "sandbox_replaced",
229
+ "ttl",
230
+ "evicted",
231
+ "context_changed",
232
+ "stale_execution"
233
+ ], v = [
234
+ "button",
235
+ "typed",
236
+ "spoken"
237
+ ], y = [
238
+ "button",
239
+ "typed",
240
+ "spoken",
241
+ "system"
242
+ ], b = [
243
+ "destructive",
244
+ "financial",
245
+ "bulk",
246
+ "permission",
247
+ "credential",
248
+ "irreversible",
249
+ "unclassified"
250
+ ], x = [
251
+ "succeeded",
252
+ "failed",
253
+ "outcome_unknown"
254
+ ];
255
+ function S(e, t) {
256
+ return e.some((e) => e === t);
257
+ }
258
+ function C(e) {
259
+ return typeof e == "object" && !!e && !Array.isArray(e);
260
+ }
261
+ function w(e) {
262
+ return typeof e == "number" && Number.isFinite(e);
263
+ }
264
+ function T(e) {
265
+ return typeof e == "number" && Number.isInteger(e) && e >= 0;
266
+ }
267
+ function E(e) {
268
+ return e === null || typeof e == "string";
269
+ }
270
+ function D(e) {
271
+ return typeof e == "string" && s.test(e);
272
+ }
273
+ function O(e) {
274
+ return e === null || D(e);
275
+ }
276
+ function k(e) {
277
+ return S(x, e);
278
+ }
279
+ function A(e, t) {
280
+ if (!Array.isArray(e)) return null;
281
+ let n = [];
282
+ for (let r of e) {
283
+ if (!t(r)) return null;
284
+ n.push(r);
285
+ }
286
+ return n;
287
+ }
288
+ function j(e, t) {
289
+ if (!Array.isArray(e)) return null;
290
+ let n = [];
291
+ for (let r of e) {
292
+ let e = t(r);
293
+ if (e === null) return null;
294
+ n.push(e);
295
+ }
296
+ return n;
297
+ }
298
+ function M(e) {
299
+ if (e !== void 0) return T(e) ? e : null;
300
+ }
301
+ var N = (e) => typeof e == "string";
302
+ function P(e) {
303
+ return !C(e) || typeof e.name != "string" || !("value" in e) || e.source !== "literal" && e.source !== "variable" || typeof e.sensitive != "boolean" ? null : {
304
+ name: e.name,
305
+ value: e.value,
306
+ source: e.source,
307
+ sensitive: e.sensitive
308
+ };
309
+ }
310
+ function F(e) {
311
+ if (!C(e) || !E(e.alias) || typeof e.field != "string") return null;
312
+ let t = j(e.args, P);
313
+ return t ? {
314
+ alias: e.alias,
315
+ field: e.field,
316
+ args: t
317
+ } : null;
318
+ }
319
+ function I(e) {
320
+ return !C(e) || typeof e.path != "string" || !("value" in e) || typeof e.sensitive != "boolean" ? null : {
321
+ path: e.path,
322
+ value: e.value,
323
+ sensitive: e.sensitive
324
+ };
325
+ }
326
+ function L(e) {
327
+ return !C(e) || typeof e.label != "string" || !E(e.value) || typeof e.sensitive != "boolean" ? null : {
328
+ label: e.label,
329
+ value: e.sensitive ? null : e.value,
330
+ sensitive: e.sensitive
331
+ };
332
+ }
333
+ function R(e) {
334
+ if (!C(e) || typeof e.verb != "string" || typeof e.noun != "string") return null;
335
+ let t = M(e.count), n = M(e.fieldsOmitted), r = j(e.fields, L);
336
+ return t === null || n === null || !r ? null : {
337
+ verb: e.verb,
338
+ noun: e.noun,
339
+ ...t === void 0 ? {} : { count: t },
340
+ fields: r,
341
+ ...n === void 0 ? {} : { fieldsOmitted: n }
342
+ };
343
+ }
344
+ function z(e) {
345
+ return !C(e) || e.kind !== "card" && e.kind !== "dialog" || !E(e.key) ? null : {
346
+ kind: e.kind,
347
+ key: e.key
348
+ };
349
+ }
350
+ function B(e) {
351
+ if (!C(e) || typeof e.label != "string" || !E(e.operationNameClaimed) || !T(e.targetCount) || typeof e.noun != "string" || typeof e.readback != "string" || typeof e.readbackPast != "string" || typeof e.confirmLabel != "string" || !(e.reversible === null || typeof e.reversible == "boolean")) return null;
352
+ let t = j(e.rootFields, F), n = j(e.variables, I), r = M(e.variablesOmitted), i = A(e.consequences, N), a = R(e.readbackParts), o = z(e.confirmSurface);
353
+ return !t || !n || r === null || !i || !a || !o ? null : {
354
+ label: e.label,
355
+ operationNameClaimed: e.operationNameClaimed,
356
+ rootFields: t,
357
+ variables: n,
358
+ ...r === void 0 ? {} : { variablesOmitted: r },
359
+ targetCount: e.targetCount,
360
+ noun: e.noun,
361
+ readback: e.readback,
362
+ readbackPast: e.readbackPast,
363
+ readbackParts: a,
364
+ confirmLabel: e.confirmLabel,
365
+ consequences: i,
366
+ reversible: e.reversible,
367
+ confirmSurface: o
368
+ };
369
+ }
370
+ function V(e) {
371
+ if (!C(e) || e.level !== "high" || typeof e.source != "string") return null;
372
+ let t = A(e.kinds, (e) => S(b, e)), n = A(e.reasons, N);
373
+ return !t || !n ? null : {
374
+ level: "high",
375
+ kinds: t,
376
+ reasons: n,
377
+ source: e.source
378
+ };
379
+ }
380
+ function H(e) {
381
+ if (!C(e) || e.outcome !== "approved" && e.outcome !== "declined" || !S(y, e.method) || !w(e.at)) return null;
382
+ let t = e.surface === void 0 ? null : e.surface, n = e.reason === void 0 ? null : e.reason;
383
+ return !E(t) || !E(n) ? null : {
384
+ outcome: e.outcome,
385
+ method: e.method,
386
+ surface: t,
387
+ reason: n,
388
+ at: e.at
389
+ };
390
+ }
391
+ function U(e) {
392
+ return !C(e) || typeof e.message != "string" || e.code !== void 0 && typeof e.code != "string" ? null : {
393
+ message: e.message,
394
+ ...typeof e.code == "string" ? { code: e.code } : {}
395
+ };
396
+ }
397
+ function W(e) {
398
+ if (!C(e) || typeof e.summary != "string") return null;
399
+ let t = e.errors === void 0 ? void 0 : j(e.errors, U);
400
+ return t === null ? null : {
401
+ summary: e.summary,
402
+ ..."dataPreview" in e ? { dataPreview: e.dataPreview } : {},
403
+ ...t ? { errors: t } : {}
404
+ };
405
+ }
406
+ function G(e) {
407
+ return !C(e) || typeof e.enabled != "boolean" || e.reason !== void 0 && typeof e.reason != "string" ? null : {
408
+ enabled: e.enabled,
409
+ ...typeof e.reason == "string" ? { reason: e.reason } : {}
410
+ };
411
+ }
412
+ function K(e, t) {
413
+ return e == null ? null : t(e) ?? void 0;
414
+ }
415
+ function q(e) {
416
+ if (!C(e)) return null;
417
+ let { proposalId: t, lineageId: n, revision: r, status: i, statusReason: a, sessionId: o, conversationId: s, payloadHash: l, gateway: u, approvable: d, createdAt: f, expiresAt: p, supersedes: m, supersededBy: h, repeatOf: y } = e;
418
+ if (!D(t) || !D(n) || typeof r != "number" || !Number.isInteger(r) || r < 1 || !S(g, i) || !(a === null || S(_, a)) || !E(o) || !E(s) || typeof l != "string" || !c.test(l) || u !== "workspace" && u !== "global" || typeof d != "boolean" || !w(f) || !w(p) || !O(m) || !O(h) || !O(y)) return null;
419
+ let b = B(e.description), x = V(e.risk), T = G(e.execution), k = A(e.allowedMethods, (e) => S(v, e)), j = K(e.decision, H), M = K(e.result, W);
420
+ return !b || !x || !T || !k || j === void 0 || M === void 0 ? null : {
421
+ proposalId: t,
422
+ lineageId: n,
423
+ revision: r,
424
+ status: i,
425
+ statusReason: a,
426
+ sessionId: o,
427
+ conversationId: s,
428
+ payloadHash: l,
429
+ gateway: u,
430
+ description: b,
431
+ risk: x,
432
+ allowedMethods: k,
433
+ execution: T,
434
+ approvable: d,
435
+ createdAt: f,
436
+ expiresAt: p,
437
+ supersedes: m,
438
+ supersededBy: h,
439
+ repeatOf: y,
440
+ decision: j,
441
+ result: M
442
+ };
443
+ }
444
+ //#endregion
445
+ export { r as WRITE_PROPOSAL_ERROR_CODES, o as WRITE_PROPOSAL_SANDBOX_MODE, i as WriteProposalError, l as createSandboxWriteProposalClient, a as isWriteProposalError, q as parseWriteProposalView };
@@ -0,0 +1,166 @@
1
+ import { WriteExecutionState, WriteProposalDeclineReason } from './writeProposals';
2
+ /** What a reply is, as far as a waiting change is concerned (contract §3.3). */
3
+ export type WriteReplyClass = "affirm" | "affirm_with_change" | "decline" | "decline_redirect" | "other";
4
+ /** Where a prompt came from. Mirrors the sandbox's `writeReply.origin`. */
5
+ export type WriteReplyOrigin = "typed" | "spoken" | "chip" | "host_queued" | "retry" | "proposal_result";
6
+ /** The kinds the sandbox accepts in `writeReply.kind`. */
7
+ export type WriteReplyKind = "affirm" | "decline" | "other";
8
+ /** The `writeReply` a forwarded prompt carries in its body. */
9
+ export interface WriteReplyTag {
10
+ kind: WriteReplyKind;
11
+ origin: WriteReplyOrigin;
12
+ }
13
+ /** The reasons the binder declines with. A subset of the client's own. */
14
+ export type WriteReplyDeclineReason = Extract<WriteProposalDeclineReason, "corrected" | "user_declined" | "redirected">;
15
+ /** A line the panel shows (and, in voice, speaks) through `tr()`. */
16
+ export interface WriteReplyLine {
17
+ readonly key: string;
18
+ readonly fallback: string;
19
+ }
20
+ /** A classified reply, and the text after a leading negative when there is one. */
21
+ export interface WriteReplyAnalysis {
22
+ cls: WriteReplyClass;
23
+ /**
24
+ * For `decline_redirect` only: what the person asked for instead, as they
25
+ * wrote it ("No, open billing" → "open billing"). `null` for every other
26
+ * class.
27
+ */
28
+ remainder: string | null;
29
+ }
30
+ /** Which text an action applies to. */
31
+ export type WriteReplyText = {
32
+ from: "utterance";
33
+ } | {
34
+ from: "remainder";
35
+ value: string;
36
+ };
37
+ export type WriteReplyDecision =
38
+ /**
39
+ * Send a prompt. When `declineAll` is set, await
40
+ * `declineAll({reason: declineAll})` FIRST (the sweep is the backstop if it
41
+ * fails). `writeReply: null` means the binder adds nothing: send it exactly
42
+ * as it would have gone.
43
+ */
44
+ {
45
+ action: "forward";
46
+ text: WriteReplyText;
47
+ declineAll: WriteReplyDeclineReason | null;
48
+ writeReply: WriteReplyTag | null;
49
+ /** Spoken after the declines, in a voice conversation. */
50
+ voiceLine: WriteReplyLine | null;
51
+ }
52
+ /** Nothing is waiting: the ordinary send path (local commands, then the model). */
53
+ | {
54
+ action: "normal";
55
+ writeReply: WriteReplyTag;
56
+ }
57
+ /** Answer in the panel. Nothing is sent and nothing is declined. */
58
+ | {
59
+ action: "local_reply";
60
+ line: WriteReplyLine;
61
+ values: {
62
+ count: number;
63
+ };
64
+ }
65
+ /**
66
+ * Run the matched UI-only command on `text`. Nothing is sent. When
67
+ * `declineAll` is set, await it first; otherwise the proposals stay live.
68
+ */
69
+ | {
70
+ action: "local";
71
+ text: WriteReplyText;
72
+ declineAll: WriteReplyDeclineReason | null;
73
+ };
74
+ export interface WriteReplyDecisionInput {
75
+ cls: WriteReplyClass;
76
+ /**
77
+ * The session's PENDING proposals: those still waiting for a decision. An
78
+ * executing one is not waiting for anything, and nothing can decline it.
79
+ */
80
+ liveCount: number;
81
+ origin: WriteReplyOrigin;
82
+ /**
83
+ * Whether a UI-only command matched. For `decline_redirect` that is the
84
+ * REMAINDER; for every other class, the whole utterance.
85
+ */
86
+ localUiMatch: boolean;
87
+ /** `WriteReplyAnalysis.remainder`. */
88
+ remainder: string | null;
89
+ /**
90
+ * The issuing sandbox's execution state. A fenced session's card has no
91
+ * confirm button, so its reply must not point to one. Unknown means fenced.
92
+ */
93
+ execution: WriteExecutionState;
94
+ }
95
+ /**
96
+ * Everything the binder says. Rendered through `tr(line.key, line.fallback,
97
+ * values)`, and read into the i18n manifest from this table.
98
+ */
99
+ export declare const WRITE_REPLY_COPY: Readonly<{
100
+ useButton: Readonly<{
101
+ key: "writeProposal.useButton";
102
+ fallback: "To make this change, press its confirm button. A reply on its own doesn't confirm it.";
103
+ }>;
104
+ whichOne: Readonly<{
105
+ key: "writeProposal.whichOne";
106
+ fallback: "I have {{count}} changes ready. Press the confirm button on the one you want. A reply on its own doesn't confirm any of them.";
107
+ }>;
108
+ replyCannotRun: Readonly<{
109
+ key: "writeProposal.replyCannotRun";
110
+ fallback: "A reply can't run a change from this session. You can review or cancel it on its card; running changes from the assistant becomes available once secure confirmation is enabled.";
111
+ }>;
112
+ cancelled: Readonly<{
113
+ key: "writeProposal.cancelled";
114
+ fallback: "Cancelled.";
115
+ }>;
116
+ }>;
117
+ /** The lexicons, for the tests. Frozen copies. */
118
+ export declare const WRITE_REPLY_LEXICON: Readonly<{
119
+ affirm: readonly ("yes" | "ok" | "approve" | "yeah" | "yep" | "yup" | "okay" | "sure" | "confirm" | "do it" | "go ahead" | "please do" | "yes please" | "sounds good" | "thats right")[];
120
+ negative: readonly ("stop" | "no" | "cancel" | "wait" | "nope" | "nah" | "dont" | "do not" | "never mind" | "nevermind" | "not now" | "forget it" | "hold on")[];
121
+ courtesy: readonly ("please" | "thanks" | "thank you")[];
122
+ maxAffirmTokens: 4;
123
+ }>;
124
+ /**
125
+ * Classify a reply, and find what a redirecting decline asks for instead.
126
+ *
127
+ * Normalised (contract §3.3): NFKC, lower-case, punctuation stripped (an
128
+ * apostrophe joins: "don't" → "dont"), trailing "please" / "thanks" / "thank
129
+ * you" and a leading "please" removed.
130
+ *
131
+ * - `affirm`: nothing but affirmatives, at most 4 words ("yes", "yes please",
132
+ * "ok, go ahead").
133
+ * - `decline`: a leading negative ("no", "cancel", "never mind", …). This
134
+ * includes "no problem, go ahead", which errs in the safe direction.
135
+ * - `decline_redirect`: a leading negative that closes its own clause, followed
136
+ * by a request ("No, open the page instead"). When the rest is not a request
137
+ * of its own (it runs on with no break, as in "no problem", or is only
138
+ * affirmatives, as in "no, go ahead"), it is a plain `decline`.
139
+ * - `affirm_with_change`: a leading affirmative with anything else ("yes, but
140
+ * make it 9", "ok, open billing").
141
+ * - `other`: everything else, and every locale that is not English.
142
+ */
143
+ export declare function analyseWriteReply(text: string, locale: string | null | undefined): WriteReplyAnalysis;
144
+ /** `analyseWriteReply(text, locale).cls`. */
145
+ export declare function classifyWriteReply(text: string, locale: string | null | undefined): WriteReplyClass;
146
+ /** Whether a reply from `origin` can bind to a waiting change at all. */
147
+ export declare function isUserOriginatedWriteReply(origin: WriteReplyOrigin): boolean;
148
+ /**
149
+ * What the panel does with a reply (design §6.4 FE6, the 5a table). There is
150
+ * no row that confirms a change, and no row that sends a bare affirmative
151
+ * while one is waiting.
152
+ *
153
+ * | Condition | Decision |
154
+ * |-----------------------------------|-----------------------------------------------------------|
155
+ * | origin not typed/spoken | forward, unchanged |
156
+ * | 0 pending + affirm | forward with writeReply{affirm} (the server's bridge) |
157
+ * | 0 pending + anything else | normal |
158
+ * | ≥1 pending + affirm | local_reply: useButton (1) / whichOne (≥2); fenced: replyCannotRun |
159
+ * | affirm_with_change | declineAll('corrected'), then forward |
160
+ * | decline | declineAll('user_declined'), then forward; voice "Cancelled." |
161
+ * | decline_redirect | declineAll('redirected'), then local on the remainder when it matched, else forward the remainder |
162
+ * | other + a local UI match | local; the proposals stay live |
163
+ * | other | forward with writeReply{other} |
164
+ */
165
+ export declare function decideWriteReply(input: WriteReplyDecisionInput): WriteReplyDecision;
166
+ //# sourceMappingURL=writeReplyBinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeReplyBinder.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/writeReplyBinder.ts"],"names":[],"mappings":"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"}