33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
/// SPDX-License-Identifier: GPL-3.0-or-later
|
|
/// SPDX-FileCopyrightText: Copyright © 2023 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
|
|
|
// Each Turn executes one Task
|
|
|
|
import type { AnyValue, Handle, Ref, Facet } from './actor.js';
|
|
import type { IdentitySet } from '@preserves/core';
|
|
|
|
export type Task = StructuredTask<TaskDescription>;
|
|
|
|
export interface StructuredTask<T> {
|
|
perform(): void;
|
|
describe(): T;
|
|
}
|
|
|
|
export type TaskDescription =
|
|
| { type: 'bootActor', detail?: AnyValue }
|
|
| { type: 'turn', tasks: TaskAction[] }
|
|
;
|
|
|
|
export type TaskAction = { targetFacet: Facet, action: ActionDescription };
|
|
|
|
export type ActionDescription =
|
|
| { type: 'spawnActor', detail?: AnyValue, initialAssertions: IdentitySet<Handle> }
|
|
| { type: 'stopActor', err?: AnyValue }
|
|
| { type: 'inertCheck' }
|
|
|
|
| { type: 'assert', target: Ref, handle: Handle, assertion: AnyValue }
|
|
| { type: 'retract', target: Ref, handle: Handle }
|
|
| { type: 'message', target: Ref, assertion: AnyValue }
|
|
| { type: 'sync', target: Ref, callback: Ref }
|
|
;
|