action_event.ts

Declarations
#

5 declarations

view source

ActionEvent
#

action_event.ts view source

Action event that manages the lifecycle of an action through its state machine.

generics

TMethod

constraint ActionMethod
default ActionMethod

TEnvironment

TPhase

constraint ActionEventPhase

TStep

constraint ActionEventStep

environment

type TEnvironment

readonly

spec

type ActionSpecUnion

readonly

constructor

type new <TMethod extends ActionMethod = "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | ... 11 more ... | "toggle_main_menu", TEnvironment extends ActionEventEnvironment = ActionEventEnvironment, TPhase extends ActionEventPhase = "send_request" | ... 7 more ... | "execute", TStep extends ActionEventStep = "initial" | ... 3 more ... | "failed">(environment: TEnvironment, spec: { ...; } | ... 1 more ... | { ...; }, data: ActionEventDatas[TMethod]): ActionEvent<...>

environment
type TEnvironment
spec
type { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | "ollama_delete" | ... 10 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }
data
type ActionEventDatas[TMethod]

toJSON

type (): ActionEventDatas[TMethod]

returns ActionEventDatas[TMethod]

observe

type (listener: ActionEventChangeObserver<TMethod>): () => void

listener
type ActionEventChangeObserver<TMethod>
returns () => void

set_data

type (new_data: ActionEventDatas[TMethod]): void

new_data
type ActionEventDatas[TMethod]
returns void

parse

Parse input data according to the action's schema.

type (): this

returns this

handle_async

Execute the handler for the current phase.

type (): Promise<void>

returns Promise<void>

handle_sync

Execute handler synchronously (only for sync local_call actions).

type (): void

returns void

transition

Transition to a new phase.

type (phase: "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute"): void

phase
type "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute"
returns void

is_complete

type (): boolean

returns boolean

update_progress

type (progress: unknown): void

progress
type unknown
returns void

set_request

type (request: { [x: string]: unknown; jsonrpc: "2.0"; id: string | number; method: string; params?: { [x: string]: unknown; _meta?: { [x: string]: unknown; progressToken?: string | number | undefined; } | undefined; } | undefined; }): void

request
type { [x: string]: unknown; jsonrpc: "2.0"; id: string | number; method: string; params?: { [x: string]: unknown; _meta?: { [x: string]: unknown; progressToken?: string | number | undefined; } | undefined; } | undefined; }
returns void

set_response

type (response: { [x: string]: unknown; jsonrpc: "2.0"; id: string | number; result: { [x: string]: unknown; _meta?: { [x: string]: unknown; } | undefined; }; } | { [x: string]: unknown; jsonrpc: "2.0"; id: string | number | null; error: { [x: string]: unknown; code: -32700 | ... 4 more ... | (number & $brand<...>); message: string; data?: unknown; }; }): void

response
type { [x: string]: unknown; jsonrpc: "2.0"; id: string | number; result: { [x: string]: unknown; _meta?: { [x: string]: unknown; } | undefined; }; } | { [x: string]: unknown; jsonrpc: "2.0"; id: string | number | null; error: { [x: string]: unknown; code: -32700 | ... 4 more ... | (number & $brand<...>); message: string...
returns void

set_notification

type (notification: { [x: string]: unknown; jsonrpc: "2.0"; method: string; params?: { [x: string]: unknown; _meta?: { [x: string]: unknown; } | undefined; } | undefined; }): void

notification
type { [x: string]: unknown; jsonrpc: "2.0"; method: string; params?: { [x: string]: unknown; _meta?: { [x: string]: unknown; } | undefined; } | undefined; }
returns void

ActionEventChangeObserver
#

create_action_event
#

action_event.ts view source

<TMethod extends ActionMethod>(environment: ActionEventEnvironment, spec: { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | ... 15 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }, input: unknown, initial_phase?: "send_request" | ... 8 more ... | undefined): ActionEvent<...>

Create an action event from a spec and initial input.

environment

spec

type { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | "ollama_delete" | ... 10 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }

input

type unknown

initial_phase?

type "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute" | undefined
optional

returns

ActionEvent<TMethod, ActionEventEnvironment, "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute", "initial" | ... 3 more ... | "failed">

create_action_event_from_json
#

action_event.ts view source

<TMethod extends ActionMethod>(json: ActionEventDatas[TMethod], environment: ActionEventEnvironment): ActionEvent<TMethod, ActionEventEnvironment, "send_request" | ... 7 more ... | "execute", "initial" | ... 3 more ... | "failed">

Reconstruct an action event from serialized JSON data.

json

type ActionEventDatas[TMethod]

environment

returns

ActionEvent<TMethod, ActionEventEnvironment, "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute", "initial" | ... 3 more ... | "failed">

parse_action_event
#

action_event.ts view source

(raw_json: unknown, environment: ActionEventEnvironment): ActionEvent<"completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | ... 14 more ... | "toggle_main_menu", ActionEventEnvironment, "send_request" | ... 7 more ... | "execute", "initial" | ... 3 more ... | "failed">

raw_json

type unknown

environment

returns

ActionEvent<"completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | "ollama_delete" | ... 10 more ... | "toggle_main_menu", ActionEventEnvironment, "send_request" | ... 7 more ... | "execute", "initial" | ... 3 more...

Depends on
#

Imported by
#