@longrun-ai/kernel 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +3 -0
  3. package/dist/app-host-contract.d.ts +87 -0
  4. package/dist/app-host-contract.js +2 -0
  5. package/dist/app-json.d.ts +139 -0
  6. package/dist/app-json.js +234 -0
  7. package/dist/diligence.d.ts +3 -0
  8. package/dist/diligence.js +64 -0
  9. package/dist/evt.d.ts +40 -0
  10. package/dist/evt.js +142 -0
  11. package/dist/index.d.ts +6 -0
  12. package/dist/index.js +25 -0
  13. package/dist/team-mgmt-manual.d.ts +20 -0
  14. package/dist/team-mgmt-manual.js +121 -0
  15. package/dist/types/context-health.d.ts +33 -0
  16. package/dist/types/context-health.js +2 -0
  17. package/dist/types/dialog.d.ts +398 -0
  18. package/dist/types/dialog.js +8 -0
  19. package/dist/types/display-state.d.ts +43 -0
  20. package/dist/types/display-state.js +2 -0
  21. package/dist/types/i18n.d.ts +2 -0
  22. package/dist/types/i18n.js +2 -0
  23. package/dist/types/language.d.ts +5 -0
  24. package/dist/types/language.js +35 -0
  25. package/dist/types/priming.d.ts +55 -0
  26. package/dist/types/priming.js +2 -0
  27. package/dist/types/problems.d.ts +128 -0
  28. package/dist/types/problems.js +2 -0
  29. package/dist/types/q4h.d.ts +9 -0
  30. package/dist/types/q4h.js +2 -0
  31. package/dist/types/setup.d.ts +170 -0
  32. package/dist/types/setup.js +2 -0
  33. package/dist/types/snippets.d.ts +68 -0
  34. package/dist/types/snippets.js +2 -0
  35. package/dist/types/storage.d.ts +561 -0
  36. package/dist/types/storage.js +85 -0
  37. package/dist/types/tools-registry.d.ts +19 -0
  38. package/dist/types/tools-registry.js +2 -0
  39. package/dist/types/wire.d.ts +227 -0
  40. package/dist/types/wire.js +18 -0
  41. package/dist/types.d.ts +112 -0
  42. package/dist/types.js +28 -0
  43. package/dist/utils/html.d.ts +2 -0
  44. package/dist/utils/html.js +20 -0
  45. package/dist/utils/id.d.ts +1 -0
  46. package/dist/utils/id.js +6 -0
  47. package/dist/utils/time.d.ts +1 -0
  48. package/dist/utils/time.js +13 -0
  49. package/package.json +87 -0
  50. package/src/app-host-contract.ts +105 -0
  51. package/src/app-json.ts +401 -0
  52. package/src/diligence.ts +64 -0
  53. package/src/evt.ts +156 -0
  54. package/src/index.ts +48 -0
  55. package/src/team-mgmt-manual.ts +151 -0
  56. package/src/types/context-health.ts +39 -0
  57. package/src/types/dialog.ts +487 -0
  58. package/src/types/display-state.ts +21 -0
  59. package/src/types/i18n.ts +3 -0
  60. package/src/types/language.ts +33 -0
  61. package/src/types/priming.ts +69 -0
  62. package/src/types/problems.ts +144 -0
  63. package/src/types/q4h.ts +11 -0
  64. package/src/types/setup.ts +140 -0
  65. package/src/types/snippets.ts +55 -0
  66. package/src/types/storage.ts +682 -0
  67. package/src/types/tools-registry.ts +24 -0
  68. package/src/types/wire.ts +335 -0
  69. package/src/types.ts +133 -0
  70. package/src/utils/html.ts +17 -0
  71. package/src/utils/id.ts +3 -0
  72. package/src/utils/time.ts +10 -0
