@dsh-ray/assistant-delivery 0.0.1-seed.0 → 0.2.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 (185) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +610 -1
  3. package/bin/dsh-restart-supervisor.js +102 -0
  4. package/cordis.patch.yml +29 -0
  5. package/lib/acceptance.d.ts +54 -0
  6. package/lib/acceptance.d.ts.map +1 -0
  7. package/lib/acceptance.js +2 -0
  8. package/lib/acceptance.js.map +1 -0
  9. package/lib/agent-runtime.d.ts +247 -0
  10. package/lib/agent-runtime.d.ts.map +1 -0
  11. package/lib/agent-runtime.js +4458 -0
  12. package/lib/agent-runtime.js.map +1 -0
  13. package/lib/approval-status-context.d.ts +8 -0
  14. package/lib/approval-status-context.d.ts.map +1 -0
  15. package/lib/approval-status-context.js +55 -0
  16. package/lib/approval-status-context.js.map +1 -0
  17. package/lib/attention-audit-store.d.ts +54 -0
  18. package/lib/attention-audit-store.d.ts.map +1 -0
  19. package/lib/attention-audit-store.js +213 -0
  20. package/lib/attention-audit-store.js.map +1 -0
  21. package/lib/attention-enforcement.d.ts +75 -0
  22. package/lib/attention-enforcement.d.ts.map +1 -0
  23. package/lib/attention-enforcement.js +84 -0
  24. package/lib/attention-enforcement.js.map +1 -0
  25. package/lib/attention.d.ts +208 -0
  26. package/lib/attention.d.ts.map +1 -0
  27. package/lib/attention.js +288 -0
  28. package/lib/attention.js.map +1 -0
  29. package/lib/canonical.d.ts +28 -0
  30. package/lib/canonical.d.ts.map +1 -0
  31. package/lib/canonical.js +190 -0
  32. package/lib/canonical.js.map +1 -0
  33. package/lib/coordinator.d.ts +134 -0
  34. package/lib/coordinator.d.ts.map +1 -0
  35. package/lib/coordinator.js +746 -0
  36. package/lib/coordinator.js.map +1 -0
  37. package/lib/feedback-command.d.ts +105 -0
  38. package/lib/feedback-command.d.ts.map +1 -0
  39. package/lib/feedback-command.js +547 -0
  40. package/lib/feedback-command.js.map +1 -0
  41. package/lib/foreground-observation.d.ts +66 -0
  42. package/lib/foreground-observation.d.ts.map +1 -0
  43. package/lib/foreground-observation.js +13 -0
  44. package/lib/foreground-observation.js.map +1 -0
  45. package/lib/foreground-termination.d.ts +31 -0
  46. package/lib/foreground-termination.d.ts.map +1 -0
  47. package/lib/foreground-termination.js +42 -0
  48. package/lib/foreground-termination.js.map +1 -0
  49. package/lib/goal-wake-types.d.ts +93 -0
  50. package/lib/goal-wake-types.d.ts.map +1 -0
  51. package/lib/goal-wake-types.js +70 -0
  52. package/lib/goal-wake-types.js.map +1 -0
  53. package/lib/in-process-reload-runtime.d.ts +120 -0
  54. package/lib/in-process-reload-runtime.d.ts.map +1 -0
  55. package/lib/in-process-reload-runtime.js +1280 -0
  56. package/lib/in-process-reload-runtime.js.map +1 -0
  57. package/lib/inbound-images.d.ts +38 -0
  58. package/lib/inbound-images.d.ts.map +1 -0
  59. package/lib/inbound-images.js +269 -0
  60. package/lib/inbound-images.js.map +1 -0
  61. package/lib/index.d.ts +41 -0
  62. package/lib/index.d.ts.map +1 -0
  63. package/lib/index.js +25 -0
  64. package/lib/index.js.map +1 -0
  65. package/lib/learning-command.d.ts +40 -0
  66. package/lib/learning-command.d.ts.map +1 -0
  67. package/lib/learning-command.js +57 -0
  68. package/lib/learning-command.js.map +1 -0
  69. package/lib/native-termination.d.ts +12 -0
  70. package/lib/native-termination.d.ts.map +1 -0
  71. package/lib/native-termination.js +57 -0
  72. package/lib/native-termination.js.map +1 -0
  73. package/lib/native-web-owner.d.ts +97 -0
  74. package/lib/native-web-owner.d.ts.map +1 -0
  75. package/lib/native-web-owner.js +338 -0
  76. package/lib/native-web-owner.js.map +1 -0
  77. package/lib/operator-snapshot.d.ts +107 -0
  78. package/lib/operator-snapshot.d.ts.map +1 -0
  79. package/lib/operator-snapshot.js +1013 -0
  80. package/lib/operator-snapshot.js.map +1 -0
  81. package/lib/operator.d.ts +25 -0
  82. package/lib/operator.d.ts.map +1 -0
  83. package/lib/operator.js +48 -0
  84. package/lib/operator.js.map +1 -0
  85. package/lib/progress-attention.d.ts +55 -0
  86. package/lib/progress-attention.d.ts.map +1 -0
  87. package/lib/progress-attention.js +128 -0
  88. package/lib/progress-attention.js.map +1 -0
  89. package/lib/reply-replay.d.ts +52 -0
  90. package/lib/reply-replay.d.ts.map +1 -0
  91. package/lib/reply-replay.js +122 -0
  92. package/lib/reply-replay.js.map +1 -0
  93. package/lib/restart-native.d.ts +47 -0
  94. package/lib/restart-native.d.ts.map +1 -0
  95. package/lib/restart-native.js +170 -0
  96. package/lib/restart-native.js.map +1 -0
  97. package/lib/restart-runtime.d.ts +38 -0
  98. package/lib/restart-runtime.d.ts.map +1 -0
  99. package/lib/restart-runtime.js +335 -0
  100. package/lib/restart-runtime.js.map +1 -0
  101. package/lib/restart-store.d.ts +132 -0
  102. package/lib/restart-store.d.ts.map +1 -0
  103. package/lib/restart-store.js +757 -0
  104. package/lib/restart-store.js.map +1 -0
  105. package/lib/restart-supervisor.d.ts +129 -0
  106. package/lib/restart-supervisor.d.ts.map +1 -0
  107. package/lib/restart-supervisor.js +615 -0
  108. package/lib/restart-supervisor.js.map +1 -0
  109. package/lib/service.d.ts +1279 -0
  110. package/lib/service.d.ts.map +1 -0
  111. package/lib/service.js +8694 -0
  112. package/lib/service.js.map +1 -0
  113. package/lib/session-commands.d.ts +52 -0
  114. package/lib/session-commands.d.ts.map +1 -0
  115. package/lib/session-commands.js +180 -0
  116. package/lib/session-commands.js.map +1 -0
  117. package/lib/session-lease-runtime.d.ts +70 -0
  118. package/lib/session-lease-runtime.d.ts.map +1 -0
  119. package/lib/session-lease-runtime.js +395 -0
  120. package/lib/session-lease-runtime.js.map +1 -0
  121. package/lib/session-lease-types.d.ts +27 -0
  122. package/lib/session-lease-types.d.ts.map +1 -0
  123. package/lib/session-lease-types.js +2 -0
  124. package/lib/session-lease-types.js.map +1 -0
  125. package/lib/sqlite.d.ts +8 -0
  126. package/lib/sqlite.d.ts.map +1 -0
  127. package/lib/sqlite.js +1665 -0
  128. package/lib/sqlite.js.map +1 -0
  129. package/lib/store.d.ts +1267 -0
  130. package/lib/store.d.ts.map +1 -0
  131. package/lib/store.js +8039 -0
  132. package/lib/store.js.map +1 -0
  133. package/lib/tools.d.ts +4 -0
  134. package/lib/tools.d.ts.map +1 -0
  135. package/lib/tools.js +73 -0
  136. package/lib/tools.js.map +1 -0
  137. package/lib/types.d.ts +1091 -0
  138. package/lib/types.d.ts.map +1 -0
  139. package/lib/types.js +10 -0
  140. package/lib/types.js.map +1 -0
  141. package/lib/version-query.d.ts +77 -0
  142. package/lib/version-query.d.ts.map +1 -0
  143. package/lib/version-query.js +2208 -0
  144. package/lib/version-query.js.map +1 -0
  145. package/lib/version.d.ts +2 -0
  146. package/lib/version.d.ts.map +1 -0
  147. package/lib/version.js +2 -0
  148. package/lib/version.js.map +1 -0
  149. package/lib/work-item-engineering-context.d.ts +127 -0
  150. package/lib/work-item-engineering-context.d.ts.map +1 -0
  151. package/lib/work-item-engineering-context.js +151 -0
  152. package/lib/work-item-engineering-context.js.map +1 -0
  153. package/lib/work-item-feedback-schema.d.ts +2 -0
  154. package/lib/work-item-feedback-schema.d.ts.map +1 -0
  155. package/lib/work-item-feedback-schema.js +29 -0
  156. package/lib/work-item-feedback-schema.js.map +1 -0
  157. package/lib/work-item-feedback-store.d.ts +29 -0
  158. package/lib/work-item-feedback-store.d.ts.map +1 -0
  159. package/lib/work-item-feedback-store.js +111 -0
  160. package/lib/work-item-feedback-store.js.map +1 -0
  161. package/lib/work-item-feedback.d.ts +157 -0
  162. package/lib/work-item-feedback.d.ts.map +1 -0
  163. package/lib/work-item-feedback.js +2 -0
  164. package/lib/work-item-feedback.js.map +1 -0
  165. package/lib/work-item-replies-schema.d.ts +3 -0
  166. package/lib/work-item-replies-schema.d.ts.map +1 -0
  167. package/lib/work-item-replies-schema.js +45 -0
  168. package/lib/work-item-replies-schema.js.map +1 -0
  169. package/lib/work-item-replies-store.d.ts +43 -0
  170. package/lib/work-item-replies-store.d.ts.map +1 -0
  171. package/lib/work-item-replies-store.js +203 -0
  172. package/lib/work-item-replies-store.js.map +1 -0
  173. package/lib/work-item-replies.d.ts +93 -0
  174. package/lib/work-item-replies.d.ts.map +1 -0
  175. package/lib/work-item-replies.js +15 -0
  176. package/lib/work-item-replies.js.map +1 -0
  177. package/lib/workflow-auto-producer.d.ts +37 -0
  178. package/lib/workflow-auto-producer.d.ts.map +1 -0
  179. package/lib/workflow-auto-producer.js +58 -0
  180. package/lib/workflow-auto-producer.js.map +1 -0
  181. package/lib/workflow-command.d.ts +16 -0
  182. package/lib/workflow-command.d.ts.map +1 -0
  183. package/lib/workflow-command.js +52 -0
  184. package/lib/workflow-command.js.map +1 -0
  185. package/package.json +174 -4
