@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
@@ -0,0 +1,1279 @@
1
+ import { type OwnerWorkItemEngineeringContextLocator, type OwnerWorkItemEngineeringContextExpectation, type OwnerWorkItemEngineeringContextReadInput, type OwnerWorkItemEngineeringContextPage, type OwnerWorkItemEngineeringContext, type OwnerWorkItemEngineeringContextSource } from './work-item-engineering-context.js';
2
+ import type { OwnerWorkItemLearningTask, OwnerLearningSourceExpectation, OwnerLearningSourceSnapshot, OwnerWorkItemLearningTaskFenceInput } from './work-item-feedback.js';
3
+ import { type WorkItemReplySource, type WorkItemReplyConsumerRegistration, type WorkItemReplyReadInput, type WorkItemReplyListInput } from './work-item-replies.js';
4
+ import { Context, Service } from '@deepseek-ai/cordis';
5
+ import type { Agent } from '@deepseek-ai/dsh-agent';
6
+ import type { ToolDefinition, ToolExecution } from '@deepseek-ai/dsh-tools';
7
+ import Schema from '@deepseek-ai/schemastery';
8
+ import { type RestartRecord } from './restart-store.js';
9
+ import { type RestartConfig } from './restart-runtime.js';
10
+ import { type ApprovalDispatchRouteV2, type AssistantPolicyService } from '@dsh-ray/assistant-policy';
11
+ import type { TrustedTaskLearningProjectionReceipt, TrustedDeliveryEvaluationClaims, TrustedDeliveryEvaluationRegistration } from '@dsh-ray/assistant-evaluation';
12
+ import { type GrowthWorkflowTraceSourceRegistration, type ResolvedWorkflowAutomationTemplate, type WorkflowAutomationTemplate, type WorkflowScope, type WorkflowTraceSink } from '@dsh-ray/assistant-growth-contract';
13
+ import { type InboundMessageProcessor } from './coordinator.js';
14
+ import { DeliveryStore, type CommitOwnerAnchoredWorkflowTraceResult } from './store.js';
15
+ import type { OwnerApprovalStatusRead } from './approval-status-context.js';
16
+ import { type NativeWebOwnerConfig, type NativeWebOwnerAccess } from './native-web-owner.js';
17
+ import { type DeliveryGoalWakeInput, type DeliveryGoalWakeResult } from './goal-wake-types.js';
18
+ import type { AcceptanceContract, TaskAcceptanceRegistration } from './acceptance.js';
19
+ import { type InProcessReloadRuntime } from './in-process-reload-runtime.js';
20
+ import { type ForegroundTaskObservationRegistration, type ForegroundToolCallAttestation, type OwnerForegroundToolInput } from './foreground-observation.js';
21
+ import { NOTIFICATION_OUTCOME_FACTS_PROTOCOL, type AttentionAuditEntry, type AttentionEnvelope, type NotificationOutcomeFact } from './attention.js';
22
+ import { type ProgressAttentionAuditPage } from './progress-attention.js';
23
+ import { type AttentionRejectionEntry, type AttentionRejectionPage, type AttentionRejectionReason } from './attention-enforcement.js';
24
+ import { type OwnerSelfIterationAction, type ParsedOwnerVersionQuery } from './session-commands.js';
25
+ import { type AssistantVersionReport } from './version-query.js';
26
+ import { type ReplyReplayBlockConfig, type ReplyReplayBlockHandle } from './reply-replay.js';
27
+ import type { ConversationBinding, DeliveryAdapter, DeadLetterResolutionResult, DeliveryPreferenceRegistration, DeliveryPreferenceProducer, DeliveryPreferencePrincipalAttestation, DeliveryPreferenceTurnAttestation, DeliveryInboundIntakeObserver, ExternalPrincipalKey, InboundEnvelope, InboxRecord, ModelPickerIntent, ModelPickerState, ModelRouteRef, ModelSelectionResult, ModelSelectionSettlementInput, ModelSelectionTerminalResult, OwnerRouteAuthority, OwnerRouteScopeSummary, OwnerForegroundTaskSourceScope, OwnerForegroundTaskSource, OwnerForegroundTaskSourceCursor, OwnerForegroundTaskSourcePage, OwnerForegroundTaskSourceContent, OwnerForegroundTaskInput, OwnerForegroundTaskSourceRef, OwnerApprovalForPreferenceInput, OwnerApprovalForPreferenceResult, OwnerAliasForegroundToolCallAttestation, OwnerAliasReceipt, OwnerRouteStateInspection, OwnerRouteValidationReceipt, OwnerRouteBindingReceipt, OutboxRecord, PairingChallenge, PermissionPickerIntent, ResolvedOwnerRoute, StoredDeliveryPresentation, TrustedDeliveryPresentationRegistration } from './types.js';
28
+ /** A wake finalizes an already-flushed native Web reply, or creates one external outbox intent. */
29
+ export type DeliveryGoalWakeResultPublication = OutboxRecord | Readonly<{
30
+ kind: 'native-session';
31
+ sessionId: string;
32
+ }>;
33
+ /**
34
+ * Process-local authenticity against accidental service-slot collisions. The
35
+ * private symbol is never exported, so copying the public method shape is not
36
+ * enough to solicit a genuine registration. This is not an OS/process sandbox
37
+ * boundary against code already executing inside the trusted Host process.
38
+ */
39
+ export declare function isTrustedDeliveryPreferenceProducer(value: unknown): value is DeliveryPreferenceProducer;
40
+ /** Owner-bound discovery evidence, not permission to execute or adopt a repair. */
41
+ export interface OwnerForegroundLearningTask {
42
+ readonly protocol: 'assistant-delivery/owner-foreground-learning/v1';
43
+ /** Current owner authority with the original task's immutable execution binding. */
44
+ readonly owner: Readonly<OwnerRouteValidationReceipt>;
45
+ readonly canonical: TrustedTaskLearningProjectionReceipt;
46
+ readonly judgement: 'independent-verifier' | 'owner-feedback' | 'unresolved';
47
+ readonly ownerRevision?: Readonly<{
48
+ version: number;
49
+ action: 'initial' | 'correct' | 'withdraw';
50
+ }>;
51
+ readonly feedback?: Readonly<{
52
+ inboxId: string;
53
+ text: string;
54
+ truncated: boolean;
55
+ }>;
56
+ readonly source: Readonly<{
57
+ sessionId: string;
58
+ inboxId: string;
59
+ objective: string;
60
+ truncated: boolean;
61
+ quiescent: boolean;
62
+ modelSelectionState: 'missing' | 'frozen' | 'inconsistent';
63
+ modelSelection?: Readonly<{
64
+ provider: string;
65
+ model: string;
66
+ reasoningEffort?: string;
67
+ }>;
68
+ reply?: Readonly<Pick<OwnerForegroundTaskSourceContent['reply'], 'outboxId' | 'intentDigest' | 'fullTextDigest'> & {
69
+ text: string;
70
+ truncated: boolean;
71
+ redacted: boolean;
72
+ }>;
73
+ }>;
74
+ }
75
+ /**
76
+ * One explicitly allowlisted provider bot. The exact channel/account/tenant/user
77
+ * tuple is the trust anchor; `senderIsBot` only labels the provider's declaration.
78
+ * A peer keeps its own Policy subject and conversation binding, so it never
79
+ * inherits the owner's tools, memory, work-item feedback or continuation lanes.
80
+ */
81
+ export interface PeerAgentAuthority {
82
+ readonly channel: string;
83
+ readonly account: string;
84
+ readonly tenant: string;
85
+ readonly user: string;
86
+ }
87
+ export interface Config {
88
+ databasePath: string;
89
+ spoolPath: string;
90
+ /** Explicit owner-scoped, finite same-code maintenance authority. Disabled when absent. */
91
+ restart?: RestartConfig;
92
+ schedulerEnabled?: boolean;
93
+ tickIntervalMs?: number;
94
+ /** Upper bound for one ordinary foreground task, including silent model/tool waits. */
95
+ agentTaskTimeoutMs?: number;
96
+ leaseMs?: number;
97
+ maxAttempts?: number;
98
+ maxConcurrency?: number;
99
+ maxTextBytes?: number;
100
+ retryBaseMs?: number;
101
+ retryMaxMs?: number;
102
+ pairingTtlMs?: number;
103
+ pairingMaxAttempts?: number;
104
+ defaultWorkspace?: string;
105
+ defaultAgentPreset?: string;
106
+ policyRef?: string;
107
+ agentProvider?: string;
108
+ agentModel?: string;
109
+ agentMaxOutputTokens?: number;
110
+ agentMaxAutoContinuationTurns?: number;
111
+ /** Opt-in foreground wait for an armed native goal round driver. Zero disables it. */
112
+ agentGoalContinuationTimeoutMs?: number;
113
+ modelPickerTtlMs?: number;
114
+ permissionPickerTtlMs?: number;
115
+ toolApprovalTtlMs?: number;
116
+ /** Bound durability preparation separately from the time given to the human. */
117
+ toolApprovalPreparationTimeoutMs?: number;
118
+ /** Host-owned stable routes. They are never exposed as Agent tools or prompt input. */
119
+ ownerRoutes?: readonly OwnerRouteAuthority[];
120
+ /**
121
+ * WP19 stage 2b (default on): over-cap background/owner notices are
122
+ * queued as a short body plus a text attachment, and a burst of inline
123
+ * notices that together exceed the cap is rejected as split evasion.
124
+ */
125
+ attentionAttachOverCap?: boolean;
126
+ /**
127
+ * WP19 stage 3 (default on): background/owner notices whose purpose
128
+ * is missing or fails the Host checks are rejected before they are queued,
129
+ * as are over-cap notices unless `attentionAttachOverCap` attaches them.
130
+ */
131
+ attentionEnforce?: boolean;
132
+ /**
133
+ * Default on: `routeWorkItemReport` keeps a report on the route of
134
+ * the same item's earlier still-unsettled report, so one lane orders both.
135
+ */
136
+ ownerReportRouting?: {
137
+ orderAcrossLanes?: boolean;
138
+ };
139
+ /**
140
+ * Default on: widen the deterministic grammar for authenticated
141
+ * owner replies to one exact result. Explicit `false` preserves the legacy
142
+ * exact-phrase parser and its admission fences.
143
+ * - `coverage`: accept synonym/multilingual result assertions plus an
144
+ * untrusted trailing reason/evidence clause. Questions, hypotheticals,
145
+ * quoted prose, negated reports, contradictions, hedges and withdrawal
146
+ * commands still abstain.
147
+ * - `mixedIntent`: when one authenticated work-item report reply carries a
148
+ * result assertion and an explicit continuation request, record the
149
+ * canonical result and admit the continuation as two independent decisions
150
+ * (each with its own permission, idempotency, budget fence and target). If
151
+ * one lane is not permitted the other still proceeds and the partial
152
+ * admission is recorded. Ignored unless `coverage` is also on.
153
+ */
154
+ naturalFeedback?: {
155
+ coverage?: boolean;
156
+ mixedIntent?: boolean;
157
+ };
158
+ /**
159
+ * Host-side Cordis in-process reload runtime registration (default on).
160
+ * Set `inProcessReload: { enabled: false }` to opt out. When `profilePath` is
161
+ * omitted, the runtime resolves it dynamically from the mounted Cordis `include` root.
162
+ */
163
+ inProcessReload?: InProcessReloadServiceConfig;
164
+ /**
165
+ * Opt-in peer-agent allowlist (default empty). A group message whose provider
166
+ * envelope carries `senderIsBot=true` and whose exact principal tuple is
167
+ * listed here is admitted into its own linked-principal lane. The peer keeps a
168
+ * distinct Policy subject and never inherits owner tools, memory, work-item
169
+ * feedback or continuation lanes. No peer is trusted by default.
170
+ */
171
+ peerAgents?: readonly PeerAgentAuthority[];
172
+ }
173
+ export interface InProcessReloadServiceConfig {
174
+ enabled?: boolean;
175
+ profilePath?: string;
176
+ entryId?: string;
177
+ package?: string;
178
+ stagingDir?: string;
179
+ hostGeneration?: number;
180
+ timeoutMs?: number;
181
+ }
182
+ export interface DeliveryInboundRuntime extends InboundMessageProcessor {
183
+ canRequestRestart?(agent: Agent): boolean;
184
+ requestRestart?(agent: Agent, reason: string): {
185
+ id: string;
186
+ status: string;
187
+ };
188
+ resumeRestart?(record: RestartRecord, binding: Readonly<ConversationBinding>, envelope: Readonly<InboundEnvelope>, signal: AbortSignal): Promise<unknown>;
189
+ createSession(input: {
190
+ envelope: Readonly<InboundEnvelope>;
191
+ generation: number;
192
+ previous?: Readonly<ConversationBinding>;
193
+ signal: AbortSignal;
194
+ }): Promise<{
195
+ sessionId: string;
196
+ workspace: string;
197
+ agentPreset: string;
198
+ policyRef: string;
199
+ }>;
200
+ /** Immediate, process-local control path; it must never wait behind the binding's Inbox lane. */
201
+ cancelActive?(binding: Readonly<ConversationBinding>, cause: 'new' | 'stop'): boolean | Promise<boolean>;
202
+ }
203
+ export type AssistantDeliveryErrorCode = 'disposed' | 'missing-binding' | 'policy-denied' | 'runtime-conflict' | 'runtime-unavailable';
204
+ /**
205
+ * Send-time withdrawal check for owner notices queued with `withdrawable`.
206
+ * `isWithdrawn` must be synchronous, side-effect free and keyed only by the
207
+ * notice's idempotency key. A withdrawable notice is never sent while no
208
+ * check is registered for its authority and source, or while the check
209
+ * throws; it is withdrawn (dead, never sent) once the check returns true.
210
+ *
211
+ * `authority` names the Cordis service slot that owns the check. Delivery
212
+ * accepts the registration only when the service currently in that slot
213
+ * vouches for this exact object through `ownsOwnerNotificationWithdrawal`
214
+ * (the same slot-anchored ownership proof the task-acceptance sink uses), so
215
+ * a plugin that does not occupy the slot cannot register for it.
216
+ */
217
+ export interface OwnerNotificationWithdrawal {
218
+ readonly protocol: typeof ownerNotificationWithdrawalProtocol;
219
+ readonly authority: string;
220
+ readonly sourceId: string;
221
+ isWithdrawn(idempotencyKey: string): boolean;
222
+ }
223
+ export declare const ownerNotificationWithdrawalProtocol: "assistant-delivery/owner-notification-withdrawal/v1";
224
+ /**
225
+ * Live registration returned to the owner. `handle` is an unguessable
226
+ * process-local capability: enqueueing a `withdrawable` notice and inspecting
227
+ * notices both require it. Notices are bound to the stable
228
+ * (authority, source) pair, not to the handle, so a restart or a later
229
+ * registration by the same authority takes over notices already queued.
230
+ */
231
+ export interface OwnerNotificationWithdrawalBinding {
232
+ readonly handle: string;
233
+ unregister(): void;
234
+ }
235
+ /** Read-only view of an owner notice found by its idempotency key; carries no text. */
236
+ export interface OwnerNotificationRecordView {
237
+ readonly outboxId: string;
238
+ readonly status: OutboxRecord['status'];
239
+ }
240
+ export declare const ownerNotificationReplyProtocol: "assistant-delivery/owner-notification-reply/v1";
241
+ /**
242
+ * Slice 5: authenticated owner reply handed to the consumer registered for
243
+ * the owner-notice source that produced the quoted message. Delivery has
244
+ * already matched the unique accepted/delivered/read Outbox by provider
245
+ * message id, the notice source, its authority, the frozen owner lineage,
246
+ * the registration's idempotency-key prefix and an `allow` Policy decision.
247
+ */
248
+ export interface OwnerNotificationReplyInput {
249
+ readonly inboxId: string;
250
+ readonly envelopeHash: string;
251
+ readonly outboxId: string;
252
+ readonly providerMessageId: string;
253
+ readonly idempotencyKey: string;
254
+ readonly sourceId: string;
255
+ readonly principalId: string;
256
+ readonly text: string;
257
+ readonly receivedAt: number;
258
+ }
259
+ /**
260
+ * `applied`: the consumer durably applied the reply; Delivery marks the Inbox
261
+ * processed. `ignored`: fall through to ordinary inbound handling. `transient`:
262
+ * the Inbox stays pending so the same reply is retried on provider redelivery
263
+ * or the next pending-inbound recovery.
264
+ */
265
+ export type OwnerNotificationReplyOutcome = 'applied' | 'ignored' | 'transient';
266
+ export interface OwnerNotificationReply {
267
+ readonly protocol: typeof ownerNotificationReplyProtocol;
268
+ /** Cordis slot that owns the consumer; Delivery vouches the exact object there. */
269
+ readonly authority: string;
270
+ readonly sourceId: string;
271
+ /** Only notices whose idempotency key starts with this prefix are matched. */
272
+ readonly idempotencyKeyPrefix: string;
273
+ consume(input: Readonly<OwnerNotificationReplyInput>): OwnerNotificationReplyOutcome;
274
+ }
275
+ export interface OwnerNotificationReplyBinding {
276
+ unregister(): void;
277
+ }
278
+ export declare class AssistantDeliveryError extends Error {
279
+ readonly code: AssistantDeliveryErrorCode;
280
+ constructor(code: AssistantDeliveryErrorCode, message: string);
281
+ }
282
+ /** WP19 stage 3 rejection: `policy-denied` with structured reason codes; nothing was queued. */
283
+ export declare class AttentionRejectedError extends AssistantDeliveryError {
284
+ readonly rejection: Readonly<AttentionRejectionEntry>;
285
+ readonly reasons: readonly AttentionRejectionReason[];
286
+ constructor(rejection: Readonly<AttentionRejectionEntry>, message?: string);
287
+ }
288
+ /**
289
+ * Structural mirrors of the Goals Host-only evidence shapes. Delivery must not
290
+ * import `@dsh-ray/assistant-goals` types for this seam: goals' public
291
+ * type surface re-exports Delivery types (its types.ts re-exports from
292
+ * `@dsh-ray/assistant-delivery`), which pulls Delivery's own emitted
293
+ * lib/*.d.ts back into its build program and fails emit (TS5055). The local
294
+ * goal-wake-types.ts mirror sets the precedent. These are structural only:
295
+ * the live Goals service is obtained through ctx.get and runtime-checked, and
296
+ * Delivery re-fetches every trusted value itself.
297
+ */
298
+ interface GoalScope {
299
+ principalId: string;
300
+ principalRecordId: string;
301
+ principalVersion: number;
302
+ workspace: string;
303
+ preset: string;
304
+ }
305
+ /** Structural mirror of goals' OwnerGoalExecutionSnapshotInput (six keys). */
306
+ interface OwnerGoalExecutionSnapshotInput {
307
+ ownerRouteId: string;
308
+ principalId: string;
309
+ workspace: string;
310
+ preset: string;
311
+ sessionId: string;
312
+ goalId: string;
313
+ }
314
+ /**
315
+ * Structural authority minted by the growth driver for one bounded wake.
316
+ * Delivery never mints it: the object is only accepted after assertCurrent()
317
+ * re-anchors the live owner route, and its scope must exactly match the
318
+ * locator the driver asked to learn from.
319
+ */
320
+ export interface OwnerAnchoredWorkflowAuthority {
321
+ readonly id: string;
322
+ readonly scope: Readonly<GoalScope>;
323
+ readonly ownerRouteId: string;
324
+ readonly expiresAt: number;
325
+ assertCurrent(): void;
326
+ }
327
+ /** Result of one Host-only owner-anchored learning commit. */
328
+ export type CommitOwnerAnchoredWorkflowTraceServiceResult = CommitOwnerAnchoredWorkflowTraceResult;
329
+ export interface OwnerSelfIterationControlRequest {
330
+ readonly action: OwnerSelfIterationAction;
331
+ readonly sourceText: string;
332
+ readonly bindingId: string;
333
+ readonly principalId: string;
334
+ readonly workspace: string;
335
+ readonly agentPreset: string;
336
+ readonly eventId: string;
337
+ }
338
+ export interface OwnerSelfIterationControlResult {
339
+ readonly ok: boolean;
340
+ readonly state?: 'enabled' | 'disabled' | 'upgraded';
341
+ readonly message?: string;
342
+ readonly error?: string;
343
+ readonly reason?: string;
344
+ }
345
+ export type OwnerSelfIterationControlHandler = (request: Readonly<OwnerSelfIterationControlRequest>) => Promise<OwnerSelfIterationControlResult>;
346
+ declare module '@deepseek-ai/cordis' {
347
+ interface Context {
348
+ assistantDelivery: AssistantDeliveryService;
349
+ inProcessReload?: InProcessReloadRuntime;
350
+ }
351
+ }
352
+ interface ApprovalSettlementInput {
353
+ operationId: string;
354
+ callbackEventId: string;
355
+ callbackChatId: string;
356
+ bindingId: string;
357
+ principal: ExternalPrincipalKey;
358
+ proposalId: string;
359
+ expectedVersion: number;
360
+ diffHash: string;
361
+ decision: 'approved' | 'rejected';
362
+ reason: string;
363
+ }
364
+ /**
365
+ * Host-native tool arguments normalized exactly as Delivery attests them:
366
+ * JSON.parse then JSON.stringify, preserving key order and rejecting any
367
+ * non-object payload. Other components must hash this exact text instead of
368
+ * re-canonicalizing it, otherwise a foreground witness cannot be matched.
369
+ */
370
+ export declare function normalizeForegroundToolArguments(raw: string): string | undefined;
371
+ export declare class AssistantDeliveryService extends Service {
372
+ #private;
373
+ static Config: Schema<Config>;
374
+ private readonly deliveryStore;
375
+ private readonly restartStore;
376
+ private readonly restartInvocationId;
377
+ private restartCodeDigest;
378
+ private restartNoticeCursor;
379
+ private restartFlight;
380
+ private readonly restartController;
381
+ private readonly restartSafeDefinitions;
382
+ private readonly context;
383
+ private readonly policy;
384
+ private readonly registry;
385
+ private readonly outbound;
386
+ private readonly inbound;
387
+ private readonly config;
388
+ private readonly ownerRoutes;
389
+ private readonly ownerRouteGuard;
390
+ private nativeWebBound;
391
+ private nativeWebOwner;
392
+ private nativeWebNoticeAdapter;
393
+ private nativeWebRuntime;
394
+ private readonly ownerId;
395
+ private readonly bindingFlights;
396
+ private readonly conversationTransitions;
397
+ private readonly agentApprovalBindings;
398
+ private readonly toolApprovalControllers;
399
+ private readonly drainingUserQuestionAdapters;
400
+ private readonly userQuestionAttempts;
401
+ private readonly modelSelectionWaiters;
402
+ private preferenceFeedbackSink;
403
+ private evaluationSink;
404
+ private workflowTraceSink;
405
+ private automationPresentationBinding;
406
+ private evolutionPresentationBinding;
407
+ private readonly activePresentationRegistrations;
408
+ private readonly evaluationProducerGeneration;
409
+ private readonly preferenceProducerGeneration;
410
+ private readonly acceptanceProducerGeneration;
411
+ private acceptanceSink;
412
+ private workItemReplyConsumer;
413
+ private inboundIntakeObserver;
414
+ private ownerSelfIterationHandler;
415
+ private readonly foregroundTaskCompletionListeners;
416
+ /** Send-time withdrawal checks for `withdrawable` owner notices, one per (authority, canonical source id). */
417
+ private readonly ownerNotificationWithdrawals;
418
+ /** Live handles issued by `registerOwnerNotificationWithdrawal`, mapped to their (authority, source) key. */
419
+ private readonly ownerNotificationWithdrawalHandles;
420
+ /** Slice-5 reply consumers, one per (authority, canonical owner-notice source id). */
421
+ private readonly ownerNotificationReplies;
422
+ private foregroundObserver;
423
+ /** Once a live verifier required acceptance, loss of that verifier must not silently bypass it. */
424
+ private acceptanceRequired;
425
+ private readonly preferenceTurns;
426
+ /** Claimed human turns of linked owner aliases; read-only alias inspection only. */
427
+ private readonly aliasTurns;
428
+ private readonly goalWakeResults;
429
+ private tickFlight;
430
+ private modelSelectionFlight;
431
+ private presentationFlight;
432
+ private workflowTraceFlight;
433
+ private workItemFeedbackFlight;
434
+ private workItemFeedbackCursor;
435
+ private workItemFeedbackAckCursor;
436
+ /** WP19 stage 1: audit writes never affect delivery; failures are counted in this process only (reset on restart). */
437
+ private attentionAuditWriteFailures;
438
+ /** WP19 stage 2c: process-local progress attention audit (no Delivery schema change). */
439
+ private readonly progressAttentionAudit;
440
+ private progressAttentionAuditFailures;
441
+ /** WP19 stage 3: process-local rejection log (rejected notices have no Outbox row). */
442
+ private readonly attentionRejections;
443
+ private naturalObjectiveFlight;
444
+ private preferenceProjectionFlight;
445
+ private inboundAdmissionRecoveryFlight;
446
+ private inboundAdmissionRecoveryAfterSequence;
447
+ private interruptedInboxNoticeFlight;
448
+ private interruptedInboxNoticeAfterSequence;
449
+ private readonly inboundAdmissionRecoveryController;
450
+ private workflowTraceRetryTimer;
451
+ private preferenceProjectionRetryTimer;
452
+ private modelSelectionRetryTimer;
453
+ private runtime;
454
+ private timer;
455
+ private active;
456
+ constructor(ctx: Context, input: Config);
457
+ issuePairing(operatorId: string, principal: ExternalPrincipalKey): {
458
+ challenge: PairingChallenge;
459
+ code: string;
460
+ };
461
+ confirmPairing(input: {
462
+ challengeId: string;
463
+ principal: ExternalPrincipalKey;
464
+ code: string;
465
+ }): import("./types.js").DeliveryPrincipal;
466
+ linkPrincipal(input: {
467
+ operatorId: string;
468
+ owner: ExternalPrincipalKey;
469
+ linked: ExternalPrincipalKey;
470
+ expectedLinkedVersion: number;
471
+ }): import("./types.js").DeliveryPrincipal;
472
+ private validateApprovalSettlement;
473
+ settleApproval(input: ApprovalSettlementInput): ReturnType<AssistantPolicyService['decideProposal']>;
474
+ recoverApprovalSettlement(input: ApprovalSettlementInput): ReturnType<AssistantPolicyService['decideProposal']> | undefined;
475
+ settleModelSelection(input: ModelSelectionSettlementInput): ModelSelectionResult;
476
+ awaitModelSelection(input: ModelSelectionSettlementInput, signal: AbortSignal): Promise<ModelSelectionTerminalResult | undefined>;
477
+ advanceModelPickerForCallback(input: {
478
+ operationId: string;
479
+ callbackChatId: string;
480
+ cardMessageId: string;
481
+ bindingId: string;
482
+ principal: ExternalPrincipalKey;
483
+ expected: ModelPickerState;
484
+ next: ModelRouteRef;
485
+ }): {
486
+ applied: boolean;
487
+ state: ModelPickerState;
488
+ };
489
+ getModelPickerForCallback(input: {
490
+ operationId: string;
491
+ callbackChatId: string;
492
+ cardMessageId: string;
493
+ bindingId: string;
494
+ principal: ExternalPrincipalKey;
495
+ }): ModelPickerIntent | undefined;
496
+ settlePermissionSelection(input: {
497
+ operationId: string;
498
+ callbackEventId: string;
499
+ callbackChatId: string;
500
+ cardMessageId: string;
501
+ bindingId: string;
502
+ bindingVersion: number;
503
+ sessionId: string;
504
+ principal: ExternalPrincipalKey;
505
+ issuedAt: number;
506
+ expiresAt: number;
507
+ expectedStateHash: string;
508
+ emergencyStopVersion: number;
509
+ targetLevel: 'ask' | 'auto' | 'full';
510
+ }): Promise<{
511
+ duplicate: boolean;
512
+ inboxId: string;
513
+ status: InboxRecord['status'];
514
+ }>;
515
+ resolveDeadLetter(input: {
516
+ operatorId: string;
517
+ kind: 'inbox' | 'outbox';
518
+ id: string;
519
+ expectedAttemptCount: number;
520
+ resolution: 'cancel' | 'retry';
521
+ }): DeadLetterResolutionResult<InboxRecord> | DeadLetterResolutionResult<OutboxRecord>;
522
+ registerInboundRuntime(runtime: DeliveryInboundRuntime): () => void;
523
+ /** Versioned capability: idle wake Agents remain alive through exact goal settlement. */
524
+ goalWakeSettlementVersion: () => 1;
525
+ goalWakeResultVersion: () => 1;
526
+ /** Only the live Goals service can mint this process-local wake capability. */
527
+ resumeScheduledGoal(input: DeliveryGoalWakeInput): Promise<DeliveryGoalWakeResult>;
528
+ /** Finalize the captured native reply, or publish it only for a still-owned external channel. */
529
+ enqueueScheduledGoalResult(input: DeliveryGoalWakeInput): DeliveryGoalWakeResultPublication;
530
+ private publishScheduledGoalResult;
531
+ /** A textless terminal Web wake may notify its original owner, never impersonate a reply. */
532
+ private publishScheduledGoalCompletionNotice;
533
+ private resolveScheduledGoalOutcome;
534
+ /** Private verifier producer generation; invalidated with this service. */
535
+ trustedAcceptanceProducerGeneration: () => string;
536
+ registerTaskAcceptanceSink: (registration: TaskAcceptanceRegistration) => (() => void);
537
+ inspectAcceptedExecution: (contract: AcceptanceContract) => Promise<import("./acceptance.js").AcceptedExecution | null>;
538
+ private removeTaskAcceptanceSink;
539
+ private beginForegroundTaskExecution;
540
+ registerForegroundTaskObserver(registration: ForegroundTaskObservationRegistration): () => void;
541
+ private observerCurrent;
542
+ private observeForegroundBegin;
543
+ private completeForegroundTaskExecution;
544
+ private prepareForegroundTaskAcceptance;
545
+ private completeForegroundTaskAcceptance;
546
+ registerAdapter(adapter: DeliveryAdapter): Promise<() => Promise<void>>;
547
+ private abortUserQuestionAttemptsForAdapter;
548
+ private abortUserQuestionAttempts;
549
+ private answerUserQuestion;
550
+ private resolveUserQuestionRoute;
551
+ private resolveUserQuestionRouteFromStore;
552
+ /** Trusted Host configuration only; the returned capability fixes a pre-paired Web owner and scope. */
553
+ bindNativeWebOwner: (ctx: Context, config: NativeWebOwnerConfig) => NativeWebOwnerAccess;
554
+ /** Host-only proof of a single live native tool call in the exact claimed owner Inbox. */
555
+ inspectOwnerForegroundToolCall(input: Readonly<{
556
+ agent: Agent;
557
+ authorityId: string;
558
+ callId: string;
559
+ toolName: string;
560
+ argumentsJson: string;
561
+ }>): Readonly<ForegroundToolCallAttestation> | undefined;
562
+ /** Read-only pages of this exact live owner's persisted human input. Callers
563
+ * cannot select an Inbox, path, owner, or replacement text through this API. */
564
+ readOwnerForegroundToolInput(input: Readonly<{
565
+ agent: Agent;
566
+ authorityId: string;
567
+ callId: string;
568
+ toolName: string;
569
+ argumentsJson: string;
570
+ offset?: number;
571
+ maxBytes?: number;
572
+ }>): Readonly<OwnerForegroundToolInput> | undefined;
573
+ /**
574
+ * The live caller's unique configured owner route. A caller never names a
575
+ * route here: zero matching routes (anonymous, unconfigured, or failed
576
+ * revalidation) and more than one matching route (ambiguous owner authority)
577
+ * both fail closed.
578
+ */
579
+ private ownerRouteForAgent;
580
+ /** Host-only proof resolved from the caller Agent's unique live owner route. */
581
+ inspectOwnerForegroundToolCallForAgent(agent: Agent, input: Readonly<{
582
+ callId: string;
583
+ toolName: string;
584
+ argumentsJson: string;
585
+ }>): Readonly<ForegroundToolCallAttestation> | undefined;
586
+ /** Read-only human-input pages resolved from the caller Agent's unique live
587
+ * owner route; the caller cannot select an Inbox, route, owner or replacement text. */
588
+ readOwnerForegroundToolInputForAgent(agent: Agent, input: Readonly<{
589
+ callId: string;
590
+ toolName: string;
591
+ argumentsJson: string;
592
+ offset?: number;
593
+ maxBytes?: number;
594
+ }>): Readonly<OwnerForegroundToolInput> | undefined;
595
+ /** Host-only, read-only source proof for an owner's live memory or wiki tool call. */
596
+ inspectOwnerRequestedChange(execution: ToolExecution, input: {
597
+ sourceId: string;
598
+ }): Readonly<{
599
+ route: ApprovalDispatchRouteV2;
600
+ text: string;
601
+ receiptDigest: string;
602
+ }> | undefined;
603
+ currentPreferenceTurn(agent: Agent): Readonly<DeliveryPreferenceTurnAttestation> | undefined;
604
+ preferencePrincipalForAgent(agent: Agent): Readonly<DeliveryPreferencePrincipalAttestation> | undefined;
605
+ private capturePreferenceTurn;
606
+ trustedPreferenceProducerGeneration(): string;
607
+ /** Exact process-local Preference owner registration; copied or self-asserted sinks fail. */
608
+ registerTrustedPreferenceSink(registration: Readonly<DeliveryPreferenceRegistration>): () => void;
609
+ trustedEvaluationProducerGeneration(): string;
610
+ registerTrustedDeliveryEvaluationSink(registration: Readonly<TrustedDeliveryEvaluationRegistration>): () => void;
611
+ /**
612
+ * Register Growth's exact private sink. Replaying current is deliberately
613
+ * queued after this method returns so a registration receipt can never be
614
+ * confused with synchronous projection success.
615
+ */
616
+ registerWorkflowTraceSink(input: Readonly<{
617
+ contractVersion: 1;
618
+ sink: WorkflowTraceSink;
619
+ }>): GrowthWorkflowTraceSourceRegistration;
620
+ registerOwnerSelfIterationHandler(handler: OwnerSelfIterationControlHandler): () => void;
621
+ resolveWorkflowAutomationTemplate(input: Readonly<{
622
+ contractVersion: 1;
623
+ template: Readonly<WorkflowAutomationTemplate>;
624
+ scope: Readonly<WorkflowScope>;
625
+ ownerBindingId: string;
626
+ }>): Readonly<ResolvedWorkflowAutomationTemplate>;
627
+ /**
628
+ * Host-only bridge from one exact reviewed workflow template to a v2 Policy
629
+ * approval route. This method is not registered as an Agent tool.
630
+ */
631
+ prepareWorkflowApproval(input: Readonly<{
632
+ sourceId: string;
633
+ contractVersion: 1;
634
+ template: Readonly<WorkflowAutomationTemplate>;
635
+ scope: Readonly<WorkflowScope>;
636
+ ownerBindingId: string;
637
+ }>): ApprovalDispatchRouteV2;
638
+ /**
639
+ * Host-only owner-anchored workflow learning bridge. This method is not
640
+ * registered as an Agent tool (same Host seam as prepareWorkflowApproval):
641
+ * only the opt-in growth driver invokes it, and only with a locator plus one
642
+ * bounded-wake authority. Delivery itself re-fetches both the verified Goals
643
+ * source and the owner-run-trace proof, so the caller can never supply the
644
+ * objective, steps, acceptance verdict or proof digest — a spoofed driver
645
+ * learns nothing. A goal that does not honestly reduce to the single
646
+ * no-tool `assistant.agent-turn` step is returned as `abstained` with zero
647
+ * writes; the trace is projected through the existing outbox/drain chain.
648
+ */
649
+ commitOwnerAnchoredWorkflowTrace(input: Readonly<{
650
+ locator: OwnerGoalExecutionSnapshotInput;
651
+ authority: OwnerAnchoredWorkflowAuthority;
652
+ }>): Promise<CommitOwnerAnchoredWorkflowTraceServiceResult>;
653
+ /**
654
+ * Host-only, content-free route minting seam for Preference promotion.
655
+ * No binding id is accepted from the caller; Delivery resolves the unique
656
+ * current binding from the exact owner lineage and generation.
657
+ */
658
+ prepareOwnerApprovalForPreference(input: Readonly<OwnerApprovalForPreferenceInput>): OwnerApprovalForPreferenceResult;
659
+ health(): ReturnType<DeliveryStore['health']> & {
660
+ adapters: number;
661
+ };
662
+ /** Exact process-local proof for a Delivery-minted publisher registration. */
663
+ ownsTrustedDeliveryPresentationRegistration(registration: Readonly<TrustedDeliveryPresentationRegistration>): boolean;
664
+ getDeliveryPresentation(presentationKey: string): StoredDeliveryPresentation | undefined;
665
+ private presentationBinding;
666
+ private setPresentationBinding;
667
+ private presentationProducerGeneration;
668
+ /**
669
+ * Delivery owns the registration and its publish closure. The producer only
670
+ * receives that closure after it has proven this exact in-process object is
671
+ * its expected Delivery owner; replacement and disposal revoke it eagerly.
672
+ */
673
+ private bindPresentationProducer;
674
+ private assertCurrentPresentationProducer;
675
+ private publishTrustedDeliveryPresentation;
676
+ private progressAuthorized;
677
+ /**
678
+ * Exact owner-configured peer bot, or `undefined`. `senderIsBot` is only the
679
+ * provider's declaration; the allowlisted tuple is the actual authority.
680
+ */
681
+ private peerAgentAuthority;
682
+ private isInboundAuthorized;
683
+ private isPermissionController;
684
+ private isOwnerFeedbackController;
685
+ private ownerLineageForBinding;
686
+ private authorizeOwnerPreferenceFeedback;
687
+ private preferenceSignalAuthorizationKey;
688
+ private dispatchPreferenceFeedback;
689
+ private dispatchLearningCommand;
690
+ private dispatchOwnerSelfIterationCommand;
691
+ dispatchVersionQuery(_binding?: Readonly<ConversationBinding>, _envelope?: Readonly<InboundEnvelope>, _query?: Readonly<ParsedOwnerVersionQuery>): Promise<AssistantVersionReport>;
692
+ private completedPreferenceEvents;
693
+ private dispatchWorkflowCommand;
694
+ /** Opt-in widened deterministic grammar; off keeps the legacy exact phrases. */
695
+ private widenedNaturalFeedbackCoverage;
696
+ /** Splitting one reply into result + continuation requires both opt-ins. */
697
+ private mixedNaturalFeedbackIntent;
698
+ /**
699
+ * One canonical selection for admission and its later re-derivation fences.
700
+ * The widened parser is a pure function, so a frozen intent keeps verifying
701
+ * even after a restart that toggles the opt-in.
702
+ */
703
+ private naturalObjectiveSelection;
704
+ /**
705
+ * Convert only an authenticated reply to one exact Automation delivery into
706
+ * a trusted objective label. The original run timestamp is retained because
707
+ * Evolution re-proves the immutable production run; the later Inbox is a
708
+ * separate evidence reference, never copied as prose.
709
+ */
710
+ private dispatchNaturalObjectiveFeedback;
711
+ private drainNaturalObjectiveIntents;
712
+ private runNaturalObjectiveIntents;
713
+ private dispatchObjectiveFeedback;
714
+ private dispatchGoalOutcomeFeedback;
715
+ private authorizePermissionReply;
716
+ /**
717
+ * Provider event ids are scoped to an adapter account, while Outbox and the
718
+ * Policy ledger share one database-wide idempotency namespace. Anchor every
719
+ * command reply to the accepted Inbox row, whose id is stable across reopen.
720
+ */
721
+ private inboundReplyIdempotencyKey;
722
+ private hasActivePrincipal;
723
+ private toolApprovalRoute;
724
+ private resolveToolApprovalAuthority;
725
+ /** A source-thread notice, never raw command arguments or a new approval grant. */
726
+ private notifyToolApproval;
727
+ private requestToolApproval;
728
+ acceptInbound(envelope: InboundEnvelope, recoverySignal?: AbortSignal): Promise<{
729
+ duplicate: boolean;
730
+ inboxId: string;
731
+ status: InboxRecord['status'];
732
+ }>;
733
+ /**
734
+ * Deterministic backend classification of one authenticated owner reply to an
735
+ * exact report. The legacy closed whole-sentence grammar stays in force unless
736
+ * the widened coverage opt-in is on; no caller text is reinterpreted as an
737
+ * instruction, and no model is called.
738
+ */
739
+ private parseWorkItemFeedback;
740
+ private workItemFeedbackPermission;
741
+ /**
742
+ * Inspect one Inbox as an authenticated owner result reply to an exact report.
743
+ * `ready` carries the frozen source plus its live admission fence; `ordinary`
744
+ * keeps the historical "recognized result but separate feedback permission
745
+ * absent" outcome and never admits the result lane by itself. The
746
+ * `continuation` flag is a deterministic classification only.
747
+ */
748
+ private inspectOwnerWorkItemFeedback;
749
+ /** One deterministic, non-durable record when a mixed reply could only admit one lane. */
750
+ private recordPartialMixedFeedbackAdmission;
751
+ /** Passing an explicit registration makes this the callback-free final local authority check. */
752
+ private workItemFeedbackFence;
753
+ private workItemFeedbackProof;
754
+ private drainWorkItemFeedback;
755
+ private runWorkItemFeedback;
756
+ private drainWorkItemFeedbackAcks;
757
+ withOwnerWorkItemFeedbackWriterFence<T>(registration: Readonly<TrustedDeliveryEvaluationRegistration>, claims: Readonly<TrustedDeliveryEvaluationClaims>, proofDigest: string, callback: () => T): T;
758
+ workItemReplyProtocolVersion(): 1;
759
+ private currentWorkItemReplyConsumer;
760
+ registerWorkItemReplyConsumer(registration: WorkItemReplyConsumerRegistration): () => void;
761
+ /**
762
+ * WP20 intake: one observer, owned by the current WorkItems service, receives
763
+ * a metadata-only signal per adapter observation. Delivery adds only the
764
+ * read-only allowlist and tracked-report-thread facts; it writes nothing.
765
+ */
766
+ registerInboundIntakeObserver(observer: DeliveryInboundIntakeObserver): () => void;
767
+ private currentInboundIntakeObserver;
768
+ /** Best-effort and side-effect free: any invalid input or observer failure is dropped. */
769
+ private observeInbound;
770
+ /** Subscribe to foreground task completion or inbound reply persistence notifications. */
771
+ onForegroundTaskCompletion(listener: () => void): () => void;
772
+ private notifyForegroundTaskCompletion;
773
+ private prepareIntakeAcceptance;
774
+ private inboundIntakeSignal;
775
+ private notifyWorkItemReplyPending;
776
+ private notifyWorkItemReplyCancellation;
777
+ private workItemOutboxReportPayload;
778
+ private inspectWorkItemReport;
779
+ enqueueWorkItemReport(input: {
780
+ sourceId: string;
781
+ workspace: string;
782
+ bindingId: string;
783
+ idempotencyKey: string;
784
+ text: string;
785
+ format?: 'markdown' | 'plain';
786
+ metadata?: Readonly<Record<string, string>>;
787
+ itemId: string;
788
+ reportRevision: number;
789
+ }): OutboxRecord;
790
+ /**
791
+ * Host-only cross-channel route for one background work-item report.
792
+ *
793
+ * The origin binding always wins (default prefer): while it is active with an active
794
+ * principal this returns `{ route: 'origin' }` and enqueues nothing, so the
795
+ * caller keeps its existing origin path unchanged. Only when the origin is
796
+ * unavailable does the Host walk the owner's explicit `linkedFallback` list
797
+ * (Delivery principal ids, in order) and pick the first alias that is still
798
+ * an active `linked` row of the CURRENT owner record, with exactly one active
799
+ * binding in the origin workspace/preset, and that existing Policy already
800
+ * allows to receive this source's sends. The report is queued on the plain
801
+ * background lane, never the typed report lane, so a reply on the fallback
802
+ * channel can never continue or give feedback on the item. The queued row
803
+ * binds the owner and alias record versions plus the alias binding
804
+ * version/generation; the send-time guard drops it after any revoke or
805
+ * relink. A replay returns the first committed destination.
806
+ *
807
+ * Opt-in `prefer: 'recent'` instead ranks eligible aliases by the owner's
808
+ * newest inbound message (`inbox_messages.received_at`); an available origin
809
+ * still wins unless an eligible alias received strictly newer inbound, and
810
+ * also when that alias is refused before its linked row commits.
811
+ *
812
+ * Opt-in `ownerReportRouting.orderAcrossLanes` (Delivery config) keeps one
813
+ * item's reports in revision order across channels: when an earlier report
814
+ * of the same item is still unsettled, the new one sticks to that route
815
+ * (same origin, or same alias while it is still eligible and owner-listed)
816
+ * so the existing per-lane claim order sends it after. A sticky origin also
817
+ * overrides `prefer: 'recent'`. An unusable sticky route falls back to the
818
+ * rules above, so ordering never blocks delivery.
819
+ */
820
+ routeWorkItemReport(input: Readonly<{
821
+ sourceId: string;
822
+ workspace: string;
823
+ originBindingId: string;
824
+ idempotencyKey: string;
825
+ text: string;
826
+ format?: 'markdown' | 'plain';
827
+ itemId: string;
828
+ reportRevision: number;
829
+ linkedFallback: readonly string[];
830
+ prefer?: 'origin' | 'recent';
831
+ }>): Readonly<{
832
+ route: 'origin';
833
+ } | {
834
+ route: 'linked';
835
+ outbox: OutboxRecord;
836
+ }>;
837
+ private linkedReportSendAllowed;
838
+ /** Send-time re-check of a linked report route; any revoke, relink or Policy change drops it. */
839
+ private linkedReportGuard;
840
+ private workItemReplyPermission;
841
+ /**
842
+ * Validate the continuation lane of one reply to an exact report without
843
+ * writing it. Mixed-intent admission reuses this report inside its combined
844
+ * transaction; the ordinary path admits it through `admitWorkItemReply`.
845
+ */
846
+ private prepareWorkItemReply;
847
+ private admitWorkItemReply;
848
+ private workItemReplyFence;
849
+ private validateWorkItemReply;
850
+ listPendingWorkItemReplies(input: WorkItemReplyListInput): {
851
+ items: readonly WorkItemReplySource[];
852
+ hasMore: boolean;
853
+ nextAfterSequence: number | null;
854
+ };
855
+ readWorkItemReply(input: WorkItemReplyReadInput): WorkItemReplySource;
856
+ selectWorkItemReplyParent(input: WorkItemReplyReadInput): WorkItemReplySource;
857
+ acknowledgeWorkItemReply(input: WorkItemReplyReadInput & {
858
+ childItemId: string;
859
+ childPlanDigest: string;
860
+ }): WorkItemReplySource;
861
+ enqueueBackground(input: {
862
+ sourceId: string;
863
+ workspace: string;
864
+ bindingId: string;
865
+ idempotencyKey: string;
866
+ text: string;
867
+ format?: 'markdown' | 'plain';
868
+ metadata?: Readonly<Record<string, string>>;
869
+ /** WP19 stage 1: audited only; omission records `missing-purpose`. */
870
+ attention?: AttentionEnvelope;
871
+ }): OutboxRecord;
872
+ /**
873
+ * Record the WP19 stage-1 verdict for one queued Outbox record. Audit only:
874
+ * the record is returned unchanged and any audit failure is swallowed.
875
+ */
876
+ private auditAttention;
877
+ /**
878
+ * WP19 stage 2b, only when `attentionAttachOverCap` is on: convert an
879
+ * over-cap notice to a short body plus one text attachment (never split),
880
+ * and reject an inline notice that, with recent inline notices from the same
881
+ * source, binding and lane, exceeds the cap of its purpose. Deterministic for
882
+ * one (input, audited history, clock). Off: the input is returned unchanged,
883
+ * except that a replay of an already converted key keeps its stored form.
884
+ * WP19 stage 3, only when `attentionEnforce` is on: a new notice with a
885
+ * missing or failed purpose, or over cap without the attachment path, is
886
+ * rejected with `AttentionRejectedError` and nothing is queued. Replays
887
+ * return above before any check, so an existing key stays idempotent.
888
+ */
889
+ private prepareAttentionDelivery;
890
+ /**
891
+ * Read-only WP19 stage-1 audit page in append order; never exposes message text.
892
+ * `processLocalWriteFailures` counts failed audit writes since this Host started;
893
+ * `unauditedOutbox` is derived from durable rows on every call (see
894
+ * `AttentionAuditStore.unauditedOutboxCount` for which lanes it can see).
895
+ */
896
+ inspectAttentionAudit(input?: Readonly<{
897
+ afterSequence?: number;
898
+ limit?: number;
899
+ }>): Readonly<{
900
+ entries: readonly AttentionAuditEntry[];
901
+ hasMore: boolean;
902
+ nextAfterSequence: number | null;
903
+ processLocalWriteFailures: number;
904
+ unauditedOutbox: number;
905
+ }>;
906
+ /**
907
+ * WP22 read adapter for Evaluation: per-notification durable facts (transport,
908
+ * owner reply, current owner judgement) keyed by audited Outbox id. Read-only,
909
+ * text-free, and classification-free. Pass `outboxIds` (max 500) to refresh
910
+ * known notifications, or `afterSequence`/`limit` to page new audit rows.
911
+ */
912
+ inspectNotificationOutcomeFacts(input?: Readonly<{
913
+ afterSequence?: number;
914
+ limit?: number;
915
+ outboxIds?: readonly string[];
916
+ }>): Readonly<{
917
+ protocol: typeof NOTIFICATION_OUTCOME_FACTS_PROTOCOL;
918
+ facts: readonly NotificationOutcomeFact[];
919
+ hasMore: boolean;
920
+ nextAfterSequence: number | null;
921
+ }>;
922
+ /**
923
+ * Attach the registered adapter's read-receipt completeness to each fact.
924
+ * The Delivery store owns transport facts but not adapter capabilities; only
925
+ * this read boundary can combine them. An undeclared capability stays absent
926
+ * so older Evaluation classifiers keep their pinned v1 digests.
927
+ */
928
+ private notificationOutcomeFacts;
929
+ /**
930
+ * Read-only WP19 stage-2c progress audit page in append order; never exposes
931
+ * progress text. Entries are process-local (`durable: false`), bounded, and
932
+ * reset on Host restart; `processLocalWriteFailures` counts failed records.
933
+ */
934
+ inspectProgressAttentionAudit(input?: Readonly<{
935
+ afterSequence?: number;
936
+ limit?: number;
937
+ }>): Readonly<ProgressAttentionAuditPage & {
938
+ processLocalWriteFailures: number;
939
+ }>;
940
+ /**
941
+ * Read-only WP19 stage-3 rejection page in append order; never exposes
942
+ * message text. Entries are process-local (`durable: false`), bounded, and
943
+ * reset on Host restart. Empty while `attentionEnforce` is off.
944
+ */
945
+ inspectAttentionRejections(input?: Readonly<{
946
+ afterSequence?: number;
947
+ limit?: number;
948
+ }>): AttentionRejectionPage;
949
+ private enqueueBackgroundAuthorized;
950
+ /** Queue a typed owner notice. Accepted means queued; it never asserts user read. */
951
+ enqueueOwnerNotification(input: {
952
+ sourceId: string;
953
+ ownerRouteId: string;
954
+ scope: {
955
+ principalId: string;
956
+ principalRecordId: string;
957
+ principalVersion: number;
958
+ workspace: string;
959
+ preset: string;
960
+ };
961
+ sessionId: string;
962
+ idempotencyKey: string;
963
+ text: string;
964
+ expiresAt: number;
965
+ attention?: AttentionEnvelope;
966
+ withdrawable?: boolean;
967
+ withdrawalHandle?: string;
968
+ }): OutboxRecord;
969
+ /**
970
+ * Register the send-time withdrawal check for one owner-notice source (see
971
+ * `OwnerNotificationWithdrawal`). The service in the `authority` slot must
972
+ * vouch for the registration; one live check per (authority, source). A
973
+ * registration its authority no longer vouches for (owner restarted or
974
+ * replaced) is superseded by the next vouched one, so the legitimate owner
975
+ * regains control of notices already queued under its authority. After
976
+ * `unregister`, those notices wait instead of sending.
977
+ */
978
+ registerOwnerNotificationWithdrawal(registration: OwnerNotificationWithdrawal): OwnerNotificationWithdrawalBinding;
979
+ /** The service now in `authority`'s slot vouches for this exact registration object. */
980
+ private withdrawalVouched;
981
+ /** Live, still-vouched registration behind `handle`, for exactly `sourceId`. */
982
+ private liveWithdrawal;
983
+ /**
984
+ * Read-only lookup of an owner notice by idempotency key. The caller
985
+ * presents its withdrawal handle; the lookup is scoped to that handle's
986
+ * source and authority. A key held by another source, another authority,
987
+ * a non-withdrawable notice or a non-notice record reads as absent. Never
988
+ * returns text or metadata.
989
+ */
990
+ inspectOwnerNotification(input: Readonly<{
991
+ sourceId: string;
992
+ idempotencyKey: string;
993
+ withdrawalHandle: string;
994
+ }>): Readonly<OwnerNotificationRecordView> | undefined;
995
+ /**
996
+ * Register the slice-5 reply consumer for one owner-notice source (see
997
+ * `OwnerNotificationReply`). The service in the `authority` slot must vouch
998
+ * for the exact object; one live consumer per (authority, source). A
999
+ * registration its authority no longer vouches for is superseded by the
1000
+ * next vouched one, so a restarted owner regains its replies without a new
1001
+ * notice. Registering never sends anything and grants no send authority.
1002
+ */
1003
+ registerOwnerNotificationReply(registration: OwnerNotificationReply): OwnerNotificationReplyBinding;
1004
+ /** The service now in `authority`'s slot vouches for this exact reply registration. */
1005
+ private replyVouched;
1006
+ /**
1007
+ * Slice 5 matcher: bind one authenticated inbound text reply to exactly one
1008
+ * accepted/delivered/read owner notice through `replyToProviderMessageId`,
1009
+ * require the live registered consumer's source and idempotency-key prefix,
1010
+ * an active owner binding/principal with the notice's frozen owner lineage,
1011
+ * and an `allow` external `answer-attention-question` Policy decision. On
1012
+ * `applied` the Inbox is marked processed; `transient` leaves it pending for
1013
+ * a retry. Everything else falls through to ordinary inbound handling.
1014
+ */
1015
+ inspectOwnerQuestionReply(inbox: InboxRecord, binding: ConversationBinding): 'none' | 'handled' | 'transient';
1016
+ /**
1017
+ * Dedicated Automation result lane. Every learning field is derived from an
1018
+ * authoritative Automations receipt; callers cannot supply metadata,
1019
+ * idempotency, source identity, occurrence, timestamp, or feedback text.
1020
+ */
1021
+ enqueueAutomationResult(input: {
1022
+ automationId: string;
1023
+ runId: string;
1024
+ workspace: string;
1025
+ bindingId: string;
1026
+ outputPreview: string;
1027
+ }): OutboxRecord;
1028
+ /** Resolve the current generation of one exact Host-owned owner route. */
1029
+ resolveOwnerRoute(authorityIdInput: string): ResolvedOwnerRoute;
1030
+ /** Host-only enumeration of active owner routes; zero message or secret exposure. */
1031
+ listActiveOwnerRouteScopes(): readonly OwnerRouteScopeSummary[];
1032
+ /**
1033
+ * Read-only Host observation of the configured owner, even after its binding
1034
+ * has been revoked. Missing routes and transient failures are not revocation.
1035
+ */
1036
+ inspectOwnerRouteState(input: {
1037
+ authorityId: string;
1038
+ principalId: string;
1039
+ workspace: string;
1040
+ agentPreset: string;
1041
+ }): OwnerRouteStateInspection;
1042
+ /**
1043
+ * Revalidate Recovery/other Host work against the live owner route without
1044
+ * exposing a session id, conversation id, user message or delivery content.
1045
+ */
1046
+ validateOwnerRoute(input: {
1047
+ authorityId: string;
1048
+ principalId: string;
1049
+ workspace: string;
1050
+ agentPreset: string;
1051
+ }): Readonly<OwnerRouteValidationReceipt>;
1052
+ /**
1053
+ * Host-only: the same receipt as `validateOwnerRoute`, plus the id of the
1054
+ * exact active binding it was resolved from (one resolve, so both describe
1055
+ * the same route state). Not an Agent tool; same `missing-binding` errors.
1056
+ */
1057
+ inspectOwnerRouteBinding(input: {
1058
+ authorityId: string;
1059
+ principalId: string;
1060
+ workspace: string;
1061
+ agentPreset: string;
1062
+ }): Readonly<OwnerRouteBindingReceipt>;
1063
+ private ownerRouteReceipt;
1064
+ /** Host-only proof that the live caller Agent belongs to the current owner route. */
1065
+ validateOwnerAgentForRoute(agent: Agent, authorityId: string): ReturnType<AssistantDeliveryService['validateOwnerRoute']> | undefined;
1066
+ /**
1067
+ * Host-only, READ-ONLY proof that the live caller Agent is bound to an
1068
+ * active `linked` principal whose `linked_to_id` is the CURRENT owner row of
1069
+ * this owner route. The receipt has a distinct protocol and no
1070
+ * `receiptVersion`, so v2 owner checks reject it; it never grants owner,
1071
+ * approval, continuation or mutation authority. Every call re-reads the
1072
+ * route, the root owner, the alias binding and the alias principal twice.
1073
+ */
1074
+ inspectOwnerAliasRoute(agent: Agent, authorityId: string): Readonly<OwnerAliasReceipt> | undefined;
1075
+ /**
1076
+ * Host-only proof of one live, unsettled native tool call in the alias's
1077
+ * exact claimed human Inbox turn. Read-only; it is NOT an owner foreground
1078
+ * proof (`assistant-delivery/foreground-tool-call/v1`) and must never be
1079
+ * accepted where one is required.
1080
+ */
1081
+ inspectOwnerAliasForegroundToolCall(input: Readonly<{
1082
+ agent: Agent;
1083
+ authorityId: string;
1084
+ callId: string;
1085
+ toolName: string;
1086
+ argumentsJson: string;
1087
+ }>): Readonly<OwnerAliasForegroundToolCallAttestation> | undefined;
1088
+ private currentAliasTurn;
1089
+ private captureAliasTurn;
1090
+ /** Host-only durable ordinary-turn metadata; never registered as a model tool. */
1091
+ listOwnerForegroundTaskSources(input: OwnerForegroundTaskSourceScope & {
1092
+ after?: Readonly<OwnerForegroundTaskSourceCursor>;
1093
+ limit?: number;
1094
+ }): Readonly<OwnerForegroundTaskSourcePage>;
1095
+ /** Host-only exact terminal source metadata, including before reply Outbox exists. */
1096
+ inspectOwnerForegroundTaskSource(input: OwnerForegroundTaskSourceScope & {
1097
+ inboxId: string;
1098
+ }): Readonly<OwnerForegroundTaskSource> | undefined;
1099
+ /** Read one exact completed source under the current owner fence. */
1100
+ readOwnerForegroundTaskSource(input: OwnerForegroundTaskSourceScope & {
1101
+ inboxId: string;
1102
+ expectedSourceDigest: string;
1103
+ maxInputBytes?: number;
1104
+ maxReplyBytes?: number;
1105
+ }): Readonly<OwnerForegroundTaskSourceContent> | undefined;
1106
+ /** Host-only bounded original input, independent of successful reply evidence. */
1107
+ readOwnerForegroundTaskInput(input: OwnerForegroundTaskSourceScope & {
1108
+ inboxId: string;
1109
+ expectedSourceDigest: string;
1110
+ offset?: number;
1111
+ maxBytes?: number;
1112
+ }): Readonly<OwnerForegroundTaskInput> | undefined;
1113
+ /** Hold Delivery's owner/source writer fence across synchronous downstream adoption. */
1114
+ withOwnerForegroundTaskSourceFence<T>(input: OwnerForegroundTaskSourceScope & {
1115
+ inboxId: string;
1116
+ expectedSourceDigest: string;
1117
+ maxInputBytes?: number;
1118
+ maxReplyBytes?: number;
1119
+ }, callback: (source: Readonly<OwnerForegroundTaskSourceContent>) => T): T;
1120
+ /** Hold one owner/source writer fence for a bounded, ordered batch of sources. */
1121
+ withOwnerForegroundTaskSourcesFence<T>(input: OwnerForegroundTaskSourceScope & {
1122
+ sources: readonly Readonly<OwnerForegroundTaskSourceRef>[];
1123
+ }, callback: (sources: readonly (Readonly<OwnerForegroundTaskSourceContent> | undefined)[]) => T): T;
1124
+ /** One Delivery → Evaluation → WorkItems source fence; callback must be local and synchronous. */
1125
+ withOwnerLearningSourcesFence<T>(input: OwnerForegroundTaskSourceScope & {
1126
+ sources: readonly OwnerLearningSourceExpectation[];
1127
+ }, callback: (sources: readonly OwnerLearningSourceSnapshot[]) => T): T;
1128
+ /** Strict single-source wrapper: unavailable or changed sources never invoke the callback. */
1129
+ withOwnerWorkItemLearningTaskFence<T>(input: OwnerWorkItemLearningTaskFenceInput, callback: (task: Readonly<OwnerWorkItemLearningTask>) => T): T;
1130
+ /** Host-only snapshot of the model selected for this owner's external conversation. */
1131
+ inspectOwnerModelSelection(input: {
1132
+ authorityId: string;
1133
+ principalId: string;
1134
+ workspace: string;
1135
+ agentPreset: string;
1136
+ sourceAgent?: Agent;
1137
+ }): Readonly<ModelRouteRef>;
1138
+ /**
1139
+ * Resolve one canonical work-item result against its actual owner lineage.
1140
+ * Evaluation's workspace/preset scope alone does not establish ownership.
1141
+ * Historical Sessions remain eligible after /new, but not after owner ABA.
1142
+ */
1143
+ inspectOwnerWorkItemLearningTask(input: {
1144
+ authorityId: string;
1145
+ principalId: string;
1146
+ workspace: string;
1147
+ agentPreset: string;
1148
+ outcomeId: string;
1149
+ }): Readonly<OwnerWorkItemLearningTask> | undefined;
1150
+ private ownerWorkItemLearningTaskState;
1151
+ /** Host-only complete historical objective; old feedback and Memory identities are not reinterpreted. */
1152
+ inspectOwnerWorkItemEngineeringContext(input: OwnerWorkItemEngineeringContextLocator): Readonly<OwnerWorkItemEngineeringContext> | undefined;
1153
+ /** Every page, including the last, revalidates the entire exact source frame. */
1154
+ readOwnerWorkItemEngineeringContext(input: OwnerWorkItemEngineeringContextReadInput): Readonly<OwnerWorkItemEngineeringContextPage> | undefined;
1155
+ withOwnerWorkItemEngineeringContextFence<T>(input: OwnerWorkItemEngineeringContextExpectation, callback: (source: Readonly<OwnerWorkItemEngineeringContextSource>) => T): T;
1156
+ private withOwnerWorkItemEngineeringContextSource;
1157
+ inspectOwnerForegroundLearningTask(input: {
1158
+ authorityId: string;
1159
+ principalId: string;
1160
+ workspace: string;
1161
+ agentPreset: string;
1162
+ outcomeId: string;
1163
+ }): Readonly<OwnerForegroundLearningTask> | undefined;
1164
+ /**
1165
+ * Enqueue against a stable Host-owned route rather than a session binding.
1166
+ * Policy is evaluated against the exact `route:<authorityId>` resource. The
1167
+ * Store re-resolves under its write transaction, so a concurrent `/new`
1168
+ * either wins completely or follows the earlier immutable Outbox receipt.
1169
+ */
1170
+ enqueueBackgroundRoute(input: {
1171
+ sourceId: string;
1172
+ authorityId: string;
1173
+ idempotencyKey: string;
1174
+ text: string;
1175
+ format?: 'markdown' | 'plain';
1176
+ /** WP19 stage 1: audited only; omission records `missing-purpose`. */
1177
+ attention?: AttentionEnvelope;
1178
+ }): OutboxRecord;
1179
+ enqueueApproval(input: {
1180
+ route: Readonly<ApprovalDispatchRouteV2>;
1181
+ idempotencyKey: string;
1182
+ text: string;
1183
+ approval: NonNullable<import('./types.js').OutboundIntent['approval']>;
1184
+ }): OutboxRecord;
1185
+ private replyCommand;
1186
+ /**
1187
+ * Answers are authored as Markdown, but the coordinator drops an intent whose format the adapter
1188
+ * does not declare (`unsupported-format`). Ask for Markdown only where the channel renders it and
1189
+ * degrade to plain text elsewhere, so a reply is never lost to a capability mismatch.
1190
+ */
1191
+ private replyFormat;
1192
+ reply(agent: Agent | undefined, input: {
1193
+ idempotencyKey: string;
1194
+ text: string;
1195
+ format?: 'markdown' | 'model-picker' | 'permission-picker' | 'plain';
1196
+ modelPicker?: ModelPickerIntent;
1197
+ permissionPicker?: PermissionPickerIntent;
1198
+ replyToEventId?: string;
1199
+ }): OutboxRecord;
1200
+ /** Host-only replay boundary. The returned tombstone fences this exact Agent object permanently. */
1201
+ blockAgentRepliesForReplay(agent: Agent, config: ReplyReplayBlockConfig): ReplyReplayBlockHandle;
1202
+ private replyCompletedPreferenceTurn;
1203
+ private prepareAgentReply;
1204
+ history(agent: Agent | undefined, input: {
1205
+ limit?: number;
1206
+ }): {
1207
+ binding: ConversationBinding;
1208
+ inbox: InboxRecord[];
1209
+ outbox: OutboxRecord[];
1210
+ };
1211
+ bindAgentApprovalRoute(agent: Agent | undefined, input: {
1212
+ bindingId: string;
1213
+ }): () => void;
1214
+ prepareAgentApproval(agent: Agent | undefined, input: {
1215
+ sourceId: string;
1216
+ }): ApprovalDispatchRouteV2;
1217
+ /** Read only the current direct owner binding's exact Policy routes. */
1218
+ readOwnerApprovalStatus(agent: Agent | undefined): OwnerApprovalStatusRead | undefined;
1219
+ private restartCapabilityDigest;
1220
+ private restartAuthorized;
1221
+ /** Host-only maintenance gate shared by the native background scheduler. */
1222
+ isMaintenanceDraining(): boolean;
1223
+ private restartDispatchPermitted;
1224
+ /** Run only from native maintenance after the continuation notice is durably flushed. */
1225
+ private releaseRestartFenceOnAdmission;
1226
+ private otherRestartWorkQuiescent;
1227
+ canRequestRestart(agent: Agent | undefined): boolean;
1228
+ requestRestart(agent: Agent | undefined, reason: string): {
1229
+ id: string;
1230
+ status: string;
1231
+ };
1232
+ get supportsPlannedRestart(): boolean;
1233
+ /** Host-side registration of an exact, currently mounted read-only definition. */
1234
+ registerRestartSafeTool(caller: Context, definition: ToolDefinition): () => void;
1235
+ isRestartSafeTool(agent: Agent, name: string): boolean;
1236
+ /** Startup/tick reconciliation uses the existing native runtime, never requeues the old Inbox. */
1237
+ private drainRestartContinuations;
1238
+ private drainRestartFailureNotices;
1239
+ tick(): Promise<void>;
1240
+ private runTick;
1241
+ whenIdle(): Promise<void>;
1242
+ start(): void;
1243
+ stop(): Promise<void>;
1244
+ private ensureBinding;
1245
+ private drainInboundAdmissions;
1246
+ private drainInterruptedInboxNotices;
1247
+ private runInterruptedInboxNotices;
1248
+ private runInboundAdmissionRecovery;
1249
+ private bindingForInbound;
1250
+ /**
1251
+ * Finish admissions that survived a process exit before their queue/rotate
1252
+ * commit. The provider need not retransmit them: any later message in the
1253
+ * same conversation first drives every older received row forward in its
1254
+ * original durable Inbox order. This includes ordinary messages that were
1255
+ * already persisted behind a blocked `/stop` or `/new` transition.
1256
+ */
1257
+ private recoverPendingInbound;
1258
+ private runConversationTransition;
1259
+ private rotateBinding;
1260
+ private clearSchedulerTimers;
1261
+ private stopInternal;
1262
+ private drainPreferenceProjections;
1263
+ private runPreferenceProjection;
1264
+ /** Host test/operator seam: project due trace revisions without waiting for the scheduler. */
1265
+ projectWorkflowTraces(): Promise<void>;
1266
+ private drainWorkflowTraces;
1267
+ private runWorkflowTraceProjection;
1268
+ private resolveModelSelectionWaiters;
1269
+ private cancelModelSelectionWaiters;
1270
+ private drainApprovalDispatches;
1271
+ private drainDeliveryPresentations;
1272
+ private runDeliveryPresentations;
1273
+ private drainModelSelectionSettlements;
1274
+ private runModelSelectionSettlements;
1275
+ private assertActive;
1276
+ }
1277
+ export declare const Config: Schema<Config>;
1278
+ export {};
1279
+ //# sourceMappingURL=service.d.ts.map