@dsh-enhanced/assistant-delivery 0.1.65 → 0.1.67

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 (101) hide show
  1. package/README.md +128 -4
  2. package/lib/agent-runtime.d.ts +6 -2
  3. package/lib/agent-runtime.d.ts.map +1 -1
  4. package/lib/agent-runtime.js +60 -14
  5. package/lib/agent-runtime.js.map +1 -1
  6. package/lib/attention-audit-store.d.ts +54 -0
  7. package/lib/attention-audit-store.d.ts.map +1 -0
  8. package/lib/attention-audit-store.js +213 -0
  9. package/lib/attention-audit-store.js.map +1 -0
  10. package/lib/attention-enforcement.d.ts +75 -0
  11. package/lib/attention-enforcement.d.ts.map +1 -0
  12. package/lib/attention-enforcement.js +84 -0
  13. package/lib/attention-enforcement.js.map +1 -0
  14. package/lib/attention.d.ts +203 -0
  15. package/lib/attention.d.ts.map +1 -0
  16. package/lib/attention.js +288 -0
  17. package/lib/attention.js.map +1 -0
  18. package/lib/coordinator.d.ts.map +1 -1
  19. package/lib/coordinator.js +6 -0
  20. package/lib/coordinator.js.map +1 -1
  21. package/lib/feedback-command.d.ts +23 -0
  22. package/lib/feedback-command.d.ts.map +1 -1
  23. package/lib/feedback-command.js +176 -0
  24. package/lib/feedback-command.js.map +1 -1
  25. package/lib/foreground-observation.d.ts +21 -0
  26. package/lib/foreground-observation.d.ts.map +1 -1
  27. package/lib/foreground-observation.js.map +1 -1
  28. package/lib/foreground-termination.d.ts +31 -0
  29. package/lib/foreground-termination.d.ts.map +1 -0
  30. package/lib/foreground-termination.js +42 -0
  31. package/lib/foreground-termination.js.map +1 -0
  32. package/lib/in-process-reload-runtime.d.ts +87 -0
  33. package/lib/in-process-reload-runtime.d.ts.map +1 -0
  34. package/lib/in-process-reload-runtime.js +319 -0
  35. package/lib/in-process-reload-runtime.js.map +1 -0
  36. package/lib/index.d.ts +20 -6
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/index.js +9 -3
  39. package/lib/index.js.map +1 -1
  40. package/lib/native-termination.d.ts +12 -0
  41. package/lib/native-termination.d.ts.map +1 -0
  42. package/lib/native-termination.js +57 -0
  43. package/lib/native-termination.js.map +1 -0
  44. package/lib/native-web-owner.d.ts +7 -0
  45. package/lib/native-web-owner.d.ts.map +1 -1
  46. package/lib/native-web-owner.js +40 -10
  47. package/lib/native-web-owner.js.map +1 -1
  48. package/lib/operator-snapshot.d.ts +31 -3
  49. package/lib/operator-snapshot.d.ts.map +1 -1
  50. package/lib/operator-snapshot.js +120 -47
  51. package/lib/operator-snapshot.js.map +1 -1
  52. package/lib/progress-attention.d.ts +55 -0
  53. package/lib/progress-attention.d.ts.map +1 -0
  54. package/lib/progress-attention.js +128 -0
  55. package/lib/progress-attention.js.map +1 -0
  56. package/lib/service.d.ts +515 -4
  57. package/lib/service.d.ts.map +1 -1
  58. package/lib/service.js +2183 -130
  59. package/lib/service.js.map +1 -1
  60. package/lib/sqlite.d.ts +1 -1
  61. package/lib/sqlite.d.ts.map +1 -1
  62. package/lib/sqlite.js +102 -2
  63. package/lib/sqlite.js.map +1 -1
  64. package/lib/store.d.ts +113 -2
  65. package/lib/store.d.ts.map +1 -1
  66. package/lib/store.js +450 -39
  67. package/lib/store.js.map +1 -1
  68. package/lib/types.d.ts +175 -0
  69. package/lib/types.d.ts.map +1 -1
  70. package/lib/types.js.map +1 -1
  71. package/lib/version.d.ts +1 -1
  72. package/lib/version.js +1 -1
  73. package/lib/work-item-engineering-context.d.ts +127 -0
  74. package/lib/work-item-engineering-context.d.ts.map +1 -0
  75. package/lib/work-item-engineering-context.js +151 -0
  76. package/lib/work-item-engineering-context.js.map +1 -0
  77. package/lib/work-item-feedback-schema.d.ts +2 -0
  78. package/lib/work-item-feedback-schema.d.ts.map +1 -0
  79. package/lib/work-item-feedback-schema.js +29 -0
  80. package/lib/work-item-feedback-schema.js.map +1 -0
  81. package/lib/work-item-feedback-store.d.ts +29 -0
  82. package/lib/work-item-feedback-store.d.ts.map +1 -0
  83. package/lib/work-item-feedback-store.js +111 -0
  84. package/lib/work-item-feedback-store.js.map +1 -0
  85. package/lib/work-item-feedback.d.ts +157 -0
  86. package/lib/work-item-feedback.d.ts.map +1 -0
  87. package/lib/work-item-feedback.js +2 -0
  88. package/lib/work-item-feedback.js.map +1 -0
  89. package/lib/work-item-replies-schema.d.ts +3 -0
  90. package/lib/work-item-replies-schema.d.ts.map +1 -0
  91. package/lib/work-item-replies-schema.js +45 -0
  92. package/lib/work-item-replies-schema.js.map +1 -0
  93. package/lib/work-item-replies-store.d.ts +43 -0
  94. package/lib/work-item-replies-store.d.ts.map +1 -0
  95. package/lib/work-item-replies-store.js +203 -0
  96. package/lib/work-item-replies-store.js.map +1 -0
  97. package/lib/work-item-replies.d.ts +93 -0
  98. package/lib/work-item-replies.d.ts.map +1 -0
  99. package/lib/work-item-replies.js +15 -0
  100. package/lib/work-item-replies.js.map +1 -0
  101. package/package.json +24 -24
