@gestaltrun/dsh-im-runtime 0.1.0 → 0.1.6
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/README.i18n.yaml +35 -20
- package/README.md +142 -10
- package/README.zh.md +141 -9
- package/lib/index.js +140 -2
- 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 +1 -1
- 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 +47 -2
- package/lib/types/agent-media.d.ts +46 -0
- package/lib/types/agent-prompt.d.ts +8 -2
- 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 +126 -2
- package/lib/types/delivery-sqlite.d.ts +206 -6
- package/lib/types/delivery-types.d.ts +97 -1
- package/lib/types/delivery.d.ts +29 -6
- package/lib/types/errors.d.ts +1 -1
- package/lib/types/evaluation-accounts.d.ts +86 -0
- package/lib/types/index.d.ts +34 -2
- 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 +10 -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/runtime.d.ts +318 -10
- package/lib/types/schema.d.ts +13 -2
- package/lib/types/script-clock.d.ts +14 -0
- package/lib/types/sdk.d.ts +108 -0
- package/lib/types/service-types.d.ts +161 -4
- package/lib/types/session-events.d.ts +9 -9
- package/lib/types/simulation-batch.d.ts +40 -0
- package/lib/types/simulation-controller.d.ts +16 -3
- package/lib/types/simulation-operator.d.ts +19 -0
- package/lib/types/sqlite-connection.d.ts +27 -0
- package/lib/types/time.d.ts +13 -0
- package/lib/types/transport.d.ts +44 -4
- package/lib/types/transports.d.ts +7 -0
- package/lib/types/types.d.ts +22 -5
- package/lib/types/typing.d.ts +33 -0
- package/lib/types/upload-types.d.ts +121 -0
- package/lib/types.js +2 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +67 -41
- package/lib/runtime-C0-S-_CC.js +0 -6758
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Safe read-receipt projections and Host-only SDK correlation facts. */
|
|
2
|
+
import type { ImDeliveryScope, ImInboundMessageView, ImOutboundRequestId, ImOutboundView, ImRealDeliveryScope } from './delivery-types.ts';
|
|
3
|
+
import type { ImDirectRecipient } from './types.ts';
|
|
4
|
+
import type { ImBuyerReadState } from './read-state.ts';
|
|
5
|
+
/** Buyer status associated with one durable DSH outbound request. */
|
|
6
|
+
export interface ImReadReceipt {
|
|
7
|
+
readonly requestId: ImOutboundRequestId;
|
|
8
|
+
readonly state: ImBuyerReadState;
|
|
9
|
+
}
|
|
10
|
+
/** One exact identifier match in durable OpenAPI history; content equality is never evidence. */
|
|
11
|
+
export interface ImSdkMessageMatch {
|
|
12
|
+
readonly scope: ImRealDeliveryScope;
|
|
13
|
+
readonly buyer: ImDirectRecipient;
|
|
14
|
+
readonly inbound?: ImInboundMessageView;
|
|
15
|
+
readonly outbound?: ImOutboundView;
|
|
16
|
+
}
|
|
17
|
+
/** Safe read status provider, separate from transport send outcomes. */
|
|
18
|
+
export interface ImReads {
|
|
19
|
+
/** @param scope - complete conversation. @returns durable buyer status; unknown is omitted. */
|
|
20
|
+
snapshot(scope: ImDeliveryScope): readonly ImReadReceipt[];
|
|
21
|
+
/** @param listener - committed scope change. @returns disposer. */
|
|
22
|
+
subscribe(listener: (scope: ImRealDeliveryScope) => void): () => void;
|
|
23
|
+
}
|
|
24
|
+
declare module '@deepseek-ai/cordis' {
|
|
25
|
+
interface Context {
|
|
26
|
+
imReads: ImReads;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
2
|
+
import type { UserMessage } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
import type { SessionEvent, SessionSeq, SessionLogOffset } from '@deepseek-ai/dsh-session';
|
|
4
|
+
/** 一轮中断及已经登记的同一条跟进输入。 */
|
|
5
|
+
export interface RestartRecovery {
|
|
6
|
+
readonly turnStartSeq: SessionSeq;
|
|
7
|
+
readonly message?: UserMessage;
|
|
8
|
+
readonly consumed: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 仅从持久日志或 live Session 的初始 seed 识别中断,再用完整日志核对跟进收据。
|
|
12
|
+
* @param events - 路由登记 Session 的实际日志。
|
|
13
|
+
* @param firstLiveSeq - live Session 的公开 seed 结束位置;冷读省略,使用完整持久日志。
|
|
14
|
+
* @returns 未完成的重启恢复证据;无中断时为空。
|
|
15
|
+
*/
|
|
16
|
+
export declare function restartRecovery(events: readonly SessionEvent[], firstLiveSeq?: SessionLogOffset): RestartRecovery | undefined;
|
|
17
|
+
/** 单个路由 Session 的公开读接口;读取期间可能由其他消费者恢复。 */
|
|
18
|
+
export interface RestartSessionSource {
|
|
19
|
+
/** @returns 当前已发布 Agent 的公开 seed 偏移;不存在时为空。 */
|
|
20
|
+
live(): {
|
|
21
|
+
readonly firstLiveSeq: SessionLogOffset;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/** @param signal - Host 生命周期。 @returns 当前 live Session 的已提交事件已刷写;无 live Session 时不写入。 */
|
|
24
|
+
flush(signal: AbortSignal): Promise<void>;
|
|
25
|
+
/** @param signal - Host 生命周期。 @returns Session 是否已创建。 */
|
|
26
|
+
exists(signal: AbortSignal): Promise<boolean>;
|
|
27
|
+
/** @param signal - Host 生命周期。 @returns 调用者负责关闭的只读句柄。 */
|
|
28
|
+
open(signal: AbortSignal): Promise<Pick<import('@deepseek-ai/dsh-session-persistence').SessionHandle, 'read' | 'close'>>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 读取单个登记 Session;未创建的 Session 留给普通准入恢复,冷读后重新观察 live 所有者。
|
|
32
|
+
* @param source - Session 的 live 与持久化读接口。
|
|
33
|
+
* @param signal - 取消读取并释放句柄;取消错误交给 Host 生命周期处理。
|
|
34
|
+
* @returns 中断与跟进日志证据,或无需恢复。
|
|
35
|
+
*/
|
|
36
|
+
export declare function discoverRestartRecovery(source: RestartSessionSource, signal: AbortSignal): Promise<RestartRecovery | undefined>;
|
|
37
|
+
/** @param error - 公开恢复接口的原始错误。 @param sessionId - 本次恢复 Session。 @returns 同一个 Session 的写入所有权占用可以等待,其他失败必须报告。 */
|
|
38
|
+
export declare function restartFailureDisposition(error: unknown, sessionId: SessionId): 'ownership-wait' | 'failed';
|
package/lib/types/runtime.d.ts
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
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';
|
|
1
7
|
import { Context, Service } from '@deepseek-ai/cordis';
|
|
2
8
|
import type { UserMessage } from '@deepseek-ai/dsh-llm';
|
|
3
|
-
import {
|
|
9
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
10
|
+
import { SessionId } from '@deepseek-ai/dsh-session';
|
|
4
11
|
import './session-events.ts';
|
|
5
12
|
import type { WorkspaceId } from '@deepseek-ai/dsh-workspace';
|
|
6
13
|
import { type ZodType } from 'zod';
|
|
14
|
+
import { type ImCheckpointActivity, type ImCheckpointTransport } from './checkpoint.ts';
|
|
7
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';
|
|
8
22
|
import { ImRoutePolicies } from './policies.ts';
|
|
9
23
|
import type { ImPolicyCheckKind, ImPolicyCheckRequest, ImPolicyDecision } from './policies.ts';
|
|
10
24
|
import { ImTransports } from './transports.ts';
|
|
11
25
|
import type { ImAutomaticSendAuthorization } from './transport.ts';
|
|
12
|
-
import type { ImBeginOutboundAttemptRequest, ImBeginOutboundAttemptResult, ImAgentTaskId, ImAgentTaskView, ImCancelPendingAiRequest, ImCommitProviderCursorRequest, ImConversationCursor, 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';
|
|
13
|
-
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, ImRouteMutationResult, ImRouteOperationQuery, ImRouteResolution, ImRouteTarget, ImRouteView, ImRuntimeChange, ImRuntimeSnapshot, ImSaveRouteRequest, ImSaveSimulationTargetRequest, ImSetAccountPausedRequest, ImSimulationTargetMutationResult, ImSimulationTargetOperationQuery, ImCreateSimulationInstanceRequest, ImSimulationInjectionQuery, ImInjectSimulationManagedHumanRequest, ImInjectSimulationMemberRequest, ImImportSimulationHistoryRequest, ImImportSimulationHistoryResult, ImSimulationInstanceView, ImSimulationSessionScope, ImSimulationTargetView } from './types.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';
|
|
14
28
|
import type { ImRuntimeService } from './service-types.ts';
|
|
15
29
|
declare module '@deepseek-ai/cordis' {
|
|
16
30
|
interface Events {
|
|
@@ -27,32 +41,114 @@ declare module '@deepseek-ai/cordis' {
|
|
|
27
41
|
}
|
|
28
42
|
/** Stable Wangwang refusal when a direct send has no observed counterpart sender. */
|
|
29
43
|
export declare const WANGWANG_DIRECT_RECIPIENT_UNAVAILABLE = "WANGWANG_DIRECT_RECIPIENT_UNAVAILABLE";
|
|
30
|
-
/** Runtime
|
|
44
|
+
/** Runtime admission, listener recovery, storage, and checkpoint settings. */
|
|
31
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;
|
|
32
56
|
/** Maximum inbound messages copied into one Agent input. */
|
|
33
57
|
readonly admissionBatchSize?: number;
|
|
34
58
|
/** Time that unconfirmed provider setup material remains in Host memory. */
|
|
35
59
|
readonly accountSetupTtlMs?: number;
|
|
36
60
|
/** Sqlite file for conversation, cursor, and execution records. */
|
|
37
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;
|
|
38
88
|
}
|
|
39
89
|
interface ResolvedConfig {
|
|
90
|
+
readonly timeZone: string;
|
|
91
|
+
readonly typingTimeoutMs: number;
|
|
92
|
+
readonly mediaMaxBytes: number;
|
|
93
|
+
readonly uploadRetryMs: number;
|
|
94
|
+
readonly uploadTestRunId?: string;
|
|
40
95
|
readonly admissionBatchSize: number;
|
|
41
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;
|
|
42
110
|
readonly deliverySqlitePath?: string | undefined;
|
|
43
111
|
}
|
|
44
112
|
/** Host service implementing the durable configuration half of IM takeover. */
|
|
45
113
|
export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
46
114
|
static inject: string[];
|
|
47
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;
|
|
48
128
|
private accounts?;
|
|
49
129
|
private simulationTargets?;
|
|
50
130
|
private simulationInstances?;
|
|
51
131
|
private deliveryRecords?;
|
|
132
|
+
private readonly mediaLifetime;
|
|
133
|
+
private mediaSender?;
|
|
52
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;
|
|
53
148
|
private coordinator;
|
|
54
149
|
private simulationController;
|
|
55
150
|
private readonly pendingAutomaticPauses;
|
|
151
|
+
private checkpointReporter;
|
|
56
152
|
private readonly automaticSendEpochs;
|
|
57
153
|
private generation;
|
|
58
154
|
private deliveryGeneration;
|
|
@@ -60,15 +156,48 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
60
156
|
private readonly activeListeners;
|
|
61
157
|
private readonly listenerStates;
|
|
62
158
|
private readonly listenerTails;
|
|
159
|
+
private readonly listenerRetries;
|
|
160
|
+
private readonly listenerAttempts;
|
|
161
|
+
private listenersDisposed;
|
|
63
162
|
private readonly pendingAccountSetups;
|
|
163
|
+
private readonly setupAccounts;
|
|
164
|
+
private reservedPlacementAccountId;
|
|
64
165
|
private readonly observations;
|
|
65
166
|
readonly transports: ImTransports;
|
|
66
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;
|
|
67
172
|
readonly config: ResolvedConfig;
|
|
68
173
|
/** @param ctx - Cordis context carrying StorageDomain and Credentials. @param config - validated Agent admission limits. */
|
|
69
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[]>;
|
|
70
179
|
/** Open the authoritative configuration domain before publishing the service. */
|
|
71
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;
|
|
72
201
|
snapshot(): ImRuntimeSnapshot;
|
|
73
202
|
subscribe(listener: (change: ImRuntimeChange) => void): () => void;
|
|
74
203
|
startPlatformLogin(platform: ImPlatform, signal?: AbortSignal): Promise<ImPlatformLoginStatus>;
|
|
@@ -82,16 +211,55 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
82
211
|
previewAccountSetup(request: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountSetupPreview>;
|
|
83
212
|
confirmAccountSetup(request: ImConfirmAccountSetupRequest): Promise<ImAccountMutationResult>;
|
|
84
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;
|
|
85
231
|
addAccount(request: ImAccountSetupRequest, signal?: AbortSignal): Promise<ImAccountView>;
|
|
86
232
|
setAccountPaused(request: ImSetAccountPausedRequest): Promise<ImAccountMutationResult>;
|
|
87
233
|
disconnectAccount(request: ImAccountLifecycleRequest): Promise<ImAccountMutationResult>;
|
|
234
|
+
/** @inheritdoc */
|
|
235
|
+
setSdkConnectionIntent(accountId: ImAccountId, intent: ImAccountView['sdkConnectionIntent'], expectedIntent?: {
|
|
236
|
+
readonly revision: ImAccountView['sdkConnectionIntentRevision'];
|
|
237
|
+
}): Promise<boolean>;
|
|
88
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>;
|
|
89
248
|
/**
|
|
90
249
|
* Delete one configured account after comparing its observed revision.
|
|
91
250
|
* @param request - account identity and revision observed before confirmation.
|
|
92
251
|
* @returns the durable deletion receipt.
|
|
93
252
|
*/
|
|
94
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;
|
|
95
263
|
refreshAccount(request: ImAccountLifecycleRequest, signal?: AbortSignal): Promise<ImAccountMutationResult>;
|
|
96
264
|
queryAccountOperation(accountId: ImAccountId, operationId: ImOperationId): ImAccountOperationQuery;
|
|
97
265
|
createRoute(request: ImCreateRouteRequest): Promise<ImRouteMutationResult>;
|
|
@@ -123,20 +291,42 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
123
291
|
/** @param scope - durable real conversation. @returns last admitted presentation, including the assigned service account when known. */
|
|
124
292
|
getConversationPresentation(scope: ImRealDeliveryScope): import('./delivery-types.ts').ImConversationPresentation | undefined;
|
|
125
293
|
saveSimulationTarget(request: ImSaveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
294
|
+
/** @inheritdoc */
|
|
295
|
+
saveFormalSimulationTarget(request: ImSaveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
296
|
+
private saveTarget;
|
|
126
297
|
removeSimulationTarget(request: ImRemoveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
298
|
+
/** @inheritdoc */
|
|
299
|
+
removeFormalSimulationTarget(request: ImRemoveSimulationTargetRequest): Promise<ImSimulationTargetMutationResult>;
|
|
300
|
+
private removeTarget;
|
|
301
|
+
private requireNonEvaluationTargets;
|
|
127
302
|
querySimulationTargetOperation(workspaceId: WorkspaceId, operationId: ImOperationId): ImSimulationTargetOperationQuery;
|
|
128
303
|
listSimulationInstances(): readonly ImSimulationInstanceView[];
|
|
129
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;
|
|
130
310
|
scopeForSession(sessionId: SessionId): ImSimulationSessionScope | undefined;
|
|
131
311
|
realScopeForSession(sessionId: SessionId): ImRealSessionBinding | undefined;
|
|
132
312
|
realBindingForScope(scopeId: ImScopeId): ImRealSessionBinding | undefined;
|
|
133
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>;
|
|
134
320
|
queryManualMessage(request: ImManualMessageQueryRequest): ImManualMessageQuery;
|
|
135
321
|
confirmManualMessage(request: ImManualMessageQueryRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
|
|
136
322
|
retryManualMessage(request: ImRetryManualMessageRequest, signal?: AbortSignal): Promise<ImManualMessageResult>;
|
|
323
|
+
createManualSimulationInstance(request: ImCreateManualSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
|
|
137
324
|
createSimulationInstance(request: ImCreateSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
|
|
325
|
+
/** @inheritdoc */
|
|
326
|
+
createFormalSimulationInstance(request: ImCreateSimulationInstanceRequest): Promise<ImSimulationInstanceView>;
|
|
138
327
|
injectSimulationMember(request: ImInjectSimulationMemberRequest): Promise<ImInboundMessageView>;
|
|
139
328
|
injectSimulationManagedHuman(request: ImInjectSimulationManagedHumanRequest): Promise<ImInboundMessageView>;
|
|
329
|
+
injectSimulationOperator(request: ImInjectSimulationOperatorRequest): Promise<ImSimulationOperatorReceipt>;
|
|
140
330
|
querySimulationInjection(request: ImSimulationInjectionQuery): ImInboundOperationQuery;
|
|
141
331
|
beginStopSimulation(instanceId: ImSimulationInstanceId): Promise<ImSimulationInstanceView>;
|
|
142
332
|
beginStopSimulationForSession(sessionId: SessionId): Promise<ImSimulationInstanceView>;
|
|
@@ -145,6 +335,7 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
145
335
|
ingestInboundPage(request: ImIngestInboundPageRequest): Promise<ImInboundPageResult>;
|
|
146
336
|
queryInboundOperation(scope: ImDeliveryScope, operationId: ImDeliveryOperationId): ImInboundOperationQuery;
|
|
147
337
|
getConversationCursor(scope: ImDeliveryScope): ImConversationCursor;
|
|
338
|
+
projectConversations<T extends object>(project: (records: ImConversationRecords) => T): ImConversationProjection<T>;
|
|
148
339
|
getProviderCursor(owner: ImProviderCursorOwner): ImProviderCursorView;
|
|
149
340
|
commitProviderCursor(request: ImCommitProviderCursorRequest): Promise<ImProviderCursorCommitResult>;
|
|
150
341
|
queryProviderCursorOperation(owner: ImProviderCursorOwner, operationId: ImDeliveryOperationId): ImProviderCursorOperationQuery;
|
|
@@ -154,6 +345,8 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
154
345
|
* @param request - account, real/simulation filter, optional substring, and reader.
|
|
155
346
|
*/
|
|
156
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;
|
|
157
350
|
/**
|
|
158
351
|
* Advance one reader's live inbound watermark with max semantics.
|
|
159
352
|
* @param request - reader, scope, and observed arrival sequence.
|
|
@@ -223,8 +416,11 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
223
416
|
getOutbound(request: ImGetOutboundRequest): ImOutboundView | undefined;
|
|
224
417
|
queryOutbound(request: ImOutboundQueryRequest): ImOutboundPage;
|
|
225
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[];
|
|
226
421
|
findSentOutbound(scope: ImRealDeliveryScope, externalMessageId: string): ImOutboundView | undefined;
|
|
227
422
|
private confirmUnknownOutbound;
|
|
423
|
+
private storedInbound;
|
|
228
424
|
private inboundSender;
|
|
229
425
|
classifyInboundSender(scope: ImRealDeliveryScope, evidence: ImInboundSenderEvidence): ImSenderAttribution;
|
|
230
426
|
private isNativeActor;
|
|
@@ -234,6 +430,10 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
234
430
|
routeForSimulationTarget(target: ImSimulationTargetView): ImRouteView | undefined;
|
|
235
431
|
/** @param target - current workspace target setting. @returns its exact safe account when still present. */
|
|
236
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;
|
|
237
437
|
/** @param scope - claimed frozen simulation scope. @returns whether its exact instance accepts delivery. */
|
|
238
438
|
isSimulationScopeRunning(scope: ImSimulationDeliveryScope): boolean;
|
|
239
439
|
/** Emit a post-commit instance notification for BFF followers. @param instanceId - changed instance. */
|
|
@@ -250,14 +450,14 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
250
450
|
private bindingFromTask;
|
|
251
451
|
/**
|
|
252
452
|
* Direct peer that a send may use.
|
|
253
|
-
* Wangwang
|
|
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.
|
|
254
454
|
* @param scope - conversation being sent or displayed.
|
|
255
455
|
* @param stored - recipient frozen on the task, when one exists.
|
|
256
|
-
* @returns usable peer, or absence when
|
|
456
|
+
* @returns usable peer, or absence when neither sender evidence nor a platform peer exists.
|
|
257
457
|
*/
|
|
258
458
|
usableDirectRecipient(scope: ImDeliveryScope, stored?: ImDirectRecipient): ImDirectRecipient | undefined;
|
|
259
459
|
/**
|
|
260
|
-
* Store the Wangwang peer a send is allowed to use, including clearing one
|
|
460
|
+
* Store the Wangwang peer a send is allowed to use, including clearing one unsupported by sender evidence or the platform.
|
|
261
461
|
* @param sessionId - Agent Session that owns the task, when one exists.
|
|
262
462
|
* @param recipient - usable peer, or absence.
|
|
263
463
|
*/
|
|
@@ -278,10 +478,13 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
278
478
|
private settleManualResult;
|
|
279
479
|
private prepareVerifiedAccount;
|
|
280
480
|
private persistPreparedAccount;
|
|
481
|
+
/** 把首次开通生成的账号固定给后续确认。重复调用必须是同一个 id。 */
|
|
482
|
+
reservePlacementAccount(accountId: ImAccountId): void;
|
|
281
483
|
private accountIdForSetup;
|
|
282
484
|
private expireAccountSetup;
|
|
283
485
|
private releaseAccountSetup;
|
|
284
486
|
private clearAccountSetups;
|
|
487
|
+
private assertFormalAccess;
|
|
285
488
|
private accountTable;
|
|
286
489
|
private simulationTargetTable;
|
|
287
490
|
private simulationInstanceTable;
|
|
@@ -313,6 +516,8 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
313
516
|
* @returns the stored next record.
|
|
314
517
|
*/
|
|
315
518
|
updateExecution(id: ImAgentTaskId, fn: (current: ImExecutionAggregate) => ImExecutionAggregate): Promise<ImExecutionAggregate>;
|
|
519
|
+
/** @returns 当前客服托管路由登记的最新 Session;只查账号与会话索引。 */
|
|
520
|
+
hostingRecoveryTasks(): readonly ImExecutionAggregate[];
|
|
316
521
|
/**
|
|
317
522
|
* List task generations for one conversation in generation order.
|
|
318
523
|
* @param scopeId - complete conversation identity.
|
|
@@ -342,18 +547,121 @@ export declare class ImRuntime extends Service implements ImRuntimeService {
|
|
|
342
547
|
private reconcileListener;
|
|
343
548
|
/** Stop one exact listener before publishing a later start for the same account. */
|
|
344
549
|
private stopListener;
|
|
345
|
-
/**
|
|
550
|
+
/** Consume a listener's terminal result before scheduling replacement work. */
|
|
346
551
|
private observeListener;
|
|
347
|
-
/**
|
|
552
|
+
/** Release the completed provider generation on the same queue as starts and stops. */
|
|
348
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;
|
|
349
562
|
/** Stop one ready provider handle and consume its terminal signal without exposing provider errors. */
|
|
350
563
|
private closeListenerHandle;
|
|
351
564
|
/** Drain every provider listener owned by this runtime. */
|
|
352
565
|
private stopAllListeners;
|
|
353
|
-
/**
|
|
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. */
|
|
354
659
|
private transportSink;
|
|
660
|
+
private receiveRealtime;
|
|
355
661
|
/** Persist every conversation page before committing the provider-owned cursor. */
|
|
356
662
|
private receiveTransportPage;
|
|
663
|
+
private persistTransportPage;
|
|
664
|
+
private persistTransportConversation;
|
|
357
665
|
/** Publish process listener facts without scheduling another reconciliation. */
|
|
358
666
|
private publishListener;
|
|
359
667
|
}
|
package/lib/types/schema.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { type CredentialKey } from '@deepseek-ai/dsh-credentials';
|
|
1
2
|
import { type ZodType } from 'zod';
|
|
2
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;
|
|
3
10
|
/** Stored account fields; listener status is process state and is derived on read. */
|
|
4
|
-
export type ImAccountRecord = Omit<ImAccountView, 'listener'
|
|
11
|
+
export type ImAccountRecord = Omit<ImAccountView, 'listener'> & {
|
|
12
|
+
readonly replacedHidden?: {
|
|
13
|
+
readonly connectionIntent: ImAccountView['connectionIntent'];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
5
16
|
export declare const imAccountRecordSchema: ZodType<ImAccountRecord>;
|
|
6
17
|
export declare const imRouteSchema: ZodType<ImRouteView>;
|
|
7
18
|
interface StoredRouteOperation {
|
|
@@ -35,7 +46,7 @@ export interface ImSimulationTargetAggregate {
|
|
|
35
46
|
readonly operations: Readonly<Record<string, StoredSimulationTargetOperation>>;
|
|
36
47
|
}
|
|
37
48
|
export declare const imSimulationTargetAggregateSchema: ZodType<ImSimulationTargetAggregate>;
|
|
38
|
-
/** Parser for one durable two-Session simulation lifecycle. */
|
|
49
|
+
/** Parser for one durable manual or two-Session simulation lifecycle. */
|
|
39
50
|
export declare const imSimulationInstanceSchema: ZodType<ImSimulationInstanceView>;
|
|
40
51
|
/** IM configuration storage schema. Cross-account or cross-table transactions are not implied. */
|
|
41
52
|
export declare const imRuntimeDomainSpec: {
|
|
@@ -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
|
+
}
|