openbot 0.3.6 → 0.4.2

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 (104) hide show
  1. package/README.md +15 -16
  2. package/dist/app/agent-ids.js +4 -0
  3. package/dist/app/cli.js +1 -1
  4. package/dist/app/config.js +10 -19
  5. package/dist/app/server.js +208 -17
  6. package/dist/bus/services.js +34 -124
  7. package/dist/harness/agent-invoke-run.js +44 -0
  8. package/dist/harness/agent-turn.js +99 -0
  9. package/dist/harness/channel-participants.js +40 -0
  10. package/dist/harness/constants.js +2 -0
  11. package/dist/harness/context-meter.js +97 -0
  12. package/dist/harness/context.js +95 -47
  13. package/dist/harness/dispatch.js +144 -0
  14. package/dist/harness/dispatcher.js +45 -156
  15. package/dist/harness/history.js +177 -0
  16. package/dist/harness/index.js +109 -0
  17. package/dist/harness/orchestration.js +88 -0
  18. package/dist/harness/participants.js +22 -0
  19. package/dist/harness/run-harness.js +154 -0
  20. package/dist/harness/run.js +98 -0
  21. package/dist/harness/runtime-factory.js +0 -34
  22. package/dist/harness/runtime.js +57 -0
  23. package/dist/harness/todo-dispatch.js +51 -0
  24. package/dist/harness/todos.js +5 -0
  25. package/dist/harness/turn.js +79 -0
  26. package/dist/plugins/approval/index.js +120 -149
  27. package/dist/plugins/bash/index.js +195 -0
  28. package/dist/plugins/delegation/index.js +121 -32
  29. package/dist/plugins/memory/index.js +103 -14
  30. package/dist/plugins/memory/service.js +152 -0
  31. package/dist/plugins/openbot/context.js +125 -0
  32. package/dist/plugins/openbot/history.js +144 -0
  33. package/dist/plugins/openbot/index.js +71 -0
  34. package/dist/plugins/openbot/runtime.js +381 -0
  35. package/dist/plugins/openbot/system-prompt.js +25 -0
  36. package/dist/plugins/plugin-manager/index.js +189 -0
  37. package/dist/plugins/shell/index.js +2 -1
  38. package/dist/plugins/storage/files.js +67 -0
  39. package/dist/plugins/storage/index.js +750 -0
  40. package/dist/plugins/storage/service.js +1316 -0
  41. package/dist/plugins/storage-tools/index.js +2 -2
  42. package/dist/plugins/thread-namer/index.js +72 -0
  43. package/dist/plugins/thread-naming/generate-title.js +44 -0
  44. package/dist/plugins/thread-naming/index.js +103 -0
  45. package/dist/plugins/threads/index.js +114 -0
  46. package/dist/plugins/todo/index.js +24 -25
  47. package/dist/plugins/ui/index.js +109 -180
  48. package/dist/registry/plugins.js +3 -9
  49. package/dist/services/abort.js +43 -0
  50. package/dist/services/plugins/domain.js +1 -0
  51. package/dist/services/plugins/plugin-cache.js +9 -0
  52. package/dist/services/plugins/registry.js +112 -0
  53. package/dist/services/plugins/service.js +232 -0
  54. package/dist/services/plugins/types.js +1 -0
  55. package/dist/services/process.js +29 -0
  56. package/dist/services/storage.js +11 -10
  57. package/dist/services/thread-naming.js +81 -0
  58. package/docs/agents.md +15 -12
  59. package/docs/architecture.md +2 -2
  60. package/docs/plugins.md +29 -17
  61. package/docs/templates/AGENT.example.md +8 -14
  62. package/package.json +1 -2
  63. package/src/app/agent-ids.ts +5 -0
  64. package/src/app/cli.ts +1 -1
  65. package/src/app/config.ts +14 -31
  66. package/src/app/server.ts +243 -19
  67. package/src/app/types.ts +331 -187
  68. package/src/harness/index.ts +166 -0
  69. package/src/plugins/approval/index.ts +107 -188
  70. package/src/plugins/bash/index.ts +232 -0
  71. package/src/plugins/delegation/index.ts +139 -39
  72. package/src/plugins/memory/index.ts +112 -15
  73. package/src/{services/memory.ts → plugins/memory/service.ts} +1 -1
  74. package/src/plugins/openbot/context.ts +140 -0
  75. package/src/plugins/openbot/history.ts +158 -0
  76. package/src/plugins/openbot/index.ts +79 -0
  77. package/src/plugins/openbot/runtime.ts +478 -0
  78. package/src/plugins/openbot/system-prompt.ts +27 -0
  79. package/src/plugins/plugin-manager/index.ts +224 -0
  80. package/src/plugins/storage/files.ts +81 -0
  81. package/src/plugins/storage/index.ts +823 -0
  82. package/src/{services/storage.ts → plugins/storage/service.ts} +485 -105
  83. package/src/plugins/ui/index.ts +117 -221
  84. package/src/services/abort.ts +46 -0
  85. package/src/{bus/types.ts → services/plugins/domain.ts} +50 -8
  86. package/src/services/plugins/plugin-cache.ts +13 -0
  87. package/src/{registry/plugins.ts → services/plugins/registry.ts} +28 -28
  88. package/src/services/plugins/service.ts +318 -0
  89. package/src/{bus/plugin.ts → services/plugins/types.ts} +7 -3
  90. package/src/bus/services.ts +0 -954
  91. package/src/harness/context.ts +0 -365
  92. package/src/harness/dispatcher.ts +0 -379
  93. package/src/harness/mcp.ts +0 -78
  94. package/src/harness/runtime-factory.ts +0 -129
  95. package/src/harness/todo-advance.ts +0 -128
  96. package/src/plugins/ai-sdk/index.ts +0 -41
  97. package/src/plugins/ai-sdk/runtime.ts +0 -468
  98. package/src/plugins/ai-sdk/system-prompt.ts +0 -18
  99. package/src/plugins/mcp/index.ts +0 -128
  100. package/src/plugins/shell/index.ts +0 -123
  101. package/src/plugins/storage-tools/index.ts +0 -90
  102. package/src/plugins/todo/index.ts +0 -64
  103. package/src/services/plugins.ts +0 -133
  104. /package/src/{harness → services}/process.ts +0 -0