@@ -0,0 +1,335 @@
1
+ // Wire Protocol Types for Dominds WebUI
2
+ // Network communication protocols and message definitions
3
+
4
+ import type { TypedDialogEvent } from './dialog';
5
+ import type { LanguageCode } from './language';
6
+ import type {
7
+ ClearResolvedProblemsRequest,
8
+ ClearResolvedProblemsResultMessage,
9
+ GetProblemsRequest,
10
+ ProblemsSnapshotMessage,
11
+ } from './problems';
12
+
13
+ export type {
14
+ ClearResolvedProblemsRequest,
15
+ ClearResolvedProblemsResultMessage,
16
+ GetProblemsRequest,
17
+ ProblemsSnapshotMessage,
18
+ } from './problems';
19
+
20
+ export type DialogStatusKind = 'running' | 'completed' | 'archived';
21
+
22
+ // Dialog Identification Structure
23
+ export interface DialogIdent {
24
+ selfId: string;
25
+ rootId: string;
26
+ // Persistence status directory of this dialog tree.
27
+ // Callers should always provide it for read/navigation operations.
28
+ status?: DialogStatusKind;
29
+ }
30
+
31
+ export interface AssignmentFromSup {
32
+ callName: 'tellask' | 'tellaskSessionless' | 'freshBootsReasoning';
33
+ mentionList?: string[];
34
+ tellaskContent: string;
35
+ originMemberId: string;
36
+ callerDialogId: string;
37
+ callId: string;
38
+ collectiveTargets?: string[];
39
+ }
40
+
41
+ // Utility function to create DialogIdent from various formats
42
+ export function createDialogIdent(
43
+ selfId: string,
44
+ rootId?: string,
45
+ status?: DialogStatusKind,
46
+ ): DialogIdent {
47
+ return status
48
+ ? {
49
+ selfId,
50
+ rootId: rootId || selfId,
51
+ status,
52
+ }
53
+ : {
54
+ selfId,
55
+ rootId: rootId || selfId,
56
+ };
57
+ }
58
+
59
+ // WebSocket Protocol Discriminated Union for Dominds WebUI
60
+ export type WebSocketMessage =
61
+ | WelcomeMessage
62
+ | ErrorMessage
63
+ | SetUiLanguageRequest
64
+ | UiLanguageSetMessage
65
+ | TeamConfigUpdatedMessage
66
+ | GetProblemsRequest
67
+ | ClearResolvedProblemsRequest
68
+ | ProblemsSnapshotMessage
69
+ | ClearResolvedProblemsResultMessage
70
+ | CreateDialogRequest
71
+ | DisplayDialogRequest
72
+ | SetDiligencePushRequest
73
+ | RefillDiligencePushBudgetRequest
74
+ | DiligencePushUpdatedMessage
75
+ | GetQ4HStateRequest
76
+ | Q4HStateResponse
77
+ | DialogsMovedMessage
78
+ | DialogsDeletedMessage
79
+ | DialogsCreatedMessage
80
+ | RunControlRefreshMessage
81
+ | RunControlCountsMessage
82
+ | InterruptDialogRequest
83
+ | EmergencyStopRequest
84
+ | ResumeDialogRequest
85
+ | ResumeAllRequest
86
+ | DeclareSubdialogDeadRequest
87
+ | DisplayRemindersRequest
88
+ | DisplayCourseRequest
89
+ | DriveDialogRequest
90
+ | DriveDialogByUserAnswer
91
+ | DialogReadyMessage
92
+ | TypedDialogEvent;
93
+
94
+ // Connection and Status Messages
95
+ export interface WelcomeMessage {
96
+ type: 'welcome';
97
+ message: string;
98
+ serverWorkLanguage: LanguageCode;
99
+ supportedLanguageCodes: LanguageCode[];
100
+ timestamp: string;
101
+ }
102
+
103
+ export interface ErrorMessage {
104
+ type: 'error';
105
+ message: string;
106
+ }
107
+
108
+ export interface SetUiLanguageRequest {
109
+ type: 'set_ui_language';
110
+ uiLanguage: LanguageCode;
111
+ }
112
+
113
+ export interface UiLanguageSetMessage {
114
+ type: 'ui_language_set';
115
+ uiLanguage: LanguageCode;
116
+ }
117
+
118
+ export interface TeamConfigUpdatedMessage {
119
+ type: 'team_config_updated';
120
+ path: string;
121
+ exists: boolean;
122
+ timestamp: string;
123
+ trigger?: string;
124
+ }
125
+
126
+ // Team and Dialog Management Messages
127
+
128
+ export type CreateDialogErrorCode =
129
+ | 'TEAM_NOT_READY'
130
+ | 'TEAM_MEMBER_INVALID'
131
+ | 'TASKDOC_INVALID'
132
+ | 'AUTH_REQUIRED'
133
+ | 'CREATE_FAILED';
134
+
135
+ export interface DialogPrimingInput {
136
+ scriptRefs: string[];
137
+ showInUi: boolean;
138
+ }
139
+
140
+ export interface CreateDialogInput {
141
+ requestId: string;
142
+ agentId: string;
143
+ taskDocPath: string;
144
+ priming?: DialogPrimingInput;
145
+ }
146
+
147
+ export interface CreateDialogRequest extends CreateDialogInput {
148
+ type: 'create_dialog';
149
+ }
150
+
151
+ export interface CreateDialogSuccess {
152
+ kind: 'success';
153
+ requestId: string;
154
+ selfId: string;
155
+ rootId: string;
156
+ agentId: string;
157
+ taskDocPath: string;
158
+ }
159
+
160
+ export interface CreateDialogFailure {
161
+ kind: 'failure';
162
+ requestId: string;
163
+ errorCode: CreateDialogErrorCode;
164
+ error: string;
165
+ }
166
+
167
+ export type CreateDialogResult = CreateDialogSuccess | CreateDialogFailure;
168
+
169
+ export interface DisplayDialogRequest {
170
+ type: 'display_dialog';
171
+ dialog: DialogIdent;
172
+ }
173
+
174
+ export interface SetDiligencePushRequest {
175
+ type: 'set_diligence_push';
176
+ dialog: DialogIdent;
177
+ disableDiligencePush: boolean;
178
+ }
179
+
180
+ export interface RefillDiligencePushBudgetRequest {
181
+ type: 'refill_diligence_push_budget';
182
+ dialog: DialogIdent;
183
+ }
184
+
185
+ export interface DiligencePushUpdatedMessage {
186
+ type: 'diligence_push_updated';
187
+ dialog: DialogIdent;
188
+ disableDiligencePush: boolean;
189
+ timestamp: string;
190
+ }
191
+
192
+ export interface DriveDialogRequest {
193
+ type: 'drive_dlg_by_user_msg';
194
+ dialog: DialogIdent;
195
+ content: string;
196
+ msgId: string;
197
+ userLanguageCode: LanguageCode;
198
+ }
199
+
200
+ export interface DriveDialogByUserAnswer {
201
+ type: 'drive_dialog_by_user_answer';
202
+ dialog: DialogIdent;
203
+ content: string;
204
+ msgId: string;
205
+ questionId: string;
206
+ continuationType: 'answer' | 'followup' | 'retry' | 'new_message';
207
+ userLanguageCode: LanguageCode;
208
+ }
209
+
210
+ export interface InterruptDialogRequest {
211
+ type: 'interrupt_dialog';
212
+ dialog: DialogIdent;
213
+ }
214
+
215
+ export interface EmergencyStopRequest {
216
+ type: 'emergency_stop';
217
+ }
218
+
219
+ export interface ResumeDialogRequest {
220
+ type: 'resume_dialog';
221
+ dialog: DialogIdent;
222
+ }
223
+
224
+ export interface ResumeAllRequest {
225
+ type: 'resume_all';
226
+ }
227
+
228
+ export interface DeclareSubdialogDeadRequest {
229
+ type: 'declare_subdialog_dead';
230
+ dialog: DialogIdent;
231
+ note?: string;
232
+ }
233
+
234
+ export interface DisplayRemindersRequest {
235
+ type: 'display_reminders';
236
+ dialog: DialogIdent;
237
+ }
238
+
239
+ export interface DisplayCourseRequest {
240
+ type: 'display_course';
241
+ dialog: DialogIdent;
242
+ course: number;
243
+ }
244
+
245
+ export interface GetQ4HStateRequest {
246
+ type: 'get_q4h_state';
247
+ }
248
+
249
+ export interface Q4HStateResponse {
250
+ type: 'q4h_state_response';
251
+ questions: Array<{
252
+ id: string;
253
+ selfId: string;
254
+ rootId: string;
255
+ agentId: string;
256
+ taskDocPath: string;
257
+ tellaskContent: string;
258
+ askedAt: string;
259
+ callId?: string;
260
+ remainingCallIds?: string[];
261
+ callSiteRef: {
262
+ course: number;
263
+ messageIndex: number;
264
+ };
265
+ }>;
266
+ }
267
+
268
+ export type DialogsMovedScope =
269
+ | { kind: 'root'; rootId: string }
270
+ | { kind: 'task'; taskDocPath: string };
271
+
272
+ export interface DialogsMovedMessage {
273
+ type: 'dialogs_moved';
274
+ scope: DialogsMovedScope;
275
+ fromStatus: DialogStatusKind;
276
+ toStatus: DialogStatusKind;
277
+ movedRootIds: string[];
278
+ timestamp: string;
279
+ }
280
+
281
+ export type DialogsDeletedScope =
282
+ | { kind: 'root'; rootId: string }
283
+ | { kind: 'task'; taskDocPath: string };
284
+
285
+ export interface DialogsDeletedMessage {
286
+ type: 'dialogs_deleted';
287
+ scope: DialogsDeletedScope;
288
+ fromStatus: DialogStatusKind;
289
+ deletedRootIds: string[];
290
+ timestamp: string;
291
+ }
292
+
293
+ export type DialogsCreatedScope =
294
+ | { kind: 'root'; rootId: string }
295
+ | { kind: 'task'; taskDocPath: string };
296
+
297
+ export interface DialogsCreatedMessage {
298
+ type: 'dialogs_created';
299
+ scope: DialogsCreatedScope;
300
+ status: DialogStatusKind;
301
+ createdRootIds: string[];
302
+ timestamp: string;
303
+ }
304
+
305
+ export type RunControlRefreshReason =
306
+ | 'resume_all'
307
+ | 'emergency_stop'
308
+ | 'run_state_marker_resumed'
309
+ | 'run_state_marker_interrupted';
310
+
311
+ export interface RunControlRefreshMessage {
312
+ type: 'run_control_refresh';
313
+ reason: RunControlRefreshReason;
314
+ timestamp: string;
315
+ }
316
+
317
+ export interface RunControlCountsMessage {
318
+ type: 'run_control_counts_evt';
319
+ proceeding: number;
320
+ resumable: number;
321
+ timestamp: string;
322
+ }
323
+
324
+ export interface DialogReadyMessage {
325
+ type: 'dialog_ready';
326
+ dialog: DialogIdent;
327
+ agentId: string;
328
+ taskDocPath: string;
329
+ supdialogId?: string;
330
+ sessionSlug?: string;
331
+ assignmentFromSup?: AssignmentFromSup;
332
+ disableDiligencePush?: boolean;
333
+ diligencePushMax?: number;
334
+ diligencePushRemainingBudget?: number;
335
+ }
package/src/types.ts ADDED
@@ -0,0 +1,133 @@
1
+ export * from './types/context-health';
2
+ export * from './types/dialog';
3
+ export * from './types/display-state';
4
+ export * from './types/i18n';
5
+ export * from './types/language';
6
+ export * from './types/priming';
7
+ export type {
8
+ ProblemSeverity,
9
+ WorkspaceProblem,
10
+ WorkspaceProblemLifecycle,
11
+ WorkspaceProblemRecord,
12
+ } from './types/problems';
13
+ export * from './types/q4h';
14
+ export * from './types/setup';
15
+ export * from './types/snippets';
16
+ export * from './types/storage';
17
+ export * from './types/tools-registry';
18
+ export * from './types/wire';
19
+
20
+ import type { DialogDisplayState } from './types/display-state';
21
+ import type { AssignmentFromSup, DialogStatusKind } from './types/wire';
22
+
23
+ export interface DialogInfo {
24
+ selfId: string;
25
+ rootId: string;
26
+ agentId: string;
27
+ agentName: string;
28
+ taskDocPath: string;
29
+ status?: DialogStatusKind;
30
+ supdialogId?: string;
31
+ sessionSlug?: string;
32
+ assignmentFromSup?: AssignmentFromSup;
33
+ }
34
+
35
+ export interface ApiRootDialogResponse {
36
+ rootId: string;
37
+ selfId?: string;
38
+ agentId: string;
39
+ taskDocPath: string;
40
+ status: 'running' | 'completed' | 'archived';
41
+ currentCourse: number;
42
+ createdAt: string;
43
+ lastModified: string;
44
+ displayState?: DialogDisplayState;
45
+ supdialogId?: string;
46
+ sessionSlug?: string;
47
+ assignmentFromSup?: AssignmentFromSup;
48
+ subdialogCount?: number;
49
+ }
50
+
51
+ export interface ApiSubdialogResponse {
52
+ selfId: string;
53
+ rootId: string;
54
+ supdialogId?: string;
55
+ agentId: string;
56
+ taskDocPath: string;
57
+ status: 'running' | 'completed' | 'archived';
58
+ currentCourse: number;
59
+ createdAt: string;
60
+ lastModified: string;
61
+ displayState?: DialogDisplayState;
62
+ sessionSlug?: string;
63
+ assignmentFromSup?: AssignmentFromSup;
64
+ }
65
+
66
+ export interface ApiDialogHierarchyResponse {
67
+ success: boolean;
68
+ hierarchy: {
69
+ root: {
70
+ id: string;
71
+ agentId: string;
72
+ taskDocPath: string;
73
+ status: 'running' | 'completed' | 'archived';
74
+ currentCourse: number;
75
+ createdAt: string;
76
+ lastModified: string;
77
+ displayState?: DialogDisplayState;
78
+ };
79
+ subdialogs: ApiSubdialogResponse[];
80
+ };
81
+ }
82
+
83
+ export interface ApiDialogListResponse {
84
+ success: boolean;
85
+ dialogs: ApiRootDialogResponse[];
86
+ }
87
+
88
+ export type ApiMoveDialogsRequest =
89
+ | {
90
+ kind: 'root';
91
+ rootId: string;
92
+ fromStatus: DialogStatusKind;
93
+ toStatus: DialogStatusKind;
94
+ }
95
+ | {
96
+ kind: 'task';
97
+ taskDocPath: string;
98
+ fromStatus: DialogStatusKind;
99
+ toStatus: DialogStatusKind;
100
+ };
101
+
102
+ export interface ApiMoveDialogsResponse {
103
+ success: boolean;
104
+ movedRootIds?: string[];
105
+ error?: string;
106
+ }
107
+
108
+ export interface ApiForkDialogRequest {
109
+ course: number;
110
+ genseq: number;
111
+ status?: DialogStatusKind;
112
+ }
113
+
114
+ export type ApiForkDialogAction =
115
+ | {
116
+ kind: 'draft_user_text';
117
+ userText: string;
118
+ }
119
+ | {
120
+ kind: 'restore_pending';
121
+ pendingQ4H: boolean;
122
+ pendingSubdialogs: boolean;
123
+ }
124
+ | {
125
+ kind: 'auto_continue';
126
+ };
127
+
128
+ export interface ApiForkDialogResponse {
129
+ success: boolean;
130
+ dialog?: DialogInfo;
131
+ action?: ApiForkDialogAction;
132
+ error?: string;
133
+ }
@@ -0,0 +1,17 @@
1
+ export function escapeHtml(text: string): string {
2
+ return text
3
+ .replace(/&/g, '&amp;')
4
+ .replace(/</g, '&lt;')
5
+ .replace(/>/g, '&gt;')
6
+ .replace(/"/g, '&quot;')
7
+ .replace(/'/g, '&#39;');
8
+ }
9
+
10
+ export function escapeHtmlAttr(text: string): string {
11
+ return text
12
+ .replace(/&/g, '&amp;')
13
+ .replace(/"/g, '&quot;')
14
+ .replace(/'/g, '&#39;')
15
+ .replace(/</g, '&lt;')
16
+ .replace(/>/g, '&gt;');
17
+ }
@@ -0,0 +1,3 @@
1
+ export function generateShortId(): string {
2
+ return Math.random().toString(36).substring(2, 8);
3
+ }
@@ -0,0 +1,10 @@
1
+ export function formatUnifiedTimestamp(date: Date): string {
2
+ const pad = (n: number) => (n < 10 ? `0${n}` : String(n));
3
+ const year = date.getFullYear();
4
+ const month = pad(date.getMonth() + 1);
5
+ const day = pad(date.getDate());
6
+ const hours = pad(date.getHours());
7
+ const minutes = pad(date.getMinutes());
8
+ const seconds = pad(date.getSeconds());
9
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
10
+ }