@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.
- package/LICENSE +21 -0
- package/README.i18n.yaml +58 -0
- package/README.md +290 -2
- package/README.zh.md +290 -0
- package/UPSTREAM.json +66 -0
- package/lib/index.js +140 -0
- package/lib/inline-image-DuX6vSEI.js +20 -0
- package/lib/read-receipts.js +413 -0
- package/lib/read-state-CnUZKCuY.js +1868 -0
- package/lib/runtime-Bm6iSEpv.js +10939 -0
- package/lib/tools.js +2 -0
- package/lib/types/account-placement.d.ts +22 -0
- package/lib/types/admission-annotations.d.ts +40 -0
- package/lib/types/agent-coordinator.d.ts +129 -0
- package/lib/types/agent-media.d.ts +46 -0
- package/lib/types/agent-prompt.d.ts +24 -0
- package/lib/types/checkpoint-recovery.d.ts +32 -0
- package/lib/types/checkpoint.d.ts +127 -0
- package/lib/types/consumer-chat-links.d.ts +59 -0
- package/lib/types/delivery-schema.d.ts +176 -0
- package/lib/types/delivery-sqlite.d.ts +387 -0
- package/lib/types/delivery-types.d.ts +744 -0
- package/lib/types/delivery.d.ts +114 -0
- package/lib/types/errors.d.ts +8 -0
- package/lib/types/evaluation-accounts.d.ts +86 -0
- package/lib/types/index.d.ts +51 -0
- package/lib/types/inline-image.d.ts +7 -0
- package/lib/types/input-drain.d.ts +73 -0
- package/lib/types/knowledge-image.d.ts +64 -0
- package/lib/types/media-lifetime.d.ts +22 -0
- package/lib/types/media.d.ts +32 -0
- package/lib/types/message-preview.d.ts +4 -0
- package/lib/types/message-upload.d.ts +55 -0
- package/lib/types/nas-host-lease.d.ts +33 -0
- package/lib/types/placement-slice.d.ts +30 -0
- package/lib/types/policies.d.ts +63 -0
- package/lib/types/preset-model.d.ts +50 -0
- package/lib/types/read-context.d.ts +27 -0
- package/lib/types/read-receipts.d.ts +10 -0
- package/lib/types/read-records.d.ts +30 -0
- package/lib/types/read-state.d.ts +18 -0
- package/lib/types/read-types.d.ts +28 -0
- package/lib/types/restart-recovery.d.ts +38 -0
- package/lib/types/route-resolve.d.ts +10 -0
- package/lib/types/runtime.d.ts +668 -0
- package/lib/types/schema.d.ts +61 -0
- package/lib/types/script-clock.d.ts +14 -0
- package/lib/types/sdk.d.ts +108 -0
- package/lib/types/service-types.d.ts +366 -0
- package/lib/types/session-events.d.ts +28 -0
- package/lib/types/simulation-batch.d.ts +40 -0
- package/lib/types/simulation-controller.d.ts +77 -0
- package/lib/types/simulation-operator.d.ts +19 -0
- package/lib/types/simulation-tools.d.ts +14 -0
- package/lib/types/sqlite-connection.d.ts +27 -0
- package/lib/types/time.d.ts +13 -0
- package/lib/types/tools.d.ts +17 -0
- package/lib/types/transport.d.ts +202 -0
- package/lib/types/transports.d.ts +48 -0
- package/lib/types/types.d.ts +521 -0
- package/lib/types/typing.d.ts +33 -0
- package/lib/types/upload-types.d.ts +121 -0
- package/lib/types.js +2 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +125 -3
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
/** Durable IM account, route, and simulation-target service. */
|
|
2
|
+
import { type SqliteLockingMode } from './sqlite-connection.ts';
|
|
3
|
+
import { type ImClockSource } from './time.ts';
|
|
4
|
+
import type { ImInjectSimulationOperatorRequest, ImSimulationOperatorReceipt } from './simulation-operator.ts';
|
|
5
|
+
import type { ImUploadBinding } from './upload-types.ts';
|
|
6
|
+
import type { SqliteJournalMode } from './nas-host-lease.ts';
|
|
7
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
8
|
+
import type { UserMessage } from '@deepseek-ai/dsh-llm';
|
|
9
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
10
|
+
import { SessionId } from '@deepseek-ai/dsh-session';
|
|
11
|
+
import './session-events.ts';
|
|
12
|
+
import type { WorkspaceId } from '@deepseek-ai/dsh-workspace';
|
|
13
|
+
import { type ZodType } from 'zod';
|
|
14
|
+
import { type ImCheckpointActivity, type ImCheckpointTransport } from './checkpoint.ts';
|
|
15
|
+
import type { ImExecutionAggregate } from './delivery-schema.ts';
|
|
16
|
+
import { ImInputDrain, type ImInputPause } from './input-drain.ts';
|
|
17
|
+
import { type ImAccountCheckpointRecovery } from './checkpoint-recovery.ts';
|
|
18
|
+
import { type ImAccountPlacementSlice } from './account-placement.ts';
|
|
19
|
+
import { type ImAdmissionAnnotator, type ImAdmissionAnnotationInput } from './admission-annotations.ts';
|
|
20
|
+
import type { ImSendMediaMessageRequest } from './delivery-types.ts';
|
|
21
|
+
import { ImTyping } from './typing.ts';
|
|
22
|
+
import { ImRoutePolicies } from './policies.ts';
|
|
23
|
+
import type { ImPolicyCheckKind, ImPolicyCheckRequest, ImPolicyDecision } from './policies.ts';
|
|
24
|
+
import { ImTransports } from './transports.ts';
|
|
25
|
+
import type { ImAutomaticSendAuthorization } from './transport.ts';
|
|
26
|
+
import type { ImBeginOutboundAttemptRequest, ImBeginOutboundAttemptResult, ImAgentTaskId, 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, ImOutboundAttemptId, ImOutboundRouteBinding, ImOutboundView, ImPendingInboundRequest, ImProviderCursorCommitResult, ImProviderCursorOperationQuery, ImProviderCursorOwner, ImProviderCursorView, ImRealDeliveryScope, ImRealSessionBinding, ImRegisterOutboundRequest, ImRetryManualMessageRequest, ImSendManualMessageRequest, ImSessionReconciliationResult, ImSenderAttribution, ImSetHandlingControlRequest, ImSettleOutboundAttemptRequest, ImSettleSimulationOutboundRequest, ImSimulationDeliveryScope, ImSimulationInstanceId, ImScopeId } from './delivery-types.ts';
|
|
27
|
+
import type { ImAccountId, ImAccountCandidate, ImAccountSetupId, ImAccountSetupPreview, ImCancelAccountSetupResult, ImConfirmAccountSetupRequest, ImAccountLifecycleRequest, ImAccountSetupRequest, ImAccountMutationResult, ImAccountOperationQuery, ImAccountView, ImAssignedActorCandidate, ImConversationCandidate, ImConversationCandidatePage, ImConversationKind, ImDirectRecipient, ImCreateRouteRequest, ImDeleteRouteRequest, ImOperationId, ImPlatform, ImPlatformLoginAttemptId, ImPlatformLoginStatus, ImRebindRouteRequest, ImRemoveSimulationTargetRequest, ImRevision, ImRouteId, ImRouteMutationResult, ImRouteOperationQuery, ImRouteResolution, ImRouteTarget, ImRouteView, ImRuntimeChange, ImRuntimeSnapshot, ImSaveRouteRequest, ImSaveSimulationTargetRequest, ImSetAccountPausedRequest, ImSimulationTargetMutationResult, ImSimulationTargetOperationQuery, ImCreateSimulationInstanceRequest, ImCreateManualSimulationInstanceRequest, ImSimulationInjectionQuery, ImInjectSimulationManagedHumanRequest, ImInjectSimulationMemberRequest, ImImportSimulationHistoryRequest, ImImportSimulationHistoryResult, ImSimulationInstanceView, ImSimulationSessionScope, ImSimulationTargetView } from './types.ts';
|
|
28
|
+
import type { ImRuntimeService } from './service-types.ts';
|
|
29
|
+
declare module '@deepseek-ai/cordis' {
|
|
30
|
+
interface Events {
|
|
31
|
+
/**
|
|
32
|
+
* Synchronous controller veto immediately before an automatic external submission.
|
|
33
|
+
* @param request - Current route controller and conversation.
|
|
34
|
+
* @returns A refusal to block submission, or void to delegate.
|
|
35
|
+
* @mode bail
|
|
36
|
+
*/
|
|
37
|
+
'imRuntime/authorize-submission'(request: ImPolicyCheckRequest): Extract<ImPolicyDecision, {
|
|
38
|
+
allow: false;
|
|
39
|
+
}> | void;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Stable Wangwang refusal when a direct send has no observed counterpart sender. */
|
|
43
|
+
export declare const WANGWANG_DIRECT_RECIPIENT_UNAVAILABLE = "WANGWANG_DIRECT_RECIPIENT_UNAVAILABLE";
|
|
44
|
+
/** Runtime admission, listener recovery, storage, and checkpoint settings. */
|
|
45
|
+
export interface Config {
|
|
46
|
+
/** IANA shop time zone for inbound records and clock context; defaults to Asia/Shanghai. */
|
|
47
|
+
readonly timeZone?: string;
|
|
48
|
+
/** Milliseconds before a verified typing observation disappears; defaults to 5000. */
|
|
49
|
+
readonly typingTimeoutMs?: number;
|
|
50
|
+
/** Maximum decoded bytes in one selected media file; SDK and platform limits may be lower. */
|
|
51
|
+
readonly mediaMaxBytes?: number;
|
|
52
|
+
/** Delay between durable upload retries; network failures never stop IM delivery. */
|
|
53
|
+
readonly uploadRetryMs?: number;
|
|
54
|
+
/** Explicit test run marks real-provider messages as test traffic. */
|
|
55
|
+
readonly uploadTestRunId?: string | undefined;
|
|
56
|
+
/** Maximum inbound messages copied into one Agent input. */
|
|
57
|
+
readonly admissionBatchSize?: number;
|
|
58
|
+
/** Time that unconfirmed provider setup material remains in Host memory. */
|
|
59
|
+
readonly accountSetupTtlMs?: number;
|
|
60
|
+
/** Sqlite file for conversation, cursor, and execution records. */
|
|
61
|
+
readonly deliverySqlitePath?: string | undefined;
|
|
62
|
+
/** SQLite 日志模式,本地缺省 WAL,NAS 配置为 DELETE。 */
|
|
63
|
+
readonly deliveryJournalMode?: SqliteJournalMode;
|
|
64
|
+
/** Connection locking policy; EXCLUSIVE requires sole ownership until close. Defaults to NORMAL. */
|
|
65
|
+
readonly deliveryLockingMode?: SqliteLockingMode;
|
|
66
|
+
/** Page-cache budget in KiB, from 1 through 2147483647; omitted keeps SQLite defaults. */
|
|
67
|
+
readonly deliveryCacheSizeKiB?: number | undefined;
|
|
68
|
+
/** 投递库语句遇锁等待毫秒数;NAS 交接窗口内旧实例短暂持锁时等待而非立即失败。整数 0–60000,缺省 2000。 */
|
|
69
|
+
readonly deliveryBusyTimeoutMs?: number;
|
|
70
|
+
/** 投递库迁移单步遇锁重试的时间预算毫秒数;超限抛 `IM_DELIVERY_SQLITE_BUSY` 且版本号保持不变。整数 0–600000,缺省 30000。 */
|
|
71
|
+
readonly deliveryMigrationRetryBudgetMs?: number;
|
|
72
|
+
/** 云端必须等待 nasHostLease 准入;缺失服务时启动失败。 */
|
|
73
|
+
readonly requireNasLease?: boolean;
|
|
74
|
+
/** Private evaluation resources and simulation upload queue when the cloud Host has no lease; requires placement standby. */
|
|
75
|
+
readonly standbyStorageRoot?: string | undefined;
|
|
76
|
+
/** 交接目标在导入和 prepareResume 完成前停止监听与新 turn,由 Host 显式释放。 */
|
|
77
|
+
readonly placementStandby?: boolean;
|
|
78
|
+
/** Minimum interval between hosting checkpoint reports for one Host. Cursor advances inside the interval share one report. */
|
|
79
|
+
readonly checkpointIntervalMs?: number;
|
|
80
|
+
/** Delay before the first listener reconnect attempt, in milliseconds. */
|
|
81
|
+
readonly listenerReconnectInitialMs?: number;
|
|
82
|
+
/** Maximum exponential reconnect delay, in milliseconds. */
|
|
83
|
+
readonly listenerReconnectMaxMs?: number;
|
|
84
|
+
/** Maximum reconnect starts before stable reception; zero disables retries. */
|
|
85
|
+
readonly listenerReconnectMaxAttempts?: number;
|
|
86
|
+
/** Continuous running time before retry reset, in milliseconds; a page committed while running resets it earlier. */
|
|
87
|
+
readonly listenerReconnectStableMs?: number;
|
|
88
|
+
}
|
|
89
|
+
interface ResolvedConfig {
|
|
90
|
+
readonly timeZone: string;
|
|
91
|
+
readonly typingTimeoutMs: number;
|
|
92
|
+
readonly mediaMaxBytes: number;
|
|
93
|
+
readonly uploadRetryMs: number;
|
|
94
|
+
readonly uploadTestRunId?: string;
|
|
95
|
+
readonly admissionBatchSize: number;
|
|
96
|
+
readonly accountSetupTtlMs: number;
|
|
97
|
+
readonly deliveryJournalMode: SqliteJournalMode;
|
|
98
|
+
readonly deliveryLockingMode: SqliteLockingMode;
|
|
99
|
+
readonly deliveryCacheSizeKiB: number | null;
|
|
100
|
+
readonly deliveryBusyTimeoutMs: number;
|
|
101
|
+
readonly deliveryMigrationRetryBudgetMs: number;
|
|
102
|
+
readonly requireNasLease: boolean;
|
|
103
|
+
readonly standbyStorageRoot?: string | undefined;
|
|
104
|
+
readonly placementStandby: boolean;
|
|
105
|
+
readonly checkpointIntervalMs: number;
|
|
106
|
+
readonly listenerReconnectInitialMs: number;
|
|
107
|
+
readonly listenerReconnectMaxMs: number;
|
|
108
|
+
readonly listenerReconnectMaxAttempts: number;
|
|
109
|
+
readonly listenerReconnectStableMs: number;
|
|
110
|
+
readonly deliverySqlitePath?: string | undefined;
|
|
111
|
+
}
|
|
112
|
+
/** Host service implementing the durable configuration half of IM takeover. */
|
|
113
|
+
export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
114
|
+
static inject: string[];
|
|
115
|
+
static Config: ZodType<Config>;
|
|
116
|
+
private readonly admissionAnnotations;
|
|
117
|
+
private readonly simulationClocks;
|
|
118
|
+
private uploadBinding;
|
|
119
|
+
private uploadQueue;
|
|
120
|
+
private settleUploads;
|
|
121
|
+
private wakeUploads;
|
|
122
|
+
private readonly restartOwner;
|
|
123
|
+
private nasLease;
|
|
124
|
+
/** Instance-private evaluation resource root; absent for formal storage. */
|
|
125
|
+
standbyStorageRoot: string | undefined;
|
|
126
|
+
private evaluationAccounts?;
|
|
127
|
+
private evaluationTail;
|
|
128
|
+
private accounts?;
|
|
129
|
+
private simulationTargets?;
|
|
130
|
+
private simulationInstances?;
|
|
131
|
+
private deliveryRecords?;
|
|
132
|
+
private readonly mediaLifetime;
|
|
133
|
+
private mediaSender?;
|
|
134
|
+
private delivery?;
|
|
135
|
+
/** Host 输入排空;不改变持久化的账号和托管意图。 */
|
|
136
|
+
readonly inputDrain: ImInputDrain;
|
|
137
|
+
private readonly placementSdkImports;
|
|
138
|
+
private placementStandby;
|
|
139
|
+
private readonly placementImports;
|
|
140
|
+
private readonly placementRecoveries;
|
|
141
|
+
private readonly placementImportPauses;
|
|
142
|
+
/** Input holds of rejected placement-import attempts; the next attempt reuses them instead of adding a hold release cannot reach. */
|
|
143
|
+
private readonly placementRetryPauses;
|
|
144
|
+
private readonly placementStopped;
|
|
145
|
+
private readonly accountInputs;
|
|
146
|
+
private agentScope;
|
|
147
|
+
private agentAccounts;
|
|
148
|
+
private coordinator;
|
|
149
|
+
private simulationController;
|
|
150
|
+
private readonly pendingAutomaticPauses;
|
|
151
|
+
private checkpointReporter;
|
|
152
|
+
private readonly automaticSendEpochs;
|
|
153
|
+
private generation;
|
|
154
|
+
private deliveryGeneration;
|
|
155
|
+
private simulationTail;
|
|
156
|
+
private readonly activeListeners;
|
|
157
|
+
private readonly listenerStates;
|
|
158
|
+
private readonly listenerTails;
|
|
159
|
+
private readonly listenerRetries;
|
|
160
|
+
private readonly listenerAttempts;
|
|
161
|
+
private listenersDisposed;
|
|
162
|
+
private readonly pendingAccountSetups;
|
|
163
|
+
private readonly setupAccounts;
|
|
164
|
+
private reservedPlacementAccountId;
|
|
165
|
+
private readonly observations;
|
|
166
|
+
readonly transports: ImTransports;
|
|
167
|
+
readonly policies: ImRoutePolicies;
|
|
168
|
+
/** Transient sidebar typing; independent of durable delivery and Agent input. */
|
|
169
|
+
readonly typing: ImTyping;
|
|
170
|
+
/** Shop time zone used by inbound records and customer-service context. */
|
|
171
|
+
get timeZone(): string;
|
|
172
|
+
readonly config: ResolvedConfig;
|
|
173
|
+
/** @param ctx - Cordis context carrying StorageDomain and Credentials. @param config - validated Agent admission limits. */
|
|
174
|
+
constructor(ctx: Context, config?: Config);
|
|
175
|
+
/** @param annotator - Optional product analysis. @returns Disposer that prevents further calls. */
|
|
176
|
+
registerAdmissionAnnotator(annotator: ImAdmissionAnnotator): () => Promise<void>;
|
|
177
|
+
/** @param input - Frozen message batch. @param signal - Coordinator lifetime. @returns Results frozen into the pending admission before append. */
|
|
178
|
+
annotateAdmission(input: ImAdmissionAnnotationInput, signal: AbortSignal): Promise<readonly import('./delivery-types.ts').ImAdmissionAnnotation[]>;
|
|
179
|
+
/** Open the authoritative configuration domain before publishing the service. */
|
|
180
|
+
protected [Service.init](): Promise<void>;
|
|
181
|
+
private initializeMediaResources;
|
|
182
|
+
/**
|
|
183
|
+
* Bind the product's authenticated customer-message transport. Standby uploads only evaluation simulation messages from private storage. A journal in each SQLite mutation bridges crashes before the external queue is synced.
|
|
184
|
+
* @param binding - capture eligibility and credential-free destination, plus cancellable transport.
|
|
185
|
+
* @returns async disposer that aborts and awaits the current request before SQLite closes.
|
|
186
|
+
*/
|
|
187
|
+
bindMessageUpload(binding: ImUploadBinding): () => Promise<void>;
|
|
188
|
+
private reportUpload;
|
|
189
|
+
/**
|
|
190
|
+
* Send throttled hosting checkpoints through this transport.
|
|
191
|
+
* @param transport - server reporter. A later bind replaces the previous one.
|
|
192
|
+
* @param activity - product-owned intent, admission and model availability.
|
|
193
|
+
* @returns disposer that stops reporting.
|
|
194
|
+
*/
|
|
195
|
+
bindCheckpointTransport(transport: ImCheckpointTransport, activity?: (accountId: ImAccountId) => Omit<ImCheckpointActivity, 'inFlight'>): () => void;
|
|
196
|
+
/** @param accountId - account whose held lease epoch changed. */
|
|
197
|
+
resumeCheckpoint(accountId: ImAccountId): void;
|
|
198
|
+
/** @param accountId - account whose automatic reception state changed. */
|
|
199
|
+
noteCheckpoint(accountId: ImAccountId): void;
|
|
200
|
+
private checkpointFacts;
|
|
201
|
+
snapshot(): ImRuntimeSnapshot;
|
|
202
|
+
subscribe(listener: (change: ImRuntimeChange) => void): () => void;
|
|
203
|
+
startPlatformLogin(platform: ImPlatform, signal?: AbortSignal): Promise<ImPlatformLoginStatus>;
|
|
204
|
+
platformLoginStatus(platform: ImPlatform, attemptId: ImPlatformLoginAttemptId): ImPlatformLoginStatus;
|
|
205
|
+
cancelPlatformLogin(platform: ImPlatform, attemptId: ImPlatformLoginAttemptId): Promise<ImPlatformLoginStatus>;
|
|
206
|
+
listAccountCandidates(platform: ImPlatform, signal?: AbortSignal): Promise<readonly ImAccountCandidate[]>;
|
|
207
|
+
discoverConversations(accountId: ImAccountId, signal?: AbortSignal): Promise<ImConversationCandidatePage>;
|
|
208
|
+
inspectConversation(accountId: ImAccountId, conversationId: string, conversationKind: ImConversationKind, signal?: AbortSignal): Promise<ImConversationCandidate>;
|
|
209
|
+
/** @param accountId - configured account. @param signal - caller lifetime. @returns assigned service accounts when the platform exposes them. */
|
|
210
|
+
listAssignedActors(accountId: ImAccountId, signal?: AbortSignal): Promise<readonly ImAssignedActorCandidate[]>;
|
|
211
|
+
previewAccountSetup(request: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountSetupPreview>;
|
|
212
|
+
confirmAccountSetup(request: ImConfirmAccountSetupRequest): Promise<ImAccountMutationResult>;
|
|
213
|
+
cancelAccountSetup(setupId: ImAccountSetupId): ImCancelAccountSetupResult;
|
|
214
|
+
/** @returns After all evaluation consumers and storage handles have closed; call from the placement owner after evaluation and CLI join. */
|
|
215
|
+
closeEvaluationResources(): Promise<void>;
|
|
216
|
+
/** @returns After this runtime reloads against an admitted NAS lease; consumers must be reacquired by the caller. */
|
|
217
|
+
reloadWithNasLease(): Promise<void>;
|
|
218
|
+
/** @inheritdoc */
|
|
219
|
+
holdsNasLease(): boolean;
|
|
220
|
+
/** @inheritdoc */
|
|
221
|
+
ensureEvaluationAccount(sellerId: string, workspaceId: WorkspaceId): Promise<{
|
|
222
|
+
readonly account: ImAccountView;
|
|
223
|
+
readonly route: ImRouteView;
|
|
224
|
+
}>;
|
|
225
|
+
/** @inheritdoc */
|
|
226
|
+
isEvaluationAccount(accountId: ImAccountId, sellerId?: string): boolean;
|
|
227
|
+
/** @inheritdoc */
|
|
228
|
+
releaseEvaluationAccountRoute(accountId: ImAccountId, observedRevision: ImRevision): Promise<boolean>;
|
|
229
|
+
private evaluationOperation;
|
|
230
|
+
private evaluationAccountTable;
|
|
231
|
+
addAccount(request: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountView>;
|
|
232
|
+
setAccountPaused(request: ImSetAccountPausedRequest): Promise<ImAccountMutationResult>;
|
|
233
|
+
disconnectAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
|
|
234
|
+
/** @inheritdoc */
|
|
235
|
+
setSdkConnectionIntent(accountId: ImAccountId, intent: ImAccountView['sdkConnectionIntent'], expectedIntent?: {
|
|
236
|
+
readonly revision: ImAccountView['sdkConnectionIntentRevision'];
|
|
237
|
+
}): Promise<boolean>;
|
|
238
|
+
reconnectAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
|
|
239
|
+
/** @inheritdoc */
|
|
240
|
+
retainedAccounts(): readonly {
|
|
241
|
+
readonly account: ImAccountView;
|
|
242
|
+
readonly replacedHidden: boolean;
|
|
243
|
+
}[];
|
|
244
|
+
/** @inheritdoc */
|
|
245
|
+
hideReplacedAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
|
|
246
|
+
/** @inheritdoc */
|
|
247
|
+
restoreReplacedAccount(request: ImAccountLifecycleRequest, setup: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountMutationResult>;
|
|
248
|
+
/**
|
|
249
|
+
* Delete one configured account after comparing its observed revision.
|
|
250
|
+
* @param request - account identity and revision observed before confirmation.
|
|
251
|
+
* @returns the durable deletion receipt.
|
|
252
|
+
*/
|
|
253
|
+
deleteAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
|
|
254
|
+
/**
|
|
255
|
+
* Install verified credentials for the same merchant under the observed revision.
|
|
256
|
+
* @param request - account and revision observed before the OAuth allocation started.
|
|
257
|
+
* @param setup - Host-only credentials for that same merchant; never a replacement merchant.
|
|
258
|
+
* @param signal - generation lifetime during verification and installation.
|
|
259
|
+
* @returns a durable receipt; a concurrent lifecycle command wins without changing credentials.
|
|
260
|
+
*/
|
|
261
|
+
renewAccount(request: ImAccountLifecycleRequest, setup: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountMutationResult>;
|
|
262
|
+
private renewCredentials;
|
|
263
|
+
refreshAccount(request: ImAccountLifecycleRequest, signal?: AbortSignal): Promise<ImAccountMutationResult>;
|
|
264
|
+
queryAccountOperation(accountId: ImAccountId, operationId: ImOperationId): ImAccountOperationQuery;
|
|
265
|
+
createRoute(request: ImCreateRouteRequest): Promise<ImRouteMutationResult>;
|
|
266
|
+
saveRoute(request: ImSaveRouteRequest): Promise<ImRouteMutationResult>;
|
|
267
|
+
rebindRoute(request: ImRebindRouteRequest): Promise<ImRouteMutationResult>;
|
|
268
|
+
deleteRoute(request: ImDeleteRouteRequest): Promise<ImRouteMutationResult>;
|
|
269
|
+
queryRouteOperation(account: ImAccountId, operationId: ImOperationId): ImRouteOperationQuery;
|
|
270
|
+
/**
|
|
271
|
+
* Keep history flowing for one account without an enabled admit route.
|
|
272
|
+
* @param accountId - connected account.
|
|
273
|
+
* @param observation - conversation kind and target to receive.
|
|
274
|
+
* @returns disposer that drops the lease and reconciles the listener.
|
|
275
|
+
*/
|
|
276
|
+
registerObservation(accountId: ImAccountId, observation: {
|
|
277
|
+
readonly conversationKind: ImConversationKind;
|
|
278
|
+
readonly target: ImRouteTarget;
|
|
279
|
+
}): () => void;
|
|
280
|
+
/**
|
|
281
|
+
* Authorize one admission or automated send when the route declared a controller.
|
|
282
|
+
* Ordinary routes without a controller are allowed.
|
|
283
|
+
* @param kind - check moment.
|
|
284
|
+
* @param route - frozen route.
|
|
285
|
+
* @param scope - conversation identity.
|
|
286
|
+
*/
|
|
287
|
+
authorizeRoutePolicy(kind: ImPolicyCheckKind, route: ImRouteView, scope: import('./delivery-types.ts').ImDeliveryScope): Promise<ImPolicyDecision>;
|
|
288
|
+
resolveRoute(account: ImAccountId, conversationKind: ImConversationKind, conversationId: string, assignedActorId?: string): ImRouteResolution;
|
|
289
|
+
/** Whether this real conversation currently admits automatic handling. */
|
|
290
|
+
private conversationAdmits;
|
|
291
|
+
/** @param scope - durable real conversation. @returns last admitted presentation, including the assigned service account when known. */
|
|
292
|
+
getConversationPresentation(scope: ImRealDeliveryScope): import('./delivery-types.ts').ImConversationPresentation | undefined;
|
|
293
|
+
saveSimulationTarget(request: ImSaveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
294
|
+
/** @inheritdoc */
|
|
295
|
+
saveFormalSimulationTarget(request: ImSaveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
296
|
+
private saveTarget;
|
|
297
|
+
removeSimulationTarget(request: ImRemoveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
298
|
+
/** @inheritdoc */
|
|
299
|
+
removeFormalSimulationTarget(request: ImRemoveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
300
|
+
private removeTarget;
|
|
301
|
+
private requireNonEvaluationTargets;
|
|
302
|
+
querySimulationTargetOperation(workspaceId: WorkspaceId, operationId: ImOperationId): ImSimulationTargetOperationQuery;
|
|
303
|
+
listSimulationInstances(): readonly ImSimulationInstanceView[];
|
|
304
|
+
getSimulationInstance(instanceId: ImSimulationInstanceId): ImSimulationInstanceView | undefined;
|
|
305
|
+
holdSimulationBuyer(instanceId: ImSimulationInstanceId): () => void;
|
|
306
|
+
deliverSimulationBuyerReplies(instanceId: ImSimulationInstanceId): Promise<number>;
|
|
307
|
+
registerSimulationClock(instanceId: ImSimulationInstanceId, source: ImClockSource): () => void;
|
|
308
|
+
private deliveryTime;
|
|
309
|
+
currentTime(sessionId: SessionId): number;
|
|
310
|
+
scopeForSession(sessionId: SessionId): ImSimulationSessionScope | undefined;
|
|
311
|
+
realScopeForSession(sessionId: SessionId): ImRealSessionBinding | undefined;
|
|
312
|
+
realBindingForScope(scopeId: ImScopeId): ImRealSessionBinding | undefined;
|
|
313
|
+
sendManualMessage(request: ImSendManualMessageRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
|
|
314
|
+
private sendManualMediaMessage;
|
|
315
|
+
/** @param request - Host-authorized media bytes and owning scope; automatic calls require the frozen task route. @param signal - operation cancellation. @returns durable media outbox result; uncertain submission is never repeated. */
|
|
316
|
+
sendMediaMessage(request: ImSendMediaMessageRequest, signal?: AbortSignal): Promise<ImOutboundView>;
|
|
317
|
+
private dispatchMediaMessage;
|
|
318
|
+
/** @param request - manual Session or scope identity and an owned file request. @returns a fresh download URL, requiring the current online IM generation. */
|
|
319
|
+
mediaDownloadUrl(request: ImManualMessageQueryRequest): Promise<string>;
|
|
320
|
+
queryManualMessage(request: ImManualMessageQueryRequest): ImManualMessageQuery;
|
|
321
|
+
confirmManualMessage(request: ImManualMessageQueryRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
|
|
322
|
+
retryManualMessage(request: ImRetryManualMessageRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
|
|
323
|
+
createManualSimulationInstance(request: ImCreateManualSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
|
|
324
|
+
createSimulationInstance(request: ImCreateSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
|
|
325
|
+
/** @inheritdoc */
|
|
326
|
+
createFormalSimulationInstance(request: ImCreateSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
|
|
327
|
+
injectSimulationMember(request: ImInjectSimulationMemberRequest): Promise<ImInboundMessageView>;
|
|
328
|
+
injectSimulationManagedHuman(request: ImInjectSimulationManagedHumanRequest): Promise<ImInboundMessageView>;
|
|
329
|
+
injectSimulationOperator(request: ImInjectSimulationOperatorRequest): Promise<ImSimulationOperatorReceipt>;
|
|
330
|
+
querySimulationInjection(request: ImSimulationInjectionQuery): ImInboundOperationQuery;
|
|
331
|
+
beginStopSimulation(instanceId: ImSimulationInstanceId): Promise<ImSimulationInstanceView>;
|
|
332
|
+
beginStopSimulationForSession(sessionId: SessionId): Promise<ImSimulationInstanceView>;
|
|
333
|
+
waitSimulationStopped(instanceId: ImSimulationInstanceId): Promise<ImSimulationInstanceView>;
|
|
334
|
+
subscribeDelivery(listener: (change: ImDeliveryChange) => void): () => void;
|
|
335
|
+
ingestInboundPage(request: ImIngestInboundPageRequest): Promise<ImInboundPageResult>;
|
|
336
|
+
queryInboundOperation(scope: ImDeliveryScope, operationId: ImDeliveryOperationId): ImInboundOperationQuery;
|
|
337
|
+
getConversationCursor(scope: ImDeliveryScope): ImConversationCursor;
|
|
338
|
+
projectConversations<T extends object>(project: (records: ImConversationRecords) => T): ImConversationProjection<T>;
|
|
339
|
+
getProviderCursor(owner: ImProviderCursorOwner): ImProviderCursorView;
|
|
340
|
+
commitProviderCursor(request: ImCommitProviderCursorRequest): Promise<ImProviderCursorCommitResult>;
|
|
341
|
+
queryProviderCursorOperation(owner: ImProviderCursorOwner, operationId: ImDeliveryOperationId): ImProviderCursorOperationQuery;
|
|
342
|
+
queryHistory(request: ImHistoryQueryRequest): ImHistoryPage;
|
|
343
|
+
/**
|
|
344
|
+
* List customer rows for one account and source from the rebuildable index.
|
|
345
|
+
* @param request - account, real/simulation filter, optional substring, and reader.
|
|
346
|
+
*/
|
|
347
|
+
listCustomers(request: ImCustomerListRequest): ImCustomerListPage;
|
|
348
|
+
/** @param request - account, source, search and cursor. @returns customer Session references without unread calculations. */
|
|
349
|
+
listCustomerSessions(request: ImCustomerSessionListRequest): ImCustomerSessionPage;
|
|
350
|
+
/**
|
|
351
|
+
* Advance one reader's live inbound watermark with max semantics.
|
|
352
|
+
* @param request - reader, scope, and observed arrival sequence.
|
|
353
|
+
*/
|
|
354
|
+
ackCustomerRead(request: ImCustomerReadAckRequest): void;
|
|
355
|
+
/**
|
|
356
|
+
* Persist one scope's automatic-handling pause fact.
|
|
357
|
+
* @param request - scope and pause fields.
|
|
358
|
+
*/
|
|
359
|
+
setHandlingControl(request: ImSetHandlingControlRequest): ImHandlingControl;
|
|
360
|
+
/**
|
|
361
|
+
* Read one scope's automatic-handling pause fact.
|
|
362
|
+
* @param scopeId - complete conversation identity.
|
|
363
|
+
*/
|
|
364
|
+
getHandlingControl(scopeId: ImScopeId): ImHandlingControl | undefined;
|
|
365
|
+
/**
|
|
366
|
+
* Project an unresolved durable forward pause into automatic-processing authorization.
|
|
367
|
+
* @param scopeId - Customer whose journal pause is unresolved.
|
|
368
|
+
* @param pending - True before attempting persistence; false only after reconciling the durable pause and journal acknowledgement.
|
|
369
|
+
* Pending projections survive their caller's disposal until reconciliation or runtime shutdown; they do not change the persisted handling control.
|
|
370
|
+
*/
|
|
371
|
+
setAutomaticHandlingPausePending(scopeId: ImScopeId, pending: boolean): void;
|
|
372
|
+
/** @param scopeId - Complete customer scope. @returns Whether a pending journal pause or durable handling control blocks automatic processing. */
|
|
373
|
+
isAutomaticHandlingBlocked(scopeId: ImScopeId): boolean;
|
|
374
|
+
private recordHandlingPaused;
|
|
375
|
+
/**
|
|
376
|
+
* Open a persisted Agent Session and append `im/handling-paused`.
|
|
377
|
+
* When no Session log exists, skip the event: handling control remains the
|
|
378
|
+
* SQLite row from `setHandlingControl`, which is the source of truth for
|
|
379
|
+
* pause/resume even if a later Agent Session is created.
|
|
380
|
+
*/
|
|
381
|
+
private appendHandlingPausedToPersisted;
|
|
382
|
+
/**
|
|
383
|
+
* Resolve a stored conversation identity from its scope id.
|
|
384
|
+
* @param scopeId - complete conversation identity.
|
|
385
|
+
*/
|
|
386
|
+
getDeliveryScope(scopeId: ImScopeId): ImDeliveryScope | undefined;
|
|
387
|
+
pendingInbound(request: ImPendingInboundRequest): readonly ImInboundMessageView[];
|
|
388
|
+
getAgentTask(scope: ImDeliveryScope): ImAgentTaskView | undefined;
|
|
389
|
+
/** @param scope - complete conversation identity. @param messageId - stored inbound identity. @returns stored message. */
|
|
390
|
+
getInboundMessage(scope: ImDeliveryScope, messageId: ImMessageId): ImInboundMessageView;
|
|
391
|
+
messageSource(scope: ImDeliveryScope, messageId: ImMessageId): ImMessageSource;
|
|
392
|
+
markSubmitted(request: ImMarkSubmittedRequest): Promise<ImMarkSubmittedResult>;
|
|
393
|
+
/** Consume live pending that a route policy just refused, without an Agent turn. */
|
|
394
|
+
suppressUnadmitted(scope: ImDeliveryScope): Promise<void>;
|
|
395
|
+
/** Advance watermarks of conversations this newly enabled route would now admit. */
|
|
396
|
+
private suppressUnadmittedMatchedBy;
|
|
397
|
+
sessionUserMessage(scope: ImDeliveryScope, messageId: ImMessageId): UserMessage;
|
|
398
|
+
reconcileSession(sessionId: SessionId): Promise<ImSessionReconciliationResult>;
|
|
399
|
+
importJsonlHistory(request: ImImportJsonlHistoryRequest): Promise<ImImportJsonlHistoryResult>;
|
|
400
|
+
importSimulationHistory(request: ImImportSimulationHistoryRequest): Promise<ImImportSimulationHistoryResult>;
|
|
401
|
+
registerOutbound(request: ImRegisterOutboundRequest): Promise<ImOutboundView>;
|
|
402
|
+
/** @param request - scope-fixed automated intent. @param binding - task generation recorded before Agent execution. @returns durable intent or a route-changed rejection. */
|
|
403
|
+
registerAgentOutbound(request: ImRegisterOutboundRequest, binding: ImOutboundRouteBinding): Promise<ImOutboundView>;
|
|
404
|
+
/**
|
|
405
|
+
* Bind automatic provider preparation to one scope's handling epoch and durable attempt.
|
|
406
|
+
* @param request - Owning dispatch attempt.
|
|
407
|
+
* @param signal - Tool cancellation, retained after external submission.
|
|
408
|
+
* @returns Provider authorization; dispose after settlement. Submission rechecks controller policy; customer pause revokes only unsubmitted preparation.
|
|
409
|
+
*/
|
|
410
|
+
automaticSendAuthorization(request: ImBeginOutboundAttemptRequest & {
|
|
411
|
+
readonly attemptId: ImOutboundAttemptId;
|
|
412
|
+
}, signal: AbortSignal): ImAutomaticSendAuthorization;
|
|
413
|
+
beginOutboundAttempt(request: ImBeginOutboundAttemptRequest): Promise<ImBeginOutboundAttemptResult>;
|
|
414
|
+
settleOutboundAttempt(request: ImSettleOutboundAttemptRequest): Promise<ImOutboundView>;
|
|
415
|
+
settleSimulationOutbound(request: ImSettleSimulationOutboundRequest): Promise<ImOutboundView>;
|
|
416
|
+
getOutbound(request: ImGetOutboundRequest): ImOutboundView | undefined;
|
|
417
|
+
queryOutbound(request: ImOutboundQueryRequest): ImOutboundPage;
|
|
418
|
+
cancelPendingAi(request: ImCancelPendingAiRequest): Promise<readonly ImOutboundView[]>;
|
|
419
|
+
/** @param accountId - authenticated transport account. @param messageId - observed SDK platform message. @param clientId - observed SDK UUID. @returns exact identifier matches in live single-chat history or confirmed outbox; never matches text. */
|
|
420
|
+
matchSdkMessage(accountId: ImAccountId, messageId: string, clientId?: string): readonly import('./read-types.ts').ImSdkMessageMatch[];
|
|
421
|
+
findSentOutbound(scope: ImRealDeliveryScope, externalMessageId: string): ImOutboundView | undefined;
|
|
422
|
+
private confirmUnknownOutbound;
|
|
423
|
+
private storedInbound;
|
|
424
|
+
private inboundSender;
|
|
425
|
+
classifyInboundSender(scope: ImRealDeliveryScope, evidence: ImInboundSenderEvidence): ImSenderAttribution;
|
|
426
|
+
private isNativeActor;
|
|
427
|
+
/** @param workspaceId - simulated-user Workspace. @returns its current target setting. */
|
|
428
|
+
simulationTargetForWorkspace(workspaceId: WorkspaceId): ImSimulationTargetView | undefined;
|
|
429
|
+
/** @param target - current workspace target setting. @returns its exact route when still present. */
|
|
430
|
+
routeForSimulationTarget(target: ImSimulationTargetView): ImRouteView | undefined;
|
|
431
|
+
/** @param target - current workspace target setting. @returns its exact safe account when still present. */
|
|
432
|
+
accountForSimulationTarget(target: ImSimulationTargetView): ImAccountView | undefined;
|
|
433
|
+
/** @param accountId - Simulation-owned account reference. @returns Formal or evaluation identity, excluding replaced accounts; never use for formal authorization. */
|
|
434
|
+
accountForSimulation(accountId: ImAccountId): ImAccountView | undefined;
|
|
435
|
+
/** @param accountId - Simulation-owned account reference. @param routeId - Exact route reference. @returns Its live formal or fixed evaluation route; never use for formal route mutation. */
|
|
436
|
+
routeForSimulation(accountId: ImAccountId, routeId: ImRouteId): ImRouteView | undefined;
|
|
437
|
+
/** @param scope - claimed frozen simulation scope. @returns whether its exact instance accepts delivery. */
|
|
438
|
+
isSimulationScopeRunning(scope: ImSimulationDeliveryScope): boolean;
|
|
439
|
+
/** Emit a post-commit instance notification for BFF followers. @param instanceId - changed instance. */
|
|
440
|
+
publishSimulationInstanceChange(instanceId: ImSimulationInstanceId): void;
|
|
441
|
+
private requireRealSessionBinding;
|
|
442
|
+
private requireManualBinding;
|
|
443
|
+
private assertNamedManualAccount;
|
|
444
|
+
/**
|
|
445
|
+
* Hosting controllers shop-match human-manual send the same way they
|
|
446
|
+
* shop-match `requireOwnedScope`. Ordinary routes without a controller skip.
|
|
447
|
+
*/
|
|
448
|
+
private authorizeManualSend;
|
|
449
|
+
private realBindingForScopeSeat;
|
|
450
|
+
private bindingFromTask;
|
|
451
|
+
/**
|
|
452
|
+
* Direct peer that a send may use.
|
|
453
|
+
* Wangwang uses an observed external sender before the latest platform-provided peer saved on the conversation. The conversation id is never a recipient. Other platforms keep a stored peer, then an observed sender.
|
|
454
|
+
* @param scope - conversation being sent or displayed.
|
|
455
|
+
* @param stored - recipient frozen on the task, when one exists.
|
|
456
|
+
* @returns usable peer, or absence when neither sender evidence nor a platform peer exists.
|
|
457
|
+
*/
|
|
458
|
+
usableDirectRecipient(scope: ImDeliveryScope, stored?: ImDirectRecipient): ImDirectRecipient | undefined;
|
|
459
|
+
/**
|
|
460
|
+
* Store the Wangwang peer a send is allowed to use, including clearing one unsupported by sender evidence or the platform.
|
|
461
|
+
* @param sessionId - Agent Session that owns the task, when one exists.
|
|
462
|
+
* @param recipient - usable peer, or absence.
|
|
463
|
+
*/
|
|
464
|
+
rememberDirectRecipient(sessionId: SessionId | undefined, recipient: ImDirectRecipient | undefined): Promise<void>;
|
|
465
|
+
private composeRealBinding;
|
|
466
|
+
private requireManualAccount;
|
|
467
|
+
private outboundOwner;
|
|
468
|
+
private assertManualRequestOwner;
|
|
469
|
+
private manualMessageResult;
|
|
470
|
+
private dispatchManualMessage;
|
|
471
|
+
private finishManualMessage;
|
|
472
|
+
/**
|
|
473
|
+
* Persist a DSH operator send as live inbound so Agent admission does not wait for a provider echo.
|
|
474
|
+
* @param scope - conversation that owns the outbound.
|
|
475
|
+
* @param outbound - settled human-manual intent.
|
|
476
|
+
*/
|
|
477
|
+
private admitManualOutbound;
|
|
478
|
+
private settleManualResult;
|
|
479
|
+
private prepareVerifiedAccount;
|
|
480
|
+
private persistPreparedAccount;
|
|
481
|
+
/** 把首次开通生成的账号固定给后续确认。重复调用必须是同一个 id。 */
|
|
482
|
+
reservePlacementAccount(accountId: ImAccountId): void;
|
|
483
|
+
private accountIdForSetup;
|
|
484
|
+
private expireAccountSetup;
|
|
485
|
+
private releaseAccountSetup;
|
|
486
|
+
private clearAccountSetups;
|
|
487
|
+
private assertFormalAccess;
|
|
488
|
+
private accountTable;
|
|
489
|
+
private simulationTargetTable;
|
|
490
|
+
private simulationInstanceTable;
|
|
491
|
+
private requireSimulationController;
|
|
492
|
+
private simulationScope;
|
|
493
|
+
private deliveryStore;
|
|
494
|
+
private deliveryRecordsStore;
|
|
495
|
+
/**
|
|
496
|
+
* Insert one execution when its task id is absent.
|
|
497
|
+
* @param task - durable Agent task generation.
|
|
498
|
+
* @returns the stored record, which may already exist.
|
|
499
|
+
*/
|
|
500
|
+
persistExecution(task: ImExecutionAggregate): Promise<ImExecutionAggregate>;
|
|
501
|
+
/**
|
|
502
|
+
* Overwrite one execution record.
|
|
503
|
+
* @param task - complete stored generation.
|
|
504
|
+
*/
|
|
505
|
+
putExecution(task: ImExecutionAggregate): Promise<void>;
|
|
506
|
+
/**
|
|
507
|
+
* Read one execution by task id.
|
|
508
|
+
* @param id - durable task identity.
|
|
509
|
+
* @returns the stored generation, or absence.
|
|
510
|
+
*/
|
|
511
|
+
getExecution(id: ImAgentTaskId): ImExecutionAggregate | undefined;
|
|
512
|
+
/**
|
|
513
|
+
* Apply one serialized transform to a stored execution.
|
|
514
|
+
* @param id - durable task identity.
|
|
515
|
+
* @param fn - synchronous transform of the current record.
|
|
516
|
+
* @returns the stored next record.
|
|
517
|
+
*/
|
|
518
|
+
updateExecution(id: ImAgentTaskId, fn: (current: ImExecutionAggregate) => ImExecutionAggregate): Promise<ImExecutionAggregate>;
|
|
519
|
+
/** @returns 当前客服托管路由登记的最新 Session;只查账号与会话索引。 */
|
|
520
|
+
hostingRecoveryTasks(): readonly ImExecutionAggregate[];
|
|
521
|
+
/**
|
|
522
|
+
* List task generations for one conversation in generation order.
|
|
523
|
+
* @param scopeId - complete conversation identity.
|
|
524
|
+
* @returns stored generations for that scope.
|
|
525
|
+
*/
|
|
526
|
+
executionsForScope(scopeId: import('./delivery-types.ts').ImScopeId): readonly ImExecutionAggregate[];
|
|
527
|
+
/**
|
|
528
|
+
* Resolve the latest execution bound to one Agent Session.
|
|
529
|
+
* @param sessionId - IM Agent Session.
|
|
530
|
+
* @returns that Session's newest task, or absence.
|
|
531
|
+
*/
|
|
532
|
+
executionForSession(sessionId: SessionId): ImExecutionAggregate | undefined;
|
|
533
|
+
private assertUnusedIdentity;
|
|
534
|
+
private requireAccount;
|
|
535
|
+
private accountError;
|
|
536
|
+
private updateAccountRoute;
|
|
537
|
+
private enqueueSimulation;
|
|
538
|
+
/** Persist a connection intent separately from pause and process listener state. */
|
|
539
|
+
private setConnectionIntent;
|
|
540
|
+
/** Store one provider authorization observation under the account revision CAS. */
|
|
541
|
+
private storeRefreshResult;
|
|
542
|
+
private publish;
|
|
543
|
+
private publishDelivery;
|
|
544
|
+
/** Serialize listener state changes for one configured account. */
|
|
545
|
+
private scheduleListener;
|
|
546
|
+
/** Start or stop the provider listener from durable account, route, and observation facts. */
|
|
547
|
+
private reconcileListener;
|
|
548
|
+
/** Stop one exact listener before publishing a later start for the same account. */
|
|
549
|
+
private stopListener;
|
|
550
|
+
/** Consume a listener's terminal result before scheduling replacement work. */
|
|
551
|
+
private observeListener;
|
|
552
|
+
/** Release the completed provider generation on the same queue as starts and stops. */
|
|
553
|
+
private finishListener;
|
|
554
|
+
/** Cancel stability observation for one exact listener generation. */
|
|
555
|
+
private cancelListenerStableTimer;
|
|
556
|
+
/** Reset retries only for the running generation that demonstrated stable reception. */
|
|
557
|
+
private markListenerStable;
|
|
558
|
+
/** Cancel the sole retry callback owned by an account. */
|
|
559
|
+
private cancelListenerRetry;
|
|
560
|
+
/** Retain a safe error code and spend the retry budget until reception stabilizes. */
|
|
561
|
+
private retryListener;
|
|
562
|
+
/** Stop one ready provider handle and consume its terminal signal without exposing provider errors. */
|
|
563
|
+
private closeListenerHandle;
|
|
564
|
+
/** Drain every provider listener owned by this runtime. */
|
|
565
|
+
private stopAllListeners;
|
|
566
|
+
/**
|
|
567
|
+
* 关闭新页面、Agent 输入及 turn;已准入工作可结束,不取消 turn。
|
|
568
|
+
* @returns 暂停所有权;调用者在取消、保留期到期或卸载时 resume。
|
|
569
|
+
*/
|
|
570
|
+
pauseInput(): ImInputPause;
|
|
571
|
+
/** @param accountId - 交接账号;不改变持久化连接或路由代次。 @returns 仅该账号的输入暂停所有权;其他账号和个人 Workspace 继续运行。 */
|
|
572
|
+
pauseAccountInput(accountId: ImAccountId): ImInputPause;
|
|
573
|
+
/**
|
|
574
|
+
* 取消排空超时的账号任务,保留尚未准入的输入。
|
|
575
|
+
* @param accountId - 已持有独立输入暂停的账号;子 Agent 按当前进程的实际所有权归属。
|
|
576
|
+
*/
|
|
577
|
+
cancelAccountActivityForPlacement(accountId: ImAccountId): void;
|
|
578
|
+
/**
|
|
579
|
+
* 停止已排空的来源账号,或仍持有目标启动暂停的账号。
|
|
580
|
+
* @param accountId - 本次显式交接的账号。
|
|
581
|
+
* @returns SDK 已登出且踢线意图已提交,监听已确认停止、未发出的自动回复已标记取消;保留在线意图,失败保留停止门,目标也不能释放启动暂停。
|
|
582
|
+
*/
|
|
583
|
+
stopAccountForPlacement(accountId: ImAccountId): Promise<void>;
|
|
584
|
+
/** @param accountId - 已鉴权的真实旺旺账号。 @param workspaceId - 来源客服内置 Workspace。 @returns 独立切片,凭据引用按本账号成功续签收据核验并映射为规范键;预复制可读取,最终导出前调用方必须排空并停止监听。 */
|
|
585
|
+
exportAccountForPlacement(accountId: ImAccountId, workspaceId: WorkspaceId): ImAccountPlacementSlice;
|
|
586
|
+
/**
|
|
587
|
+
* Stop one account and release its live Sessions before an authenticated incoming transfer.
|
|
588
|
+
* @param accountId - Account selected by the incoming lease, including a previously exported local account.
|
|
589
|
+
* @param signal - Drain budget and incoming transfer lifetime.
|
|
590
|
+
* @returns Account import standby is held; failures retain the stop gate and cannot activate reception. A later call retries a rejected attempt with its retained input hold.
|
|
591
|
+
*/
|
|
592
|
+
beginAccountPlacementImport(accountId: ImAccountId, signal: AbortSignal): Promise<void>;
|
|
593
|
+
private beginPlacementImport;
|
|
594
|
+
/**
|
|
595
|
+
* Activate an imported account only after the caller obtains fresh lease authorization and prepares its Agents.
|
|
596
|
+
* @param accountId - Account whose import standby was successfully established.
|
|
597
|
+
*/
|
|
598
|
+
releaseAccountPlacement(accountId: ImAccountId): void;
|
|
599
|
+
/**
|
|
600
|
+
* Check whether local delivery records permit cursor-only recovery before lease acquisition.
|
|
601
|
+
* @param accountId - Account with an established import hold and stopped history listener.
|
|
602
|
+
* @param checkpoint - Parsed checkpoint; pending or unknown bodies cannot be reconstructed.
|
|
603
|
+
* @param signal - Preflight lifetime.
|
|
604
|
+
* @returns Existing nonnull local cursors match exactly; rejection leaves delivery records and the hold unchanged.
|
|
605
|
+
*/
|
|
606
|
+
validateAccountCheckpointRecovery(accountId: ImAccountId, checkpoint: ImAccountCheckpointRecovery['checkpoint'], signal: AbortSignal): Promise<void>;
|
|
607
|
+
/**
|
|
608
|
+
* Adopt cursor-only cloud recovery while account import standby remains held.
|
|
609
|
+
* @param accountId - Account fenced by the completed outbound handoff and fresh incoming lease.
|
|
610
|
+
* @param request - Parsed checkpoint and caller-verified continuous source fence; no cloud Session is reconstructed.
|
|
611
|
+
* @param signal - Incoming activation lifetime.
|
|
612
|
+
* @returns Old local Sessions remain untouched; fresh task generations and their logged recovery notice are ready, reception still paused.
|
|
613
|
+
*/
|
|
614
|
+
recoverAccountPlacement(accountId: ImAccountId, request: ImAccountCheckpointRecovery, signal: AbortSignal): Promise<void>;
|
|
615
|
+
private recoverCheckpointAccount;
|
|
616
|
+
/** @param slice - 已通过网络解析和目标 epoch 鉴权的账号切片。 @param workspaceId - 目标端已物化的客服内置 Workspace。 @returns 配置与投递事实已提交,接待仍停止;部分提交失败不恢复接待,调用者按原交接核验。 */
|
|
617
|
+
importAccountForPlacement(slice: ImAccountPlacementSlice, workspaceId: WorkspaceId): Promise<void>;
|
|
618
|
+
/**
|
|
619
|
+
* 使用本端 preset 和模型准入恢复本账号的当前任务;不转移来源 Agent 配置。
|
|
620
|
+
* @param accountId - 已导入或已在本端接待的当前账号。
|
|
621
|
+
* @param prepare - 在同一空闲 Agent 上按已核验的当前任务完成续写准备。
|
|
622
|
+
* @param signal - 本次激活及身份寿命。
|
|
623
|
+
* @returns 当前任务已准备,仍持有启动暂停;模型不可用或任一失败均不释放暂停。
|
|
624
|
+
*/
|
|
625
|
+
prepareAccountPlacement(accountId: ImAccountId, prepare: (agent: Agent, task: ImAgentTaskView) => Promise<void>, signal: AbortSignal): Promise<void>;
|
|
626
|
+
/**
|
|
627
|
+
* 等待本账号当前监听的建立与 Provider 初始追平;不以启动调度代替就绪。
|
|
628
|
+
* @param accountId - 已释放启动暂停的导入账号。
|
|
629
|
+
* @param signal - 激活预算及身份寿命。
|
|
630
|
+
* @returns 需要接收时监听已就绪;暂停、断开或无接收路由时保持原意图,不擅自开启。
|
|
631
|
+
*/
|
|
632
|
+
waitAccountPlacementReady(accountId: ImAccountId, signal: AbortSignal): Promise<void>;
|
|
633
|
+
/** Host 在控制面授权、导入与 prepareResume 完成后调用;幂等释放自己的启动暂停,不释放其他暂停。 */
|
|
634
|
+
releasePlacementStartup(): void;
|
|
635
|
+
private publishPlacementSdkRecovery;
|
|
636
|
+
/**
|
|
637
|
+
* 读取 Host 与账号的共同暂停状态。
|
|
638
|
+
* @param accountId - 当前真实或模拟账号。
|
|
639
|
+
* @returns 任一暂停或已停止时为 true。
|
|
640
|
+
*/
|
|
641
|
+
inputPaused(accountId: ImAccountId, kind?: ImDeliveryScope['kind']): boolean;
|
|
642
|
+
/**
|
|
643
|
+
* 同步预约 Host 与账号的输入计数。
|
|
644
|
+
* @param accountId - 当前准入账号。
|
|
645
|
+
* @returns 两份计数的释放函数;任一暂停时不准入。
|
|
646
|
+
*/
|
|
647
|
+
tryEnterInput(accountId: ImAccountId, kind?: ImDeliveryScope['kind']): (() => void) | undefined;
|
|
648
|
+
/**
|
|
649
|
+
* 为已准入输入保留首个 step 的工作计数。
|
|
650
|
+
* @param accountId - 当前准入账号。
|
|
651
|
+
* @param sessionId - 已确认归属该账号的 Session。
|
|
652
|
+
* @returns 输入提交后的两份预约释放函数。
|
|
653
|
+
*/
|
|
654
|
+
reserveInput(accountId: ImAccountId, sessionId: SessionId): () => void;
|
|
655
|
+
private accountInput;
|
|
656
|
+
private accountOwnsAgent;
|
|
657
|
+
private agentAccount;
|
|
658
|
+
/** Bind page receipts and stability evidence to one exact listener generation. */
|
|
659
|
+
private transportSink;
|
|
660
|
+
private receiveRealtime;
|
|
661
|
+
/** Persist every conversation page before committing the provider-owned cursor. */
|
|
662
|
+
private receiveTransportPage;
|
|
663
|
+
private persistTransportPage;
|
|
664
|
+
private persistTransportConversation;
|
|
665
|
+
/** Publish process listener facts without scheduling another reconciliation. */
|
|
666
|
+
private publishListener;
|
|
667
|
+
}
|
|
668
|
+
export default ImRuntime;
|