package/lib/service.d.ts CHANGED
@@ -1,3 +1,6 @@
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';
1
4
  import { Context, Service } from '@deepseek-ai/cordis';
2
5
  import type { Agent } from '@deepseek-ai/dsh-agent';
3
6
  import type { ToolDefinition, ToolExecution } from '@deepseek-ai/dsh-tools';
@@ -5,7 +8,7 @@ import Schema from '@deepseek-ai/schemastery';
5
8
  import { type RestartRecord } from './restart-store.js';
6
9
  import { type RestartConfig } from './restart-runtime.js';
7
10
  import { type ApprovalDispatchRouteV2, type AssistantPolicyService } from '@dsh-enhanced/assistant-policy';
8
- import type { TrustedTaskLearningProjectionReceipt, TrustedDeliveryEvaluationRegistration } from '@dsh-enhanced/assistant-evaluation';
11
+ import type { TrustedTaskLearningProjectionReceipt, TrustedDeliveryEvaluationClaims, TrustedDeliveryEvaluationRegistration } from '@dsh-enhanced/assistant-evaluation';
9
12
  import { type GrowthWorkflowTraceSourceRegistration, type ResolvedWorkflowAutomationTemplate, type WorkflowAutomationTemplate, type WorkflowScope, type WorkflowTraceSink } from '@dsh-enhanced/assistant-growth-contract';
10
13
  import { type InboundMessageProcessor } from './coordinator.js';
11
14
  import { DeliveryStore, type CommitOwnerAnchoredWorkflowTraceResult } from './store.js';
@@ -13,9 +16,12 @@ import type { OwnerApprovalStatusRead } from './approval-status-context.js';
13
16
  import { type NativeWebOwnerConfig, type NativeWebOwnerAccess } from './native-web-owner.js';
14
17
  import { type DeliveryGoalWakeInput, type DeliveryGoalWakeResult } from './goal-wake-types.js';
15
18
  import type { AcceptanceContract, TaskAcceptanceRegistration } from './acceptance.js';
16
- import { type ForegroundTaskObservationRegistration, type ForegroundToolCallAttestation } from './foreground-observation.js';
19
+ import { type ForegroundTaskObservationRegistration, type ForegroundToolCallAttestation, type OwnerForegroundToolInput } from './foreground-observation.js';
20
+ import { NOTIFICATION_OUTCOME_FACTS_PROTOCOL, type AttentionAuditEntry, type AttentionEnvelope, type NotificationOutcomeFact } from './attention.js';
21
+ import { type ProgressAttentionAuditPage } from './progress-attention.js';
22
+ import { type AttentionRejectionEntry, type AttentionRejectionPage, type AttentionRejectionReason } from './attention-enforcement.js';
17
23
  import { type ReplyReplayBlockConfig, type ReplyReplayBlockHandle } from './reply-replay.js';
18
- import type { ConversationBinding, DeliveryAdapter, DeadLetterResolutionResult, DeliveryPreferenceRegistration, DeliveryPreferenceProducer, DeliveryPreferencePrincipalAttestation, DeliveryPreferenceTurnAttestation, ExternalPrincipalKey, InboundEnvelope, InboxRecord, ModelPickerIntent, ModelPickerState, ModelRouteRef, ModelSelectionResult, ModelSelectionSettlementInput, ModelSelectionTerminalResult, OwnerRouteAuthority, OwnerForegroundTaskSourceScope, OwnerForegroundTaskSource, OwnerForegroundTaskSourceCursor, OwnerForegroundTaskSourcePage, OwnerForegroundTaskSourceContent, OwnerForegroundTaskSourceRef, OwnerApprovalForPreferenceInput, OwnerApprovalForPreferenceResult, OwnerRouteValidationReceipt, OutboxRecord, PairingChallenge, PermissionPickerIntent, ResolvedOwnerRoute, StoredDeliveryPresentation, TrustedDeliveryPresentationRegistration } from './types.js';
24
+ import type { ConversationBinding, DeliveryAdapter, DeadLetterResolutionResult, DeliveryPreferenceRegistration, DeliveryPreferenceProducer, DeliveryPreferencePrincipalAttestation, DeliveryPreferenceTurnAttestation, DeliveryInboundIntakeObserver, ExternalPrincipalKey, InboundEnvelope, InboxRecord, ModelPickerIntent, ModelPickerState, ModelRouteRef, ModelSelectionResult, ModelSelectionSettlementInput, ModelSelectionTerminalResult, OwnerRouteAuthority, OwnerForegroundTaskSourceScope, OwnerForegroundTaskSource, OwnerForegroundTaskSourceCursor, OwnerForegroundTaskSourcePage, OwnerForegroundTaskSourceContent, OwnerForegroundTaskInput, OwnerForegroundTaskSourceRef, OwnerApprovalForPreferenceInput, OwnerApprovalForPreferenceResult, OwnerAliasForegroundToolCallAttestation, OwnerAliasReceipt, OwnerRouteStateInspection, OwnerRouteValidationReceipt, OwnerRouteBindingReceipt, OutboxRecord, PairingChallenge, PermissionPickerIntent, ResolvedOwnerRoute, StoredDeliveryPresentation, TrustedDeliveryPresentationRegistration } from './types.js';
19
25
  /** A wake finalizes an already-flushed native Web reply, or creates one external outbox intent. */
20
26
  export type DeliveryGoalWakeResultPublication = OutboxRecord | Readonly<{
21
27
  kind: 'native-session';
@@ -63,6 +69,18 @@ export interface OwnerForegroundLearningTask {
63
69
  }>;
64
70
  }>;
65
71
  }
