@gestaltrun/dsh-im-runtime 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.i18n.yaml +43 -0
- package/README.md +158 -2
- package/README.zh.md +158 -0
- package/UPSTREAM.json +66 -0
- package/lib/index.js +2 -0
- package/lib/runtime-C0-S-_CC.js +6758 -0
- package/lib/tools.js +2 -0
- package/lib/types/agent-coordinator.d.ts +84 -0
- package/lib/types/agent-prompt.d.ts +18 -0
- package/lib/types/delivery-schema.d.ts +52 -0
- package/lib/types/delivery-sqlite.d.ts +187 -0
- package/lib/types/delivery-types.d.ts +648 -0
- package/lib/types/delivery.d.ts +91 -0
- package/lib/types/errors.d.ts +8 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/policies.d.ts +53 -0
- package/lib/types/route-resolve.d.ts +10 -0
- package/lib/types/runtime.d.ts +360 -0
- package/lib/types/schema.d.ts +50 -0
- package/lib/types/service-types.d.ts +209 -0
- package/lib/types/session-events.d.ts +28 -0
- package/lib/types/simulation-controller.d.ts +64 -0
- package/lib/types/simulation-tools.d.ts +14 -0
- package/lib/types/tools.d.ts +17 -0
- package/lib/types/transport.d.ts +162 -0
- package/lib/types/transports.d.ts +41 -0
- package/lib/types/types.d.ts +504 -0
- package/lib/types.js +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +99 -3
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
/** Client-safe identifiers, views, and mutation requests for the IM runtime. */
|
|
2
|
+
import type { Branded } from '@deepseek-ai/dsh-brand';
|
|
3
|
+
import type { CredentialKey } from '@deepseek-ai/dsh-credentials/types';
|
|
4
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
5
|
+
import type { WorkspaceId } from '@deepseek-ai/dsh-workspace/types';
|
|
6
|
+
import type { ImDeliveryOperationId, ImSimulationDeliveryScope, ImSimulationInstanceId } from './delivery-types.ts';
|
|
7
|
+
export type * from './delivery-types.ts';
|
|
8
|
+
/** Identifier minted by the Host for one configured account. */
|
|
9
|
+
export type ImAccountId = Branded<'ImAccountId'>;
|
|
10
|
+
/** Identifier minted by the Host for one route lifecycle. */
|
|
11
|
+
export type ImRouteId = Branded<'ImRouteId'>;
|
|
12
|
+
/** Product controller identity registered on `ctx.imRoutePolicies`. */
|
|
13
|
+
export type ImRouteControllerId = Branded<'ImRouteControllerId'>;
|
|
14
|
+
/** Caller-minted idempotency identifier for one configuration mutation. */
|
|
15
|
+
export type ImOperationId = Branded<'ImOperationId'>;
|
|
16
|
+
/** Opaque token replaced by every successful aggregate mutation. */
|
|
17
|
+
export type ImRevision = Branded<'ImRevision'>;
|
|
18
|
+
/** Host-minted identifier for one short-lived account setup attempt. */
|
|
19
|
+
export type ImAccountSetupId = Branded<'ImAccountSetupId'>;
|
|
20
|
+
/** Host-provider identifier for one interactive platform login process. */
|
|
21
|
+
export type ImPlatformLoginAttemptId = Branded<'ImPlatformLoginAttemptId'>;
|
|
22
|
+
/** Supported product IM platforms. */
|
|
23
|
+
export type ImPlatform = 'dingtalk' | 'wangwang';
|
|
24
|
+
/** Supported conversation categories. */
|
|
25
|
+
export type ImConversationKind = 'direct' | 'group';
|
|
26
|
+
/** Installed DingTalk employee profile available for explicit account setup. */
|
|
27
|
+
export interface ImDingTalkAccountCandidate {
|
|
28
|
+
readonly platform: 'dingtalk';
|
|
29
|
+
readonly profile: string;
|
|
30
|
+
readonly displayName: string;
|
|
31
|
+
}
|
|
32
|
+
/** Admitted Wangwang merchant available for explicit account setup. */
|
|
33
|
+
export interface ImWangwangAccountCandidate {
|
|
34
|
+
readonly platform: 'wangwang';
|
|
35
|
+
readonly candidateId: string;
|
|
36
|
+
readonly endpoint: string;
|
|
37
|
+
readonly displayName: string;
|
|
38
|
+
readonly merchantId?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Safe provider-discovered account candidate. */
|
|
41
|
+
export type ImAccountCandidate = ImDingTalkAccountCandidate | ImWangwangAccountCandidate;
|
|
42
|
+
/** Safe interactive login facts. Provider tokens and process output never enter this value. */
|
|
43
|
+
export type ImPlatformLoginStatus = {
|
|
44
|
+
readonly attemptId: ImPlatformLoginAttemptId;
|
|
45
|
+
readonly platform: ImPlatform;
|
|
46
|
+
readonly state: 'starting';
|
|
47
|
+
} | {
|
|
48
|
+
readonly attemptId: ImPlatformLoginAttemptId;
|
|
49
|
+
readonly platform: ImPlatform;
|
|
50
|
+
readonly state: 'waiting-user';
|
|
51
|
+
readonly verificationUri: string;
|
|
52
|
+
readonly verificationUriComplete?: string;
|
|
53
|
+
readonly userCode: string;
|
|
54
|
+
readonly expiresAt: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly attemptId: ImPlatformLoginAttemptId;
|
|
57
|
+
readonly platform: ImPlatform;
|
|
58
|
+
readonly state: 'complete';
|
|
59
|
+
} | {
|
|
60
|
+
readonly attemptId: ImPlatformLoginAttemptId;
|
|
61
|
+
readonly platform: ImPlatform;
|
|
62
|
+
readonly state: 'cancelled';
|
|
63
|
+
} | {
|
|
64
|
+
readonly attemptId: ImPlatformLoginAttemptId;
|
|
65
|
+
readonly platform: ImPlatform;
|
|
66
|
+
readonly state: 'failed';
|
|
67
|
+
readonly code: string;
|
|
68
|
+
readonly message: string;
|
|
69
|
+
};
|
|
70
|
+
/** Safe conversation candidate returned for route configuration. */
|
|
71
|
+
export interface ImConversationCandidate {
|
|
72
|
+
readonly conversationId: string;
|
|
73
|
+
readonly conversationKind: ImConversationKind;
|
|
74
|
+
readonly displayName: string;
|
|
75
|
+
readonly directRecipient?: ImDirectRecipient;
|
|
76
|
+
readonly assignedActorId?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Assigned service account exposed by platforms that have sub-accounts. */
|
|
79
|
+
export interface ImAssignedActorCandidate {
|
|
80
|
+
readonly assignedActorId: string;
|
|
81
|
+
readonly displayName: string;
|
|
82
|
+
readonly groupName?: string;
|
|
83
|
+
}
|
|
84
|
+
/** Provider page of conversation candidates. */
|
|
85
|
+
export interface ImConversationCandidatePage {
|
|
86
|
+
readonly items: readonly ImConversationCandidate[];
|
|
87
|
+
readonly cursor?: string;
|
|
88
|
+
}
|
|
89
|
+
/** DingTalk employee-profile setup input. */
|
|
90
|
+
export interface ImDingTalkAccountSetupRequest {
|
|
91
|
+
readonly platform: 'dingtalk';
|
|
92
|
+
readonly profile: string;
|
|
93
|
+
readonly displayName?: string;
|
|
94
|
+
}
|
|
95
|
+
/** Wangwang setup input. Secret fields are write-only; provider verification owns the returned identity. */
|
|
96
|
+
export interface ImWangwangAccountSetupRequest {
|
|
97
|
+
readonly platform: 'wangwang';
|
|
98
|
+
/** Legacy admitted-catalog selector, or the merchant id for a use-time connection. */
|
|
99
|
+
readonly candidateId: string;
|
|
100
|
+
/** Merchant identity entered for use-time connection; absence selects the legacy admitted catalog. */
|
|
101
|
+
readonly merchantId?: string;
|
|
102
|
+
/** Claimed sender/service account, enabled only after provider evidence agrees. */
|
|
103
|
+
readonly mainServiceAccountId?: string;
|
|
104
|
+
readonly endpoint: string;
|
|
105
|
+
readonly accessKeyId: string;
|
|
106
|
+
readonly accessKeySecret: string;
|
|
107
|
+
readonly displayName?: string;
|
|
108
|
+
}
|
|
109
|
+
/** Client-safe account setup union dispatched by platform. */
|
|
110
|
+
export type ImAccountSetupRequest = ImDingTalkAccountSetupRequest | ImWangwangAccountSetupRequest;
|
|
111
|
+
/** Safe verified facts returned before the caller confirms durable account creation. */
|
|
112
|
+
export interface ImAccountSetupPreview {
|
|
113
|
+
readonly setupId: ImAccountSetupId;
|
|
114
|
+
readonly displayName: string;
|
|
115
|
+
readonly identity: ImAccountIdentity;
|
|
116
|
+
readonly authorization: ImAccountAuthorization;
|
|
117
|
+
readonly expiresAt: string;
|
|
118
|
+
}
|
|
119
|
+
/** Idempotent confirmation of one Host-held setup attempt. */
|
|
120
|
+
export interface ImConfirmAccountSetupRequest {
|
|
121
|
+
readonly setupId: ImAccountSetupId;
|
|
122
|
+
readonly operationId: ImOperationId;
|
|
123
|
+
}
|
|
124
|
+
/** Result of releasing one unconfirmed setup attempt. */
|
|
125
|
+
export type ImCancelAccountSetupResult = {
|
|
126
|
+
readonly state: 'cancelled';
|
|
127
|
+
} | {
|
|
128
|
+
readonly state: 'not-found';
|
|
129
|
+
} | {
|
|
130
|
+
readonly state: 'confirming';
|
|
131
|
+
} | {
|
|
132
|
+
readonly state: 'confirmed';
|
|
133
|
+
readonly accountId: ImAccountId;
|
|
134
|
+
};
|
|
135
|
+
/** Safe DingTalk employee identity returned by the registered transport. */
|
|
136
|
+
export interface ImDingTalkIdentity {
|
|
137
|
+
readonly platform: 'dingtalk';
|
|
138
|
+
readonly profile: string;
|
|
139
|
+
readonly corpId: string;
|
|
140
|
+
readonly userId: string;
|
|
141
|
+
readonly displayName: string;
|
|
142
|
+
}
|
|
143
|
+
/** Safe Wangwang merchant identity returned by the registered transport. */
|
|
144
|
+
export interface ImWangwangIdentity {
|
|
145
|
+
readonly platform: 'wangwang';
|
|
146
|
+
readonly merchantId: string;
|
|
147
|
+
readonly displayName: string;
|
|
148
|
+
readonly mainServiceAccountId?: string;
|
|
149
|
+
}
|
|
150
|
+
/** Platform identity safe to persist and project to clients. */
|
|
151
|
+
export type ImAccountIdentity = ImDingTalkIdentity | ImWangwangIdentity;
|
|
152
|
+
/** Durable authorization fact. It never implies a listener is running. */
|
|
153
|
+
export type ImAccountAuthorization = {
|
|
154
|
+
readonly state: 'unchecked';
|
|
155
|
+
} | {
|
|
156
|
+
readonly state: 'ready';
|
|
157
|
+
readonly checkedAt: string;
|
|
158
|
+
} | {
|
|
159
|
+
readonly state: 'required';
|
|
160
|
+
readonly reason: 'missing' | 'expired' | 'revoked';
|
|
161
|
+
readonly checkedAt?: string;
|
|
162
|
+
} | {
|
|
163
|
+
readonly state: 'failed';
|
|
164
|
+
readonly code: string;
|
|
165
|
+
readonly message: string;
|
|
166
|
+
readonly checkedAt: string;
|
|
167
|
+
};
|
|
168
|
+
/** Durable operator intent; process listener facts are projected separately. */
|
|
169
|
+
export type ImAccountConnectionIntent = 'connected' | 'disconnected';
|
|
170
|
+
/** Process listener state projected separately from authorization. */
|
|
171
|
+
export type ImAccountListener = {
|
|
172
|
+
readonly state: 'stopped';
|
|
173
|
+
readonly reason: 'no-enabled-route' | 'account-paused' | 'authorization-required' | 'disconnected' | 'manual';
|
|
174
|
+
} | {
|
|
175
|
+
readonly state: 'starting';
|
|
176
|
+
readonly since: string;
|
|
177
|
+
} | {
|
|
178
|
+
readonly state: 'running';
|
|
179
|
+
readonly readyAt: string;
|
|
180
|
+
readonly lastEventAt?: string;
|
|
181
|
+
} | {
|
|
182
|
+
readonly state: 'reconnecting';
|
|
183
|
+
readonly attempt: number;
|
|
184
|
+
readonly since: string;
|
|
185
|
+
readonly lastError: string;
|
|
186
|
+
} | {
|
|
187
|
+
readonly state: 'failed';
|
|
188
|
+
readonly attempts: number;
|
|
189
|
+
readonly lastError: string;
|
|
190
|
+
};
|
|
191
|
+
/** Safe account projection. Secret values never have a field in this value. */
|
|
192
|
+
export interface ImAccountView {
|
|
193
|
+
readonly id: ImAccountId;
|
|
194
|
+
readonly platform: ImPlatform;
|
|
195
|
+
readonly displayName: string;
|
|
196
|
+
readonly identity: ImAccountIdentity;
|
|
197
|
+
readonly credentialKey?: CredentialKey;
|
|
198
|
+
readonly authorization: ImAccountAuthorization;
|
|
199
|
+
readonly listener: ImAccountListener;
|
|
200
|
+
readonly connectionIntent: ImAccountConnectionIntent;
|
|
201
|
+
readonly paused: boolean;
|
|
202
|
+
readonly revision: ImRevision;
|
|
203
|
+
readonly createdAt: string;
|
|
204
|
+
readonly updatedAt: string;
|
|
205
|
+
}
|
|
206
|
+
/** Match every conversation of one account and category, including future conversations. */
|
|
207
|
+
export interface ImAllConversationsTarget {
|
|
208
|
+
readonly kind: 'all';
|
|
209
|
+
}
|
|
210
|
+
/** Provider peer identifiers retained separately from the stable platform conversation id. */
|
|
211
|
+
export interface ImDirectRecipient {
|
|
212
|
+
readonly providerActorId: string;
|
|
213
|
+
readonly userId?: string;
|
|
214
|
+
readonly openDingTalkId?: string;
|
|
215
|
+
}
|
|
216
|
+
/** Match one provider conversation identifier and retain its direct-send peer when known. */
|
|
217
|
+
export interface ImSpecificConversationTarget {
|
|
218
|
+
readonly kind: 'specific';
|
|
219
|
+
readonly conversationId: string;
|
|
220
|
+
readonly directRecipient?: ImDirectRecipient;
|
|
221
|
+
}
|
|
222
|
+
/** Match buyer conversations currently assigned to one service account. */
|
|
223
|
+
export interface ImAssignedActorTarget {
|
|
224
|
+
readonly kind: 'assigned-actor';
|
|
225
|
+
readonly assignedActorId: string;
|
|
226
|
+
}
|
|
227
|
+
/** Conversation selection component of a route tuple. */
|
|
228
|
+
export type ImRouteTarget = ImAllConversationsTarget | ImSpecificConversationTarget | ImAssignedActorTarget;
|
|
229
|
+
/** OR-combined group activation settings. Numeric conditions are positive integers. */
|
|
230
|
+
export interface ImGroupTrigger {
|
|
231
|
+
readonly mention?: boolean;
|
|
232
|
+
readonly everyN?: number;
|
|
233
|
+
readonly fixedIntervalSeconds?: number;
|
|
234
|
+
}
|
|
235
|
+
/** Complete route tuple and its bound workspace. */
|
|
236
|
+
export interface ImRouteView {
|
|
237
|
+
readonly id: ImRouteId;
|
|
238
|
+
readonly platform: ImPlatform;
|
|
239
|
+
readonly accountId: ImAccountId;
|
|
240
|
+
readonly conversationKind: ImConversationKind;
|
|
241
|
+
readonly target: ImRouteTarget;
|
|
242
|
+
readonly workspaceId: WorkspaceId;
|
|
243
|
+
readonly enabled: boolean;
|
|
244
|
+
readonly groupTrigger?: ImGroupTrigger;
|
|
245
|
+
/** Recorded Agent preset; absence resolves to the runtime default at admit time. */
|
|
246
|
+
readonly agentPreset?: string;
|
|
247
|
+
/** Product controller identity; absence skips policy checks. */
|
|
248
|
+
readonly controller?: string;
|
|
249
|
+
readonly revision: ImRevision;
|
|
250
|
+
readonly createdAt: string;
|
|
251
|
+
readonly updatedAt: string;
|
|
252
|
+
}
|
|
253
|
+
/** Input that creates one route under an existing account aggregate. */
|
|
254
|
+
export interface ImCreateRouteRequest {
|
|
255
|
+
readonly operationId: ImOperationId;
|
|
256
|
+
readonly accountId: ImAccountId;
|
|
257
|
+
readonly conversationKind: ImConversationKind;
|
|
258
|
+
readonly target: ImRouteTarget;
|
|
259
|
+
readonly workspaceId: WorkspaceId;
|
|
260
|
+
readonly enabled: boolean;
|
|
261
|
+
readonly groupTrigger?: ImGroupTrigger;
|
|
262
|
+
/** Agent preset to freeze on the route; omission resolves to the runtime default. */
|
|
263
|
+
readonly agentPreset?: string;
|
|
264
|
+
/** Product controller that must authorize admission and automated sends. */
|
|
265
|
+
readonly controller?: string;
|
|
266
|
+
}
|
|
267
|
+
/** Input that edits route behavior without changing its workspace owner. */
|
|
268
|
+
export interface ImSaveRouteRequest {
|
|
269
|
+
readonly operationId: ImOperationId;
|
|
270
|
+
readonly accountId: ImAccountId;
|
|
271
|
+
readonly routeId: ImRouteId;
|
|
272
|
+
readonly observedRevision: ImRevision;
|
|
273
|
+
readonly enabled: boolean;
|
|
274
|
+
readonly groupTrigger?: ImGroupTrigger;
|
|
275
|
+
/** Replace the frozen Agent preset; omission keeps the recorded value. */
|
|
276
|
+
readonly agentPreset?: string;
|
|
277
|
+
/** Replace the product controller; omission keeps the recorded value. */
|
|
278
|
+
readonly controller?: string;
|
|
279
|
+
}
|
|
280
|
+
/** Explicit route ownership transfer guarded by both observed values. */
|
|
281
|
+
export interface ImRebindRouteRequest {
|
|
282
|
+
readonly operationId: ImOperationId;
|
|
283
|
+
readonly accountId: ImAccountId;
|
|
284
|
+
readonly routeId: ImRouteId;
|
|
285
|
+
readonly observedRevision: ImRevision;
|
|
286
|
+
readonly observedWorkspaceId: WorkspaceId;
|
|
287
|
+
readonly workspaceId: WorkspaceId;
|
|
288
|
+
}
|
|
289
|
+
/** Route deletion guarded by the current lifecycle and workspace owner. */
|
|
290
|
+
export interface ImDeleteRouteRequest {
|
|
291
|
+
readonly operationId: ImOperationId;
|
|
292
|
+
readonly accountId: ImAccountId;
|
|
293
|
+
readonly routeId: ImRouteId;
|
|
294
|
+
readonly observedRevision: ImRevision;
|
|
295
|
+
readonly observedWorkspaceId: WorkspaceId;
|
|
296
|
+
}
|
|
297
|
+
/** Stable mutation outcome stored with the account aggregate. */
|
|
298
|
+
export interface ImRouteMutationResult {
|
|
299
|
+
readonly operationId: ImOperationId;
|
|
300
|
+
readonly status: 'applied' | 'unchanged' | 'conflict' | 'rejected';
|
|
301
|
+
readonly route?: ImRouteView;
|
|
302
|
+
readonly deletedRevision?: ImRevision;
|
|
303
|
+
readonly code?: string;
|
|
304
|
+
readonly message?: string;
|
|
305
|
+
}
|
|
306
|
+
/** Query result distinguishing an unknown operation from its durable receipt. */
|
|
307
|
+
export type ImRouteOperationQuery = {
|
|
308
|
+
readonly state: 'not-found';
|
|
309
|
+
} | {
|
|
310
|
+
readonly state: 'known';
|
|
311
|
+
readonly result: ImRouteMutationResult;
|
|
312
|
+
};
|
|
313
|
+
/** Account pause mutation guarded by the account revision. */
|
|
314
|
+
export interface ImSetAccountPausedRequest {
|
|
315
|
+
readonly operationId: ImOperationId;
|
|
316
|
+
readonly accountId: ImAccountId;
|
|
317
|
+
readonly observedRevision: ImRevision;
|
|
318
|
+
readonly paused: boolean;
|
|
319
|
+
}
|
|
320
|
+
/** Guarded disconnect, reconnect, refresh, or delete account request. */
|
|
321
|
+
export interface ImAccountLifecycleRequest {
|
|
322
|
+
readonly operationId: ImOperationId;
|
|
323
|
+
readonly accountId: ImAccountId;
|
|
324
|
+
readonly observedRevision: ImRevision;
|
|
325
|
+
}
|
|
326
|
+
/** Stable account mutation outcome. */
|
|
327
|
+
export interface ImAccountMutationResult {
|
|
328
|
+
readonly operationId: ImOperationId;
|
|
329
|
+
readonly status: 'applied' | 'unchanged' | 'conflict' | 'rejected';
|
|
330
|
+
readonly account: ImAccountView;
|
|
331
|
+
readonly deletedRevision?: ImRevision;
|
|
332
|
+
readonly code?: string;
|
|
333
|
+
readonly message?: string;
|
|
334
|
+
}
|
|
335
|
+
/** Query result distinguishing an unknown account operation from its durable receipt. */
|
|
336
|
+
export type ImAccountOperationQuery = {
|
|
337
|
+
readonly state: 'not-found';
|
|
338
|
+
} | {
|
|
339
|
+
readonly state: 'known';
|
|
340
|
+
readonly result: ImAccountMutationResult;
|
|
341
|
+
};
|
|
342
|
+
/** Configured route used when a workspace opens a channel simulation. */
|
|
343
|
+
export interface ImSimulationTargetView {
|
|
344
|
+
readonly workspaceId: WorkspaceId;
|
|
345
|
+
readonly accountId: ImAccountId;
|
|
346
|
+
readonly routeId: ImRouteId;
|
|
347
|
+
readonly revision: ImRevision;
|
|
348
|
+
readonly updatedAt: string;
|
|
349
|
+
}
|
|
350
|
+
/** One simulated participant whose identity may be used for inbound injection. */
|
|
351
|
+
export interface ImSimulationParticipant {
|
|
352
|
+
readonly actorId: string;
|
|
353
|
+
readonly displayName?: string;
|
|
354
|
+
}
|
|
355
|
+
/** Target and execution policy frozen when one simulation instance is created. */
|
|
356
|
+
export interface ImSimulationFrozenTarget {
|
|
357
|
+
readonly platform: ImPlatform;
|
|
358
|
+
readonly accountId: ImAccountId;
|
|
359
|
+
readonly routeId: ImRouteId;
|
|
360
|
+
readonly routeRevision: ImRevision;
|
|
361
|
+
readonly accountRevision: ImRevision;
|
|
362
|
+
readonly conversationKind: ImConversationKind;
|
|
363
|
+
readonly conversationId: string;
|
|
364
|
+
readonly workspaceId: WorkspaceId;
|
|
365
|
+
readonly agentPreset: string;
|
|
366
|
+
readonly controller?: string;
|
|
367
|
+
readonly groupTrigger?: ImGroupTrigger;
|
|
368
|
+
readonly directRecipient?: ImDirectRecipient;
|
|
369
|
+
}
|
|
370
|
+
/** Durable two-Session simulation instance. `stopped` and `failed` are terminal. */
|
|
371
|
+
export interface ImSimulationInstanceView {
|
|
372
|
+
readonly instanceId: ImSimulationInstanceId;
|
|
373
|
+
readonly status: 'creating' | 'running' | 'stopping' | 'stopped' | 'failed';
|
|
374
|
+
readonly simUserSessionId: SessionId;
|
|
375
|
+
readonly simUserWorkspaceId: WorkspaceId;
|
|
376
|
+
readonly testedSessionId: SessionId;
|
|
377
|
+
readonly target: ImSimulationFrozenTarget;
|
|
378
|
+
readonly speakingMembers: readonly ImSimulationParticipant[];
|
|
379
|
+
readonly historyImports: readonly ImSimulationHistoryImport[];
|
|
380
|
+
readonly createdAt: string;
|
|
381
|
+
readonly updatedAt: string;
|
|
382
|
+
readonly stoppedAt?: string;
|
|
383
|
+
readonly failure?: {
|
|
384
|
+
readonly code: string;
|
|
385
|
+
readonly message: string;
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
/** Durable display facts for one query-only simulation history import. */
|
|
389
|
+
export interface ImSimulationHistoryImport {
|
|
390
|
+
readonly operationId: ImDeliveryOperationId;
|
|
391
|
+
readonly fileName: string;
|
|
392
|
+
readonly messageCount: number;
|
|
393
|
+
readonly importedCount: number;
|
|
394
|
+
readonly duplicateCount: number;
|
|
395
|
+
}
|
|
396
|
+
/** Scope-free local history import; the Host derives the frozen instance scope. */
|
|
397
|
+
export interface ImImportSimulationHistoryRequest {
|
|
398
|
+
readonly instanceId: ImSimulationInstanceId;
|
|
399
|
+
readonly operationId: ImDeliveryOperationId;
|
|
400
|
+
readonly fileName: string;
|
|
401
|
+
readonly jsonl: string;
|
|
402
|
+
}
|
|
403
|
+
/** Updated instance and exact durable receipt for one local history import. */
|
|
404
|
+
export interface ImImportSimulationHistoryResult {
|
|
405
|
+
readonly source: ImSimulationHistoryImport;
|
|
406
|
+
readonly instance: ImSimulationInstanceView;
|
|
407
|
+
}
|
|
408
|
+
/** Create a simulation from one live, workspace-owned simulated-user Session. */
|
|
409
|
+
export interface ImCreateSimulationInstanceRequest {
|
|
410
|
+
readonly simUserSessionId: SessionId;
|
|
411
|
+
/** Required only when the configured route targets every conversation. */
|
|
412
|
+
readonly conversationId?: string;
|
|
413
|
+
readonly speakingMembers?: readonly ImSimulationParticipant[];
|
|
414
|
+
}
|
|
415
|
+
/** Trusted navigation and delivery facts for either Session in one instance. */
|
|
416
|
+
export interface ImSimulationSessionScope {
|
|
417
|
+
readonly instanceId: ImSimulationInstanceId;
|
|
418
|
+
readonly role: 'sim-user' | 'tested';
|
|
419
|
+
readonly sessionId: SessionId;
|
|
420
|
+
readonly peerSessionId: SessionId;
|
|
421
|
+
readonly workspaceId: WorkspaceId;
|
|
422
|
+
readonly peerWorkspaceId: WorkspaceId;
|
|
423
|
+
readonly deliveryScope: ImSimulationDeliveryScope;
|
|
424
|
+
readonly status: ImSimulationInstanceView['status'];
|
|
425
|
+
}
|
|
426
|
+
/** Inject one allow-listed simulated participant message through normal IM admission. */
|
|
427
|
+
export interface ImInjectSimulationMemberRequest {
|
|
428
|
+
readonly requestId: ImDeliveryOperationId;
|
|
429
|
+
readonly instanceId: ImSimulationInstanceId;
|
|
430
|
+
readonly actorId: string;
|
|
431
|
+
readonly text: string;
|
|
432
|
+
}
|
|
433
|
+
/** Inject the managed human actor through normal IM admission. */
|
|
434
|
+
export interface ImInjectSimulationManagedHumanRequest {
|
|
435
|
+
readonly requestId: ImDeliveryOperationId;
|
|
436
|
+
readonly instanceId: ImSimulationInstanceId;
|
|
437
|
+
readonly text: string;
|
|
438
|
+
}
|
|
439
|
+
/** Query a durable injection receipt without admitting another message, including after stop. */
|
|
440
|
+
export interface ImSimulationInjectionQuery {
|
|
441
|
+
readonly instanceId: ImSimulationInstanceId;
|
|
442
|
+
readonly requestId: ImDeliveryOperationId;
|
|
443
|
+
}
|
|
444
|
+
/** Save or replace a simulation target with absent-or-current CAS. */
|
|
445
|
+
export interface ImSaveSimulationTargetRequest {
|
|
446
|
+
readonly operationId: ImOperationId;
|
|
447
|
+
readonly workspaceId: WorkspaceId;
|
|
448
|
+
readonly observedRevision: ImRevision | null;
|
|
449
|
+
readonly accountId: ImAccountId;
|
|
450
|
+
readonly routeId: ImRouteId;
|
|
451
|
+
}
|
|
452
|
+
/** Remove a simulation target guarded by its current revision. */
|
|
453
|
+
export interface ImRemoveSimulationTargetRequest {
|
|
454
|
+
readonly operationId: ImOperationId;
|
|
455
|
+
readonly workspaceId: WorkspaceId;
|
|
456
|
+
readonly observedRevision: ImRevision;
|
|
457
|
+
}
|
|
458
|
+
/** Stable simulation-target mutation outcome. */
|
|
459
|
+
export interface ImSimulationTargetMutationResult {
|
|
460
|
+
readonly operationId: ImOperationId;
|
|
461
|
+
readonly status: 'applied' | 'unchanged' | 'conflict' | 'rejected';
|
|
462
|
+
readonly target?: ImSimulationTargetView;
|
|
463
|
+
readonly deletedRevision?: ImRevision;
|
|
464
|
+
readonly code?: string;
|
|
465
|
+
readonly message?: string;
|
|
466
|
+
}
|
|
467
|
+
/** Query result for one durable simulation-target operation. */
|
|
468
|
+
export type ImSimulationTargetOperationQuery = {
|
|
469
|
+
readonly state: 'not-found';
|
|
470
|
+
} | {
|
|
471
|
+
readonly state: 'known';
|
|
472
|
+
readonly result: ImSimulationTargetMutationResult;
|
|
473
|
+
};
|
|
474
|
+
/** Current durable configuration with a process-generation revision. */
|
|
475
|
+
export interface ImRuntimeSnapshot {
|
|
476
|
+
readonly revision: number;
|
|
477
|
+
readonly registeredPlatforms: readonly ImPlatform[];
|
|
478
|
+
readonly accounts: readonly ImAccountView[];
|
|
479
|
+
readonly routes: readonly ImRouteView[];
|
|
480
|
+
readonly simulationTargets: readonly ImSimulationTargetView[];
|
|
481
|
+
}
|
|
482
|
+
/** Post-commit configuration change notification. */
|
|
483
|
+
export interface ImRuntimeChange {
|
|
484
|
+
readonly revision: number;
|
|
485
|
+
readonly kind: 'account' | 'account-listener' | 'route' | 'simulation-target' | 'simulation-instance' | 'transport';
|
|
486
|
+
readonly platform?: ImPlatform;
|
|
487
|
+
readonly accountId?: ImAccountId;
|
|
488
|
+
readonly routeId?: ImRouteId;
|
|
489
|
+
readonly workspaceId?: WorkspaceId;
|
|
490
|
+
readonly operationId?: ImOperationId;
|
|
491
|
+
readonly instanceId?: ImSimulationInstanceId;
|
|
492
|
+
}
|
|
493
|
+
/** Result of resolving the precedence-ordered routes for one inbound conversation. */
|
|
494
|
+
export type ImRouteResolution = {
|
|
495
|
+
readonly state: 'matched';
|
|
496
|
+
readonly route: ImRouteView;
|
|
497
|
+
} | {
|
|
498
|
+
readonly state: 'disabled';
|
|
499
|
+
readonly route: ImRouteView;
|
|
500
|
+
} | {
|
|
501
|
+
readonly state: 'account-paused';
|
|
502
|
+
} | {
|
|
503
|
+
readonly state: 'unmatched';
|
|
504
|
+
};
|
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,102 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gestaltrun/dsh-im-runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Durable IM account and routing runtime for Gestaltrun Desktop",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./types": {
|
|
14
|
+
"types": "./lib/types/types.d.ts",
|
|
15
|
+
"default": "./lib/types.js"
|
|
16
|
+
},
|
|
17
|
+
"./tools": {
|
|
18
|
+
"types": "./lib/types/tools.d.ts",
|
|
19
|
+
"default": "./lib/tools.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
"./locale/*.json": "./locale/*.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib",
|
|
26
|
+
"locale/*.json",
|
|
27
|
+
"README.md",
|
|
28
|
+
"README.zh.md",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"UPSTREAM.json"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/gestaltrun/deepseek-harness.git",
|
|
36
|
+
"directory": "product/im-runtime"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"registry": "https://registry.npmjs.org/",
|
|
41
|
+
"tag": "candidate"
|
|
42
|
+
},
|
|
43
|
+
"dsh": {
|
|
44
|
+
"engines": {
|
|
45
|
+
"dsh": ">=0.1.6-alpha.2"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"zod": "4.4.3"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@deepseek-ai/cordis": "4.0.5-alpha.1",
|
|
53
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.3",
|
|
54
|
+
"@deepseek-ai/dsh-agent-default-model": "0.2.1-alpha.3",
|
|
55
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.3",
|
|
56
|
+
"@deepseek-ai/dsh-brand": "0.2.1-alpha.3",
|
|
57
|
+
"@deepseek-ai/dsh-credentials": "0.2.1-alpha.3",
|
|
58
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.3",
|
|
59
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.3",
|
|
60
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.3",
|
|
61
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.1-alpha.3",
|
|
62
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.3",
|
|
63
|
+
"@deepseek-ai/dsh-tools": "0.2.1-alpha.3",
|
|
64
|
+
"@deepseek-ai/dsh-workspace": "0.2.1-alpha.3"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@deepseek-ai/cordis": "4.0.5-alpha.1",
|
|
68
|
+
"@deepseek-ai/cordis-plugin-include": "1.0.10-alpha.1",
|
|
69
|
+
"@deepseek-ai/cordis-plugin-loader": "1.0.6-alpha.1",
|
|
70
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.3",
|
|
71
|
+
"@deepseek-ai/dsh-agent-default-model": "0.2.1-alpha.3",
|
|
72
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.3",
|
|
73
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.3",
|
|
74
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.3",
|
|
75
|
+
"@deepseek-ai/dsh-brand": "0.2.1-alpha.3",
|
|
76
|
+
"@deepseek-ai/dsh-credentials": "0.2.1-alpha.3",
|
|
77
|
+
"@deepseek-ai/dsh-credentials-local": "0.2.1-alpha.3",
|
|
78
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.3",
|
|
79
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.3",
|
|
80
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.3",
|
|
81
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-alpha.3",
|
|
82
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.3",
|
|
83
|
+
"@deepseek-ai/dsh-storage": "0.2.1-alpha.3",
|
|
84
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.1-alpha.3",
|
|
85
|
+
"@deepseek-ai/dsh-storage-json": "0.2.1-alpha.3",
|
|
86
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.3",
|
|
87
|
+
"@deepseek-ai/dsh-tools": "0.2.1-alpha.3",
|
|
88
|
+
"@deepseek-ai/dsh-workspace": "0.2.1-alpha.3",
|
|
89
|
+
"@types/node": "22.20.0",
|
|
90
|
+
"tsdown": "0.22.2",
|
|
91
|
+
"typescript": "6.0.3",
|
|
92
|
+
"vite-tsconfig-paths": "6.1.1",
|
|
93
|
+
"vitest": "4.1.8",
|
|
94
|
+
"@gestaltrun/dsh-workspace-bundle": "^0.1.0"
|
|
95
|
+
},
|
|
96
|
+
"scripts": {
|
|
97
|
+
"build": "node scripts/clean.mjs && tsc -p tsconfig.build.json && tsdown",
|
|
98
|
+
"typecheck": "tsc --noEmit",
|
|
99
|
+
"test": "vitest run",
|
|
100
|
+
"smoke:loader": "node scripts/smoke-loader.mjs"
|
|
101
|
+
}
|
|
6
102
|
}
|