package/lib/types.d.ts ADDED
@@ -0,0 +1,1091 @@
1
+ import type { ForegroundTerminationObservation } from './foreground-termination.js';
2
+ import type { ImageAttachmentRef, ImageMediaType } from '@deepseek-ai/dsh-attachment';
3
+ import type { Agent } from '@deepseek-ai/dsh-agent';
4
+ import type { AskUserQuestionAnswer, AskUserQuestionItem } from '@deepseek-ai/dsh-user-questions/types';
5
+ import type { ApprovalDispatchRouteV2 } from '@dsh-ray/assistant-policy';
6
+ import type { OwnerGoalOutcomeFeedbackLocator, OwnerGoalOutcomeFeedbackProof } from './goal-wake-types.js';
7
+ import type { ForegroundExecution } from './acceptance.js';
8
+ /** Host-only owner scope; every read revalidates this exact durable lineage. */
9
+ export interface OwnerForegroundTaskSourceScope {
10
+ readonly authorityId: string;
11
+ readonly principalId: string;
12
+ readonly workspace: string;
13
+ readonly agentPreset: string;
14
+ readonly expectedOwner: Readonly<{
15
+ authorityHash: string;
16
+ principalRecordId: string;
17
+ principalVersion: number;
18
+ }>;
19
+ }
20
+ /** Host-only summary of one active configured owner route; zero message/secret exposure. */
21
+ export interface OwnerRouteScopeSummary {
22
+ readonly authorityId: string;
23
+ readonly authorityHash: string;
24
+ readonly principalId: string;
25
+ readonly principalRecordId: string;
26
+ readonly principalVersion: number;
27
+ readonly workspace: string;
28
+ readonly agentPreset: string;
29
+ }
30
+ export interface OwnerForegroundTaskSourceCursor {
31
+ readonly protocol: 'assistant-delivery/owner-foreground-source-cursor/v1';
32
+ readonly epoch: string;
33
+ readonly scopeKey: string;
34
+ readonly sequence: number;
35
+ }
36
+ /** Completion metadata, not evidence that the task achieved its business objective. */
37
+ export interface OwnerForegroundTaskSource {
38
+ readonly protocol: 'assistant-delivery/owner-foreground-source/v1';
39
+ readonly inboxId: string;
40
+ readonly sourceDigest: string;
41
+ readonly completionSequence: number;
42
+ readonly admissionCursor: Readonly<DeliveryAdmissionCursor>;
43
+ readonly authorityId: string;
44
+ readonly authorityHash: string;
45
+ readonly principalId: string;
46
+ readonly owner: Readonly<DeliveryOwnerLineage>;
47
+ readonly scope: Readonly<{
48
+ workspace: string;
49
+ preset: string;
50
+ }>;
51
+ readonly binding: Readonly<{
52
+ id: string;
53
+ version: number;
54
+ generation: number;
55
+ sessionId: string;
56
+ }>;
57
+ readonly execution: Readonly<ForegroundExecution>;
58
+ readonly termination?: Readonly<ForegroundTerminationObservation>;
59
+ }
60
+ export interface OwnerForegroundTaskSourcePage {
61
+ readonly items: readonly Readonly<OwnerForegroundTaskSource>[];
62
+ readonly nextCursor: Readonly<OwnerForegroundTaskSourceCursor>;
63
+ readonly watermark: number;
64
+ readonly hasMore: boolean;
65
+ }
66
+ export interface OwnerForegroundTaskSourceText {
67
+ readonly text: string;
68
+ readonly fullTextDigest: string;
69
+ readonly returnedBytes: number;
70
+ readonly fullBytes: number;
71
+ readonly truncated: boolean;
72
+ }
73
+ export interface OwnerForegroundTaskSourceContent {
74
+ readonly source: Readonly<OwnerForegroundTaskSource>;
75
+ readonly sourceDigest: string;
76
+ readonly contentDigest: string;
77
+ readonly input: Readonly<OwnerForegroundTaskSourceText>;
78
+ readonly reply: Readonly<OwnerForegroundTaskSourceText & {
79
+ outboxId: string;
80
+ intentDigest: string;
81
+ }>;
82
+ }
83
+ /** Owner-fenced original-input page, independent of a successful answer or model route. */
84
+ export interface OwnerForegroundTaskInput {
85
+ readonly source: Readonly<OwnerForegroundTaskSource>;
86
+ readonly sourceDigest: string;
87
+ readonly contentDigest: string;
88
+ readonly input: Readonly<{
89
+ text: string;
90
+ fullTextDigest: string;
91
+ fullBytes: number;
92
+ returnedBytes: number;
93
+ offset: number;
94
+ nextOffset?: number;
95
+ }>;
96
+ }
97
+ /** An exact completed source to recheck under one owner-bound writer fence. */
98
+ export interface OwnerForegroundTaskSourceRef {
99
+ readonly inboxId: string;
100
+ readonly expectedSourceDigest: string;
101
+ }
102
+ export interface ExternalPrincipalKey {
103
+ channel: string;
104
+ account: string;
105
+ tenant: string;
106
+ user: string;
107
+ }
108
+ export type ConversationKind = 'dm' | 'group';
109
+ export interface ConversationRef {
110
+ channel: string;
111
+ account: string;
112
+ tenant: string;
113
+ kind: ConversationKind;
114
+ chat: string;
115
+ thread?: string;
116
+ }
117
+ export interface DeliveryTarget {
118
+ conversation: ConversationRef;
119
+ principal: ExternalPrincipalKey;
120
+ }
121
+ export interface ConversationBinding {
122
+ id: string;
123
+ conversation: ConversationRef;
124
+ principal: ExternalPrincipalKey;
125
+ workspace: string;
126
+ agentPreset: string;
127
+ sessionId: string;
128
+ generation: number;
129
+ policyRef: string;
130
+ status: 'active' | 'revoked';
131
+ createdAt: number;
132
+ updatedAt: number;
133
+ version: number;
134
+ }
135
+ /**
136
+ * Host-owned authority for one stable owner delivery route.
137
+ *
138
+ * The authority follows only monotonic generations of the exact canonical
139
+ * conversation/principal/workspace/preset/policy lineage. It is deployment
140
+ * configuration, not model input or a model-callable capability.
141
+ */
142
+ export interface OwnerRouteAuthority {
143
+ id: string;
144
+ conversation: ConversationRef;
145
+ principal: ExternalPrincipalKey;
146
+ workspace: string;
147
+ agentPreset: string;
148
+ policyRef: string;
149
+ minimumGeneration: number;
150
+ }
151
+ /** Immutable route evidence captured when a binding is resolved or enqueued. */
152
+ export interface OwnerRouteBindingSnapshot {
153
+ receiptVersion: 2;
154
+ authorityId: string;
155
+ authorityHash: string;
156
+ bindingId: string;
157
+ bindingVersion: number;
158
+ generation: number;
159
+ minimumGeneration: number;
160
+ }
161
+ export interface ResolvedOwnerRoute {
162
+ authorityId: string;
163
+ binding: ConversationBinding;
164
+ snapshot: OwnerRouteBindingSnapshot;
165
+ }
166
+ /** Content-free Host receipt proving that one exact configured owner route is live. */
167
+ export interface OwnerRouteValidationReceipt {
168
+ receiptVersion: 2;
169
+ authorityId: string;
170
+ authorityHash: string;
171
+ principalId: string;
172
+ /** Exact durable Delivery principal row, so the same external id cannot ABA. */
173
+ principalRecordId: string;
174
+ principalVersion: number;
175
+ workspace: string;
176
+ agentPreset: string;
177
+ bindingVersion: number;
178
+ generation: number;
179
+ }
180
+ /**
181
+ * Content-free, READ-ONLY Host receipt proving that the live caller Agent is
182
+ * bound to an active `linked` principal whose `linked_to_id` is the CURRENT
183
+ * owner row of one configured owner route.
184
+ *
185
+ * It deliberately has no `receiptVersion`: every consumer that requires a v2
186
+ * owner receipt (`receiptVersion === 2`) rejects it. It never grants approval,
187
+ * continuation, mutation, or owner foreground authority.
188
+ */
189
+ export interface OwnerAliasReceipt {
190
+ protocol: 'assistant-delivery/owner-alias-receipt/v1';
191
+ authorityId: string;
192
+ authorityHash: string;
193
+ workspace: string;
194
+ agentPreset: string;
195
+ alias: Readonly<{
196
+ principalId: string;
197
+ principalRecordId: string;
198
+ principalVersion: number;
199
+ bindingId: string;
200
+ bindingVersion: number;
201
+ bindingGeneration: number;
202
+ sessionId: string;
203
+ }>;
204
+ root: Readonly<{
205
+ principalId: string;
206
+ principalRecordId: string;
207
+ principalVersion: number;
208
+ bindingVersion: number;
209
+ generation: number;
210
+ }>;
211
+ }
212
+ /** Host-only proof of one live native tool call in the alias's claimed human Inbox turn. */
213
+ export interface OwnerAliasForegroundToolCallAttestation {
214
+ protocol: 'assistant-delivery/owner-alias-foreground-tool-call/v1';
215
+ receipt: Readonly<OwnerAliasReceipt>;
216
+ sourceInboxId: string;
217
+ sourceEventId: string;
218
+ turn: number;
219
+ call: Readonly<{
220
+ id: string;
221
+ toolName: string;
222
+ eventSeq: number;
223
+ eventDigest: string;
224
+ argumentsDigest: string;
225
+ }>;
226
+ }
227
+ /**
228
+ * Host-only companion of {@link OwnerRouteValidationReceipt}: the unchanged v2
229
+ * receipt plus the id of the exact active binding row it was read from, both
230
+ * from one route resolve. Lets a consumer pin work frozen under one binding
231
+ * without the v2 receipt itself ever carrying a binding address.
232
+ */
233
+ export interface OwnerRouteBindingReceipt {
234
+ protocol: 'assistant-delivery/owner-route-binding/v1';
235
+ receipt: Readonly<OwnerRouteValidationReceipt>;
236
+ bindingId: string;
237
+ }
238
+ /** Content-free Host observation; only an exact durable owner row proves revocation. */
239
+ export type OwnerRouteStateInspection = {
240
+ status: 'active';
241
+ receipt: Readonly<OwnerRouteValidationReceipt>;
242
+ } | {
243
+ status: 'revoked';
244
+ authorityId: string;
245
+ authorityHash: string;
246
+ principalId: string;
247
+ principalRecordId: string;
248
+ principalVersion: number;
249
+ } | {
250
+ status: 'unavailable';
251
+ reason: string;
252
+ };
253
+ /** A provider/model route without persistence metadata. */
254
+ export interface ModelRouteRef {
255
+ provider: string;
256
+ model: string;
257
+ reasoningEffort?: string;
258
+ }
259
+ /** The authoritative, durable selection shown by one model-picker operation. */
260
+ export interface ModelPickerState extends ModelRouteRef {
261
+ revision: number;
262
+ }
263
+ /** A durable provider/model override scoped to one canonical external conversation. */
264
+ export interface ConversationModelSelection extends ModelRouteRef {
265
+ updatedAt: number;
266
+ version: number;
267
+ }
268
+ export interface InboundEnvelope {
269
+ channel: string;
270
+ account: string;
271
+ eventId: string;
272
+ occurredAt: number;
273
+ principal: ExternalPrincipalKey;
274
+ conversation: ConversationRef;
275
+ kind: 'command' | 'text';
276
+ text: string;
277
+ metadata?: Readonly<Record<string, string>>;
278
+ attachments?: readonly InboundAttachmentDescriptor[];
279
+ }
280
+ /** Durable Delivery owner-row lineage. Version changes on revoke/reactivation, preventing owner ABA. */
281
+ export interface DeliveryOwnerLineage {
282
+ readonly principalRecordId: string;
283
+ readonly principalVersion: number;
284
+ }
285
+ /** Durable total order minted by the Delivery database when an Inbox is admitted. */
286
+ export interface DeliveryAdmissionCursor {
287
+ /** Immutable Delivery database epoch. Cursors from different epochs are never comparable. */
288
+ readonly epoch: string;
289
+ readonly sequence: number;
290
+ }
291
+ /** Closed key/value catalog emitted by Delivery's authenticated `/feedback` command. */
292
+ export type DeliveryPreferenceSelection = {
293
+ readonly preferenceKey: 'feedback.response';
294
+ readonly candidateValue: 'helpful' | 'not-helpful' | 'too-long' | 'too-short' | 'wrong-format' | 'wrong-action' | 'unwanted-reminder';
295
+ } | {
296
+ readonly preferenceKey: 'recommendation.ranking';
297
+ readonly candidateValue: 'recency' | 'familiarity' | 'evidence';
298
+ } | {
299
+ readonly preferenceKey: 'response.explanation_depth';
300
+ readonly candidateValue: 'result-first' | 'balanced' | 'tutorial';
301
+ } | {
302
+ readonly preferenceKey: 'response.language';
303
+ readonly candidateValue: 'zh-CN' | 'en';
304
+ } | {
305
+ readonly preferenceKey: 'response.structure';
306
+ readonly candidateValue: 'prose' | 'bullets' | 'mixed';
307
+ } | {
308
+ readonly preferenceKey: 'response.verbosity';
309
+ readonly candidateValue: 'concise' | 'balanced' | 'detailed';
310
+ } | {
311
+ readonly preferenceKey: 'suggestion.frequency';
312
+ readonly candidateValue: 'low' | 'normal';
313
+ };
314
+ /**
315
+ * Immutable Host-attested feedback event. Delivery, not a model or listener,
316
+ * owns every field and the downstream idempotency identity.
317
+ */
318
+ export type DeliveryPreferenceFeedback = Readonly<{
319
+ readonly scope: Readonly<{
320
+ workspace: string;
321
+ preset: string;
322
+ }>;
323
+ readonly principalId: string;
324
+ readonly principalLineage?: Readonly<DeliveryOwnerLineage>;
325
+ /** Optional only so a rolling upgrade can parse and fail closed on legacy queued projections. */
326
+ readonly admissionCursor?: Readonly<DeliveryAdmissionCursor>;
327
+ readonly stance: 'support';
328
+ readonly actorTrust: 'owner-authenticated';
329
+ readonly interpretationTrust: 'explicit-selection' | 'typed-feedback';
330
+ readonly source: 'direct-owner-feedback';
331
+ readonly occurredAt: number;
332
+ readonly idempotencyKey: string;
333
+ /** Optional exact reply target; identifiers only, never message content. */
334
+ readonly exposureTarget?: Readonly<{
335
+ sourceInboxId: string;
336
+ sourceOutboxId: string;
337
+ }>;
338
+ }> & DeliveryPreferenceSelection;
339
+ /**
340
+ * Content-free observation emitted only after one authenticated owner turn has
341
+ * completed, its session has flushed, and its exact reply Outbox is durable.
342
+ */
343
+ export type DeliveryPreferenceCompletionIdentity = Readonly<{
344
+ bindingId: string;
345
+ bindingVersion: number;
346
+ sessionId: string;
347
+ sourceEventId: string;
348
+ sourceInboxId: string;
349
+ replyOutboxId: string;
350
+ }>;
351
+ export type DeliveryPreferenceObservation = Readonly<{
352
+ readonly scope: Readonly<{
353
+ workspace: string;
354
+ preset: string;
355
+ }>;
356
+ readonly principalId: string;
357
+ readonly principalLineage?: Readonly<DeliveryOwnerLineage>;
358
+ readonly admissionCursor?: Readonly<DeliveryAdmissionCursor>;
359
+ readonly preferenceKey: 'response.language';
360
+ readonly candidateValue: 'zh-CN' | 'en';
361
+ readonly stance: 'support';
362
+ readonly actorTrust: 'owner-authenticated';
363
+ readonly interpretationTrust: 'behavioral-inference';
364
+ readonly source: 'delivery-observation';
365
+ readonly occurredAt: number;
366
+ readonly idempotencyKey: string;
367
+ readonly completion: DeliveryPreferenceCompletionIdentity;
368
+ }>;
369
+ /** A successful owner turn with a durable reply, even when no behavior classifier emits a signal. */
370
+ export type DeliveryPreferenceCompletion = Readonly<{
371
+ readonly scope: Readonly<{
372
+ workspace: string;
373
+ preset: string;
374
+ }>;
375
+ readonly principalId: string;
376
+ readonly principalLineage?: Readonly<DeliveryOwnerLineage>;
377
+ readonly admissionCursor?: Readonly<DeliveryAdmissionCursor>;
378
+ readonly actorTrust: 'owner-authenticated';
379
+ readonly source: 'delivery-completion';
380
+ readonly occurredAt: number;
381
+ readonly idempotencyKey: string;
382
+ readonly completion: DeliveryPreferenceCompletionIdentity;
383
+ }>;
384
+ export type DeliveryPreferenceEvent = DeliveryPreferenceCompletion | DeliveryPreferenceFeedback | DeliveryPreferenceObservation;
385
+ export type DeliveryLearningControlAction = 'explain' | 'export' | 'forget' | 'pause' | 'resume' | 'rollback' | 'status';
386
+ export interface DeliveryLearningExplanation {
387
+ readonly key: string;
388
+ readonly value: string;
389
+ readonly state: 'active' | 'inactive' | 'rolled-back' | 'shadow' | 'suppressed';
390
+ readonly version: number;
391
+ readonly supportingSignals: number;
392
+ readonly contradictingSignals: number;
393
+ readonly evidenceMass: number;
394
+ }
395
+ /** Portable, content-free snapshot for the exact current owner scope. */
396
+ export interface DeliveryLearningExportDocument {
397
+ readonly format: 'dsh-preference-learning';
398
+ readonly version: 1;
399
+ readonly records: readonly Readonly<DeliveryLearningExplanation>[];
400
+ }
401
+ /** Content-free owner command minted only after Delivery revalidates the exact Inbox binding. */
402
+ export interface DeliveryLearningControlRequest {
403
+ readonly scope: Readonly<{
404
+ workspace: string;
405
+ preset: string;
406
+ }>;
407
+ readonly principalId: string;
408
+ readonly principalLineage: Readonly<DeliveryOwnerLineage>;
409
+ readonly admissionCursor: Readonly<DeliveryAdmissionCursor>;
410
+ readonly action: DeliveryLearningControlAction;
411
+ /** Required only for rollback; it must be one exact Host-catalog T1 key. */
412
+ readonly preferenceKey?: string;
413
+ readonly occurredAt: number;
414
+ readonly idempotencyKey: string;
415
+ }
416
+ export interface DeliveryLearningScopeStatus {
417
+ /** Compatibility summary; use the independent fields below for decisions. */
418
+ readonly mode: 'active' | 'disabled' | 'paused';
419
+ readonly administrativelyEnabled: boolean;
420
+ readonly collectionMode: 'active' | 'paused';
421
+ readonly signals: number;
422
+ readonly hypotheses: number;
423
+ /** Active catalog hypotheses retained in the ledger, even while suppressed. */
424
+ readonly storedActiveOverlays: number;
425
+ /** Overlays that may currently enter a prompt after both gates are applied. */
426
+ readonly effectiveActiveOverlays: number;
427
+ /** Compatibility alias for effectiveActiveOverlays. */
428
+ readonly activeOverlays: number;
429
+ readonly shadowHypotheses: number;
430
+ }
431
+ export type DeliveryLearningControlReceipt = Readonly<{
432
+ outcome: 'applied';
433
+ action: DeliveryLearningControlAction;
434
+ idempotencyKey: string;
435
+ replayed: boolean;
436
+ state: Readonly<DeliveryLearningScopeStatus>;
437
+ deletedSignals?: number;
438
+ deletedHypotheses?: number;
439
+ explanation?: readonly Readonly<DeliveryLearningExplanation>[];
440
+ exportDocument?: Readonly<DeliveryLearningExportDocument>;
441
+ rolledBack?: boolean;
442
+ rolledBackVersion?: number;
443
+ }> | Readonly<{
444
+ outcome: 'stale';
445
+ action: DeliveryLearningControlAction;
446
+ idempotencyKey: string;
447
+ }>;
448
+ export type DeliveryLearningControlListener = (request: Readonly<DeliveryLearningControlRequest>) => Readonly<DeliveryLearningControlReceipt> | Promise<Readonly<DeliveryLearningControlReceipt>>;
449
+ /** Durable acknowledgement returned by the single authoritative sink. */
450
+ export interface DeliveryPreferenceFeedbackReceipt {
451
+ readonly idempotencyKey: string;
452
+ readonly status: 'recorded';
453
+ }
454
+ export type DeliveryPreferenceFeedbackListener = (events: readonly Readonly<DeliveryPreferenceEvent>[]) => readonly Readonly<DeliveryPreferenceFeedbackReceipt>[] | Promise<readonly Readonly<DeliveryPreferenceFeedbackReceipt>[]>;
455
+ /**
456
+ * Process-local writer used while Delivery holds its SQLite owner-lineage
457
+ * fence. Implementations must commit before returning and must never call back
458
+ * into Delivery; the fixed lock order is Delivery -> Preference.
459
+ */
460
+ export type DeliveryPreferenceSynchronousFeedbackListener = (events: readonly Readonly<DeliveryPreferenceEvent>[]) => readonly Readonly<DeliveryPreferenceFeedbackReceipt>[];
461
+ export declare const DELIVERY_PREFERENCE_PROJECTION_PROTOCOL: "assistant-delivery/preference-projection/v2";
462
+ /** Process-local ownership proof minted by the exact Preference Learning instance. */
463
+ export interface DeliveryPreferenceRegistrationOwner {
464
+ ownsDeliveryPreferenceRegistration(registration: Readonly<DeliveryPreferenceRegistration>): boolean;
465
+ }
466
+ export interface DeliveryPreferenceRegistration {
467
+ readonly protocol: typeof DELIVERY_PREFERENCE_PROJECTION_PROTOCOL;
468
+ readonly producer: 'preference-learning';
469
+ readonly generation: string;
470
+ readonly owner: DeliveryPreferenceRegistrationOwner;
471
+ append: DeliveryPreferenceFeedbackListener;
472
+ /** Optional rolling-upgrade capability; current Preference instances always provide it. */
473
+ appendSynchronously?: DeliveryPreferenceSynchronousFeedbackListener;
474
+ control?: DeliveryLearningControlListener;
475
+ }
476
+ /** Exact current Delivery turn; identifiers only, never message or model content. */
477
+ export interface DeliveryPreferenceTurnAttestation {
478
+ readonly scope: Readonly<{
479
+ workspace: string;
480
+ preset: string;
481
+ }>;
482
+ readonly principalId: string;
483
+ readonly principalLineage: Readonly<DeliveryOwnerLineage>;
484
+ readonly bindingId: string;
485
+ readonly bindingVersion: number;
486
+ readonly sessionId: string;
487
+ readonly sourceEventId: string;
488
+ readonly sourceInboxId: string;
489
+ readonly turn: number;
490
+ }
491
+ /** Content-free owner identity for a currently bound Agent outside prompt assembly. */
492
+ export interface DeliveryPreferencePrincipalAttestation {
493
+ readonly scope: Readonly<{
494
+ workspace: string;
495
+ preset: string;
496
+ }>;
497
+ readonly principalId: string;
498
+ readonly principalLineage: Readonly<DeliveryOwnerLineage>;
499
+ readonly bindingId: string;
500
+ readonly bindingVersion: number;
501
+ readonly bindingGeneration: number;
502
+ readonly sessionId: string;
503
+ }
504
+ /** Host-only authority query used to mint an exact approval route for Preference promotion. */
505
+ export interface OwnerApprovalForPreferenceInput {
506
+ readonly sourceId: string;
507
+ readonly scope: Readonly<{
508
+ workspace: string;
509
+ preset: string;
510
+ }>;
511
+ readonly principalId: string;
512
+ readonly principalLineage: Readonly<DeliveryOwnerLineage>;
513
+ readonly ownerGeneration: number;
514
+ }
515
+ export type OwnerApprovalForPreferenceResult = ApprovalDispatchRouteV2 | Readonly<{
516
+ kind: 'stale-owner';
517
+ }>;
518
+ /** Structural Host contract consumed by Preference without a reverse package dependency. */
519
+ export interface DeliveryPreferenceProducer {
520
+ trustedPreferenceProducerGeneration(): string;
521
+ registerTrustedPreferenceSink(registration: Readonly<DeliveryPreferenceRegistration>): () => void;
522
+ currentPreferenceTurn(agent: Agent): Readonly<DeliveryPreferenceTurnAttestation> | undefined;
523
+ preferencePrincipalForAgent(agent: Agent): Readonly<DeliveryPreferencePrincipalAttestation> | undefined;
524
+ prepareOwnerApprovalForPreference(input: Readonly<OwnerApprovalForPreferenceInput>): OwnerApprovalForPreferenceResult;
525
+ }
526
+ export type AttachmentResourceType = 'audio' | 'file' | 'image' | 'sticker' | 'video';
527
+ export interface InboundAttachmentDescriptor {
528
+ resourceType: AttachmentResourceType;
529
+ providerRef: string;
530
+ fileName?: string;
531
+ mediaType?: string;
532
+ sizeBytes?: number;
533
+ }
534
+ export interface DeliveryAttachment {
535
+ id: string;
536
+ ownerKind: 'inbox' | 'outbox';
537
+ ownerId: string;
538
+ resourceType: AttachmentResourceType;
539
+ providerRef: string;
540
+ fileName?: string;
541
+ mediaType?: string;
542
+ sizeBytes?: number;
543
+ contentSha256?: string;
544
+ /** Complete durable image reference; `spool_ref` is only its private JSON persistence slot. */
545
+ imageRef?: ImageAttachmentRef;
546
+ status: 'expired' | 'metadata' | 'quarantined' | 'ready';
547
+ expiresAt?: number;
548
+ createdAt: number;
549
+ }
550
+ export type InboxStatus = 'authorized' | 'claimed' | 'dead_letter' | 'processed' | 'queued' | 'received' | 'retry_wait';
551
+ export interface InboxRecord {
552
+ id: string;
553
+ channel: string;
554
+ account: string;
555
+ eventId: string;
556
+ envelope: InboundEnvelope;
557
+ envelopeHash: string;
558
+ status: InboxStatus;
559
+ bindingId?: string;
560
+ attemptCount: number;
561
+ nextAttemptAt?: number;
562
+ claimedBy?: string;
563
+ fencingToken?: number;
564
+ leaseUntil?: number;
565
+ failureCode?: string;
566
+ admissionCursor: Readonly<DeliveryAdmissionCursor>;
567
+ receivedAt: number;
568
+ updatedAt: number;
569
+ }
570
+ export interface OutboundIntent {
571
+ idempotencyKey: string;
572
+ bindingId: string;
573
+ target: DeliveryTarget;
574
+ text: string;
575
+ format?: OutboundFormat;
576
+ approval?: ApprovalIntent;
577
+ modelPicker?: ModelPickerIntent;
578
+ permissionPicker?: PermissionPickerIntent;
579
+ replyToEventId?: string;
580
+ metadata?: Readonly<Record<string, string>>;
581
+ /**
582
+ * WP19 stage 2b: the full text of an over-cap notice. Only on `plain`
583
+ * intents; the coordinator never sends it to an adapter that does not
584
+ * declare `capabilities.textAttachments`.
585
+ */
586
+ attachment?: OutboundTextAttachment;
587
+ }
588
+ /** One UTF-8 text attachment; `sha256` is the hex digest of `text`. */
589
+ export interface OutboundTextAttachment {
590
+ kind: 'text';
591
+ name: string;
592
+ mediaType: 'text/plain' | 'text/markdown';
593
+ text: string;
594
+ sha256: string;
595
+ }
596
+ export type OutboundFormat = 'approval' | 'markdown' | 'model-picker' | 'permission-picker' | 'plain';
597
+ export interface ApprovalIntent {
598
+ operationId: string;
599
+ proposalId: string;
600
+ expectedVersion: number;
601
+ expiresAt: number;
602
+ title: string;
603
+ diffHash: string;
604
+ }
605
+ export type PermissionPickerLevel = 'ask' | 'auto' | 'full' | 'custom';
606
+ /** The exact permission state and binding snapshot represented by one durable picker card. */
607
+ export interface PermissionPickerIntent {
608
+ operationId: string;
609
+ issuedAt: number;
610
+ expiresAt: number;
611
+ current: PermissionPickerLevel;
612
+ expectedStateHash: string;
613
+ /** AssistantPolicy emergency-stop revision observed when the card was issued. */
614
+ emergencyStopVersion: number;
615
+ bindingVersion: number;
616
+ sessionId: string;
617
+ }
618
+ export interface ModelPickerIntent {
619
+ operationId: string;
620
+ expiresAt: number;
621
+ current: ModelRouteRef;
622
+ providers: readonly ModelPickerProvider[];
623
+ models: readonly ModelPickerModel[];
624
+ efforts: readonly ModelPickerEffort[];
625
+ }
626
+ export interface ModelPickerProvider {
627
+ id: string;
628
+ name: string;
629
+ }
630
+ export interface ModelPickerModel {
631
+ provider: string;
632
+ id: string;
633
+ name: string;
634
+ effortIds: readonly string[];
635
+ }
636
+ export interface ModelPickerEffort {
637
+ id: string;
638
+ name: string;
639
+ }
640
+ export type ModelSelectionRejectionReason = 'authorization-revoked' | 'invalid-effort' | 'model-unavailable' | 'provider-model-mismatch' | 'provider-unavailable' | 'selection-superseded';
641
+ export type ModelSelectionResult = {
642
+ status: 'pending';
643
+ } | {
644
+ status: 'rejected';
645
+ reason: ModelSelectionRejectionReason;
646
+ } | {
647
+ status: 'selected';
648
+ selection: ModelRouteRef;
649
+ };
650
+ export type ModelSelectionTerminalResult = Exclude<ModelSelectionResult, {
651
+ status: 'pending';
652
+ }>;
653
+ /** Exact, replay-safe identity for one durable model-picker confirmation. */
654
+ export interface ModelSelectionSettlementInput {
655
+ operationId: string;
656
+ callbackEventId: string;
657
+ callbackChatId: string;
658
+ cardMessageId: string;
659
+ bindingId: string;
660
+ principal: ExternalPrincipalKey;
661
+ provider: string;
662
+ modelProvider: string;
663
+ model: string;
664
+ reasoningEffort?: string;
665
+ expectedRevision: number;
666
+ }
667
+ export type OutboxStatus = 'accepted' | 'attempting' | 'dead' | 'delivered' | 'pending' | 'read' | 'retry_wait' | 'unknown_after_send';
668
+ export interface OutboxRecord {
669
+ id: string;
670
+ intent: OutboundIntent;
671
+ intentHash: string;
672
+ status: OutboxStatus;
673
+ providerMessageId?: string;
674
+ attemptCount: number;
675
+ nextAttemptAt?: number;
676
+ claimedBy?: string;
677
+ fencingToken?: number;
678
+ leaseUntil?: number;
679
+ failureCode?: string;
680
+ createdAt: number;
681
+ updatedAt: number;
682
+ }
683
+ /** Durable authority sidecar for one typed scheduled whole-goal result. */
684
+ export interface DeliveryGoalOutcomeTarget {
685
+ readonly outboxId: string;
686
+ readonly locator: Readonly<OwnerGoalOutcomeFeedbackLocator>;
687
+ readonly proof: Readonly<OwnerGoalOutcomeFeedbackProof>;
688
+ }
689
+ export type DeadLetterResolutionKind = 'inbox' | 'outbox';
690
+ export type DeadLetterResolutionStatus = 'dead' | 'dead_letter' | 'unknown_after_send';
691
+ /**
692
+ * Immutable operator-resolution receipt for one exact terminal attempt.
693
+ *
694
+ * A retry receipt only resolves the referenced attempt. If a later attempt
695
+ * fails, its larger attemptCount has no receipt and is actionable again.
696
+ */
697
+ export interface DeadLetterResolutionReceipt {
698
+ receiptVersion: 1;
699
+ kind: DeadLetterResolutionKind;
700
+ id: string;
701
+ attemptCount: number;
702
+ resolution: 'cancel' | 'retry';
703
+ originalStatus: DeadLetterResolutionStatus;
704
+ originalFailureCode?: string;
705
+ operatorId: string;
706
+ createdAt: number;
707
+ }
708
+ export interface DeadLetterResolutionResult<T extends InboxRecord | OutboxRecord> {
709
+ record: T;
710
+ receipt: DeadLetterResolutionReceipt;
711
+ /** True when the exact same operator decision was already durably committed. */
712
+ replayed: boolean;
713
+ }
714
+ export type ReceiptStatus = 'accepted' | 'delivered' | 'read';
715
+ export interface DeliveryReceipt {
716
+ channel: string;
717
+ account: string;
718
+ providerMessageId: string;
719
+ status: ReceiptStatus;
720
+ occurredAt: number;
721
+ metadata?: Readonly<Record<string, string>>;
722
+ }
723
+ export type AdapterSendResult = {
724
+ outcome: 'accepted';
725
+ providerMessageId: string;
726
+ } | {
727
+ outcome: 'not-sent';
728
+ failureCode: string;
729
+ retryable: boolean;
730
+ retryAfterMs?: number;
731
+ } | {
732
+ outcome: 'unknown';
733
+ failureCode: string;
734
+ providerMessageId?: string;
735
+ };
736
+ export type AdapterReconcileResult = {
737
+ outcome: 'accepted' | 'delivered' | 'read';
738
+ providerMessageId: string;
739
+ } | {
740
+ outcome: 'not-sent';
741
+ } | {
742
+ outcome: 'unknown';
743
+ };
744
+ /**
745
+ * Domain-authoritative terminal state for an owner approval card.
746
+ *
747
+ * Policy `approved` is only a decision. This receipt is emitted by the domain
748
+ * after its own atomic settlement and is therefore the only state that may be
749
+ * rendered as an applied change.
750
+ */
751
+ export interface ApprovalApplicationPresentation {
752
+ kind: 'approval-application';
753
+ policyProposalId: string;
754
+ localProposalId: string;
755
+ applicationStatus: 'applied' | 'conflicted' | 'expired' | 'rejected';
756
+ operation: 'adopt' | 'owner-undo' | 'retire';
757
+ terminalAt: number;
758
+ receiptDigest: string;
759
+ ruleId?: string;
760
+ resultingRuleVersion?: number;
761
+ ruleStatus?: 'active' | 'retired';
762
+ }
763
+ /** Mutable projection of one Automation incident generation onto one provider message. */
764
+ export interface AutomationIncidentPresentation {
765
+ kind: 'automation-incident';
766
+ incidentId: string;
767
+ automationId: string;
768
+ definitionHash: string;
769
+ stage: 'claim' | 'materialize' | 'terminal';
770
+ state: 'open' | 'recovering' | 'resolved';
771
+ failureClass: 'budget' | 'cancelled' | 'configuration' | 'execution' | 'infrastructure' | 'policy' | 'provider' | 'timeout' | 'unknown';
772
+ failurePhase: string;
773
+ failureCode: string;
774
+ sideEffectState: 'none' | 'possible' | 'unknown';
775
+ retryability: 'after-intervention' | 'safe' | 'unsafe' | 'unknown';
776
+ lifecycleGeneration: number;
777
+ /** Same monotonic value as the enclosing desired-presentation revision. */
778
+ incidentRevision: number;
779
+ openedAt: number;
780
+ updatedAt: number;
781
+ resolvedAt?: number;
782
+ }
783
+ export type DeliveryPresentation = ApprovalApplicationPresentation | AutomationIncidentPresentation;
784
+ export interface DeliveryPresentationUpdate {
785
+ /** Stable producer-owned lifecycle identity. */
786
+ presentationKey: string;
787
+ /** Idempotency identity of the original message that must be replaced. */
788
+ originalOutboxIdempotencyKey: string;
789
+ /** Monotonic desired presentation revision. */
790
+ revision: number;
791
+ presentation: Readonly<DeliveryPresentation>;
792
+ }
793
+ export interface StoredDeliveryPresentation extends DeliveryPresentationUpdate {
794
+ status: 'attempting' | 'dead' | 'pending' | 'presented' | 'retry_wait';
795
+ attemptCount: number;
796
+ presentedRevision: number;
797
+ providerMessageId?: string;
798
+ failureCode?: string;
799
+ createdAt: number;
800
+ updatedAt: number;
801
+ }
802
+ /**
803
+ * Private Host-to-Host protocol for domain-owned presentation projections.
804
+ *
805
+ * The Delivery service mints each registration and owns its `publish` closure.
806
+ * A producer never receives a general Delivery write API: it only receives the
807
+ * one registration bound to its exact live instance and generation.
808
+ */
809
+ export declare const TRUSTED_DELIVERY_PRESENTATION_PRODUCER_PROTOCOL: "assistant-delivery/trusted-presentation-producer/v1";
810
+ /** Process-local ownership proof carried by a Delivery-minted registration. */
811
+ export interface TrustedDeliveryPresentationRegistrationOwner {
812
+ ownsTrustedDeliveryPresentationRegistration(registration: Readonly<TrustedDeliveryPresentationRegistration>): boolean;
813
+ }
814
+ /**
815
+ * One ephemeral, revocable publisher issued by Delivery to a trusted domain
816
+ * producer. It is intentionally not an Agent tool or a durable wire payload.
817
+ */
818
+ export interface TrustedDeliveryPresentationRegistration {
819
+ readonly protocol: typeof TRUSTED_DELIVERY_PRESENTATION_PRODUCER_PROTOCOL;
820
+ readonly producer: 'assistant-automations' | 'assistant-evolution';
821
+ readonly generation: string;
822
+ readonly owner: TrustedDeliveryPresentationRegistrationOwner;
823
+ publish(input: DeliveryPresentationUpdate): StoredDeliveryPresentation;
824
+ }
825
+ /** Structural Host contract implemented by the two authorized producers. */
826
+ export interface TrustedDeliveryPresentationProducer {
827
+ trustedDeliveryPresentationProducerGeneration(): string;
828
+ registerTrustedDeliveryPresentationSink(registration: Readonly<TrustedDeliveryPresentationRegistration>): () => void;
829
+ }
830
+ export interface InboundImageReadInput {
831
+ eventId: string;
832
+ attachment: Readonly<InboundAttachmentDescriptor>;
833
+ maxBytes: number;
834
+ }
835
+ export type AdapterInboundImageReadResult = {
836
+ outcome: 'downloaded';
837
+ data: Uint8Array;
838
+ mediaType: ImageMediaType;
839
+ } | {
840
+ outcome: 'not-downloaded';
841
+ failureCode: string;
842
+ retryable: boolean;
843
+ retryAfterMs?: number;
844
+ };
845
+ /** One open-turn, one-shot tool approval routed to the authenticated conversation owner. */
846
+ export interface DeliveryToolApprovalRequest {
847
+ operationId: string;
848
+ bindingId: string;
849
+ target: DeliveryTarget;
850
+ expiresAt: number;
851
+ /** SHA-256 over the exact session, call identity, tool name, arguments, and permission state. */
852
+ actionHash: string;
853
+ toolName: string;
854
+ /** Exact call identity from the current open Session turn. */
855
+ callId: string;
856
+ /** Bounded, untrusted display text; never interpreted as instructions. */
857
+ reason?: string;
858
+ /** Exact bounded JSON argument text already recorded by the Session. */
859
+ arguments: string;
860
+ }
861
+ export type DeliveryToolApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable';
862
+ /** One live Host question routed to the authenticated Delivery conversation owner. */
863
+ export interface DeliveryUserQuestionRequest {
864
+ /** Opaque id for this exact live waterfall attempt, used to bind channel callbacks. */
865
+ operationId: string;
866
+ bindingId: string;
867
+ bindingVersion: number;
868
+ bindingGeneration: number;
869
+ sessionId: string;
870
+ target: DeliveryTarget;
871
+ /** Exact upstream batch. An adapter must answer every item once and in order. */
872
+ questions: readonly AskUserQuestionItem[];
873
+ }
874
+ export type DeliveryUserQuestionOutcome = {
875
+ outcome: 'answered';
876
+ answer: AskUserQuestionAnswer;
877
+ } | {
878
+ outcome: 'cancelled';
879
+ } | {
880
+ outcome: 'unavailable';
881
+ };
882
+ /**
883
+ * Bounded, user-visible execution progress.
884
+ *
885
+ * `step` carries a neutral execution phase, never model reasoning/thinking content. Tool updates
886
+ * carry redacted previews so an adapter can render useful call details for an audience it considers
887
+ * private; adapters must still account for the target conversation before publishing them. Preview
888
+ * strings are presentation-only and are not durable Delivery state.
889
+ *
890
+ * `failed` carries the short failure *code* only. The human-readable provider message may quote the
891
+ * prompt or upstream payloads, so it stays behind this boundary; the code is what makes a failed
892
+ * turn legible instead of leaving the surface stuck on its opening line.
893
+ */
894
+ export type DeliveryProgressUpdate = {
895
+ kind: 'started';
896
+ } | {
897
+ kind: 'step';
898
+ text: string;
899
+ } | {
900
+ kind: 'tool-started';
901
+ callId: string;
902
+ toolName: string;
903
+ argumentsPreview?: string;
904
+ } | {
905
+ kind: 'tool-finished';
906
+ callId: string;
907
+ failed: boolean;
908
+ resultPreview?: string;
909
+ code?: string;
910
+ } | {
911
+ kind: 'todos';
912
+ todos: readonly DeliveryProgressTodo[];
913
+ } | {
914
+ kind: 'completed';
915
+ } | {
916
+ kind: 'paused';
917
+ } | {
918
+ kind: 'failed';
919
+ code?: string;
920
+ };
921
+ export interface DeliveryProgressTodo {
922
+ content: string;
923
+ status: 'pending' | 'in_progress' | 'completed';
924
+ }
925
+ /**
926
+ * Which execution produced a progress update (WP19 stage 2c).
927
+ *
928
+ * `foreground` is the owner's claimed inbound turn (and its automatic answer
929
+ * completion turns) plus Delivery's own lifecycle updates (`started` and the
930
+ * terminal). `background` is any other turn observed while the inbound run is
931
+ * attached to the session, chiefly native Goal continuation rounds and turns
932
+ * that were already running before the inbound message was claimed.
933
+ */
934
+ export type DeliveryProgressOrigin = 'foreground' | 'background';
935
+ /** One presentation-only progress update, correlated to a durable inbound message and binding. */
936
+ export interface DeliveryProgressIntent {
937
+ bindingId: string;
938
+ target: DeliveryTarget;
939
+ eventId: string;
940
+ update: DeliveryProgressUpdate;
941
+ /**
942
+ * Absent means `foreground` (pre-2c callers). Adapters should hide
943
+ * non-terminal `background` updates from the owner unless explicitly opted in,
944
+ * and must not open a new progress surface for one.
945
+ */
946
+ origin?: DeliveryProgressOrigin;
947
+ }
948
+ /** Opaque provider handle and minimal state needed to close an existing progress surface. */
949
+ export interface DeliveryProgressRecord {
950
+ bindingId: string;
951
+ eventId: string;
952
+ target: DeliveryTarget;
953
+ providerHandle?: string;
954
+ sequence: number;
955
+ step: number;
956
+ showDetails: boolean;
957
+ state: 'creating' | 'active' | 'pending' | 'delivered';
958
+ terminal?: Extract<DeliveryProgressUpdate, {
959
+ kind: 'completed' | 'failed' | 'paused';
960
+ }>;
961
+ }
962
+ /**
963
+ * Delivery owns this journal. An adapter must never use it to repeat the original task or create
964
+ * a second provider progress message after a create request may have reached the provider.
965
+ */
966
+ export interface DeliveryProgressJournal {
967
+ begin(intent: DeliveryProgressIntent, credentialFingerprint: string, sequence: number, showDetails: boolean): Promise<{
968
+ record: DeliveryProgressRecord;
969
+ created: boolean;
970
+ } | undefined>;
971
+ get(intent: DeliveryProgressIntent, credentialFingerprint: string): Promise<DeliveryProgressRecord | undefined>;
972
+ created(intent: DeliveryProgressIntent, credentialFingerprint: string, providerHandle: string): Promise<DeliveryProgressRecord | undefined>;
973
+ advance(intent: DeliveryProgressIntent, credentialFingerprint: string): Promise<DeliveryProgressRecord | undefined>;
974
+ stageTerminal(intent: DeliveryProgressIntent, credentialFingerprint: string): Promise<DeliveryProgressRecord | undefined>;
975
+ delivered(intent: DeliveryProgressIntent, credentialFingerprint: string): Promise<void>;
976
+ recover(channel: string, account: string, credentialFingerprint: string, limit: number): Promise<readonly DeliveryProgressRecord[]>;
977
+ }
978
+ /**
979
+ * Metadata-only report of one inbound message an adapter saw, whether it was
980
+ * then accepted or dropped by the adapter's own gate (WP20 intake).
981
+ * `contentDigest` is the adapter's sha256 of normalized text. The optional
982
+ * `text` is that normalized text, held in memory only: Delivery never stores
983
+ * it and forwards it only to an observer that set `acceptsSourceText`, and
984
+ * only when it hashes to `contentDigest`.
985
+ */
986
+ export interface DeliveryInboundObservation {
987
+ readonly eventId: string;
988
+ readonly occurredAt: number;
989
+ readonly principal: Readonly<ExternalPrincipalKey>;
990
+ readonly conversation: Readonly<{
991
+ kind: ConversationKind;
992
+ chat: string;
993
+ }>;
994
+ /** Direct message, explicit bot mention, or an accepted command. */
995
+ readonly addressed: boolean;
996
+ readonly senderIsBot: boolean;
997
+ readonly replyToProviderMessageId?: string;
998
+ readonly contentDigest?: string;
999
+ readonly text?: string;
1000
+ }
1001
+ /** Normalized intake signal handed to the registered observer; mirrors the WorkItems intake input. */
1002
+ export interface DeliveryInboundIntakeSignal {
1003
+ readonly source: string;
1004
+ readonly sourceEventId: string;
1005
+ readonly kind: 'message';
1006
+ readonly senderAllowlisted: boolean;
1007
+ readonly addressed: boolean;
1008
+ readonly threadFollowUp: boolean;
1009
+ readonly senderIsBot: boolean;
1010
+ readonly groupMessage: boolean;
1011
+ readonly contentDigest?: string;
1012
+ /** Transient authenticated text; present only for an opted-in observer and a matching `contentDigest`. */
1013
+ readonly sourceText?: string;
1014
+ readonly occurredAt: number;
1015
+ }
1016
+ /**
1017
+ * The single inbound intake observer. Ownership is fenced by object identity
1018
+ * (WorkItems `ownsInboundIntakeObserver`), so it is an object, not a bare
1019
+ * function that a service proxy could re-wrap.
1020
+ */
1021
+ export interface DeliveryInboundIntakeObserver {
1022
+ readonly protocol: 1;
1023
+ readonly observe: (signal: Readonly<DeliveryInboundIntakeSignal>) => void;
1024
+ /** Opt in to the transient `sourceText` (WP20 inferred evaluation); omitted means metadata only. */
1025
+ readonly acceptsSourceText?: true;
1026
+ }
1027
+ export interface DeliveryAdapterContext {
1028
+ accept(envelope: InboundEnvelope): Promise<{
1029
+ duplicate: boolean;
1030
+ inboxId: string;
1031
+ status: InboxStatus;
1032
+ }>;
1033
+ /**
1034
+ * Optional, synchronous and best-effort: never throws, never changes
1035
+ * acceptance, and is a no-op unless an intake observer is registered.
1036
+ */
1037
+ observe?(observation: Readonly<DeliveryInboundObservation>): void;
1038
+ receipt(receipt: DeliveryReceipt): Promise<void>;
1039
+ progressJournal?: DeliveryProgressJournal;
1040
+ }
1041
+ export interface DeliveryAdapter {
1042
+ readonly channel: string;
1043
+ readonly account: string;
1044
+ readonly capabilities: Readonly<{
1045
+ reconcileUnknownSend: boolean;
1046
+ receipts: readonly ReceiptStatus[];
1047
+ /**
1048
+ * How complete this adapter's read receipts are. 'complete' is the only
1049
+ * value that lets Evaluation distinguish "missed" from an event gap;
1050
+ * absent/none/best-effort keep the legacy expired-unhandled classification.
1051
+ */
1052
+ readReceipts?: 'none' | 'best-effort' | 'complete';
1053
+ formats: readonly OutboundFormat[];
1054
+ inboundImages?: boolean;
1055
+ toolApprovals?: boolean;
1056
+ userQuestions?: boolean;
1057
+ /** Sends `OutboundIntent.attachment` as one file alongside the inline text (WP19 stage 2b). */
1058
+ textAttachments?: boolean;
1059
+ }>;
1060
+ start(context: DeliveryAdapterContext): Promise<void | (() => void | Promise<void>)>;
1061
+ readInboundImage?(input: Readonly<InboundImageReadInput>, signal: AbortSignal): Promise<AdapterInboundImageReadResult>;
1062
+ /** Open-turn and deliberately non-durable; abort/restart/disconnect always fail closed. */
1063
+ requestToolApproval?(input: Readonly<DeliveryToolApprovalRequest>, signal: AbortSignal): Promise<DeliveryToolApprovalOutcome>;
1064
+ /** Live and deliberately non-durable; Delivery participates as a user-question waterfall answerer. */
1065
+ requestUserQuestion?(input: Readonly<DeliveryUserQuestionRequest>, signal: AbortSignal): Promise<DeliveryUserQuestionOutcome>;
1066
+ /** Best-effort UI only; implementations must not treat it as task state or a durable reply. */
1067
+ progress?(intent: Readonly<DeliveryProgressIntent>): Promise<void>;
1068
+ /** Replace one exact bot-authored durable message with a domain terminal projection. */
1069
+ updatePresentation?(providerMessageId: string, presentation: Readonly<DeliveryPresentation>, signal: AbortSignal): Promise<void>;
1070
+ send(intent: Readonly<OutboundIntent>, signal: AbortSignal): Promise<AdapterSendResult>;
1071
+ reconcileUnknownSend?(record: Readonly<OutboxRecord>, signal: AbortSignal): Promise<AdapterReconcileResult>;
1072
+ }
1073
+ export interface PairingChallenge {
1074
+ id: string;
1075
+ principal: ExternalPrincipalKey;
1076
+ expiresAt: number;
1077
+ status: 'active' | 'consumed' | 'expired' | 'locked';
1078
+ attempts: number;
1079
+ createdAt: number;
1080
+ }
1081
+ export interface DeliveryPrincipal {
1082
+ id: string;
1083
+ principal: ExternalPrincipalKey;
1084
+ role: 'linked' | 'owner';
1085
+ status: 'active' | 'revoked';
1086
+ linkedToId?: string;
1087
+ createdAt: number;
1088
+ updatedAt: number;
1089
+ version: number;
1090
+ }
1091
+ //# sourceMappingURL=types.d.ts.map