opencode-oncall 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.
Files changed (105) hide show
  1. package/LICENSE +151 -0
  2. package/README.md +50 -0
  3. package/dist/common-settings-actions.d.ts +15 -0
  4. package/dist/common-settings-actions.js +48 -0
  5. package/dist/common-settings-store.d.ts +1 -0
  6. package/dist/common-settings-store.js +1 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +1 -0
  9. package/dist/plugin-hooks.d.ts +51 -0
  10. package/dist/plugin-hooks.js +288 -0
  11. package/dist/plugin.d.ts +10 -0
  12. package/dist/plugin.js +115 -0
  13. package/dist/settings-store.d.ts +50 -0
  14. package/dist/settings-store.js +214 -0
  15. package/dist/store-paths.d.ts +16 -0
  16. package/dist/store-paths.js +61 -0
  17. package/dist/ui/wechat-menu.d.ts +26 -0
  18. package/dist/ui/wechat-menu.js +90 -0
  19. package/dist/wechat/bind-flow.d.ts +29 -0
  20. package/dist/wechat/bind-flow.js +207 -0
  21. package/dist/wechat/bridge.d.ts +136 -0
  22. package/dist/wechat/bridge.js +1059 -0
  23. package/dist/wechat/broker-client.d.ts +23 -0
  24. package/dist/wechat/broker-client.js +274 -0
  25. package/dist/wechat/broker-endpoint.d.ts +21 -0
  26. package/dist/wechat/broker-endpoint.js +78 -0
  27. package/dist/wechat/broker-entry.d.ts +123 -0
  28. package/dist/wechat/broker-entry.js +1321 -0
  29. package/dist/wechat/broker-launcher.d.ts +37 -0
  30. package/dist/wechat/broker-launcher.js +418 -0
  31. package/dist/wechat/broker-mutation-queue.d.ts +93 -0
  32. package/dist/wechat/broker-mutation-queue.js +126 -0
  33. package/dist/wechat/broker-server.d.ts +86 -0
  34. package/dist/wechat/broker-server.js +1340 -0
  35. package/dist/wechat/broker-state-store.d.ts +335 -0
  36. package/dist/wechat/broker-state-store.js +1964 -0
  37. package/dist/wechat/command-parser.d.ts +18 -0
  38. package/dist/wechat/command-parser.js +58 -0
  39. package/dist/wechat/compat/jiti-loader.d.ts +27 -0
  40. package/dist/wechat/compat/jiti-loader.js +118 -0
  41. package/dist/wechat/compat/openclaw-account-helpers.d.ts +29 -0
  42. package/dist/wechat/compat/openclaw-account-helpers.js +60 -0
  43. package/dist/wechat/compat/openclaw-bind-helpers.d.ts +29 -0
  44. package/dist/wechat/compat/openclaw-bind-helpers.js +169 -0
  45. package/dist/wechat/compat/openclaw-guided-smoke.d.ts +180 -0
  46. package/dist/wechat/compat/openclaw-guided-smoke.js +1134 -0
  47. package/dist/wechat/compat/openclaw-public-entry.d.ts +33 -0
  48. package/dist/wechat/compat/openclaw-public-entry.js +62 -0
  49. package/dist/wechat/compat/openclaw-public-helpers.d.ts +70 -0
  50. package/dist/wechat/compat/openclaw-public-helpers.js +68 -0
  51. package/dist/wechat/compat/openclaw-qr-gateway.d.ts +15 -0
  52. package/dist/wechat/compat/openclaw-qr-gateway.js +39 -0
  53. package/dist/wechat/compat/openclaw-smoke.d.ts +48 -0
  54. package/dist/wechat/compat/openclaw-smoke.js +100 -0
  55. package/dist/wechat/compat/openclaw-sync-buf.d.ts +24 -0
  56. package/dist/wechat/compat/openclaw-sync-buf.js +80 -0
  57. package/dist/wechat/compat/openclaw-updates-send.d.ts +47 -0
  58. package/dist/wechat/compat/openclaw-updates-send.js +38 -0
  59. package/dist/wechat/compat/qrcode-terminal-loader.d.ts +12 -0
  60. package/dist/wechat/compat/qrcode-terminal-loader.js +16 -0
  61. package/dist/wechat/compat/slash-guard.d.ts +11 -0
  62. package/dist/wechat/compat/slash-guard.js +24 -0
  63. package/dist/wechat/dead-letter-store.d.ts +48 -0
  64. package/dist/wechat/dead-letter-store.js +224 -0
  65. package/dist/wechat/debug-bundle-collector.d.ts +49 -0
  66. package/dist/wechat/debug-bundle-collector.js +580 -0
  67. package/dist/wechat/debug-bundle-flow.d.ts +37 -0
  68. package/dist/wechat/debug-bundle-flow.js +180 -0
  69. package/dist/wechat/debug-bundle-redaction.d.ts +14 -0
  70. package/dist/wechat/debug-bundle-redaction.js +339 -0
  71. package/dist/wechat/handle.d.ts +10 -0
  72. package/dist/wechat/handle.js +57 -0
  73. package/dist/wechat/ipc-auth.d.ts +6 -0
  74. package/dist/wechat/ipc-auth.js +39 -0
  75. package/dist/wechat/latest-account-state-store.d.ts +8 -0
  76. package/dist/wechat/latest-account-state-store.js +38 -0
  77. package/dist/wechat/notification-dispatcher.d.ts +34 -0
  78. package/dist/wechat/notification-dispatcher.js +266 -0
  79. package/dist/wechat/notification-format.d.ts +15 -0
  80. package/dist/wechat/notification-format.js +196 -0
  81. package/dist/wechat/notification-store.d.ts +72 -0
  82. package/dist/wechat/notification-store.js +807 -0
  83. package/dist/wechat/notification-types.d.ts +37 -0
  84. package/dist/wechat/notification-types.js +1 -0
  85. package/dist/wechat/openclaw-account-adapter.d.ts +30 -0
  86. package/dist/wechat/openclaw-account-adapter.js +60 -0
  87. package/dist/wechat/operator-store.d.ts +9 -0
  88. package/dist/wechat/operator-store.js +69 -0
  89. package/dist/wechat/protocol.d.ts +150 -0
  90. package/dist/wechat/protocol.js +197 -0
  91. package/dist/wechat/question-interaction.d.ts +24 -0
  92. package/dist/wechat/question-interaction.js +180 -0
  93. package/dist/wechat/request-store.d.ts +108 -0
  94. package/dist/wechat/request-store.js +669 -0
  95. package/dist/wechat/session-digest.d.ts +50 -0
  96. package/dist/wechat/session-digest.js +167 -0
  97. package/dist/wechat/state-paths.d.ts +26 -0
  98. package/dist/wechat/state-paths.js +92 -0
  99. package/dist/wechat/status-format.d.ts +26 -0
  100. package/dist/wechat/status-format.js +616 -0
  101. package/dist/wechat/token-store.d.ts +20 -0
  102. package/dist/wechat/token-store.js +193 -0
  103. package/dist/wechat/wechat-status-runtime.d.ts +89 -0
  104. package/dist/wechat/wechat-status-runtime.js +518 -0
  105. package/package.json +74 -0