package/src/app/types.ts CHANGED
@@ -6,9 +6,9 @@ import {
6
6
  PluginDescriptor,
7
7
  Thread,
8
8
  ThreadDetails,
9
- } from '../bus/types.js';
10
- import type { PluginRef } from '../bus/plugin.js';
11
- import type { MemoryRecord } from '../services/memory.js';
9
+ } from '../services/plugins/domain.js';
10
+ import type { PluginRef } from '../services/plugins/types.js';
11
+ import type { MemoryRecord } from '../plugins/memory/service.js';
12
12
 
13
13
  export interface OpenBotState {
14
14
  agentId: string;
@@ -19,15 +19,16 @@ export interface OpenBotState {
19
19
  channelDetails?: ChannelDetails;
20
20
  threadDetails?: ThreadDetails;
21
21
  triggerEvent?: OpenBotEvent;
22
- shortTermMessages?: ShortTermMessage[];
22
+ /** Active model string (e.g. `openai/gpt-4o-mini`). */
23
+ model?: string;
24
+ /** Persisted tool call IDs waiting for results. */
25
+ pendingToolCallIds?: string[];
26
+ /** Current user information if available. */
27
+ currentUser?: {
28
+ userName?: string;
29
+ };
23
30
  }
24
31
 
25
- export type ShortTermMessage =
26
- | { role: 'system'; content: string }
27
- | { role: 'user'; content: string }
28
- | { role: 'assistant'; content: string; toolCalls?: any[] }
29
- | { role: 'tool'; content: string; toolCallId: string; toolName: string };
30
-
31
32
  export type BaseEvent = {
32
33
  id?: string;
33
34
  type: string;
@@ -68,6 +69,23 @@ export type GetThreadsResultEvent = BaseEvent & {
68
69
  };
69
70
  };
70
71
 
72
+ export type SetLastReadEvent = BaseEvent & {
73
+ type: 'action:storage:set-last-read';
74
+ data: {
75
+ channelId?: string;
76
+ threadId?: string;
77
+ lastReadEventId: string;
78
+ };
79
+ };
80
+
81
+ export type SetLastReadResultEvent = BaseEvent & {
82
+ type: 'action:storage:set-last-read-result';
83
+ data: {
84
+ success: boolean;
85
+ error?: string;
86
+ };
87
+ };
88
+
71
89
  export type GetChannelDetailsEvent = BaseEvent & {
72
90
  type: 'action:storage:get-channel-details';
73
91
  };
@@ -144,6 +162,7 @@ export type CreateAgentEvent = BaseEvent & {
144
162
  name: string;
145
163
  description?: string;
146
164
  image?: string;
165
+ hidden?: boolean;
147
166
  instructions: string;
148
167
  plugins: PluginRef[];
149
168
  };
@@ -164,6 +183,7 @@ export type UpdateAgentEvent = BaseEvent & {
164
183
  name?: string;
165
184
  description?: string;
166
185
  image?: string;
186
+ hidden?: boolean;
167
187
  instructions?: string;
168
188
  plugins?: PluginRef[];
169
189
  };
@@ -325,6 +345,7 @@ export type ReadFileEvent = BaseEvent & {
325
345
  type: 'action:storage:read-file';
326
346
  data: {
327
347
  path: string;
348
+ encoding?: 'utf8' | 'base64';
328
349
  };
329
350
  };
330
351
 
@@ -334,6 +355,107 @@ export type ReadFileResultEvent = BaseEvent & {
334
355
  success: boolean;
335
356
  content?: string;
336
357
  path: string;
358
+ encoding?: 'utf8' | 'base64';
359
+ mimeType?: string;
360
+ size?: number;
361
+ error?: string;
362
+ };
363
+ };
364
+
365
+ export type ServeFileEvent = BaseEvent & {
366
+ type: 'action:storage:serve-file';
367
+ data: {
368
+ path: string;
369
+ };
370
+ };
371
+
372
+ export type WriteFileEvent = BaseEvent & {
373
+ type: 'action:storage:write-file';
374
+ data: {
375
+ path: string;
376
+ content: string;
377
+ encoding?: 'utf8' | 'base64';
378
+ overwrite?: boolean;
379
+ };
380
+ };
381
+
382
+ export type WriteFileResultEvent = BaseEvent & {
383
+ type: 'action:storage:write-file:result';
384
+ data: {
385
+ success: boolean;
386
+ path: string;
387
+ url?: string;
388
+ mimeType?: string;
389
+ size?: number;
390
+ error?: string;
391
+ };
392
+ };
393
+
394
+ export type GetFileUrlEvent = BaseEvent & {
395
+ type: 'action:storage:get-file-url';
396
+ data: {
397
+ path: string;
398
+ };
399
+ };
400
+
401
+ export type GetFileUrlResultEvent = BaseEvent & {
402
+ type: 'action:storage:get-file-url:result';
403
+ data: {
404
+ success: boolean;
405
+ path: string;
406
+ url?: string;
407
+ mimeType?: string;
408
+ size?: number;
409
+ error?: string;
410
+ };
411
+ };
412
+
413
+ export type GetWorkspaceFileUrlEvent = BaseEvent & {
414
+ type: 'action:get_workspace_file_url';
415
+ data: {
416
+ path: string;
417
+ };
418
+ meta?: {
419
+ toolCallId?: string;
420
+ agentId?: string;
421
+ threadId?: string;
422
+ };
423
+ };
424
+
425
+ export type GetWorkspaceFileUrlResultEvent = BaseEvent & {
426
+ type: 'action:get_workspace_file_url:result';
427
+ data: {
428
+ success: boolean;
429
+ path: string;
430
+ url?: string;
431
+ mimeType?: string;
432
+ size?: number;
433
+ output?: string;
434
+ error?: string;
435
+ };
436
+ meta?: {
437
+ toolCallId?: string;
438
+ agentId?: string;
439
+ threadId?: string;
440
+ };
441
+ };
442
+
443
+ export type UploadFileEvent = BaseEvent & {
444
+ type: 'action:storage:upload-file';
445
+ data: {
446
+ path: string;
447
+ overwrite?: boolean;
448
+ };
449
+ };
450
+
451
+ export type UploadFileResultEvent = BaseEvent & {
452
+ type: 'action:storage:upload-file:result';
453
+ data: {
454
+ success: boolean;
455
+ path: string;
456
+ url?: string;
457
+ mimeType?: string;
458
+ size?: number;
337
459
  error?: string;
338
460
  };
339
461
  };
