@gestaltrun/dsh-im-runtime 0.0.0-stage → 0.1.5

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 (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +58 -0
  3. package/README.md +290 -2
  4. package/README.zh.md +290 -0
  5. package/UPSTREAM.json +66 -0
  6. package/lib/index.js +140 -0
  7. package/lib/inline-image-DuX6vSEI.js +20 -0
  8. package/lib/read-receipts.js +413 -0
  9. package/lib/read-state-CnUZKCuY.js +1868 -0
  10. package/lib/runtime-Bm6iSEpv.js +10939 -0
  11. package/lib/tools.js +2 -0
  12. package/lib/types/account-placement.d.ts +22 -0
  13. package/lib/types/admission-annotations.d.ts +40 -0
  14. package/lib/types/agent-coordinator.d.ts +129 -0
  15. package/lib/types/agent-media.d.ts +46 -0
  16. package/lib/types/agent-prompt.d.ts +24 -0
  17. package/lib/types/checkpoint-recovery.d.ts +32 -0
  18. package/lib/types/checkpoint.d.ts +127 -0
  19. package/lib/types/consumer-chat-links.d.ts +59 -0
  20. package/lib/types/delivery-schema.d.ts +176 -0
  21. package/lib/types/delivery-sqlite.d.ts +387 -0
  22. package/lib/types/delivery-types.d.ts +744 -0
  23. package/lib/types/delivery.d.ts +114 -0
  24. package/lib/types/errors.d.ts +8 -0
  25. package/lib/types/evaluation-accounts.d.ts +86 -0
  26. package/lib/types/index.d.ts +51 -0
  27. package/lib/types/inline-image.d.ts +7 -0
  28. package/lib/types/input-drain.d.ts +73 -0
  29. package/lib/types/knowledge-image.d.ts +64 -0
  30. package/lib/types/media-lifetime.d.ts +22 -0
  31. package/lib/types/media.d.ts +32 -0
  32. package/lib/types/message-preview.d.ts +4 -0
  33. package/lib/types/message-upload.d.ts +55 -0
  34. package/lib/types/nas-host-lease.d.ts +33 -0
  35. package/lib/types/placement-slice.d.ts +30 -0
  36. package/lib/types/policies.d.ts +63 -0
  37. package/lib/types/preset-model.d.ts +50 -0
  38. package/lib/types/read-context.d.ts +27 -0
  39. package/lib/types/read-receipts.d.ts +10 -0
  40. package/lib/types/read-records.d.ts +30 -0
  41. package/lib/types/read-state.d.ts +18 -0
  42. package/lib/types/read-types.d.ts +28 -0
  43. package/lib/types/restart-recovery.d.ts +38 -0
  44. package/lib/types/route-resolve.d.ts +10 -0
  45. package/lib/types/runtime.d.ts +668 -0
  46. package/lib/types/schema.d.ts +61 -0
  47. package/lib/types/script-clock.d.ts +14 -0
  48. package/lib/types/sdk.d.ts +108 -0
  49. package/lib/types/service-types.d.ts +366 -0
  50. package/lib/types/session-events.d.ts +28 -0
  51. package/lib/types/simulation-batch.d.ts +40 -0
  52. package/lib/types/simulation-controller.d.ts +77 -0
  53. package/lib/types/simulation-operator.d.ts +19 -0
  54. package/lib/types/simulation-tools.d.ts +14 -0
  55. package/lib/types/sqlite-connection.d.ts +27 -0
  56. package/lib/types/time.d.ts +13 -0
  57. package/lib/types/tools.d.ts +17 -0
  58. package/lib/types/transport.d.ts +202 -0
  59. package/lib/types/transports.d.ts +48 -0
  60. package/lib/types/types.d.ts +521 -0
  61. package/lib/types/typing.d.ts +33 -0
  62. package/lib/types/upload-types.d.ts +121 -0
  63. package/lib/types.js +2 -0
  64. package/locale/en.json +6 -0
  65. package/locale/zh.json +6 -0
  66. package/package.json +125 -3
@@ -0,0 +1,61 @@
1
+ import { type CredentialKey } from '@deepseek-ai/dsh-credentials';
2
+ import { type ZodType } from 'zod';
3
+ import type { ImAccountId, ImAccountMutationResult, ImAccountView, ImRouteMutationResult, ImRouteView, ImSimulationTargetMutationResult, ImSimulationTargetView, ImSimulationInstanceId, ImSimulationInstanceView } from './types.ts';
4
+ /**
5
+ * IM 账号凭据的规范地址;续签使用收据绑定的独立代次键,交接映射回此地址。
6
+ * @param accountId - 当前账号的稳定标识。
7
+ * @returns 本账号在 Credentials 中的地址。
8
+ */
9
+ export declare function imAccountCredentialKey(accountId: ImAccountId): CredentialKey;
10
+ /** Stored account fields; listener status is process state and is derived on read. */
11
+ export type ImAccountRecord = Omit<ImAccountView, 'listener'> & {
12
+ readonly replacedHidden?: {
13
+ readonly connectionIntent: ImAccountView['connectionIntent'];
14
+ };
15
+ };
16
+ export declare const imAccountRecordSchema: ZodType<ImAccountRecord>;
17
+ export declare const imRouteSchema: ZodType<ImRouteView>;
18
+ interface StoredRouteOperation {
19
+ readonly fingerprint: string;
20
+ readonly result: ImRouteMutationResult;
21
+ }
22
+ interface StoredAccountMutationResult extends Omit<ImAccountMutationResult, 'account'> {
23
+ readonly account: ImAccountRecord;
24
+ }
25
+ interface StoredAccountOperation {
26
+ readonly fingerprint: string;
27
+ readonly result: StoredAccountMutationResult;
28
+ }
29
+ /** One atomic account aggregate: safe account facts, routes, and queryable operation receipts. */
30
+ export interface ImAccountAggregate {
31
+ readonly account: ImAccountRecord;
32
+ readonly routes: Readonly<Record<string, ImRouteView>>;
33
+ readonly routeOperations: Readonly<Record<string, StoredRouteOperation>>;
34
+ readonly accountOperations: Readonly<Record<string, StoredAccountOperation>>;
35
+ }
36
+ export declare const imAccountAggregateSchema: ZodType<ImAccountAggregate>;
37
+ export declare const imSimulationTargetSchema: ZodType<ImSimulationTargetView>;
38
+ interface StoredSimulationTargetOperation {
39
+ readonly fingerprint: string;
40
+ readonly result: ImSimulationTargetMutationResult;
41
+ }
42
+ /** Workspace simulation-target aggregate retaining receipts after target removal. */
43
+ export interface ImSimulationTargetAggregate {
44
+ readonly workspaceId: import('@deepseek-ai/dsh-workspace').WorkspaceId;
45
+ readonly target?: ImSimulationTargetView;
46
+ readonly operations: Readonly<Record<string, StoredSimulationTargetOperation>>;
47
+ }
48
+ export declare const imSimulationTargetAggregateSchema: ZodType<ImSimulationTargetAggregate>;
49
+ /** Parser for one durable manual or two-Session simulation lifecycle. */
50
+ export declare const imSimulationInstanceSchema: ZodType<ImSimulationInstanceView>;
51
+ /** IM configuration storage schema. Cross-account or cross-table transactions are not implied. */
52
+ export declare const imRuntimeDomainSpec: {
53
+ name: string;
54
+ version: number;
55
+ tables: {
56
+ accounts: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<ImAccountId, ImAccountAggregate>;
57
+ simulation_targets: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<import("@deepseek-ai/dsh-workspace/types").WorkspaceId, ImSimulationTargetAggregate>;
58
+ simulation_instances: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<ImSimulationInstanceId, ImSimulationInstanceView>;
59
+ };
60
+ };
61
+ export {};
@@ -0,0 +1,14 @@
1
+ /** Monotonic script time shared by the two Sessions of one simulation. */
2
+ import type { ImClockSource } from './time.ts';
3
+ /** Host-owned clock. Advance between Host steps, including reply-wait timeouts; an unfinished Agent uses the advanced time for later events. */
4
+ export declare class ImScriptClock implements ImClockSource {
5
+ private readonly realNow;
6
+ private instant;
7
+ private anchoredAt;
8
+ /** @param initialAt - Script origin in 13-digit Unix milliseconds. @param realNow - Source of elapsed real milliseconds. */
9
+ constructor(initialAt: number, realNow?: () => number);
10
+ /** @returns Current script instant in Unix milliseconds. */
11
+ now(): number;
12
+ /** @param at - Next segment instant; earlier instants keep the running clock, invalid instants throw. */
13
+ advance(at: number): void;
14
+ }
@@ -0,0 +1,108 @@
1
+ /** Optional Host SDK capability of an IM transport; account configuration remains runtime-owned. */
2
+ import type { ImAccountId } from './types.ts';
3
+ import type { Branded } from '@deepseek-ai/dsh-brand';
4
+ import type { ImOutboundRequestId } from './delivery-types.ts';
5
+ /** Verified platform single-chat identity, distinct from runtime delivery scopes. */
6
+ export type ImSdkConversationId = Branded<'ImSdkConversationId'>;
7
+ /** Platform message identity linked to persisted inbound or outbound data. */
8
+ export type ImSdkMessageId = Branded<'ImSdkMessageId'>;
9
+ /** Verified platform message recipient UID. */
10
+ export type ImSdkReceiverId = Branded<'ImSdkReceiverId'>;
11
+ declare module '@deepseek-ai/cordis' {
12
+ interface Context {
13
+ imSdk: ImSdkProvider;
14
+ }
15
+ }
16
+ /** Credential-free process state of an SDK connection. */
17
+ export type ImSdkState = 'offline' | 'connecting' | 'online' | 'reconnecting' | 'refreshing' | 'kicked' | 'login-required' | 'failed' | 'unknown';
18
+ /** Stable SDK failure categories suitable for localized UI. */
19
+ export type ImSdkFailureCode = 'SDK_AUTH_FAILED' | 'SDK_IDENTITY_MISMATCH' | 'SDK_LOGIN_REQUIRED' | 'SDK_STORAGE_FAILED' | 'SDK_REFRESH_UNKNOWN' | 'SDK_REFRESH_FAILED' | 'SDK_TOKEN_NOT_READY' | 'SDK_TOKEN_UNKNOWN' | 'SDK_NETWORK_FAILED' | 'SDK_CLOSED';
20
+ /** Safe SDK process projection; generation identifies one admitted connection. */
21
+ export interface ImSdkStatus {
22
+ readonly accountId: ImAccountId;
23
+ readonly state: ImSdkState;
24
+ readonly generation: number;
25
+ readonly error?: ImSdkFailureCode;
26
+ }
27
+ /** Host-only protocol notification. Readers validate message/recipient ownership before persistence or model use. */
28
+ export interface ImSdkEvent {
29
+ readonly accountId: ImAccountId;
30
+ readonly generation: number;
31
+ readonly kind: 'message' | 'read-to-reader' | 'read-to-sender' | 'receipt' | 'typing';
32
+ readonly data: Readonly<Record<string, unknown>>;
33
+ }
34
+ /** Host-authorized bytes and verified direct buyer identity. Files require the observed buyer nickname; images do not. Bytes never enter the status Remote API. */
35
+ export type ImSdkUpload = {
36
+ readonly name: string;
37
+ readonly mime: string;
38
+ readonly bytes: Uint8Array;
39
+ readonly receiver: ImSdkReceiverId;
40
+ readonly conversationId: ImSdkConversationId;
41
+ } & ({
42
+ readonly kind: 'image';
43
+ } | {
44
+ readonly kind: 'file';
45
+ readonly receiverNick: string;
46
+ });
47
+ /** Upload metadata is opaque platform JSON, never a local path or an authorization credential. */
48
+ export type ImSdkUploaded = {
49
+ readonly kind: 'image';
50
+ readonly metadata: Readonly<Record<string, unknown>>;
51
+ } | {
52
+ readonly kind: 'file';
53
+ readonly metadata: Readonly<Record<string, unknown>> | string;
54
+ };
55
+ /** One prepared submission. Media and text are exclusive; `requestId` is the SDK `clientId`. */
56
+ export type ImSdkSend = {
57
+ readonly conversationId: ImSdkConversationId;
58
+ readonly receiver: ImSdkReceiverId;
59
+ readonly requestId: ImOutboundRequestId;
60
+ } & ({
61
+ readonly media: ImSdkUploaded;
62
+ readonly text?: undefined;
63
+ } | {
64
+ readonly text: string;
65
+ readonly media?: undefined;
66
+ });
67
+ /** One authenticated connection lease; methods reject after generation revocation. */
68
+ export interface ImSdkLease {
69
+ readonly generation: number;
70
+ readonly signal: AbortSignal;
71
+ /** @param conversationId - verified single chat. @param messageIds - persisted inbound platform messages. @returns only after platform acknowledgement. */
72
+ markRead(conversationId: ImSdkConversationId, messageIds: readonly ImSdkMessageId[]): Promise<void>;
73
+ /** @param conversationId - verified single chat. @param messageId - linked platform message. @returns explicit per-recipient states; absence remains unknown. */
74
+ queryRead(conversationId: ImSdkConversationId, messageId: ImSdkMessageId): Promise<readonly {
75
+ readonly uid: ImSdkReceiverId;
76
+ readonly status: number;
77
+ }[]>;
78
+ /** @param conversationId - opaque cid from the raw SDK message. @param signal - optional caller cancellation within this generation. @returns true only when one SDK detail query confirms type 1 for that cid; absent capability, no result or an unconfirmed type leaves realtime reception to SaaS. */
79
+ isDirectConversation?(conversationId: ImSdkConversationId, signal?: AbortSignal): Promise<boolean>;
80
+ /** @param receiver - verified buyer UID, never a text transport conversation id. @param signal - optional operation cancellation. @returns SDK-owned single-chat identity; failure occurs before message submission. */
81
+ resolveConversation(receiver: ImSdkReceiverId, signal?: AbortSignal): Promise<ImSdkConversationId>;
82
+ /** @param file - authorized private bytes. @param signal - optional upload cancellation within the admitted connection. @returns preparation metadata; no chat message is submitted. */
83
+ upload(file: ImSdkUpload, signal?: AbortSignal): Promise<ImSdkUploaded>;
84
+ /** @param media - persisted upload metadata of an owned file message. @returns a fresh HTTPS download URL, never cached as a permanent file reference. */
85
+ downloadUrl(media: ImSdkUploaded): Promise<string>;
86
+ /** @param request - prepared media or text. `requestId` is sent as `clientId`. @param signal - caller cancellation. @param authorizeSubmission - optional automatic authority, called once after conversation resolution and immediately before page request dispatch; false refuses without submission. @returns the platform `messageId`, or `failed` only when nothing was submitted. A missing id, timeout, teardown, or rejection after dispatch is `unknown` and must not be resent automatically. */
87
+ sendMessages(request: ImSdkSend, signal?: AbortSignal, authorizeSubmission?: () => boolean): Promise<{
88
+ readonly state: 'sent';
89
+ readonly messageId: ImSdkMessageId;
90
+ } | {
91
+ readonly state: 'failed' | 'unknown';
92
+ }>;
93
+ }
94
+ /** Product SDK Provider projected through its existing platform transport. */
95
+ export interface ImSdkProvider {
96
+ /** @param accountId - configured runtime account. @returns safe process status; no SDK initialization occurs. */
97
+ status(accountId: ImAccountId): ImSdkStatus;
98
+ /** @param accountId - configured account selected by the operator or admitted startup or placement recovery. @param signal - optional restoration cancellation; abort revokes connection admission before cleanup. @returns verified terminal login status. */
99
+ login(accountId: ImAccountId, signal?: AbortSignal): Promise<ImSdkStatus>;
100
+ /** @param accountId - account stopped by an explicit command or placement handoff; this method does not mutate online intent. @returns offline status after accepted SDK work, kickout intent writes and page cleanup settle; rejects if cleanup or required intent persistence fails. */
101
+ logout(accountId: ImAccountId): Promise<ImSdkStatus>;
102
+ /** @param listener - safe process-state observer. @returns disposer. */
103
+ subscribe(listener: () => void): () => void;
104
+ /** @param listener - trusted protocol consumer, responsible for recovery of its mutated state; a throwing consumer is withdrawn and reported without payloads. @returns disposer that stops admission and joins accepted callbacks. */
105
+ subscribeEvents(listener: (event: ImSdkEvent) => void | Promise<void>): () => Promise<void>;
106
+ /** @param accountId - account whose online generation is required. @param generation - generation observed from this Provider instance. @param consume - trusted Host consumer; must honor signal and keep private protocol data out of logs. @returns consumer result; rejected when stale or the Provider is withdrawn. */
107
+ withConnection<T>(accountId: ImAccountId, generation: number, consume: (lease: ImSdkLease) => Promise<T>): Promise<T>;
108
+ }
@@ -0,0 +1,366 @@
1
+ /** Host service and event declarations kept out of the client-safe DTO entry. */
2
+ import type { ImAutomaticSendAuthorization } from './transport.ts';
3
+ import type { ImInjectSimulationOperatorRequest, ImSimulationOperatorReceipt } from './simulation-operator.ts';
4
+ import type { WorkspaceId } from '@deepseek-ai/dsh-workspace';
5
+ import type { UserMessage } from '@deepseek-ai/dsh-llm';
6
+ import type { SessionId } from '@deepseek-ai/dsh-session';
7
+ import type { ImBeginOutboundAttemptRequest, ImOutboundAttemptId, ImBeginOutboundAttemptResult, ImAgentTaskView, ImCancelPendingAiRequest, ImCommitProviderCursorRequest, ImConversationCursor, ImConversationProjection, ImConversationRecords, ImCustomerSessionListRequest, ImCustomerSessionPage, ImCustomerListPage, ImCustomerListRequest, ImCustomerReadAckRequest, ImDeliveryChange, ImDeliveryOperationId, ImDeliveryScope, ImGetOutboundRequest, ImHandlingControl, ImHistoryPage, ImHistoryQueryRequest, ImImportJsonlHistoryRequest, ImImportJsonlHistoryResult, ImInboundMessageView, ImInboundSenderEvidence, ImInboundOperationQuery, ImInboundPageResult, ImIngestInboundPageRequest, ImMarkSubmittedRequest, ImMarkSubmittedResult, ImManualMessageQuery, ImManualMessageQueryRequest, ImManualMessageResult, ImMessageId, ImMessageSource, ImOutboundPage, ImOutboundQueryRequest, ImOutboundView, ImPendingInboundRequest, ImProviderCursorCommitResult, ImProviderCursorOperationQuery, ImProviderCursorOwner, ImProviderCursorView, ImRealDeliveryScope, ImRealSessionBinding, ImRegisterOutboundRequest, ImRetryManualMessageRequest, ImSendManualMessageRequest, ImSetHandlingControlRequest, ImSettleOutboundAttemptRequest, ImSettleSimulationOutboundRequest, ImSessionReconciliationResult, ImSenderAttribution, ImScopeId } from './delivery-types.ts';
8
+ import type { ImAccountId, ImAccountCandidate, ImAccountSetupId, ImAccountSetupPreview, ImCancelAccountSetupResult, ImConfirmAccountSetupRequest, ImAccountLifecycleRequest, ImAccountMutationResult, ImAccountOperationQuery, ImAccountSetupRequest, ImAccountView, ImAssignedActorCandidate, ImConversationCandidate, ImConversationCandidatePage, ImConversationKind, ImCreateRouteRequest, ImDeleteRouteRequest, ImOperationId, ImPlatform, ImPlatformLoginAttemptId, ImPlatformLoginStatus, ImRebindRouteRequest, ImRevision, ImRouteView, ImRemoveSimulationTargetRequest, ImRouteMutationResult, ImRouteOperationQuery, ImRouteResolution, ImRuntimeChange, ImRuntimeSnapshot, ImSaveRouteRequest, ImSaveSimulationTargetRequest, ImSetAccountPausedRequest, ImSimulationTargetMutationResult, ImSimulationTargetOperationQuery, ImCreateSimulationInstanceRequest, ImCreateManualSimulationInstanceRequest, ImSimulationInjectionQuery, ImInjectSimulationManagedHumanRequest, ImInjectSimulationMemberRequest, ImImportSimulationHistoryRequest, ImImportSimulationHistoryResult, ImSimulationInstanceView, ImSimulationSessionScope } from './types.ts';
9
+ declare module '@deepseek-ai/cordis' {
10
+ interface Context {
11
+ imRuntime: ImRuntimeService;
12
+ }
13
+ interface Events {
14
+ /**
15
+ * IM configuration or process listener state changed. The emitted revision is newer than every prior event from this process.
16
+ * @param change - changed account, route, target, instance, transport, or listener and its process generation revision.
17
+ * @mode emit
18
+ */
19
+ 'imRuntime/changed'(change: ImRuntimeChange): void;
20
+ /**
21
+ * Durable inbound, submission, or outbox state changed.
22
+ * @param change - committed scope and affected message or request identities.
23
+ * @mode emit
24
+ */
25
+ 'imRuntime/delivery-changed'(change: ImDeliveryChange): void;
26
+ }
27
+ }
28
+ declare module '@deepseek-ai/dsh-llm' {
29
+ interface MessageSourceMap {
30
+ /** Stable IM identity used to reconcile a Session append with the delivery domain. */
31
+ im: ImMessageSource;
32
+ /** 重启中断的稳定日志位置;普通 user/message 和 inbox 事件持有同一输入。 */
33
+ 'im-restart': {
34
+ readonly kind: 'im-restart';
35
+ readonly turnStartSeq: import('@deepseek-ai/dsh-session').SessionSeq;
36
+ };
37
+ }
38
+ }
39
+ /** Read and mutation surface consumed by the product BFF. */
40
+ export interface ImRuntimeService {
41
+ /** Process-local sidebar typing; never persisted or sent to an Agent. */
42
+ readonly typing: Pick<import('./typing.ts').ImTyping, 'snapshot' | 'subscribe'>;
43
+ /** Instance-private evaluation root and simulation upload queue; absent when using formal storage. */
44
+ readonly standbyStorageRoot?: string | undefined;
45
+ /**
46
+ * Whether this runtime bound a NAS host lease.
47
+ * This is the condition `ensureEvaluationAccount` uses to reject with `正式云端接待不能创建评测账号`. It stays true after hosting intent is turned off: intent only changes the projected route and does not dispose the lease or call `releaseHostingLease`.
48
+ * `NasHostLease.holderIdentity()` is a different read. It is undefined before admission and after a fence, while this method can still be true.
49
+ * The control plane releases the lease only from `CloudNasHostLease.releaseOnStop`, and only when `shouldReleaseOnStop()` is true. The cloud host sets that flag in `releaseFailedPlacement` and `stopLive`, immediately before disposing the lease fiber. A fence or `stopHost` exits without `releaseHostingLease`; the control-plane holder remains until it expires.
50
+ * Evaluation command proxy (#1216) reads this method, not hosting intent and not `CsHostingEvaluationSummary.canStart`.
51
+ * @returns True when `nasHostLease` was bound at IM startup, including before admission and while hosting intent is off.
52
+ */
53
+ holdsNasLease(): boolean;
54
+ /** @param sellerId - Host-verified seller. @param workspaceId - Tested Workspace, aligned on every call. @returns Credential-free account and its fixed disabled route; leased cloud runtimes (`holdsNasLease()`), conflicting formal ids and unavailable evaluation data reject. Calls for one runtime are serialized. */
55
+ ensureEvaluationAccount(sellerId: string, workspaceId: WorkspaceId): Promise<{
56
+ readonly account: ImAccountView;
57
+ readonly route: ImRouteView;
58
+ }>;
59
+ /** @param accountId - Account to classify by its evaluation domain. @param sellerId - Optional exact seller identity. @returns Whether the stored evaluation account matches; names and id prefixes grant no evaluation authority. */
60
+ isEvaluationAccount(accountId: ImAccountId, sellerId?: string): boolean;
61
+ /** @param accountId - Evaluation account whose run finished. @param observedRevision - Route generation held by the run. @returns True after removing that route, or if already absent; false for unknown accounts or a changed generation. The account remains durable. Formal routes cannot be removed. */
62
+ releaseEvaluationAccountRoute(accountId: ImAccountId, observedRevision: ImRevision): Promise<boolean>;
63
+ /** @returns After evaluation consumers and handles close; failures reject. */
64
+ closeEvaluationResources(): Promise<void>;
65
+ /** @returns After reload against an admitted lease; caller reacquires consumers. */
66
+ reloadWithNasLease(): Promise<void>;
67
+ /** @param annotator - Product-owned optional admission analysis. @returns Disposer that prevents further calls. */
68
+ registerAdmissionAnnotator(annotator: import('./admission-annotations.ts').ImAdmissionAnnotator): () => Promise<void>;
69
+ /** @param request - owned manual file message and Session or scope. @returns a fresh URL requiring an authenticated SDK generation. */
70
+ mediaDownloadUrl(request: ImManualMessageQueryRequest): Promise<string>;
71
+ /** @param request - scope-verified media and private bytes. @param signal - operation lifetime. @returns durable outbox result without automatic resubmission. */
72
+ sendMediaMessage(request: import('./delivery-types.ts').ImSendMediaMessageRequest, signal?: AbortSignal): Promise<ImOutboundView>;
73
+ /** @returns 暂停新输入的所有权;等待已准入工作后由调用者恢复。 */
74
+ pauseInput(): import('./input-drain.ts').ImInputPause;
75
+ /** @param accountId - 待交接账号。 @returns 仅该账号的暂停;不改变路由代次或其他 Workspace 的运行。停止监听后 resume 拒绝,必须核验交接。 */
76
+ pauseAccountInput(accountId: ImAccountId): import('./input-drain.ts').ImInputPause;
77
+ /** @param accountId - 已持有账号输入暂停的账号;只取消其当前实际拥有的运行任务,保留 inbox。 */
78
+ cancelAccountActivityForPlacement(accountId: ImAccountId): void;
79
+ /** @param accountId - 已排空账号。 @returns SDK 已主动登出、已接纳踢线意图已提交、监听已停止且未发送自动回复已取消;保留在线意图,失败不恢复。 */
80
+ stopAccountForPlacement(accountId: ImAccountId): Promise<void>;
81
+ /** @param accountId - 已鉴权的旺旺账号。 @param workspaceId - 来源客服内置 Workspace。 @returns 最终导出前须排空的独立切片。 */
82
+ exportAccountForPlacement(accountId: ImAccountId, workspaceId: WorkspaceId): import('./account-placement.ts').ImAccountPlacementSlice;
83
+ /** @param accountId - Incoming leased account in a Host without startup or maintenance pause, including a previously exported account. @param signal - Drain and incoming transfer lifetime. @returns Account standby held and owned Agent persistence locks released before Session import; failures retain reception stop. */
84
+ beginAccountPlacementImport(accountId: ImAccountId, signal: AbortSignal): Promise<void>;
85
+ /** @param accountId - Successfully established incoming account standby; caller must obtain fresh lease authorization and prepare Agents first. Releases this account's import hold and schedules reception without releasing Host startup holds. */
86
+ releaseAccountPlacement(accountId: ImAccountId): void;
87
+ /** @param accountId - Account under import hold with its listener stopped. @param checkpoint - Parsed cursor-only checkpoint. @param signal - Pre-CAS validation lifetime. @returns Existing nonnull local cursors match exactly and checkpoint counts are zero; failures preserve stopped reception. */
88
+ validateAccountCheckpointRecovery(accountId: ImAccountId, checkpoint: import('./checkpoint-recovery.ts').ImAccountCheckpointRecovery['checkpoint'], signal: AbortSignal): Promise<void>;
89
+ /** @param accountId - Fenced recovery account with an established account import hold. @param request - Parsed checkpoint and caller-verified continuous source fence. @param signal - Activation lifetime. @returns New local task generations are prepared with a logged history-gap notice; old Sessions stay untouched and reception stays paused. Nonzero checkpoint pending/unknown counts reject. */
90
+ recoverAccountPlacement(accountId: ImAccountId, request: import('./checkpoint-recovery.ts').ImAccountCheckpointRecovery, signal: AbortSignal): Promise<void>;
91
+ /** @param slice - 已鉴权并校验的切片。 @param workspaceId - 目标内置 Workspace。 @returns 提交配置与投递事实,保持停止;失败可能部分提交,调用者核验。 */
92
+ importAccountForPlacement(slice: import('./account-placement.ts').ImAccountPlacementSlice, workspaceId: WorkspaceId): Promise<void>;
93
+ /** @param accountId - 已导入或已在本端接待的账号。 @param prepare - 接收同一空闲 Agent 及已核验账号、Workspace 和持久化会话头的当前任务,准备续写。 @param signal - 激活与身份寿命。 @returns 当前任务准备完毕;未知 Session 不会被创建,失败保留启动暂停。 */
94
+ prepareAccountPlacement(accountId: ImAccountId, prepare: (agent: import('@deepseek-ai/dsh-agent').Agent, task: import('./delivery-types.ts').ImAgentTaskView) => Promise<void>, signal: AbortSignal): Promise<void>;
95
+ /** @param accountId - 已释放启动暂停的账号。 @param signal - 激活与身份寿命。 @returns 当前监听已就绪并完成初始追平,或账号按原连接意图保持空闲;失败不代表激活完成。 */
96
+ waitAccountPlacementReady(accountId: ImAccountId, signal: AbortSignal): Promise<void>;
97
+ /** @param accountId - 当前账号。 @returns 账号停止、账号暂停或启动暂停中的任一门禁是否生效。 */
98
+ inputPaused(accountId: ImAccountId): boolean;
99
+ /** 控制面授权、导入和 prepareResume 完成后幂等释放目标启动暂停,不授予租约。 */
100
+ releasePlacementStartup(): void;
101
+ /** 首次开通已生成的账号。之后确认旺旺账号时使用它,不再另生成。 */
102
+ reservePlacementAccount(accountId: ImAccountId): void;
103
+ /** @param platform - installed provider selected by the operator. @param signal - caller lifetime until safe instructions are available. @returns current safe interactive login state. */
104
+ startPlatformLogin(platform: ImPlatform, signal?: AbortSignal): Promise<ImPlatformLoginStatus>;
105
+ /** @param platform - owning provider. @param attemptId - login identity returned by start. @returns current safe login state. */
106
+ platformLoginStatus(platform: ImPlatform, attemptId: ImPlatformLoginAttemptId): ImPlatformLoginStatus;
107
+ /** @param platform - owning provider. @param attemptId - login identity returned by start. @returns cancelled or already-terminal state. */
108
+ cancelPlatformLogin(platform: ImPlatform, attemptId: ImPlatformLoginAttemptId): Promise<ImPlatformLoginStatus>;
109
+ /** @returns Formal accounts, their routes and simulation targets referencing visible formal accounts; evaluation resources are excluded. */
110
+ snapshot(): ImRuntimeSnapshot;
111
+ /** @param listener - post-commit change observer. @returns disposer for this subscription. */
112
+ subscribe(listener: (change: ImRuntimeChange) => void): () => void;
113
+ /** In standby, only evaluation simulation messages are uploaded from private storage. @param binding - hosted traffic eligibility and authenticated upload. @returns async disposer that aborts and awaits requests. */
114
+ bindMessageUpload(binding: import('./upload-types.ts').ImUploadBinding): () => Promise<void>;
115
+ /**
116
+ * Send throttled hosting checkpoints through this transport.
117
+ * The runtime calls it for durable cursors and reception state changes. The transport owns the lease epoch.
118
+ * @param transport - one server reporter. A later bind replaces it.
119
+ * @param activity - current product intent, admission and model availability.
120
+ * @returns disposer that stops reporting. Local cursors stay.
121
+ */
122
+ bindCheckpointTransport(transport: import('./checkpoint.ts').ImCheckpointTransport, activity?: (accountId: ImAccountId) => Omit<import('./checkpoint.ts').ImCheckpointActivity, 'inFlight'>): () => void;
123
+ /** @param accountId - account whose reception intent, admission, or model state changed. */
124
+ noteCheckpoint(accountId: ImAccountId): void;
125
+ /**
126
+ * Report again after the held lease epoch changes.
127
+ * A rejected epoch is not reused.
128
+ * @param accountId - account whose new epoch is now held.
129
+ */
130
+ resumeCheckpoint(accountId: ImAccountId): void;
131
+ /** @param platform - provider whose installed or admitted identities are requested. @param signal - caller lifetime. @returns safe selectable candidates. */
132
+ listAccountCandidates(platform: ImPlatform, signal?: AbortSignal): Promise<readonly ImAccountCandidate[]>;
133
+ /** @param accountId - configured account whose provider conversations are listed. @param signal - caller lifetime. @returns provider-known titles with stable conversation ids. */
134
+ discoverConversations(accountId: ImAccountId, signal?: AbortSignal): Promise<ImConversationCandidatePage>;
135
+ /** @param accountId - configured account. @param conversationId - platform conversation identifier. @param conversationKind - provider category. @param signal - caller lifetime. @returns provider-known title, or the identifier when the title is unknown. */
136
+ inspectConversation(accountId: ImAccountId, conversationId: string, conversationKind: ImConversationKind, signal?: AbortSignal): Promise<ImConversationCandidate>;
137
+ /** @param accountId - configured account. @param signal - caller lifetime. @returns assigned service accounts when the platform exposes them. */
138
+ listAssignedActors(accountId: ImAccountId, signal?: AbortSignal): Promise<readonly ImAssignedActorCandidate[]>;
139
+ /** @param request - candidate-bound write-only setup input. @param signal - caller lifetime. @returns safe verified facts and a short-lived Host setup identifier. */
140
+ previewAccountSetup(request: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountSetupPreview>;
141
+ /** @param request - setup identifier and idempotency identifier. @returns the durable account-creation outcome. */
142
+ confirmAccountSetup(request: ImConfirmAccountSetupRequest): Promise<ImAccountMutationResult>;
143
+ /** @param setupId - unconfirmed setup to release. @returns whether it was released or had already advanced. */
144
+ cancelAccountSetup(setupId: ImAccountSetupId): ImCancelAccountSetupResult;
145
+ /** @param accountId - receiving account. @param conversationKind - provider category. @param conversationId - provider conversation. @returns precedence-ordered route resolution. */
146
+ resolveRoute(accountId: ImAccountId, conversationKind: ImConversationKind, conversationId: string, assignedActorId?: string): ImRouteResolution;
147
+ /** @param request - candidate-bound setup input for non-interactive Host consumers. @param signal - caller lifetime. @returns the persisted safe account. */
148
+ addAccount(request: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountView>;
149
+ /** @param request - account and observed revision. @param setup - verified credentials for the same merchant. @param signal - optional generation cancellation; absent uses an uncancelled operation. @returns durable renewal receipt preserving pause, intent, rules, and history. */
150
+ renewAccount(request: ImAccountLifecycleRequest, setup: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountMutationResult>;
151
+ /** @returns all retained Host account facts, including replaced records omitted from Client snapshots. */
152
+ retainedAccounts(): readonly {
153
+ readonly account: ImAccountView;
154
+ readonly replacedHidden: boolean;
155
+ }[];
156
+ /** @param request - old account and observed revision after replacement OAuth succeeds. @returns durable disconnection and list removal; rules and history remain retained. */
157
+ hideReplacedAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
158
+ /** @param request - retained account and observed revision. @param setup - new verified credentials for the same merchant. @param signal - optional authorization generation; absent does not cancel. @returns explicit restoration of a replaced account; concurrent lifecycle changes win. */
159
+ restoreReplacedAccount(request: ImAccountLifecycleRequest, setup: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountMutationResult>;
160
+ /** @param request - guarded account pause mutation. @returns its durable outcome. */
161
+ setAccountPaused(request: ImSetAccountPausedRequest): Promise<ImAccountMutationResult>;
162
+ /** @param request - guarded persistent disconnect intent. @returns its durable outcome. */
163
+ disconnectAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
164
+ /** @param accountId - retained runtime account. @param intent - explicit online intent, persistent kickout, or absence after logout. @param expectedIntent - optional intent-generation CAS for asynchronous connection observations. @returns whether the account write was accepted; rejects if durability cannot be confirmed. */
165
+ setSdkConnectionIntent(accountId: ImAccountId, intent: ImAccountView['sdkConnectionIntent'], expectedIntent?: {
166
+ readonly revision: ImAccountView['sdkConnectionIntentRevision'];
167
+ }): Promise<boolean>;
168
+ /** @param request - account revision and idempotent operation for a disconnected account or failed listener. @returns durable intent acknowledgement; a fresh accepted operation resets the listener retry budget and starts reconciliation. */
169
+ reconnectAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
170
+ /** @param request - guarded account deletion. @returns its durable outcome; conversation history remains. */
171
+ deleteAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
172
+ /** @param request - guarded provider authorization refresh. @param signal - caller lifetime. @returns its durable outcome. */
173
+ refreshAccount(request: ImAccountLifecycleRequest, signal?: AbortSignal): Promise<ImAccountMutationResult>;
174
+ /** @param accountId - owning account. @param operationId - idempotency identifier. @returns stored result or an explicit miss. */
175
+ queryAccountOperation(accountId: ImAccountId, operationId: ImOperationId): ImAccountOperationQuery;
176
+ /** @param request - new route tuple and workspace owner. @returns its durable outcome. */
177
+ createRoute(request: ImCreateRouteRequest): Promise<ImRouteMutationResult>;
178
+ /** @param request - guarded non-ownership route edit. @returns its durable outcome. */
179
+ saveRoute(request: ImSaveRouteRequest): Promise<ImRouteMutationResult>;
180
+ /** @param request - guarded ownership transfer. @returns its durable outcome. */
181
+ rebindRoute(request: ImRebindRouteRequest): Promise<ImRouteMutationResult>;
182
+ /** @param request - guarded route deletion. @returns its durable outcome. */
183
+ deleteRoute(request: ImDeleteRouteRequest): Promise<ImRouteMutationResult>;
184
+ /** @param accountId - owning account. @param operationId - idempotency identifier. @returns stored result or an explicit miss. */
185
+ queryRouteOperation(accountId: ImAccountId, operationId: ImOperationId): ImRouteOperationQuery;
186
+ /**
187
+ * Keep history flowing for one account without an enabled admit route.
188
+ * @param accountId - connected account.
189
+ * @param observation - conversation kind and target to receive.
190
+ */
191
+ registerObservation(accountId: ImAccountId, observation: {
192
+ readonly conversationKind: ImConversationKind;
193
+ readonly target: import('./types.ts').ImRouteTarget;
194
+ }): () => void;
195
+ /** @param request - guarded simulation-target save. @returns its durable outcome. */
196
+ saveSimulationTarget(request: ImSaveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
197
+ /** @param request - Formal route and observed target revision. @returns Durable result; evaluation requested, current or receipt targets reject inside the serialized operation before any write. */
198
+ saveFormalSimulationTarget(request: ImSaveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
199
+ /** @param workspaceId - Simulated-user Workspace. @returns Its current Host target, including evaluation targets. */
200
+ simulationTargetForWorkspace(workspaceId: WorkspaceId): import('./types.ts').ImSimulationTargetView | undefined;
201
+ /** @param request - guarded simulation-target removal. @returns its durable outcome. */
202
+ removeSimulationTarget(request: ImRemoveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
203
+ /** @param request - Workspace and observed formal target revision. @returns Durable result; evaluation current or receipt targets reject inside the serialized operation before any write. */
204
+ removeFormalSimulationTarget(request: ImRemoveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
205
+ /** @param workspaceId - target-owning workspace. @param operationId - idempotency identifier. @returns stored result or an explicit miss. */
206
+ querySimulationTargetOperation(workspaceId: WorkspaceId, operationId: ImOperationId): ImSimulationTargetOperationQuery;
207
+ /** @param sessionId - durable real IM task Session. @returns its frozen target plus current safe account, listener, presentation, and sync facts. */
208
+ realScopeForSession(sessionId: SessionId): ImRealSessionBinding | undefined;
209
+ /** @param scopeId - complete conversation identity. @returns current safe account, listener, presentation, and sync facts, even before an Agent task exists. */
210
+ realBindingForScope(scopeId: ImScopeId): ImRealSessionBinding | undefined;
211
+ /**
212
+ * Send one human-manual message.
213
+ * Session-bound calls may use any locally configured account that owns the
214
+ * Agent task. Hosting-console callers name the selected {@link ImSendManualMessageRequest.accountId}
215
+ * and, when no task exists, {@link ImSendManualMessageRequest.scopeId}; unknown,
216
+ * other-account, and simulation scopes are rejected.
217
+ * @param request - Session- or scope-bound stable request and text.
218
+ * @param signal - caller lifetime.
219
+ * @returns durable manual delivery and identity facts when the account is available.
220
+ */
221
+ sendManualMessage(request: ImSendManualMessageRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
222
+ /** @param request - Session- or scope-bound stable request identity. @returns durable result without provider activity. */
223
+ queryManualMessage(request: ImManualMessageQueryRequest): ImManualMessageQuery;
224
+ /** @param request - Session- or scope-bound uncertain request. @param signal - caller lifetime. @returns provider-confirmed or still-unknown result without sending. */
225
+ confirmManualMessage(request: ImManualMessageQueryRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
226
+ /** @param request - new request linked to an uncertain predecessor. @param signal - caller lifetime. @returns explicit retry delivery result. */
227
+ retryManualMessage(request: ImRetryManualMessageRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
228
+ /** @returns all durable simulation instances in creation order. */
229
+ listSimulationInstances(): readonly ImSimulationInstanceView[];
230
+ /** @param instanceId - Host-minted instance identity. @returns its durable state or absence. */
231
+ getSimulationInstance(instanceId: import('./delivery-types.ts').ImSimulationInstanceId): ImSimulationInstanceView | undefined;
232
+ /**
233
+ * Pause automatic buyer delivery and remove simulation operator tools while a Host drives the buyer.
234
+ * @param instanceId - Running paired simulation; only one Host driver may hold it.
235
+ * @returns Idempotent disposer; release after stopping the instance, otherwise queued replies resume automatic delivery.
236
+ */
237
+ holdSimulationBuyer(instanceId: import('./delivery-types.ts').ImSimulationInstanceId): () => void;
238
+ /**
239
+ * Deliver pending AI replies and, during a Host-driven confirmed handoff, received human-dsh replies through native IM input.
240
+ * AI rows are marked submitted. Staff rows keep their received stage; durable buyer input deduplicates their delivery.
241
+ * The Host must prepare its buyer state before calling; delivery wakes the buyer Agent.
242
+ * @param instanceId - Running paired simulation held by exactly one Host driver; otherwise rejects.
243
+ * @returns Number of AI and eligible staff replies durably delivered to the buyer Session or inbox; zero when none are pending.
244
+ */
245
+ deliverSimulationBuyerReplies(instanceId: import('./delivery-types.ts').ImSimulationInstanceId): Promise<number>;
246
+ /** IANA shop zone configured at runtime load; defaults to Asia/Shanghai. */
247
+ readonly timeZone: string;
248
+ /**
249
+ * Register an external clock for both Sessions of one creating or running simulation.
250
+ * The source is sampled synchronously for every request step; the caller advances it only
251
+ * between settled steps. It must return valid Unix milliseconds; its failures stop preparation.
252
+ * Registration is Host-local and is not persisted or transferred. Re-register after restart.
253
+ * Real Sessions and other instances always retain their own source or the system clock.
254
+ * @param instanceId - Host-minted simulation identity; unknown, terminal, or already registered instances fail without mutation.
255
+ * @param source - caller-owned clock; never modified or disposed by the runtime.
256
+ * @returns Idempotent disposer restoring system time; also released at instance termination or runtime disposal.
257
+ */
258
+ registerSimulationClock(instanceId: import('./delivery-types.ts').ImSimulationInstanceId, source: import('./time.ts').ImClockSource): () => void;
259
+ /**
260
+ * @param sessionId - either simulation Session or any real/ordinary Session.
261
+ * @returns Current Unix milliseconds from that instance's registered source, or Date.now when absent. Source errors propagate.
262
+ */
263
+ currentTime(sessionId: SessionId): number;
264
+ /** @param sessionId - either side of a simulation pair. @returns Host-authoritative role, peer, workspace, and delivery scope. */
265
+ scopeForSession(sessionId: SessionId): ImSimulationSessionScope | undefined;
266
+ /** @param request - enabled all-direct route. @returns a durable tested Session with no simulated-user Session. */
267
+ createManualSimulationInstance(request: ImCreateManualSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
268
+ /** @param request - live simulated-user Session and optional all-route conversation. @returns durable pair after tested Session flush. */
269
+ createSimulationInstance(request: ImCreateSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
270
+ /** @param request - Live simulated-user Session and optional conversation. @returns A pair using a non-evaluation account; evaluation targets reject inside the serialized creation operation. */
271
+ createFormalSimulationInstance(request: ImCreateSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
272
+ /** @param request - allow-listed member identity and text. @returns shared-path durable inbound message. */
273
+ injectSimulationMember(request: ImInjectSimulationMemberRequest): Promise<ImInboundMessageView>;
274
+ /** @param request - instance and text; Host derives the frozen account actor. @returns shared-path durable inbound message. */
275
+ injectSimulationManagedHuman(request: ImInjectSimulationManagedHumanRequest): Promise<ImInboundMessageView>;
276
+ /** @param request - Private operator text and retry identity for a running instance. @returns Durable acceptance in the tested Session; no IM row or transport send. */
277
+ injectSimulationOperator(request: ImInjectSimulationOperatorRequest): Promise<ImSimulationOperatorReceipt>;
278
+ /** @param request - original injection identity. @returns durable receipt; never resends. */
279
+ querySimulationInjection(request: ImSimulationInjectionQuery): ImInboundOperationQuery;
280
+ /** @param instanceId - instance to close. @returns durable stopping or terminal state without awaiting caller activity. */
281
+ beginStopSimulation(instanceId: import('./delivery-types.ts').ImSimulationInstanceId): Promise<ImSimulationInstanceView>;
282
+ /** @param sessionId - trusted tool caller Session. @returns its instance's durable stopping or terminal state. */
283
+ beginStopSimulationForSession(sessionId: SessionId): Promise<ImSimulationInstanceView>;
284
+ /** @param instanceId - already-stopping instance. @returns terminal state after both sides and derived work quiesce. */
285
+ waitSimulationStopped(instanceId: import('./delivery-types.ts').ImSimulationInstanceId): Promise<ImSimulationInstanceView>;
286
+ /** @param request - instance identity, stable operation, display filename, and local JSONL. @returns durable query-only source counts and updated instance. */
287
+ importSimulationHistory(request: ImImportSimulationHistoryRequest): Promise<ImImportSimulationHistoryResult>;
288
+ /** @param listener - post-commit delivery observer. @returns disposer for this subscription. */
289
+ subscribeDelivery(listener: (change: ImDeliveryChange) => void): () => void;
290
+ /** @param request - complete real scope, cursor CAS, and provider page. @returns durable page receipt. */
291
+ ingestInboundPage(request: ImIngestInboundPageRequest): Promise<ImInboundPageResult>;
292
+ /** @param scope - complete conversation identity. @param operationId - page or import operation. @returns durable receipt or explicit miss. */
293
+ queryInboundOperation(scope: ImDeliveryScope, operationId: ImDeliveryOperationId): ImInboundOperationQuery;
294
+ /** @param scope - complete conversation identity. @returns current live-delivery cursor. */
295
+ getConversationCursor(scope: ImDeliveryScope): ImConversationCursor;
296
+ /**
297
+ * Derive one value per conversation whenever its document is parsed or written, so later reads need no document read.
298
+ * @param project - pure function of one conversation's records; the result must depend only on them and must not keep them.
299
+ * @returns accessor of the derived values; the caller disposes it with its own lifetime.
300
+ */
301
+ projectConversations<T extends object>(project: (records: ImConversationRecords) => T): ImConversationProjection<T>;
302
+ /** @param owner - platform account and provider feed identity. @returns current feed cursor without claiming conversation ownership. */
303
+ getProviderCursor(owner: ImProviderCursorOwner): ImProviderCursorView;
304
+ /** @param request - feed cursor CAS and every durable conversation-page receipt. @returns stored cursor outcome. */
305
+ commitProviderCursor(request: ImCommitProviderCursorRequest): Promise<ImProviderCursorCommitResult>;
306
+ /** @param owner - provider feed identity. @param operationId - uncertain cursor operation. @returns durable receipt or explicit miss. */
307
+ queryProviderCursorOperation(owner: ImProviderCursorOwner, operationId: ImDeliveryOperationId): ImProviderCursorOperationQuery;
308
+ /** @param request - bounded history cursor and origin filter. @returns ascending message page. */
309
+ queryHistory(request: ImHistoryQueryRequest): ImHistoryPage;
310
+ /** @param request - account, real/simulation filter, optional substring, and reader. @returns a keyset page of customer rows. */
311
+ listCustomers(request: ImCustomerListRequest): ImCustomerListPage;
312
+ /** @param request - account, source, search and cursor. @returns customer Session references without unread calculations. */
313
+ listCustomerSessions(request: ImCustomerSessionListRequest): ImCustomerSessionPage;
314
+ /** @param request - reader, scope, and observed arrival sequence. */
315
+ ackCustomerRead(request: ImCustomerReadAckRequest): void;
316
+ /** @param request - scope and pause fields. @returns the stored handling control. */
317
+ setHandlingControl(request: ImSetHandlingControlRequest): ImHandlingControl;
318
+ /** @param scopeId - Customer whose durable journal pause needs reconciliation. @param pending - Hold automatic processing until persistence and acknowledgement complete; caller disposal does not release it. */
319
+ setAutomaticHandlingPausePending(scopeId: ImScopeId, pending: boolean): void;
320
+ /** @param scopeId - Complete customer scope. @returns Pending journal or durable handling pause blocks automatic processing. */
321
+ isAutomaticHandlingBlocked(scopeId: ImScopeId): boolean;
322
+ /** @param scopeId - complete conversation identity. @returns the stored handling control, or absence. */
323
+ getHandlingControl(scopeId: ImScopeId): ImHandlingControl | undefined;
324
+ /** @param scopeId - complete conversation identity. @returns the stored scope, or absence. */
325
+ getDeliveryScope(scopeId: ImScopeId): ImDeliveryScope | undefined;
326
+ /** @param request - scope and maximum pending live messages. @returns oldest received rows. */
327
+ pendingInbound(request: ImPendingInboundRequest): readonly ImInboundMessageView[];
328
+ /** @param scope - complete conversation identity. @returns frozen Agent task assignment, or absence before admission. */
329
+ getAgentTask(scope: ImDeliveryScope): ImAgentTaskView | undefined;
330
+ /** @param sessionId - real or simulated IM Agent Session. @returns its newest retained task generation, or absence without creating an Agent or reading Session history. */
331
+ executionForSession(sessionId: SessionId): ImAgentTaskView | undefined;
332
+ /** @param scope - complete conversation identity. @param messageId - stored inbound identity. @returns source for an existing Session user/message event. */
333
+ messageSource(scope: ImDeliveryScope, messageId: ImMessageId): ImMessageSource;
334
+ /** @param scope - complete conversation identity. @param messageId - stored inbound identity. @returns identified Session user message with durable IM source. */
335
+ sessionUserMessage(scope: ImDeliveryScope, messageId: ImMessageId): UserMessage;
336
+ /** @param sessionId - durable Session log to compare with pending delivery rows. @returns matched submissions and ignored stale evidence. */
337
+ reconcileSession(sessionId: SessionId): Promise<ImSessionReconciliationResult>;
338
+ /** @param request - Session evidence for atomically submitted inbound rows. @returns committed rows and cursor. */
339
+ markSubmitted(request: ImMarkSubmittedRequest): Promise<ImMarkSubmittedResult>;
340
+ /** @param request - query-only JSONL history and idempotency identity. @returns durable import receipt. */
341
+ importJsonlHistory(request: ImImportJsonlHistoryRequest): Promise<ImImportJsonlHistoryResult>;
342
+ /** @param request - outbound intent persisted before any send. @returns durable safe outbox row. */
343
+ registerOutbound(request: ImRegisterOutboundRequest): Promise<ImOutboundView>;
344
+ /** @param request - Durable automatic dispatch attempt. @param signal - Tool cancellation. @returns Epoch-scoped authorization disposed after provider settlement. */
345
+ automaticSendAuthorization(request: ImBeginOutboundAttemptRequest & {
346
+ readonly attemptId: ImOutboundAttemptId;
347
+ }, signal: AbortSignal): ImAutomaticSendAuthorization;
348
+ /** @param request - real scope and pending request. @returns sole attempt or durable block. */
349
+ beginOutboundAttempt(request: ImBeginOutboundAttemptRequest): Promise<ImBeginOutboundAttemptResult>;
350
+ /** @param request - provider attempt and observed outcome. @returns settled outbox row. */
351
+ settleOutboundAttempt(request: ImSettleOutboundAttemptRequest): Promise<ImOutboundView>;
352
+ /** @param request - simulation scope and local request. @returns locally sent outbox row. */
353
+ settleSimulationOutbound(request: ImSettleSimulationOutboundRequest): Promise<ImOutboundView>;
354
+ /** @param request - complete scope and request identity. @returns outbox row or absence. */
355
+ getOutbound(request: ImGetOutboundRequest): ImOutboundView | undefined;
356
+ /** @param request - bounded outbox history cursor. @returns ascending outbox page. */
357
+ queryOutbound(request: ImOutboundQueryRequest): ImOutboundPage;
358
+ /** @param request - scope and terminal reason. @returns discarded automated rows. */
359
+ cancelPendingAi(request: ImCancelPendingAiRequest): Promise<readonly ImOutboundView[]>;
360
+ /** @param accountId - authenticated SDK account. @param messageId - platform message ID. @param clientId - SDK UUID. @returns exact durable single-chat matches, without matching content. */
361
+ matchSdkMessage(accountId: ImAccountId, messageId: string, clientId?: string): readonly import('./read-types.ts').ImSdkMessageMatch[];
362
+ /** @param scope - complete real scope. @param externalMessageId - provider message identity. @returns matching sent outbox evidence. */
363
+ findSentOutbound(scope: ImRealDeliveryScope, externalMessageId: string): ImOutboundView | undefined;
364
+ /** @param scope - complete real conversation. @param evidence - provider actor or echo facts without message-text heuristics. @returns evidence-backed sender category, including human-native for remembered native-client actors. */
365
+ classifyInboundSender(scope: ImRealDeliveryScope, evidence: ImInboundSenderEvidence): ImSenderAttribution;
366
+ }
@@ -0,0 +1,28 @@
1
+ import type { ImDeliveryScope } from './delivery-types.ts';
2
+ /** Confirmed buyer reading of one exact durable outbound; observation time is not the buyer's reading time. */
3
+ export interface ImMessageReadEvent {
4
+ readonly scope: import('./delivery-types.ts').ImRealDeliveryScope;
5
+ readonly requestId: import('./delivery-types.ts').ImOutboundRequestId;
6
+ readonly platformMessageId: import('./sdk.ts').ImSdkMessageId;
7
+ readonly observedAt: string;
8
+ }
9
+ /** Payload recorded when automatic handling is paused for one conversation. */
10
+ export interface ImHandlingPausedEvent {
11
+ /** Frozen conversation identity. */
12
+ readonly scope: ImDeliveryScope;
13
+ /** Pause reason such as `operator-pause` or `forward-*`; never a secret. */
14
+ readonly reason: string;
15
+ /** Tool or GUI call identity that initiated the pause; empty when none. */
16
+ readonly callId: string;
17
+ }
18
+ declare module '@deepseek-ai/dsh-session/types' {
19
+ interface SessionEventMap {
20
+ /** Buyer read evidence for one identified outbound. Required-on-read; the corresponding im-read context is reconstructed from this fact. */
21
+ 'im/message-read': ImMessageReadEvent;
22
+ /**
23
+ * Automatic handling was paused for one IM scope. Records the scope, pause
24
+ * reason, and initiating call id. Contains no secrets. Required-on-read.
25
+ */
26
+ 'im/handling-paused': ImHandlingPausedEvent;
27
+ }
28
+ }