72
+ /**
73
+ * One explicitly allowlisted provider bot. The exact channel/account/tenant/user
74
+ * tuple is the trust anchor; `senderIsBot` only labels the provider's declaration.
75
+ * A peer keeps its own Policy subject and conversation binding, so it never
76
+ * inherits the owner's tools, memory, work-item feedback or continuation lanes.
77
+ */
78
+ export interface PeerAgentAuthority {
79
+ readonly channel: string;
80
+ readonly account: string;
81
+ readonly tenant: string;
82
+ readonly user: string;
83
+ }
66
84
  export interface Config {
67
85
  databasePath: string;
68
86
  spoolPath: string;
@@ -96,6 +114,52 @@ export interface Config {
96
114
  toolApprovalPreparationTimeoutMs?: number;
97
115
  /** Host-owned stable routes. They are never exposed as Agent tools or prompt input. */
98
116
  ownerRoutes?: readonly OwnerRouteAuthority[];
117
+ /**
118
+ * WP19 stage 2b opt-in (default off): over-cap background/owner notices are
119
+ * queued as a short body plus a text attachment, and a burst of inline
120
+ * notices that together exceed the cap is rejected as split evasion.
121
+ */
122
+ attentionAttachOverCap?: boolean;
123
+ /**
124
+ * WP19 stage 3 opt-in (default off): background/owner notices whose purpose
125
+ * is missing or fails the Host checks are rejected before they are queued,
126
+ * as are over-cap notices unless `attentionAttachOverCap` attaches them.
127
+ */
128
+ attentionEnforce?: boolean;
129
+ /**
130
+ * Opt-in (default off): `routeWorkItemReport` keeps a report on the route of
131
+ * the same item's earlier still-unsettled report, so one lane orders both.
132
+ */
133
+ ownerReportRouting?: {
134
+ orderAcrossLanes?: boolean;
135
+ };
136
+ /**
137
+ * Opt-in (default off): widen the deterministic grammar for authenticated
138
+ * owner replies to one exact result. Off means the legacy exact-phrase parser
139
+ * and its admission fences are unchanged.
140
+ * - `coverage`: accept synonym/multilingual result assertions plus an
141
+ * untrusted trailing reason/evidence clause. Questions, hypotheticals,
142
+ * quoted prose, negated reports, contradictions, hedges and withdrawal
143
+ * commands still abstain.
144
+ * - `mixedIntent`: when one authenticated work-item report reply carries a
145
+ * result assertion and an explicit continuation request, record the
146
+ * canonical result and admit the continuation as two independent decisions
147
+ * (each with its own permission, idempotency, budget fence and target). If
148
+ * one lane is not permitted the other still proceeds and the partial
149
+ * admission is recorded. Ignored unless `coverage` is also on.
150
+ */
151
+ naturalFeedback?: {
152
+ coverage?: boolean;
153
+ mixedIntent?: boolean;
154
+ };
155
+ /**
156
+ * Opt-in peer-agent allowlist (default empty). A group message whose provider
157
+ * envelope carries `senderIsBot=true` and whose exact principal tuple is
158
+ * listed here is admitted into its own linked-principal lane. The peer keeps a
159
+ * distinct Policy subject and never inherits owner tools, memory, work-item
160
+ * feedback or continuation lanes. No peer is trusted by default.
161
+ */
162
+ peerAgents?: readonly PeerAgentAuthority[];
99
163
  }
100
164
  export interface DeliveryInboundRuntime extends InboundMessageProcessor {
101
165
  canRequestRestart?(agent: Agent): boolean;
@@ -119,10 +183,90 @@ export interface DeliveryInboundRuntime extends InboundMessageProcessor {
119
183
  cancelActive?(binding: Readonly<ConversationBinding>, cause: 'new' | 'stop'): boolean | Promise<boolean>;
120
184
  }
121
185
  export type AssistantDeliveryErrorCode = 'disposed' | 'missing-binding' | 'policy-denied' | 'runtime-conflict' | 'runtime-unavailable';
186
+ /**
187
+ * Send-time withdrawal check for owner notices queued with `withdrawable`.
188
+ * `isWithdrawn` must be synchronous, side-effect free and keyed only by the
189
+ * notice's idempotency key. A withdrawable notice is never sent while no
190
+ * check is registered for its authority and source, or while the check
191
+ * throws; it is withdrawn (dead, never sent) once the check returns true.
192
+ *
193
+ * `authority` names the Cordis service slot that owns the check. Delivery
194
+ * accepts the registration only when the service currently in that slot
195
+ * vouches for this exact object through `ownsOwnerNotificationWithdrawal`
196
+ * (the same slot-anchored ownership proof the task-acceptance sink uses), so
197
+ * a plugin that does not occupy the slot cannot register for it.
198
+ */
199
+ export interface OwnerNotificationWithdrawal {
200
+ readonly protocol: typeof ownerNotificationWithdrawalProtocol;
201
+ readonly authority: string;
202
+ readonly sourceId: string;
203
+ isWithdrawn(idempotencyKey: string): boolean;
204
+ }
205
+ export declare const ownerNotificationWithdrawalProtocol: "assistant-delivery/owner-notification-withdrawal/v1";
206
+ /**
207
+ * Live registration returned to the owner. `handle` is an unguessable
208
+ * process-local capability: enqueueing a `withdrawable` notice and inspecting
209
+ * notices both require it. Notices are bound to the stable
210
+ * (authority, source) pair, not to the handle, so a restart or a later
211
+ * registration by the same authority takes over notices already queued.
212
+ */
213
+ export interface OwnerNotificationWithdrawalBinding {
214
+ readonly handle: string;
215
+ unregister(): void;
216
+ }
217
+ /** Read-only view of an owner notice found by its idempotency key; carries no text. */
218
+ export interface OwnerNotificationRecordView {
219
+ readonly outboxId: string;
220
+ readonly status: OutboxRecord['status'];
221
+ }
222
+ export declare const ownerNotificationReplyProtocol: "assistant-delivery/owner-notification-reply/v1";
223
+ /**
224
+ * Slice 5: authenticated owner reply handed to the consumer registered for
225
+ * the owner-notice source that produced the quoted message. Delivery has
226
+ * already matched the unique accepted/delivered/read Outbox by provider
227
+ * message id, the notice source, its authority, the frozen owner lineage,
228
+ * the registration's idempotency-key prefix and an `allow` Policy decision.
229
+ */
230
+ export interface OwnerNotificationReplyInput {
231
+ readonly inboxId: string;
232
+ readonly envelopeHash: string;
233
+ readonly outboxId: string;
234
+ readonly providerMessageId: string;
235
+ readonly idempotencyKey: string;
236
+ readonly sourceId: string;
237
+ readonly principalId: string;
238
+ readonly text: string;
239
+ readonly receivedAt: number;
240
+ }
241
+ /**
242
+ * `applied`: the consumer durably applied the reply; Delivery marks the Inbox
243
+ * processed. `ignored`: fall through to ordinary inbound handling. `transient`:
244
+ * the Inbox stays pending so the same reply is retried on provider redelivery
245
+ * or the next pending-inbound recovery.
246
+ */
247
+ export type OwnerNotificationReplyOutcome = 'applied' | 'ignored' | 'transient';
248
+ export interface OwnerNotificationReply {
249
+ readonly protocol: typeof ownerNotificationReplyProtocol;
250
+ /** Cordis slot that owns the consumer; Delivery vouches the exact object there. */
251
+ readonly authority: string;
252
+ readonly sourceId: string;
253
+ /** Only notices whose idempotency key starts with this prefix are matched. */
254
+ readonly idempotencyKeyPrefix: string;
255
+ consume(input: Readonly<OwnerNotificationReplyInput>): OwnerNotificationReplyOutcome;
256
+ }
257
+ export interface OwnerNotificationReplyBinding {
258
+ unregister(): void;
259
+ }
122
260
  export declare class AssistantDeliveryError extends Error {
123
261
  readonly code: AssistantDeliveryErrorCode;
124
262
  constructor(code: AssistantDeliveryErrorCode, message: string);
125
263
  }
264
+ /** WP19 stage 3 rejection: `policy-denied` with structured reason codes; nothing was queued. */
265
+ export declare class AttentionRejectedError extends AssistantDeliveryError {
266
+ readonly rejection: Readonly<AttentionRejectionEntry>;
267
+ readonly reasons: readonly AttentionRejectionReason[];
268
+ constructor(rejection: Readonly<AttentionRejectionEntry>, message?: string);
269
+ }
126
270
  /**
127
271
  * Structural mirrors of the Goals Host-only evidence shapes. Delivery must not
128
272
  * import `@dsh-enhanced/assistant-goals` types for this seam: goals' public
@@ -221,14 +365,34 @@ export declare class AssistantDeliveryService extends Service {
221
365
  private readonly preferenceProducerGeneration;
222
366
  private readonly acceptanceProducerGeneration;
223
367
  private acceptanceSink;
368
+ private workItemReplyConsumer;
369
+ private inboundIntakeObserver;
370
+ /** Send-time withdrawal checks for `withdrawable` owner notices, one per (authority, canonical source id). */
371
+ private readonly ownerNotificationWithdrawals;
372
+ /** Live handles issued by `registerOwnerNotificationWithdrawal`, mapped to their (authority, source) key. */
373
+ private readonly ownerNotificationWithdrawalHandles;
374
+ /** Slice-5 reply consumers, one per (authority, canonical owner-notice source id). */
375
+ private readonly ownerNotificationReplies;
224
376
  private foregroundObserver;
225
377
  /** Once a live verifier required acceptance, loss of that verifier must not silently bypass it. */
226
378
  private acceptanceRequired;
227
379
  private readonly preferenceTurns;
380
+ /** Claimed human turns of linked owner aliases; read-only alias inspection only. */
381
+ private readonly aliasTurns;
228
382
  private readonly goalWakeResults;
229
383
  private modelSelectionFlight;
230
384
  private presentationFlight;
231
385
  private workflowTraceFlight;
386
+ private workItemFeedbackFlight;
387
+ private workItemFeedbackCursor;
388
+ private workItemFeedbackAckCursor;
389
+ /** WP19 stage 1: audit writes never affect delivery; failures are counted in this process only (reset on restart). */
390
+ private attentionAuditWriteFailures;
391
+ /** WP19 stage 2c: process-local progress attention audit (no Delivery schema change). */
392
+ private readonly progressAttentionAudit;
393
+ private progressAttentionAuditFailures;
394
+ /** WP19 stage 3: process-local rejection log (rejected notices have no Outbox row). */
395
+ private readonly attentionRejections;
232
396
  private naturalObjectiveFlight;
233
397
  private preferenceProjectionFlight;
234
398
  private inboundAdmissionRecoveryFlight;
@@ -348,6 +512,17 @@ export declare class AssistantDeliveryService extends Service {
348
512
  toolName: string;
349
513
  argumentsJson: string;
350
514
  }>): Readonly<ForegroundToolCallAttestation> | undefined;
515
+ /** Read-only pages of this exact live owner's persisted human input. Callers
516
+ * cannot select an Inbox, path, owner, or replacement text through this API. */
517
+ readOwnerForegroundToolInput(input: Readonly<{
518
+ agent: Agent;
519
+ authorityId: string;
520
+ callId: string;
521
+ toolName: string;
522
+ argumentsJson: string;
523
+ offset?: number;
524
+ maxBytes?: number;
525
+ }>): Readonly<OwnerForegroundToolInput> | undefined;
351
526
  /** Host-only, read-only source proof for an owner's live memory or wiki tool call. */
352
527
  inspectOwnerRequestedChange(execution: ToolExecution, input: {
353
528
  sourceId: string;
@@ -429,6 +604,11 @@ export declare class AssistantDeliveryService extends Service {
429
604
  private assertCurrentPresentationProducer;
430
605
  private publishTrustedDeliveryPresentation;
431
606
  private progressAuthorized;
607
+ /**
608
+ * Exact owner-configured peer bot, or `undefined`. `senderIsBot` is only the
609
+ * provider's declaration; the allowlisted tuple is the actual authority.
610
+ */
611
+ private peerAgentAuthority;
432
612
  private isInboundAuthorized;
433
613
  private isPermissionController;
434
614
  private isOwnerFeedbackController;
@@ -439,6 +619,16 @@ export declare class AssistantDeliveryService extends Service {
439
619
  private dispatchLearningCommand;
440
620
  private completedPreferenceEvents;
441
621
  private dispatchWorkflowCommand;
622
+ /** Opt-in widened deterministic grammar; off keeps the legacy exact phrases. */
623
+ private widenedNaturalFeedbackCoverage;
624
+ /** Splitting one reply into result + continuation requires both opt-ins. */
625
+ private mixedNaturalFeedbackIntent;
626
+ /**
627
+ * One canonical selection for admission and its later re-derivation fences.
628
+ * The widened parser is a pure function, so a frozen intent keeps verifying
629
+ * even after a restart that toggles the opt-in.
630
+ */
631
+ private naturalObjectiveSelection;
442
632
  /**
443
633
  * Convert only an authenticated reply to one exact Automation delivery into
444
634
  * a trusted objective label. The original run timestamp is retained because
@@ -468,6 +658,129 @@ export declare class AssistantDeliveryService extends Service {
468
658
  inboxId: string;
469
659
  status: InboxRecord['status'];
470
660
  }>;
661
+ /**
662
+ * Deterministic backend classification of one authenticated owner reply to an
663
+ * exact report. The legacy closed whole-sentence grammar stays in force unless
664
+ * the widened coverage opt-in is on; no caller text is reinterpreted as an
665
+ * instruction, and no model is called.
666
+ */
667
+ private parseWorkItemFeedback;
668
+ private workItemFeedbackPermission;
669
+ /**
670
+ * Inspect one Inbox as an authenticated owner result reply to an exact report.
671
+ * `ready` carries the frozen source plus its live admission fence; `ordinary`
672
+ * keeps the historical "recognized result but separate feedback permission
673
+ * absent" outcome and never admits the result lane by itself. The
674
+ * `continuation` flag is a deterministic classification only.
675
+ */
676
+ private inspectOwnerWorkItemFeedback;
677
+ /** One deterministic, non-durable record when a mixed reply could only admit one lane. */
678
+ private recordPartialMixedFeedbackAdmission;
679
+ /** Passing an explicit registration makes this the callback-free final local authority check. */
680
+ private workItemFeedbackFence;
681
+ private workItemFeedbackProof;
682
+ private drainWorkItemFeedback;
683
+ private runWorkItemFeedback;
684
+ private drainWorkItemFeedbackAcks;
685
+ withOwnerWorkItemFeedbackWriterFence<T>(registration: Readonly<TrustedDeliveryEvaluationRegistration>, claims: Readonly<TrustedDeliveryEvaluationClaims>, proofDigest: string, callback: () => T): T;
686
+ workItemReplyProtocolVersion(): 1;
687
+ private currentWorkItemReplyConsumer;
688
+ registerWorkItemReplyConsumer(registration: WorkItemReplyConsumerRegistration): () => void;
689
+ /**
690
+ * WP20 intake: one observer, owned by the current WorkItems service, receives
691
+ * a metadata-only signal per adapter observation. Delivery adds only the
692
+ * read-only allowlist and tracked-report-thread facts; it writes nothing.
693
+ */
694
+ registerInboundIntakeObserver(observer: DeliveryInboundIntakeObserver): () => void;
695
+ private currentInboundIntakeObserver;
696
+ /** Best-effort and side-effect free: any invalid input or observer failure is dropped. */
697
+ private observeInbound;
698
+ private inboundIntakeSignal;
699
+ private notifyWorkItemReplyPending;
700
+ private notifyWorkItemReplyCancellation;
701
+ private inspectWorkItemReport;
702
+ enqueueWorkItemReport(input: {
703
+ sourceId: string;
704
+ workspace: string;
705
+ bindingId: string;
706
+ idempotencyKey: string;
707
+ text: string;
708
+ format?: 'markdown' | 'plain';
709
+ metadata?: Readonly<Record<string, string>>;
710
+ itemId: string;
711
+ reportRevision: number;
712
+ }): OutboxRecord;
713
+ /**
714
+ * Host-only cross-channel route for one background work-item report.
715
+ *
716
+ * The origin binding always wins (default prefer): while it is active with an active
717
+ * principal this returns `{ route: 'origin' }` and enqueues nothing, so the
718
+ * caller keeps its existing origin path unchanged. Only when the origin is
719
+ * unavailable does the Host walk the owner's explicit `linkedFallback` list
720
+ * (Delivery principal ids, in order) and pick the first alias that is still
721
+ * an active `linked` row of the CURRENT owner record, with exactly one active
722
+ * binding in the origin workspace/preset, and that existing Policy already
723
+ * allows to receive this source's sends. The report is queued on the plain
724
+ * background lane, never the typed report lane, so a reply on the fallback
725
+ * channel can never continue or give feedback on the item. The queued row
726
+ * binds the owner and alias record versions plus the alias binding
727
+ * version/generation; the send-time guard drops it after any revoke or
728
+ * relink. A replay returns the first committed destination.
729
+ *
730
+ * Opt-in `prefer: 'recent'` instead ranks eligible aliases by the owner's
731
+ * newest inbound message (`inbox_messages.received_at`); an available origin
732
+ * still wins unless an eligible alias received strictly newer inbound, and
733
+ * also when that alias is refused before its linked row commits.
734
+ *
735
+ * Opt-in `ownerReportRouting.orderAcrossLanes` (Delivery config) keeps one
736
+ * item's reports in revision order across channels: when an earlier report
737
+ * of the same item is still unsettled, the new one sticks to that route
738
+ * (same origin, or same alias while it is still eligible and owner-listed)
739
+ * so the existing per-lane claim order sends it after. A sticky origin also
740
+ * overrides `prefer: 'recent'`. An unusable sticky route falls back to the
741
+ * rules above, so ordering never blocks delivery.
742
+ */
743
+ routeWorkItemReport(input: Readonly<{
744
+ sourceId: string;
745
+ workspace: string;
746
+ originBindingId: string;
747
+ idempotencyKey: string;
748
+ text: string;
749
+ format?: 'markdown' | 'plain';
750
+ itemId: string;
751
+ reportRevision: number;
752
+ linkedFallback: readonly string[];
753
+ prefer?: 'origin' | 'recent';
754
+ }>): Readonly<{
755
+ route: 'origin';
756
+ } | {
757
+ route: 'linked';
758
+ outbox: OutboxRecord;
759
+ }>;
760
+ private linkedReportSendAllowed;
761
+ /** Send-time re-check of a linked report route; any revoke, relink or Policy change drops it. */
762
+ private linkedReportGuard;
763
+ private workItemReplyPermission;
764
+ /**
765
+ * Validate the continuation lane of one reply to an exact report without
766
+ * writing it. Mixed-intent admission reuses this report inside its combined
767
+ * transaction; the ordinary path admits it through `admitWorkItemReply`.
768
+ */
769
+ private prepareWorkItemReply;
770
+ private admitWorkItemReply;
771
+ private workItemReplyFence;
772
+ private validateWorkItemReply;
773
+ listPendingWorkItemReplies(input: WorkItemReplyListInput): {
774
+ items: readonly WorkItemReplySource[];
775
+ hasMore: boolean;
776
+ nextAfterSequence: number | null;
777
+ };
778
+ readWorkItemReply(input: WorkItemReplyReadInput): WorkItemReplySource;
779
+ selectWorkItemReplyParent(input: WorkItemReplyReadInput): WorkItemReplySource;
780
+ acknowledgeWorkItemReply(input: WorkItemReplyReadInput & {
781
+ childItemId: string;
782
+ childPlanDigest: string;
783
+ }): WorkItemReplySource;
471
784
  enqueueBackground(input: {
472
785
  sourceId: string;
473
786
  workspace: string;
@@ -476,7 +789,79 @@ export declare class AssistantDeliveryService extends Service {
476
789
  text: string;
477
790
  format?: 'markdown' | 'plain';
478
791
  metadata?: Readonly<Record<string, string>>;
792
+ /** WP19 stage 1: audited only; omission records `missing-purpose`. */
793
+ attention?: AttentionEnvelope;
479
794
  }): OutboxRecord;
795
+ /**
796
+ * Record the WP19 stage-1 verdict for one queued Outbox record. Audit only:
797
+ * the record is returned unchanged and any audit failure is swallowed.
798
+ */
799
+ private auditAttention;
800
+ /**
801
+ * WP19 stage 2b, only when `attentionAttachOverCap` is on: convert an
802
+ * over-cap notice to a short body plus one text attachment (never split),
803
+ * and reject an inline notice that, with recent inline notices from the same
804
+ * source, binding and lane, exceeds the cap of its purpose. Deterministic for
805
+ * one (input, audited history, clock). Off: the input is returned unchanged,
806
+ * except that a replay of an already converted key keeps its stored form.
807
+ * WP19 stage 3, only when `attentionEnforce` is on: a new notice with a
808
+ * missing or failed purpose, or over cap without the attachment path, is
809
+ * rejected with `AttentionRejectedError` and nothing is queued. Replays
810
+ * return above before any check, so an existing key stays idempotent.
811
+ */
812
+ private prepareAttentionDelivery;
813
+ /**
814
+ * Read-only WP19 stage-1 audit page in append order; never exposes message text.
815
+ * `processLocalWriteFailures` counts failed audit writes since this Host started;
816
+ * `unauditedOutbox` is derived from durable rows on every call (see
817
+ * `AttentionAuditStore.unauditedOutboxCount` for which lanes it can see).
818
+ */
819
+ inspectAttentionAudit(input?: Readonly<{
820
+ afterSequence?: number;
821
+ limit?: number;
822
+ }>): Readonly<{
823
+ entries: readonly AttentionAuditEntry[];
824
+ hasMore: boolean;
825
+ nextAfterSequence: number | null;
826
+ processLocalWriteFailures: number;
827
+ unauditedOutbox: number;
828
+ }>;
829
+ /**
830
+ * WP22 read adapter for Evaluation: per-notification durable facts (transport,
831
+ * owner reply, current owner judgement) keyed by audited Outbox id. Read-only,
832
+ * text-free, and classification-free. Pass `outboxIds` (max 500) to refresh
833
+ * known notifications, or `afterSequence`/`limit` to page new audit rows.
834
+ */
835
+ inspectNotificationOutcomeFacts(input?: Readonly<{
836
+ afterSequence?: number;
837
+ limit?: number;
838
+ outboxIds?: readonly string[];
839
+ }>): Readonly<{
840
+ protocol: typeof NOTIFICATION_OUTCOME_FACTS_PROTOCOL;
841
+ facts: readonly NotificationOutcomeFact[];
842
+ hasMore: boolean;
843
+ nextAfterSequence: number | null;
844
+ }>;
845
+ /**
846
+ * Read-only WP19 stage-2c progress audit page in append order; never exposes
847
+ * progress text. Entries are process-local (`durable: false`), bounded, and
848
+ * reset on Host restart; `processLocalWriteFailures` counts failed records.
849
+ */
850
+ inspectProgressAttentionAudit(input?: Readonly<{
851
+ afterSequence?: number;
852
+ limit?: number;
853
+ }>): Readonly<ProgressAttentionAuditPage & {
854
+ processLocalWriteFailures: number;
855
+ }>;
856
+ /**
857
+ * Read-only WP19 stage-3 rejection page in append order; never exposes
858
+ * message text. Entries are process-local (`durable: false`), bounded, and
859
+ * reset on Host restart. Empty while `attentionEnforce` is off.
860
+ */
861
+ inspectAttentionRejections(input?: Readonly<{
862
+ afterSequence?: number;
863
+ limit?: number;
864
+ }>): AttentionRejectionPage;
480
865
  private enqueueBackgroundAuthorized;
481
866
  /** Queue a typed owner notice. Accepted means queued; it never asserts user read. */
482
867
  enqueueOwnerNotification(input: {
@@ -493,7 +878,57 @@ export declare class AssistantDeliveryService extends Service {
493
878
  idempotencyKey: string;
494
879
  text: string;
495
880
  expiresAt: number;
881
+ attention?: AttentionEnvelope;
882
+ withdrawable?: boolean;
883
+ withdrawalHandle?: string;
496
884
  }): OutboxRecord;
885
+ /**
886
+ * Register the send-time withdrawal check for one owner-notice source (see
887
+ * `OwnerNotificationWithdrawal`). The service in the `authority` slot must
888
+ * vouch for the registration; one live check per (authority, source). A
889
+ * registration its authority no longer vouches for (owner restarted or
890
+ * replaced) is superseded by the next vouched one, so the legitimate owner
891
+ * regains control of notices already queued under its authority. After
892
+ * `unregister`, those notices wait instead of sending.
893
+ */
894
+ registerOwnerNotificationWithdrawal(registration: OwnerNotificationWithdrawal): OwnerNotificationWithdrawalBinding;
895
+ /** The service now in `authority`'s slot vouches for this exact registration object. */
896
+ private withdrawalVouched;
897
+ /** Live, still-vouched registration behind `handle`, for exactly `sourceId`. */
898
+ private liveWithdrawal;
899
+ /**
900
+ * Read-only lookup of an owner notice by idempotency key. The caller
901
+ * presents its withdrawal handle; the lookup is scoped to that handle's
902
+ * source and authority. A key held by another source, another authority,
903
+ * a non-withdrawable notice or a non-notice record reads as absent. Never
904
+ * returns text or metadata.
905
+ */
906
+ inspectOwnerNotification(input: Readonly<{
907
+ sourceId: string;
908
+ idempotencyKey: string;
909
+ withdrawalHandle: string;
910
+ }>): Readonly<OwnerNotificationRecordView> | undefined;
911
+ /**
912
+ * Register the slice-5 reply consumer for one owner-notice source (see
913
+ * `OwnerNotificationReply`). The service in the `authority` slot must vouch
914
+ * for the exact object; one live consumer per (authority, source). A
915
+ * registration its authority no longer vouches for is superseded by the
916
+ * next vouched one, so a restarted owner regains its replies without a new
917
+ * notice. Registering never sends anything and grants no send authority.
918
+ */
919
+ registerOwnerNotificationReply(registration: OwnerNotificationReply): OwnerNotificationReplyBinding;
920
+ /** The service now in `authority`'s slot vouches for this exact reply registration. */
921
+ private replyVouched;
922
+ /**
923
+ * Slice 5 matcher: bind one authenticated inbound text reply to exactly one
924
+ * accepted/delivered/read owner notice through `replyToProviderMessageId`,
925
+ * require the live registered consumer's source and idempotency-key prefix,
926
+ * an active owner binding/principal with the notice's frozen owner lineage,
927
+ * and an `allow` external `answer-attention-question` Policy decision. On
928
+ * `applied` the Inbox is marked processed; `transient` leaves it pending for
929
+ * a retry. Everything else falls through to ordinary inbound handling.
930
+ */
931
+ inspectOwnerQuestionReply(inbox: InboxRecord, binding: ConversationBinding): 'none' | 'handled' | 'transient';
497
932
  /**
498
933
  * Dedicated Automation result lane. Every learning field is derived from an
499
934
  * authoritative Automations receipt; callers cannot supply metadata,
@@ -508,6 +943,16 @@ export declare class AssistantDeliveryService extends Service {
508
943
  }): OutboxRecord;
509
944
  /** Resolve the current generation of one exact Host-owned owner route. */
510
945
  resolveOwnerRoute(authorityIdInput: string): ResolvedOwnerRoute;
946
+ /**
947
+ * Read-only Host observation of the configured owner, even after its binding
948
+ * has been revoked. Missing routes and transient failures are not revocation.
949
+ */
950
+ inspectOwnerRouteState(input: {
951
+ authorityId: string;
952
+ principalId: string;
953
+ workspace: string;
954
+ agentPreset: string;
955
+ }): OwnerRouteStateInspection;
511
956
  /**
512
957
  * Revalidate Recovery/other Host work against the live owner route without
513
958
  * exposing a session id, conversation id, user message or delivery content.
@@ -518,8 +963,44 @@ export declare class AssistantDeliveryService extends Service {
518
963
  workspace: string;
519
964
  agentPreset: string;
520
965
  }): Readonly<OwnerRouteValidationReceipt>;
966
+ /**
967
+ * Host-only: the same receipt as `validateOwnerRoute`, plus the id of the
968
+ * exact active binding it was resolved from (one resolve, so both describe
969
+ * the same route state). Not an Agent tool; same `missing-binding` errors.
970
+ */
971
+ inspectOwnerRouteBinding(input: {
972
+ authorityId: string;
973
+ principalId: string;
974
+ workspace: string;
975
+ agentPreset: string;
976
+ }): Readonly<OwnerRouteBindingReceipt>;
977
+ private ownerRouteReceipt;
521
978
  /** Host-only proof that the live caller Agent belongs to the current owner route. */
522
979
  validateOwnerAgentForRoute(agent: Agent, authorityId: string): ReturnType<AssistantDeliveryService['validateOwnerRoute']> | undefined;
980
+ /**
981
+ * Host-only, READ-ONLY proof that the live caller Agent is bound to an
982
+ * active `linked` principal whose `linked_to_id` is the CURRENT owner row of
983
+ * this owner route. The receipt has a distinct protocol and no
984
+ * `receiptVersion`, so v2 owner checks reject it; it never grants owner,
985
+ * approval, continuation or mutation authority. Every call re-reads the
986
+ * route, the root owner, the alias binding and the alias principal twice.
987
+ */
988
+ inspectOwnerAliasRoute(agent: Agent, authorityId: string): Readonly<OwnerAliasReceipt> | undefined;
989
+ /**
990
+ * Host-only proof of one live, unsettled native tool call in the alias's
991
+ * exact claimed human Inbox turn. Read-only; it is NOT an owner foreground
992
+ * proof (`assistant-delivery/foreground-tool-call/v1`) and must never be
993
+ * accepted where one is required.
994
+ */
995
+ inspectOwnerAliasForegroundToolCall(input: Readonly<{
996
+ agent: Agent;
997
+ authorityId: string;
998
+ callId: string;
999
+ toolName: string;
1000
+ argumentsJson: string;
1001
+ }>): Readonly<OwnerAliasForegroundToolCallAttestation> | undefined;
1002
+ private currentAliasTurn;
1003
+ private captureAliasTurn;
523
1004
  /** Host-only durable ordinary-turn metadata; never registered as a model tool. */
524
1005
  listOwnerForegroundTaskSources(input: OwnerForegroundTaskSourceScope & {
525
1006
  after?: Readonly<OwnerForegroundTaskSourceCursor>;
@@ -536,6 +1017,13 @@ export declare class AssistantDeliveryService extends Service {
536
1017
  maxInputBytes?: number;
537
1018
  maxReplyBytes?: number;
538
1019
  }): Readonly<OwnerForegroundTaskSourceContent> | undefined;
1020
+ /** Host-only bounded original input, independent of successful reply evidence. */
1021
+ readOwnerForegroundTaskInput(input: OwnerForegroundTaskSourceScope & {
1022
+ inboxId: string;
1023
+ expectedSourceDigest: string;
1024
+ offset?: number;
1025
+ maxBytes?: number;
1026
+ }): Readonly<OwnerForegroundTaskInput> | undefined;
539
1027
  /** Hold Delivery's owner/source writer fence across synchronous downstream adoption. */
540
1028
  withOwnerForegroundTaskSourceFence<T>(input: OwnerForegroundTaskSourceScope & {
541
1029
  inboxId: string;
@@ -547,6 +1035,12 @@ export declare class AssistantDeliveryService extends Service {
547
1035
  withOwnerForegroundTaskSourcesFence<T>(input: OwnerForegroundTaskSourceScope & {
548
1036
  sources: readonly Readonly<OwnerForegroundTaskSourceRef>[];
549
1037
  }, callback: (sources: readonly (Readonly<OwnerForegroundTaskSourceContent> | undefined)[]) => T): T;
1038
+ /** One Delivery → Evaluation → WorkItems source fence; callback must be local and synchronous. */
1039
+ withOwnerLearningSourcesFence<T>(input: OwnerForegroundTaskSourceScope & {
1040
+ sources: readonly OwnerLearningSourceExpectation[];
1041
+ }, callback: (sources: readonly OwnerLearningSourceSnapshot[]) => T): T;
1042
+ /** Strict single-source wrapper: unavailable or changed sources never invoke the callback. */
1043
+ withOwnerWorkItemLearningTaskFence<T>(input: OwnerWorkItemLearningTaskFenceInput, callback: (task: Readonly<OwnerWorkItemLearningTask>) => T): T;
550
1044
  /** Host-only snapshot of the model selected for this owner's external conversation. */
551
1045
  inspectOwnerModelSelection(input: {
552
1046
  authorityId: string;
@@ -556,10 +1050,24 @@ export declare class AssistantDeliveryService extends Service {
556
1050
  sourceAgent?: Agent;
557
1051
  }): Readonly<ModelRouteRef>;
558
1052
  /**
559
- * Resolve one canonical foreground result against its actual owner lineage.
1053
+ * Resolve one canonical work-item result against its actual owner lineage.
560
1054
  * Evaluation's workspace/preset scope alone does not establish ownership.
561
1055
  * Historical Sessions remain eligible after /new, but not after owner ABA.
562
1056
  */
1057
+ inspectOwnerWorkItemLearningTask(input: {
1058
+ authorityId: string;
1059
+ principalId: string;
1060
+ workspace: string;
1061
+ agentPreset: string;
1062
+ outcomeId: string;
1063
+ }): Readonly<OwnerWorkItemLearningTask> | undefined;
1064
+ private ownerWorkItemLearningTaskState;
1065
+ /** Host-only complete historical objective; old feedback and Memory identities are not reinterpreted. */
1066
+ inspectOwnerWorkItemEngineeringContext(input: OwnerWorkItemEngineeringContextLocator): Readonly<OwnerWorkItemEngineeringContext> | undefined;
1067
+ /** Every page, including the last, revalidates the entire exact source frame. */
1068
+ readOwnerWorkItemEngineeringContext(input: OwnerWorkItemEngineeringContextReadInput): Readonly<OwnerWorkItemEngineeringContextPage> | undefined;
1069
+ withOwnerWorkItemEngineeringContextFence<T>(input: OwnerWorkItemEngineeringContextExpectation, callback: (source: Readonly<OwnerWorkItemEngineeringContextSource>) => T): T;
1070
+ private withOwnerWorkItemEngineeringContextSource;
563
1071
  inspectOwnerForegroundLearningTask(input: {
564
1072
  authorityId: string;
565
1073
  principalId: string;
@@ -579,6 +1087,8 @@ export declare class AssistantDeliveryService extends Service {
579
1087
  idempotencyKey: string;
580
1088
  text: string;
581
1089
  format?: 'markdown' | 'plain';
1090
+ /** WP19 stage 1: audited only; omission records `missing-purpose`. */
1091
+ attention?: AttentionEnvelope;
582
1092
  }): OutboxRecord;
583
1093
  enqueueApproval(input: {
584
1094
  route: Readonly<ApprovalDispatchRouteV2>;
@@ -660,6 +1170,7 @@ export declare class AssistantDeliveryService extends Service {
660
1170
  private recoverPendingInbound;
661
1171
  private runConversationTransition;
662
1172
  private rotateBinding;
1173
+ private clearSchedulerTimers;
663
1174
  private stopInternal;
664
1175
  private drainPreferenceProjections;
665
1176
  private runPreferenceProjection;