@oagi/oagi 0.1.4 → 0.2.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/dist/index.d.cts CHANGED
@@ -22,6 +22,7 @@ declare const ActionSchema: z.ZodObject<{
22
22
  type: "type";
23
23
  scroll: "scroll";
24
24
  finish: "finish";
25
+ fail: "fail";
25
26
  wait: "wait";
26
27
  call_user: "call_user";
27
28
  }>;
@@ -72,7 +73,7 @@ interface Todo {
72
73
  /**
73
74
  * Current status of the todo
74
75
  */
75
- status: 'pending' | 'in_progress' | 'completed' | 'blocked';
76
+ status: 'pending' | 'in_progress' | 'completed' | 'skipped';
76
77
  /**
77
78
  * Summary of execution for this todo
78
79
  */
@@ -266,11 +267,11 @@ declare const ActionEventSchema: z.ZodObject<{
266
267
  type: z.ZodLiteral<"action">;
267
268
  step_num: z.ZodNumber;
268
269
  actions: z.ZodArray<z.ZodCustom<{
269
- type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "wait" | "call_user";
270
+ type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "fail" | "wait" | "call_user";
270
271
  argument: string;
271
272
  count: number;
272
273
  }, {
273
- type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "wait" | "call_user";
274
+ type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "fail" | "wait" | "call_user";
274
275
  argument: string;
275
276
  count: number;
276
277
  }>>;
@@ -416,23 +417,6 @@ declare class DefaultAgent implements Agent {
416
417
  execute(instruction: string, action_handler: ActionHandler, image_provider: ImageProvider): Promise<boolean>;
417
418
  }
418
419
 
419
- /**
420
- * -----------------------------------------------------------------------------
421
- * Copyright (c) OpenAGI Foundation
422
- * All rights reserved.
423
- *
424
- * This file is part of the official API project.
425
- * Licensed under the MIT License.
426
- * -----------------------------------------------------------------------------
427
- */
428
-
429
- interface Agent {
430
- /**
431
- * Protocol for synchronous task execution agents.
432
- */
433
- execute(instruction: string, action_handler: ActionHandler, image_provider: ImageProvider): Promise<boolean>;
434
- }
435
-
436
420
  /**
437
421
  * -----------------------------------------------------------------------------
438
422
  * Copyright (c) OpenAGI Foundation
@@ -515,6 +499,170 @@ declare class Client {
515
499
  callWorker({ workerId, overallTodo, taskDescription, todos, history, currentTodoIndex, taskExecutionSummary, currentScreenshot, currentSubtaskInstruction, windowSteps, windowScreenshots, resultScreenshot, priorNotes, latestTodoSummary, apiVersion, }: GenerateOption): Promise<GenerateResponse>;
516
500
  }
517
501
 
502
+ /**
503
+ * -----------------------------------------------------------------------------
504
+ * Copyright (c) OpenAGI Foundation
505
+ * All rights reserved.
506
+ *
507
+ * This file is part of the official API project.
508
+ * Licensed under the MIT License.
509
+ * -----------------------------------------------------------------------------
510
+ */
511
+
512
+ type ImageLike = ArrayBuffer | string;
513
+ type TodoStatus = Todo['status'];
514
+ interface TodoItem {
515
+ description: string;
516
+ status: TodoStatus;
517
+ }
518
+ interface TaskerAction {
519
+ timestamp: string;
520
+ action_type: string;
521
+ target?: string | null;
522
+ details?: Record<string, unknown>;
523
+ reasoning?: string | null;
524
+ result?: string | null;
525
+ screenshot_uuid?: string | null;
526
+ }
527
+ interface TodoHistory {
528
+ todo_index: number;
529
+ todo: string;
530
+ actions: TaskerAction[];
531
+ summary?: string;
532
+ completed: boolean;
533
+ }
534
+ interface PlannerOutput {
535
+ instruction: string;
536
+ reasoning: string;
537
+ subtodos: string[];
538
+ }
539
+ interface ReflectionOutput {
540
+ continue_current: boolean;
541
+ new_instruction?: string | null;
542
+ reasoning: string;
543
+ success_assessment: boolean;
544
+ }
545
+ type PlannerContext = Record<string, unknown>;
546
+ declare class PlannerMemory {
547
+ taskDescription: string;
548
+ todos: TodoItem[];
549
+ history: TodoHistory[];
550
+ taskExecutionSummary: string;
551
+ todoExecutionSummaries: Record<number, string>;
552
+ setTask(taskDescription: string, todos: string[] | TodoItem[]): void;
553
+ getCurrentTodo(): {
554
+ todo: TodoItem;
555
+ index: number;
556
+ } | null;
557
+ updateTodo(index: number, status: TodoStatus, summary?: string): void;
558
+ addHistory(todoIndex: number, actions: TaskerAction[], summary?: string, completed?: boolean): void;
559
+ getContext(): PlannerContext;
560
+ getTodoStatusSummary(): Record<string, number>;
561
+ appendTodo(description: string): void;
562
+ }
563
+ declare class Planner {
564
+ private apiKey?;
565
+ private baseUrl?;
566
+ private client?;
567
+ private ownsClient;
568
+ constructor(client?: Client, apiKey?: string | undefined, baseUrl?: string | undefined);
569
+ private ensureClient;
570
+ getClient(): Client;
571
+ close(): Promise<void>;
572
+ private extractMemoryData;
573
+ private extractJsonString;
574
+ private parsePlannerOutput;
575
+ private parseReflectionOutput;
576
+ private formatExecutionNotes;
577
+ private ensureScreenshotUuid;
578
+ initialPlan(todo: string, context: PlannerContext, screenshot?: ImageLike, memory?: PlannerMemory, todoIndex?: number): Promise<{
579
+ output: PlannerOutput;
580
+ requestId?: string | null;
581
+ }>;
582
+ reflect(actions: TaskerAction[], context: PlannerContext, screenshot?: ImageLike, memory?: PlannerMemory, todoIndex?: number, currentInstruction?: string, reflectionInterval?: number): Promise<{
583
+ output: ReflectionOutput;
584
+ requestId?: string | null;
585
+ }>;
586
+ summarize(_executionHistory: TaskerAction[], context: PlannerContext, memory?: PlannerMemory, todoIndex?: number): Promise<{
587
+ summary: string;
588
+ requestId?: string | null;
589
+ }>;
590
+ }
591
+ declare class TaskerAgent implements Agent {
592
+ /** Hierarchical agent that manages multi-todo workflows. */
593
+ private apiKey?;
594
+ private baseUrl?;
595
+ private model;
596
+ private maxSteps;
597
+ private temperature?;
598
+ private reflectionInterval;
599
+ private planner;
600
+ private stepObserver?;
601
+ private stepDelay;
602
+ private memory;
603
+ private currentTaskeeAgent?;
604
+ constructor(apiKey?: string, baseUrl?: string, model?: string, maxSteps?: number, temperature?: number | undefined, reflectionInterval?: number, planner?: Planner, stepObserver?: StepObserver, stepDelay?: number);
605
+ setTask(task: string, todos: string[]): void;
606
+ set_task(task: string, todos: string[]): void;
607
+ execute(_instruction: string, actionHandler: ActionHandler, imageProvider: ImageProvider): Promise<boolean>;
608
+ private prepare;
609
+ private executeTodo;
610
+ private updateMemoryFromExecution;
611
+ private updateTaskSummary;
612
+ getMemory(): PlannerMemory;
613
+ appendTodo(description: string): void;
614
+ }
615
+
616
+ /**
617
+ * -----------------------------------------------------------------------------
618
+ * Copyright (c) OpenAGI Foundation
619
+ * All rights reserved.
620
+ *
621
+ * This file is part of the official API project.
622
+ * Licensed under the MIT License.
623
+ * -----------------------------------------------------------------------------
624
+ */
625
+
626
+ declare enum ExportFormat {
627
+ /** Supported export formats. */
628
+ MARKDOWN = "markdown",
629
+ HTML = "html",
630
+ JSON = "json"
631
+ }
632
+ declare class AsyncAgentObserver extends StepObserver {
633
+ /**
634
+ * Records agent execution events and exports to various formats.
635
+ *
636
+ * This class implements the AsyncObserver protocol and provides
637
+ * functionality for recording events during agent execution and
638
+ * exporting them to Markdown or HTML formats.
639
+ */
640
+ events: ObserverEvent[];
641
+ onEvent(event: ObserverEvent): Promise<void>;
642
+ addLog(message: string): void;
643
+ addSplit(label?: string): void;
644
+ clear(): void;
645
+ getEventsByStep(step_num: number): ObserverEvent[];
646
+ export(format: ExportFormat | string, path: string, images_dir?: string | null): void;
647
+ }
648
+
649
+ /**
650
+ * -----------------------------------------------------------------------------
651
+ * Copyright (c) OpenAGI Foundation
652
+ * All rights reserved.
653
+ *
654
+ * This file is part of the official API project.
655
+ * Licensed under the MIT License.
656
+ * -----------------------------------------------------------------------------
657
+ */
658
+
659
+ interface Agent {
660
+ /**
661
+ * Protocol for synchronous task execution agents.
662
+ */
663
+ execute(instruction: string, action_handler: ActionHandler, image_provider: ImageProvider): Promise<boolean>;
664
+ }
665
+
518
666
  /**
519
667
  * -----------------------------------------------------------------------------
520
668
  * Copyright (c) OpenAGI Foundation
@@ -571,4 +719,4 @@ declare class DefaultActionHandler implements ActionHandler {
571
719
  handle(actions: Action[]): Promise<void>;
572
720
  }
573
721
 
574
- export { APIError, type Action, Actor, type Agent, AuthenticationError, Client, type ClientOptions, ConfigurationError, DefaultActionHandler, DefaultAgent, type ErrorDetail, type ErrorResponse, type GenerateResponse, NetworkError, NotFoundError, OAGIError, RateLimitError, RequestTimeoutError, ScreenshotMaker, ServerError, type Step, type UploadFileResponse, ValidationError };
722
+ export { APIError, type Action, Actor, type Agent, AsyncAgentObserver, AuthenticationError, Client, type ClientOptions, ConfigurationError, DefaultActionHandler, DefaultAgent, type ErrorDetail, type ErrorResponse, ExportFormat, type GenerateResponse, NetworkError, NotFoundError, OAGIError, RateLimitError, RequestTimeoutError, ScreenshotMaker, ServerError, type Step, TaskerAgent, type UploadFileResponse, ValidationError };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ declare const ActionSchema: z.ZodObject<{
22
22
  type: "type";
23
23
  scroll: "scroll";
24
24
  finish: "finish";
25
+ fail: "fail";
25
26
  wait: "wait";
26
27
  call_user: "call_user";
27
28
  }>;
@@ -72,7 +73,7 @@ interface Todo {
72
73
  /**
73
74
  * Current status of the todo
74
75
  */
75
- status: 'pending' | 'in_progress' | 'completed' | 'blocked';
76
+ status: 'pending' | 'in_progress' | 'completed' | 'skipped';
76
77
  /**
77
78
  * Summary of execution for this todo
78
79
  */
@@ -266,11 +267,11 @@ declare const ActionEventSchema: z.ZodObject<{
266
267
  type: z.ZodLiteral<"action">;
267
268
  step_num: z.ZodNumber;
268
269
  actions: z.ZodArray<z.ZodCustom<{
269
- type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "wait" | "call_user";
270
+ type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "fail" | "wait" | "call_user";
270
271
  argument: string;
271
272
  count: number;
272
273
  }, {
273
- type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "wait" | "call_user";
274
+ type: "click" | "left_double" | "left_triple" | "right_single" | "drag" | "hotkey" | "type" | "scroll" | "finish" | "fail" | "wait" | "call_user";
274
275
  argument: string;
275
276
  count: number;
276
277
  }>>;
@@ -416,23 +417,6 @@ declare class DefaultAgent implements Agent {
416
417
  execute(instruction: string, action_handler: ActionHandler, image_provider: ImageProvider): Promise<boolean>;
417
418
  }
418
419
 
419
- /**
420
- * -----------------------------------------------------------------------------
421
- * Copyright (c) OpenAGI Foundation
422
- * All rights reserved.
423
- *
424
- * This file is part of the official API project.
425
- * Licensed under the MIT License.
426
- * -----------------------------------------------------------------------------
427
- */
428
-
429
- interface Agent {
430
- /**
431
- * Protocol for synchronous task execution agents.
432
- */
433
- execute(instruction: string, action_handler: ActionHandler, image_provider: ImageProvider): Promise<boolean>;
434
- }
435
-
436
420
  /**
437
421
  * -----------------------------------------------------------------------------
438
422
  * Copyright (c) OpenAGI Foundation
@@ -515,6 +499,170 @@ declare class Client {
515
499
  callWorker({ workerId, overallTodo, taskDescription, todos, history, currentTodoIndex, taskExecutionSummary, currentScreenshot, currentSubtaskInstruction, windowSteps, windowScreenshots, resultScreenshot, priorNotes, latestTodoSummary, apiVersion, }: GenerateOption): Promise<GenerateResponse>;
516
500
  }
517
501
 
502
+ /**
503
+ * -----------------------------------------------------------------------------
504
+ * Copyright (c) OpenAGI Foundation
505
+ * All rights reserved.
506
+ *
507
+ * This file is part of the official API project.
508
+ * Licensed under the MIT License.
509
+ * -----------------------------------------------------------------------------
510
+ */
511
+
512
+ type ImageLike = ArrayBuffer | string;
513
+ type TodoStatus = Todo['status'];
514
+ interface TodoItem {
515
+ description: string;
516
+ status: TodoStatus;
517
+ }
518
+ interface TaskerAction {
519
+ timestamp: string;
520
+ action_type: string;
521
+ target?: string | null;
522
+ details?: Record<string, unknown>;
523
+ reasoning?: string | null;
524
+ result?: string | null;
525
+ screenshot_uuid?: string | null;
526
+ }
527
+ interface TodoHistory {
528
+ todo_index: number;
529
+ todo: string;
530
+ actions: TaskerAction[];
531
+ summary?: string;
532
+ completed: boolean;
533
+ }
534
+ interface PlannerOutput {
535
+ instruction: string;
536
+ reasoning: string;
537
+ subtodos: string[];
538
+ }
539
+ interface ReflectionOutput {
540
+ continue_current: boolean;
541
+ new_instruction?: string | null;
542
+ reasoning: string;
543
+ success_assessment: boolean;
544
+ }
545
+ type PlannerContext = Record<string, unknown>;
546
+ declare class PlannerMemory {
547
+ taskDescription: string;
548
+ todos: TodoItem[];
549
+ history: TodoHistory[];
550
+ taskExecutionSummary: string;
551
+ todoExecutionSummaries: Record<number, string>;
552
+ setTask(taskDescription: string, todos: string[] | TodoItem[]): void;
553
+ getCurrentTodo(): {
554
+ todo: TodoItem;
555
+ index: number;
556
+ } | null;
557
+ updateTodo(index: number, status: TodoStatus, summary?: string): void;
558
+ addHistory(todoIndex: number, actions: TaskerAction[], summary?: string, completed?: boolean): void;
559
+ getContext(): PlannerContext;
560
+ getTodoStatusSummary(): Record<string, number>;
561
+ appendTodo(description: string): void;
562
+ }
563
+ declare class Planner {
564
+ private apiKey?;
565
+ private baseUrl?;
566
+ private client?;
567
+ private ownsClient;
568
+ constructor(client?: Client, apiKey?: string | undefined, baseUrl?: string | undefined);
569
+ private ensureClient;
570
+ getClient(): Client;
571
+ close(): Promise<void>;
572
+ private extractMemoryData;
573
+ private extractJsonString;
574
+ private parsePlannerOutput;
575
+ private parseReflectionOutput;
576
+ private formatExecutionNotes;
577
+ private ensureScreenshotUuid;
578
+ initialPlan(todo: string, context: PlannerContext, screenshot?: ImageLike, memory?: PlannerMemory, todoIndex?: number): Promise<{
579
+ output: PlannerOutput;
580
+ requestId?: string | null;
581
+ }>;
582
+ reflect(actions: TaskerAction[], context: PlannerContext, screenshot?: ImageLike, memory?: PlannerMemory, todoIndex?: number, currentInstruction?: string, reflectionInterval?: number): Promise<{
583
+ output: ReflectionOutput;
584
+ requestId?: string | null;
585
+ }>;
586
+ summarize(_executionHistory: TaskerAction[], context: PlannerContext, memory?: PlannerMemory, todoIndex?: number): Promise<{
587
+ summary: string;
588
+ requestId?: string | null;
589
+ }>;
590
+ }
591
+ declare class TaskerAgent implements Agent {
592
+ /** Hierarchical agent that manages multi-todo workflows. */
593
+ private apiKey?;
594
+ private baseUrl?;
595
+ private model;
596
+ private maxSteps;
597
+ private temperature?;
598
+ private reflectionInterval;
599
+ private planner;
600
+ private stepObserver?;
601
+ private stepDelay;
602
+ private memory;
603
+ private currentTaskeeAgent?;
604
+ constructor(apiKey?: string, baseUrl?: string, model?: string, maxSteps?: number, temperature?: number | undefined, reflectionInterval?: number, planner?: Planner, stepObserver?: StepObserver, stepDelay?: number);
605
+ setTask(task: string, todos: string[]): void;
606
+ set_task(task: string, todos: string[]): void;
607
+ execute(_instruction: string, actionHandler: ActionHandler, imageProvider: ImageProvider): Promise<boolean>;
608
+ private prepare;
609
+ private executeTodo;
610
+ private updateMemoryFromExecution;
611
+ private updateTaskSummary;
612
+ getMemory(): PlannerMemory;
613
+ appendTodo(description: string): void;
614
+ }
615
+
616
+ /**
617
+ * -----------------------------------------------------------------------------
618
+ * Copyright (c) OpenAGI Foundation
619
+ * All rights reserved.
620
+ *
621
+ * This file is part of the official API project.
622
+ * Licensed under the MIT License.
623
+ * -----------------------------------------------------------------------------
624
+ */
625
+
626
+ declare enum ExportFormat {
627
+ /** Supported export formats. */
628
+ MARKDOWN = "markdown",
629
+ HTML = "html",
630
+ JSON = "json"
631
+ }
632
+ declare class AsyncAgentObserver extends StepObserver {
633
+ /**
634
+ * Records agent execution events and exports to various formats.
635
+ *
636
+ * This class implements the AsyncObserver protocol and provides
637
+ * functionality for recording events during agent execution and
638
+ * exporting them to Markdown or HTML formats.
639
+ */
640
+ events: ObserverEvent[];
641
+ onEvent(event: ObserverEvent): Promise<void>;
642
+ addLog(message: string): void;
643
+ addSplit(label?: string): void;
644
+ clear(): void;
645
+ getEventsByStep(step_num: number): ObserverEvent[];
646
+ export(format: ExportFormat | string, path: string, images_dir?: string | null): void;
647
+ }
648
+
649
+ /**
650
+ * -----------------------------------------------------------------------------
651
+ * Copyright (c) OpenAGI Foundation
652
+ * All rights reserved.
653
+ *
654
+ * This file is part of the official API project.
655
+ * Licensed under the MIT License.
656
+ * -----------------------------------------------------------------------------
657
+ */
658
+
659
+ interface Agent {
660
+ /**
661
+ * Protocol for synchronous task execution agents.
662
+ */
663
+ execute(instruction: string, action_handler: ActionHandler, image_provider: ImageProvider): Promise<boolean>;
664
+ }
665
+
518
666
  /**
519
667
  * -----------------------------------------------------------------------------
520
668
  * Copyright (c) OpenAGI Foundation
@@ -571,4 +719,4 @@ declare class DefaultActionHandler implements ActionHandler {
571
719
  handle(actions: Action[]): Promise<void>;
572
720
  }
573
721
 
574
- export { APIError, type Action, Actor, type Agent, AuthenticationError, Client, type ClientOptions, ConfigurationError, DefaultActionHandler, DefaultAgent, type ErrorDetail, type ErrorResponse, type GenerateResponse, NetworkError, NotFoundError, OAGIError, RateLimitError, RequestTimeoutError, ScreenshotMaker, ServerError, type Step, type UploadFileResponse, ValidationError };
722
+ export { APIError, type Action, Actor, type Agent, AsyncAgentObserver, AuthenticationError, Client, type ClientOptions, ConfigurationError, DefaultActionHandler, DefaultAgent, type ErrorDetail, type ErrorResponse, ExportFormat, type GenerateResponse, NetworkError, NotFoundError, OAGIError, RateLimitError, RequestTimeoutError, ScreenshotMaker, ServerError, type Step, TaskerAgent, type UploadFileResponse, ValidationError };
package/dist/index.js CHANGED
@@ -2,11 +2,13 @@
2
2
  import {
3
3
  APIError,
4
4
  Actor,
5
+ AsyncAgentObserver,
5
6
  AuthenticationError,
6
7
  Client,
7
8
  ConfigurationError,
8
9
  DefaultActionHandler,
9
10
  DefaultAgent,
11
+ ExportFormat,
10
12
  NetworkError,
11
13
  NotFoundError,
12
14
  OAGIError,
@@ -14,16 +16,19 @@ import {
14
16
  RequestTimeoutError,
15
17
  ScreenshotMaker,
16
18
  ServerError,
19
+ TaskerAgent,
17
20
  ValidationError
18
- } from "./chunk-JVNTVY6W.js";
21
+ } from "./chunk-LA6CBP44.js";
19
22
  export {
20
23
  APIError,
21
24
  Actor,
25
+ AsyncAgentObserver,
22
26
  AuthenticationError,
23
27
  Client,
24
28
  ConfigurationError,
25
29
  DefaultActionHandler,
26
30
  DefaultAgent,
31
+ ExportFormat,
27
32
  NetworkError,
28
33
  NotFoundError,
29
34
  OAGIError,
@@ -31,6 +36,7 @@ export {
31
36
  RequestTimeoutError,
32
37
  ScreenshotMaker,
33
38
  ServerError,
39
+ TaskerAgent,
34
40
  ValidationError
35
41
  };
36
42
  //# sourceMappingURL=index.js.map
package/dist/index.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * -----------------------------------------------------------------------------
3
+ * Copyright (c) OpenAGI Foundation
4
+ * All rights reserved.
5
+ *
6
+ * This file is part of the official API project.
7
+ * Licensed under the MIT License.
8
+ * -----------------------------------------------------------------------------
9
+ */
10
+
11
+ export type {
12
+ ActionEvent,
13
+ BaseEvent,
14
+ ImageEvent,
15
+ LogEvent,
16
+ ObserverEvent,
17
+ PlanEvent,
18
+ SplitEvent,
19
+ StepEvent,
20
+ } from '../../types/index.js';
21
+
22
+ export { AsyncAgentObserver, ExportFormat } from './agent_observer.js';
23
+ export { exportToHtml, exportToJson, exportToMarkdown } from './exporters.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * -----------------------------------------------------------------------------
3
+ * Copyright (c) OpenAGI Foundation
4
+ * All rights reserved.
5
+ *
6
+ * This file is part of the official API project.
7
+ * Licensed under the MIT License.
8
+ * -----------------------------------------------------------------------------
9
+ */
10
+
11
+ // Re-export from types for convenience
12
+ import type { AsyncObserver } from '../../types/index.js';
13
+
14
+ export type { AsyncObserver };