@@ -0,0 +1,335 @@
1
+ import type { BrokerAckPayload, BrokerCommandStatus, BrokerToBridgeCommandType, BrokerToBridgeControlType, BridgeToBrokerEvent } from "./protocol.js";
2
+ type UnknownRecord = Record<string, unknown>;
3
+ export declare const BROKER_STATE_SCHEMA_MARKER_KIND = "wechat-broker-state-store";
4
+ export declare const LEGACY_STATE_RESET_UPGRADE_CLOSE_REASON = "legacy-state-reset-awaiting-full-sync";
5
+ export type BrokerStateSchemaMarker = {
6
+ kind?: string;
7
+ protocolVersion: number;
8
+ stateGeneration: string;
9
+ updatedAt: number;
10
+ upgradeCloseReason?: string;
11
+ legacyHandleClosures?: string[];
12
+ };
13
+ export type PrepareBrokerStateStoreForStartupInput = {
14
+ protocolVersion: number;
15
+ stateGeneration: string;
16
+ now?: () => number;
17
+ };
18
+ export type PrepareBrokerStateStoreForStartupResult = {
19
+ state: BrokerState;
20
+ recoveredFromLegacyState: boolean;
21
+ legacyHandleClosures: string[];
22
+ };
23
+ export type BrokerConnectionState = {
24
+ instanceID: string;
25
+ instanceIncarnation: string;
26
+ online: boolean;
27
+ lastEventSeq: number;
28
+ lastAckedEventSeq: number;
29
+ lastSentBrokerSeq: number;
30
+ lastObservedAt?: number;
31
+ connectedAt?: number;
32
+ disconnectedAt?: number;
33
+ disconnectReason?: string;
34
+ };
35
+ export type BrokerConnectionScope = {
36
+ instanceID: string;
37
+ instanceIncarnation: string;
38
+ };
39
+ export type BrokerActiveState = {
40
+ instances: Record<string, UnknownRecord>;
41
+ sessions: Record<string, UnknownRecord>;
42
+ questions: Record<string, UnknownRecord>;
43
+ permissions: Record<string, UnknownRecord>;
44
+ naturalStops: Record<string, UnknownRecord>;
45
+ retryErrors: Record<string, UnknownRecord>;
46
+ };
47
+ export type BrokerTerminalMetadata = {
48
+ reason: string;
49
+ replacementHandle?: string;
50
+ terminalResultSent?: boolean;
51
+ retainedUntil?: number;
52
+ handle?: string;
53
+ requestID?: string;
54
+ scopeKey?: string;
55
+ prompt?: unknown;
56
+ wechatAccountId?: string;
57
+ userId?: string;
58
+ createdAt?: number;
59
+ answeredAt?: number;
60
+ rejectedAt?: number;
61
+ expiredAt?: number;
62
+ cleanedAt?: number;
63
+ };
64
+ export type BrokerRetainedOccupancy = {
65
+ handle: string;
66
+ retainedUntil: number;
67
+ };
68
+ export type BrokerIndexedRequestRecord = {
69
+ kind: "question" | "permission";
70
+ requestID: string;
71
+ routeKey: string;
72
+ handle: string;
73
+ scopeKey?: string;
74
+ prompt?: unknown;
75
+ wechatAccountId: string;
76
+ userId: string;
77
+ status: "open" | "answered" | "rejected" | "expired" | "cleaned";
78
+ createdAt: number;
79
+ answeredAt?: number;
80
+ rejectedAt?: number;
81
+ expiredAt?: number;
82
+ cleanedAt?: number;
83
+ terminalReason?: "answered" | "handled" | "rejected" | "expired" | "replaced";
84
+ replacementHandle?: string;
85
+ terminalResultSent?: boolean;
86
+ };
87
+ export type BrokerDeliveryTokenState = {
88
+ wechatAccountId: string;
89
+ userId: string;
90
+ contextToken: string;
91
+ updatedAt: number;
92
+ source: "question" | "permission" | "message";
93
+ sourceRef?: string;
94
+ staleReason?: string;
95
+ };
96
+ export type BrokerRuntimeExpiredRequest = BrokerIndexedRequestRecord;
97
+ export type BrokerRuntimeClosedNaturalStop = {
98
+ handle: string;
99
+ scopeKey?: string;
100
+ idempotencyKey?: string;
101
+ terminalReason: string;
102
+ };
103
+ export type BrokerRuntimeCleanupResult = {
104
+ cleanedRequests: BrokerIndexedRequestRecord[];
105
+ purgedRequests: BrokerIndexedRequestRecord[];
106
+ };
107
+ export type BrokerLegacyHandleKind = "question" | "permission" | "naturalStop";
108
+ export type BrokerLegacyHandleClosure = {
109
+ kind: BrokerLegacyHandleKind;
110
+ handle: string;
111
+ reason: string;
112
+ message?: string;
113
+ replacementHandle?: string;
114
+ routeKey?: string;
115
+ retainedUntil?: number;
116
+ };
117
+ export type BrokerCommandRecord = {
118
+ commandId: string;
119
+ brokerSeq: number;
120
+ type: BrokerToBridgeCommandType;
121
+ target: UnknownRecord;
122
+ payload?: unknown;
123
+ status: BrokerCommandStatus;
124
+ acceptedAt?: number;
125
+ completedAt?: number;
126
+ failure?: UnknownRecord;
127
+ instanceID?: string;
128
+ instanceIncarnation?: string;
129
+ acceptedEventSeq?: number;
130
+ resultEventSeq?: number;
131
+ };
132
+ export type BrokerControlStatus = "inFlight" | "completed";
133
+ export type BrokerControlRecord = {
134
+ controlId: string;
135
+ brokerSeq: number;
136
+ type: BrokerToBridgeControlType;
137
+ status: BrokerControlStatus;
138
+ instanceID: string;
139
+ instanceIncarnation: string;
140
+ fromEventSeq?: number;
141
+ toEventSeq?: number;
142
+ reason?: string;
143
+ completedEventSeq?: number;
144
+ };
145
+ export type BrokerFullSyncStage = {
146
+ controlId: string;
147
+ instanceID: string;
148
+ instanceIncarnation: string;
149
+ state: BrokerState;
150
+ };
151
+ export type BrokerFullSyncSnapshot = {
152
+ connections?: Record<string, Record<string, BrokerConnectionState>>;
153
+ active: BrokerActiveState;
154
+ };
155
+ export type BrokerState = {
156
+ connections: Record<string, Record<string, BrokerConnectionState>>;
157
+ active: BrokerActiveState;
158
+ terminalMetadata: Record<string, BrokerTerminalMetadata>;
159
+ retainedOccupancy: Record<string, BrokerRetainedOccupancy>;
160
+ legacyHandleClosures: Record<string, BrokerLegacyHandleClosure>;
161
+ requestIndex: Record<string, BrokerIndexedRequestRecord>;
162
+ deliveryTokens: Record<string, BrokerDeliveryTokenState>;
163
+ commandLedger: Record<string, BrokerCommandRecord>;
164
+ controlLedger: Record<string, BrokerControlRecord>;
165
+ fullSync: {
166
+ lastCompletedControlId?: string;
167
+ lastCompletedEventSeq?: number;
168
+ lastCompletedInstanceIncarnation?: string;
169
+ stagedByControlId: Record<string, BrokerFullSyncStage>;
170
+ };
171
+ };
172
+ export type UpsertBrokerCommandInput = {
173
+ commandId: string;
174
+ brokerSeq: number;
175
+ type: BrokerToBridgeCommandType;
176
+ status: "queued" | "delivered";
177
+ target: UnknownRecord;
178
+ payload?: unknown;
179
+ instanceID?: string;
180
+ instanceIncarnation?: string;
181
+ };
182
+ export type RequestBrokerReplayInput = {
183
+ controlId: string;
184
+ brokerSeq: number;
185
+ instanceID: string;
186
+ instanceIncarnation: string;
187
+ fromEventSeq: number;
188
+ toEventSeq: number;
189
+ };
190
+ export type MarkBrokerReplayCompletedInput = {
191
+ controlId: string;
192
+ completedEventSeq: number;
193
+ };
194
+ export type RequestBrokerFullSyncInput = {
195
+ controlId: string;
196
+ brokerSeq: number;
197
+ instanceID: string;
198
+ instanceIncarnation: string;
199
+ reason: string;
200
+ };
201
+ export type StageBrokerFullSyncEventInput = {
202
+ controlId: string;
203
+ event: BridgeToBrokerEvent;
204
+ context?: ApplyBridgeEventContext;
205
+ };
206
+ export type MarkBrokerFullSyncCompletedInput = {
207
+ controlId: string;
208
+ instanceID: string;
209
+ instanceIncarnation: string;
210
+ eventSeq: number;
211
+ };
212
+ export type MarkBrokerCommandAcceptedInput = {
213
+ commandId: string;
214
+ instanceID: string;
215
+ instanceIncarnation: string;
216
+ eventSeq: number;
217
+ acceptedAt?: number;
218
+ };
219
+ export type MarkBrokerCommandResultInput = {
220
+ commandId: string;
221
+ instanceID: string;
222
+ instanceIncarnation: string;
223
+ eventSeq: number;
224
+ status: "completed" | "failed";
225
+ completedAt?: number;
226
+ failure?: UnknownRecord;
227
+ };
228
+ export type UpsertRetryErrorSummaryInput = {
229
+ instanceID: string;
230
+ sessionID?: string;
231
+ action: string;
232
+ redactedSummary: string;
233
+ severityAdvice: string;
234
+ updatedAt?: number;
235
+ instanceIncarnation?: string;
236
+ };
237
+ export type MarkConnectionAckedEventSeqInput = BrokerAckPayload & {
238
+ instanceID: string;
239
+ };
240
+ export type MarkConnectionSentBrokerSeqInput = BrokerConnectionScope & {
241
+ brokerSeq: number;
242
+ };
243
+ export type ApplyBridgeEventContext = {
244
+ instanceID?: string;
245
+ };
246
+ export type BrokerAuthoritativeView = {
247
+ connections: Record<string, Record<string, BrokerConnectionState>>;
248
+ active: BrokerActiveState;
249
+ terminalMetadata: Record<string, BrokerTerminalMetadata>;
250
+ retainedOccupancy: Record<string, BrokerRetainedOccupancy>;
251
+ commandLedger: Record<string, BrokerCommandRecord>;
252
+ legacyHandleClosures: Record<string, BrokerLegacyHandleClosure>;
253
+ };
254
+ export type BrokerCommandActionInput = {
255
+ type: BrokerToBridgeCommandType;
256
+ target: UnknownRecord;
257
+ payload?: unknown;
258
+ };
259
+ export declare function persistBrokerStateStoreSnapshot(state: BrokerState): Promise<void>;
260
+ export declare function loadBrokerStateStoreSnapshot(): Promise<BrokerState | undefined>;
261
+ export declare function loadBrokerStateStoreForMutation(): Promise<BrokerState>;
262
+ export declare function setBrokerStateMutationTarget(state: BrokerState | undefined): void;
263
+ export declare function readBrokerStateSchemaMarker(): Promise<BrokerStateSchemaMarker | undefined>;
264
+ export declare function writeBrokerStateSchemaMarker(input: BrokerStateSchemaMarker): Promise<BrokerStateSchemaMarker>;
265
+ export declare function prepareBrokerStateStoreForStartup(input: PrepareBrokerStateStoreForStartupInput): Promise<PrepareBrokerStateStoreForStartupResult>;
266
+ export declare function readBrokerStateUpgradeCloseReason(handle: string): Promise<string | undefined>;
267
+ export declare function createEmptyBrokerState(options?: {
268
+ track?: boolean;
269
+ }): BrokerState;
270
+ export declare function writeLegacyHandleClosure(state: BrokerState, input: BrokerLegacyHandleClosure): BrokerLegacyHandleClosure;
271
+ export declare function readLegacyHandleClosure(state: BrokerState | undefined, input: {
272
+ kind: BrokerLegacyHandleKind;
273
+ handle: string;
274
+ }): BrokerLegacyHandleClosure | undefined;
275
+ export declare function applyBridgeEvent<TPayload = unknown>(state: BrokerState, event: BridgeToBrokerEvent<TPayload>, context?: ApplyBridgeEventContext): BrokerState;
276
+ export declare function applyFullSyncSnapshot(state: BrokerState, scope: BrokerConnectionScope, snapshot: BrokerFullSyncSnapshot): BrokerState;
277
+ export declare function upsertBrokerCommand(state: BrokerState, input: UpsertBrokerCommandInput): BrokerCommandRecord;
278
+ export declare function reconcileBrokerActiveRequestHandlesWithVisibleNotifications(state: BrokerState): Promise<BrokerState>;
279
+ export declare function readBrokerControlRecord(state: BrokerState, controlId: string): BrokerControlRecord | undefined;
280
+ export declare function upsertRetryErrorSummary(state: BrokerState, input: UpsertRetryErrorSummaryInput): UnknownRecord;
281
+ export declare function upsertBrokerIndexedRequest(state: BrokerState, input: BrokerIndexedRequestRecord): BrokerIndexedRequestRecord;
282
+ export declare function readBrokerIndexedRequest(input: {
283
+ kind: "question" | "permission";
284
+ routeKey: string;
285
+ }, state?: BrokerState): Promise<BrokerIndexedRequestRecord | undefined>;
286
+ export declare function upsertBrokerDeliveryToken(state: BrokerState, input: BrokerDeliveryTokenState): BrokerDeliveryTokenState;
287
+ export declare function readBrokerDeliveryToken(input: {
288
+ wechatAccountId: string;
289
+ userId: string;
290
+ }, state?: BrokerState): Promise<BrokerDeliveryTokenState | undefined>;
291
+ export declare function expireBrokerIndexedRequestsForScope(state: BrokerState, input: {
292
+ scopeKey: string;
293
+ expiredAt: number;
294
+ }): BrokerRuntimeExpiredRequest[];
295
+ export declare function closeBrokerNaturalStopsForScope(state: BrokerState, input: {
296
+ scopeKey: string;
297
+ terminalReason: string;
298
+ }): BrokerRuntimeClosedNaturalStop[];
299
+ export declare function clearBrokerActiveScope(state: BrokerState, input: {
300
+ scopeKey: string;
301
+ }): void;
302
+ export declare function removeBrokerConnectionScope(state: BrokerState, input: BrokerConnectionScope): void;
303
+ export declare function reconcileBrokerDisconnectedScopes(state: BrokerState, input: {
304
+ disconnectedAt: number;
305
+ }): void;
306
+ export declare function cleanupBrokerRuntimeTerminalRequests(state: BrokerState, input: {
307
+ now: number;
308
+ cleanAfterMs: number;
309
+ purgeRetentionMs: number;
310
+ }): BrokerRuntimeCleanupResult;
311
+ export declare function markBrokerConnectionObserved(state: BrokerState, input: BrokerConnectionScope & {
312
+ observedAt: number;
313
+ connectedAt?: number;
314
+ }): BrokerConnectionState;
315
+ export declare function markBrokerConnectionOffline(state: BrokerState, input: BrokerConnectionScope & {
316
+ disconnectedAt: number;
317
+ reason: string;
318
+ }): BrokerConnectionState;
319
+ export declare function listTimedOutBrokerConnectionScopes(state: BrokerState, input: {
320
+ now: number;
321
+ timeoutMs: number;
322
+ }): BrokerConnectionScope[];
323
+ export declare function readBrokerAuthoritativeView(state?: BrokerState): BrokerAuthoritativeView;
324
+ export declare function readBrokerCommandStateByAction(input: BrokerCommandActionInput, state?: BrokerState): BrokerCommandRecord | undefined;
325
+ export declare function readBrokerFullSyncStage(state: BrokerState, controlId: string): BrokerState | undefined;
326
+ export declare function requestBrokerReplay(state: BrokerState, input: RequestBrokerReplayInput): BrokerControlRecord;
327
+ export declare function markBrokerReplayCompleted(state: BrokerState, input: MarkBrokerReplayCompletedInput): BrokerControlRecord;
328
+ export declare function requestBrokerFullSync(state: BrokerState, input: RequestBrokerFullSyncInput): BrokerControlRecord;
329
+ export declare function stageBrokerFullSyncEvent(state: BrokerState, input: StageBrokerFullSyncEventInput): BrokerState;
330
+ export declare function markBrokerFullSyncCompleted(state: BrokerState, input: MarkBrokerFullSyncCompletedInput): BrokerControlRecord;
331
+ export declare function markBrokerCommandAccepted(state: BrokerState, input: MarkBrokerCommandAcceptedInput): BrokerCommandRecord;
332
+ export declare function markBrokerCommandResult(state: BrokerState, input: MarkBrokerCommandResultInput): BrokerCommandRecord;
333
+ export declare function markConnectionAckedEventSeq(state: BrokerState, input: MarkConnectionAckedEventSeqInput): BrokerConnectionState;
334
+ export declare function markConnectionSentBrokerSeq(state: BrokerState, input: MarkConnectionSentBrokerSeqInput): BrokerConnectionState;
335
+ export {};