@@ -482,6 +604,42 @@ export type UpdateChannelResultEvent = BaseEvent & {
482
604
  };
483
605
  };
484
606
 
607
+ export type DeleteChannelEvent = BaseEvent & {
608
+ type: 'action:storage:delete-channel';
609
+ data: {
610
+ channelId: string;
611
+ };
612
+ };
613
+
614
+ export type DeleteChannelResultEvent = BaseEvent & {
615
+ type: 'action:storage:delete-channel-result';
616
+ data: {
617
+ success: boolean;
618
+ error?: string;
619
+ };
620
+ };
621
+
622
+ export type DeleteChannelToolEvent = BaseEvent & {
623
+ type: 'action:delete_channel';
624
+ data: {
625
+ channelId: string;
626
+ };
627
+ meta?: {
628
+ toolCallId?: string;
629
+ agentId?: string;
630
+ threadId?: string;
631
+ };
632
+ };
633
+
634
+ export type DeleteChannelToolResultEvent = BaseEvent & {
635
+ type: 'action:delete_channel:result';
636
+ data: {
637
+ success: boolean;
638
+ channelId: string;
639
+ error?: string;
640
+ };
641
+ };
642
+
485
643
  export type UIWidgetAction = {
486
644
  id: string;
487
645
  label: string;
@@ -509,12 +667,26 @@ export type UIWidgetListItem = {
509
667
  metadata?: Record<string, unknown>;
510
668
  };
511
669
 
670
+ export type UIMediaItem = {
671
+ type: 'image' | 'video' | 'audio' | 'file';
672
+ url: string;
673
+ title?: string;
674
+ alt?: string;
675
+ thumbnailUrl?: string;
676
+ metadata?: Record<string, unknown>;
677
+ };
678
+
512
679
  export type UIWidgetBase = {
513
680
  widgetId: string;
514
681
  title?: string;
515
682
  description?: string;
516
- body?: string;
683
+ /** Optional hero media for the widget */
684
+ media?: UIMediaItem;
685
+ /** Optional actions for the widget */
686
+ actions?: UIWidgetAction[];
517
687
  state?: 'open' | 'submitted' | 'cancelled' | 'error';
688
+ display?: 'expanded' | 'collapsed';
689
+ size?: 'small' | 'medium' | 'large' | 'full';
518
690
  metadata?: Record<string, unknown>;
519
691
  };
520
692
 
@@ -543,19 +715,6 @@ export type UIListWidget = UIWidgetBase & {
543
715
 
544
716
  export type UIWidgetSpec = UIMessageWidget | UIChoiceWidget | UIFormWidget | UIListWidget;
545
717
 
546
- export type RenderUIWidgetData =
547
- | (Omit<UIMessageWidget, 'widgetId'> & { widgetId?: string })
548
- | (Omit<UIChoiceWidget, 'widgetId'> & { widgetId?: string })
549
- | (Omit<UIFormWidget, 'widgetId'> & { widgetId?: string })
550
- | (Omit<UIListWidget, 'widgetId'> & { widgetId?: string })
551
- | {
552
- kind: 'approval' | 'todo_list';
553
- widgetId?: string;
554
- title?: string;
555
- props?: Record<string, unknown>;
556
- metadata?: Record<string, unknown>;
557
- };
558
-
559
718
  export type UIWidgetEvent = BaseEvent & {
560
719
  type: 'client:ui:widget';
561
720
  data: UIWidgetSpec;
@@ -565,11 +724,6 @@ export type UIWidgetEvent = BaseEvent & {
565
724
  };
566
725
  };
567
726
 
568
- export type RenderUIWidgetEvent = BaseEvent & {
569
- type: 'action:render_ui_widget';
570
- data: RenderUIWidgetData;
571
- };
572
-
573
727
  export type UIWidgetResponseEvent = BaseEvent & {
574
728
  type: 'client:ui:widget:response';
575
729
  data: {
@@ -580,118 +734,61 @@ export type UIWidgetResponseEvent = BaseEvent & {
580
734
  };
581
735
  };
582
736
 
583
- export type HandoffEvent = BaseEvent & {
584
- type: 'action:handoff';
737
+ export type BashEvent = BaseEvent & {
738
+ type: 'action:bash';
585
739
  data: {
586
- agentId: string;
587
- content: string;
740
+ command: string;
741
+ restart?: boolean;
588
742
  };
589
743
  meta?: {
590
744
  toolCallId?: string;
745
+ approvalId?: string;
746
+ approvalStatus?: 'approved' | 'denied';
591
747
  [key: string]: any;
592
748
  };
593
749
  };
594
750
 
595
- export type HandoffResultEvent = BaseEvent & {
596
- type: 'action:handoff:result';
597
- data: {
598
- success: boolean;
599
- agentId: string;
600
- accepted: boolean;
601
- };
602
- meta: {
603
- toolCallId: string;
604
- agentId: string;
605
- threadId?: string;
606
- [key: string]: any;
607
- };
608
- };
609
-
610
- /** Internal routing: handoff plugin → orchestrator only (not stored or broadcast). */
611
- export type HandoffRequestEvent = BaseEvent & {
612
- type: 'handoff:request';
613
- data: {
614
- agentId: string;
615
- content: string;
616
- };
617
- meta?: Record<string, unknown>;
618
- };
619
-
620
- export type MCPListToolsEvent = BaseEvent & {
621
- type: 'action:mcp_list_tools';
622
- data: {
623
- serverId: string;
624
- };
625
- };
626
-
627
- export type MCPListToolsResultEvent = BaseEvent & {
628
- type: 'action:mcp_list_tools:result';
751
+ export type BashResultEvent = BaseEvent & {
752
+ type: 'action:bash:result';
629
753
  data: {
630
754
  success: boolean;
631
- serverId: string;
632
- tools: Array<{ name: string; description?: string; inputSchema?: unknown }>;
755
+ approved?: boolean;
756
+ exitCode: number | null;
757
+ stdout: string;
758
+ stderr: string;
759
+ timedOut: boolean;
633
760
  error?: string;
634
761
  };
635
762
  };
636
763
 
637
- export type MCPCallEvent = BaseEvent & {
638
- type: 'action:mcp_call';
764
+ export type BashStopEvent = BaseEvent & {
765
+ type: 'action:bash_stop';
639
766
  data: {
640
- serverId: string;
641
- toolName: string;
642
- args?: Record<string, unknown>;
767
+ channelId?: string;
643
768
  };
644
769
  };
645
770
 
646
- export type MCPCallResultEvent = BaseEvent & {
647
- type: 'action:mcp_call:result';
771
+ export type BashStopResultEvent = BaseEvent & {
772
+ type: 'action:bash_stop:result';
648
773
  data: {
649
774
  success: boolean;
650
- serverId: string;
651
- toolName: string;
652
- result?: unknown;
653
- error?: string;
654
775
  };
655
776
  };
656
777
 
657
- export type ShellExecEvent = BaseEvent & {
658
- type: 'action:shell_exec';
659
- data: {
660
- command: string;
661
- cwd?: string;
662
- shell?: string;
663
- timeoutMs?: number;
664
- };
665
- meta?: {
666
- toolCallId?: string;
667
- approvalId?: string;
668
- approvalStatus?: 'approved' | 'denied';
669
- [key: string]: any;
670
- };
778
+ export type BashListSessionsEvent = BaseEvent & {
779
+ type: 'action:bash_list_sessions';
780
+ data: {};
671
781
  };
672
782
 
673
- export type ShellExecResultEvent = BaseEvent & {
674
- type: 'action:shell_exec:result';
783
+ export type BashListSessionsResultEvent = BaseEvent & {
784
+ type: 'action:bash_list_sessions:result';
675
785
  data: {
676
786
  success: boolean;
677
- approved?: boolean;
678
- exitCode: number | null;
679
- stdout: string;
680
- stderr: string;
681
- timedOut: boolean;
682
- error?: string;
683
- };
684
- };
685
-
686
- export type UserInputEvent = BaseEvent & {
687
- type: 'user:input';
688
- data: {
689
- content: string;
690
- };
691
- meta?: {
692
- userId?: string;
693
- userName?: string;
694
- userAvatarUrl?: string;
787
+ sessions: Array<{
788
+ channelId: string;
789
+ cwd: string;
790
+ lastActivity: number;
791
+ }>;
695
792
  };
696
793
  };
697
794
 
@@ -727,11 +824,11 @@ export type UninstallPluginResultEvent = BaseEvent & {
727
824
  };
728
825
  };
729
826
 
730
- export type ListMarketplaceAgentsEvent = BaseEvent & {
827
+ export type ListMarketplaceRegistryEvent = BaseEvent & {
731
828
  type: 'action:marketplace:list';
732
829
  };
733
830
 
734
- export type ListMarketplaceAgentsResultEvent = BaseEvent & {
831
+ export type ListMarketplaceRegistryResultEvent = BaseEvent & {
735
832
  type: 'action:marketplace:list:result';
736
833
  data: {
737
834
  success: boolean;
@@ -743,6 +840,36 @@ export type ListMarketplaceAgentsResultEvent = BaseEvent & {
743
840
  instructions: string;
744
841
  plugins: PluginRef[];
745
842
  }>;
843
+ channels: Array<{
844
+ id: string;
845
+ name: string;
846
+ description: string;
847
+ image?: string;
848
+ spec?: string;
849
+ initialState?: Record<string, unknown>;
850
+ participants: string[];
851
+ starterPrompts?: Array<{ label: string; prompt: string }>;
852
+ }>;
853
+ error?: string;
854
+ };
855
+ };
856
+
857
+ export type InstallChannelEvent = BaseEvent & {
858
+ type: 'action:channel:install';
859
+ data: {
860
+ channelId: string;
861
+ name?: string;
862
+ participants?: string[];
863
+ initialState?: Record<string, unknown>;
864
+ };
865
+ };
866
+
867
+ export type InstallChannelResultEvent = BaseEvent & {
868
+ type: 'action:channel:install:result';
869
+ data: {
870
+ success: boolean;
871
+ channelId?: string;
872
+ channelUrl?: string;
746
873
  error?: string;
747
874
  };
748
875
  };
@@ -770,6 +897,25 @@ export type InstallAgentResultEvent = BaseEvent & {
770
897
 
771
898
  export type MemoryScopeAlias = 'global' | 'agent' | 'channel';
772
899
 
900
+ export interface Usage {
901
+ promptTokens: number;
902
+ completionTokens: number;
903
+ totalTokens: number;
904
+ }
905
+
906
+ export type AgentUsageEvent = BaseEvent & {
907
+ type: 'agent:usage';
908
+ data: {
909
+ usage: Usage;
910
+ model?: string;
911
+ };
912
+ meta: {
913
+ agentId: string;
914
+ threadId?: string;
915
+ runId?: string;
916
+ };
917
+ };
918
+
773
919
  export type RememberEvent = BaseEvent & {
774
920
  type: 'action:remember';
775
921
  data: {
@@ -821,83 +967,68 @@ export type ForgetResultEvent = BaseEvent & {
821
967
  };
822
968
  };
823
969
 
824
- export type TodoStatus = 'pending' | 'in_progress' | 'done' | 'cancelled';
825
-
826
- /**
827
- * A single unit of work tracked in thread state. Todos are owned by the
828
- * system (bus services); agents can only mutate them by calling the
829
- * `todo_write` / `todo_update` tools so every change is observable on the
830
- * event stream and audit-friendly.
831
- */
832
- export interface TodoItem {
833
- id: string;
834
- content: string;
835
- status: TodoStatus;
836
- /** Optional agent id responsible for this item — drives autonomous handoffs. */
837
- assignee?: string;
838
- /** Agent id that created the todo (or "system"). */
839
- createdBy: string;
840
- createdAt: number;
841
- updatedAt: number;
842
- /**
843
- * Captured final reply when this item reaches `done` (last `agent:output`
844
- * from the assignee for that run). Lets downstream agents rely on thread
845
- * state instead of merged short-term messages.
846
- */
847
- result?: string;
848
- }
849
-
850
- export type TodoWriteInput = {
851
- id?: string;
852
- content: string;
853
- status?: TodoStatus;
854
- assignee?: string;
855
- };
856
-
857
- export type TodoWriteEvent = BaseEvent & {
858
- type: 'action:todo_write';
970
+ export type DelegateTaskEvent = BaseEvent & {
971
+ type: 'action:delegate_task';
859
972
  data: {
860
- todos: TodoWriteInput[];
973
+ agentId: string;
974
+ prompt: string;
861
975
  };
862
- meta?: { toolCallId?: string; agentId?: string; threadId?: string };
863
976
  };
864
977
 
865
- export type TodoWriteResultEvent = BaseEvent & {
866
- type: 'action:todo_write:result';
978
+ export type DelegateTaskResultEvent = BaseEvent & {
979
+ type: 'action:delegate_task:result';
867
980
  data: {
868
981
  success: boolean;
869
- todos: TodoItem[];
982
+ output?: string;
870
983
  error?: string;
871
984
  };
872
- meta?: { toolCallId?: string; agentId?: string; threadId?: string };
873
985
  };
874
986
 
875
- export type TodoUpdateEvent = BaseEvent & {
876
- type: 'action:todo_update';
987
+ export type RenderWidgetEvent = BaseEvent & {
988
+ type: 'action:render_widget';
877
989
  data: {
878
- id: string;
879
- status?: TodoStatus;
880
- content?: string;
881
- assignee?: string;
990
+ kind: 'message' | 'choice' | 'form' | 'list';
991
+ title: string;
992
+ description?: string;
993
+ fields?: UIWidgetField[];
994
+ actions?: UIWidgetAction[];
995
+ items?: UIWidgetListItem[];
996
+ submitLabel?: string;
997
+ };
998
+ meta?: {
999
+ toolCallId?: string;
1000
+ threadId?: string;
1001
+ [key: string]: any;
882
1002
  };
883
- meta?: { toolCallId?: string; agentId?: string; threadId?: string };
884
1003
  };
885
1004
 
886
- export type TodoUpdateResultEvent = BaseEvent & {
887
- type: 'action:todo_update:result';
1005
+ export type RenderWidgetResultEvent = BaseEvent & {
1006
+ type: 'action:render_widget:result';
888
1007
  data: {
889
1008
  success: boolean;
890
- todo?: TodoItem;
891
- todos: TodoItem[];
892
- error?: string;
1009
+ actionId: string;
1010
+ values?: Record<string, unknown>;
893
1011
  };
894
- meta?: { toolCallId?: string; agentId?: string; threadId?: string };
895
1012
  };
896
1013
 
1014
+ /**
1015
+ * Internal message representation to decouple harness history from specific AI SDKs.
1016
+ */
1017
+ export type OpenBotMessage =
1018
+ | { role: 'user'; content: string | OpenBotMessagePart[] }
1019
+ | { role: 'assistant'; content: string | OpenBotMessagePart[] }
1020
+ | { role: 'system'; content: string }
1021
+ | { role: 'tool'; content: OpenBotMessagePart[] };
1022
+
1023
+ export type OpenBotMessagePart =
1024
+ | { type: 'text'; text: string }
1025
+ | { type: 'tool-call'; toolCallId: string; toolName: string; input: any }
1026
+ | { type: 'tool-result'; toolCallId: string; toolName: string; output: any };
1027
+
897
1028
  export type OpenBotEvent =
898
- | UserInputEvent
899
1029
  | AgentInvokeEvent
900
1030
  | AgentOutputEvent
1031
+ | AgentUsageEvent
901
1032
  | AgentRunStartEvent
902
1033
  | AgentRunEndEvent
903
1034
  | AgentRunStoppedEvent
@@ -908,6 +1039,8 @@ export type OpenBotEvent =
908
1039
  | GetChannelsResultEvent
909
1040
  | GetThreadsEvent
910
1041
  | GetThreadsResultEvent
1042
+ | SetLastReadEvent
1043
+ | SetLastReadResultEvent
911
1044
  | GetChannelDetailsEvent
912
1045
  | GetChannelDetailsResultEvent
913
1046
  | GetThreadDetailsEvent
@@ -945,39 +1078,50 @@ export type OpenBotEvent =
945
1078
  | ListFilesResultEvent
946
1079
  | ReadFileEvent
947
1080
  | ReadFileResultEvent
1081
+ | ServeFileEvent
1082
+ | WriteFileEvent
1083
+ | WriteFileResultEvent
1084
+ | GetFileUrlEvent
1085
+ | GetFileUrlResultEvent
1086
+ | GetWorkspaceFileUrlEvent
1087
+ | GetWorkspaceFileUrlResultEvent
1088
+ | UploadFileEvent
1089
+ | UploadFileResultEvent
948
1090
  | CreateThreadEvent
949
1091
  | CreateThreadResultEvent
950
1092
  | CreateChannelEvent
951
1093
  | CreateChannelResultEvent
952
1094
  | UpdateChannelEvent
953
1095
  | UpdateChannelResultEvent
1096
+ | DeleteChannelEvent
1097
+ | DeleteChannelResultEvent
1098
+ | DeleteChannelToolEvent
1099
+ | DeleteChannelToolResultEvent
954
1100
  | UIWidgetEvent
955
- | RenderUIWidgetEvent
956
1101
  | UIWidgetResponseEvent
957
- | HandoffEvent
958
- | HandoffResultEvent
959
- | HandoffRequestEvent
960
- | MCPListToolsEvent
961
- | MCPListToolsResultEvent
962
- | MCPCallEvent
963
- | MCPCallResultEvent
964
- | ShellExecEvent
965
- | ShellExecResultEvent
1102
+ | BashEvent
1103
+ | BashResultEvent
1104
+ | BashStopEvent
1105
+ | BashStopResultEvent
1106
+ | BashListSessionsEvent
1107
+ | BashListSessionsResultEvent
966
1108
  | InstallPluginEvent
967
1109
  | InstallPluginResultEvent
968
1110
  | UninstallPluginEvent
969
1111
  | UninstallPluginResultEvent
970
- | ListMarketplaceAgentsEvent
971
- | ListMarketplaceAgentsResultEvent
1112
+ | ListMarketplaceRegistryEvent
1113
+ | ListMarketplaceRegistryResultEvent
972
1114
  | InstallAgentEvent
973
1115
  | InstallAgentResultEvent
1116
+ | InstallChannelEvent
1117
+ | InstallChannelResultEvent
974
1118
  | RememberEvent
975
1119
  | RememberResultEvent
976
1120
  | RecallEvent
977
1121
  | RecallResultEvent
978
1122
  | ForgetEvent
979
1123
  | ForgetResultEvent
980
- | TodoWriteEvent
981
- | TodoWriteResultEvent
982
- | TodoUpdateEvent
983
- | TodoUpdateResultEvent;
1124
+ | DelegateTaskEvent
1125
+ | DelegateTaskResultEvent
1126
+ | RenderWidgetEvent
1127
+ | RenderWidgetResultEvent;