@myclaw163/game-agent-runtime 0.0.0-stage → 0.1.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/README.md +67 -2
- package/dist/framework/action-diagnostics.d.ts +11 -0
- package/dist/framework/action-diagnostics.js +67 -0
- package/dist/framework/capability-registry.d.ts +58 -0
- package/dist/framework/capability-registry.js +325 -0
- package/dist/framework/contracts.d.ts +121 -0
- package/dist/framework/contracts.js +2 -0
- package/dist/framework/control/control-scheduler.d.ts +69 -0
- package/dist/framework/control/control-scheduler.js +1016 -0
- package/dist/framework/control/domain-set.d.ts +18 -0
- package/dist/framework/control/domain-set.js +70 -0
- package/dist/framework/control/index.d.ts +3 -0
- package/dist/framework/control/index.js +3 -0
- package/dist/framework/control/types.d.ts +142 -0
- package/dist/framework/control/types.js +13 -0
- package/dist/framework/control-coordinator.d.ts +7 -0
- package/dist/framework/control-coordinator.js +7 -0
- package/dist/framework/events/event-catalog.d.ts +23 -0
- package/dist/framework/events/event-catalog.js +52 -0
- package/dist/framework/events/event-delivery-service.d.ts +33 -0
- package/dist/framework/events/event-delivery-service.js +165 -0
- package/dist/framework/events/event-ingress.d.ts +28 -0
- package/dist/framework/events/event-ingress.js +76 -0
- package/dist/framework/events/event-repository.d.ts +38 -0
- package/dist/framework/events/event-repository.js +20 -0
- package/dist/framework/events/index.d.ts +7 -0
- package/dist/framework/events/index.js +7 -0
- package/dist/framework/events/memory-event-repository.d.ts +77 -0
- package/dist/framework/events/memory-event-repository.js +909 -0
- package/dist/framework/events/runtime-resume.d.ts +11 -0
- package/dist/framework/events/runtime-resume.js +7 -0
- package/dist/framework/events/sqlite-event-repository.d.ts +94 -0
- package/dist/framework/events/sqlite-event-repository.js +2044 -0
- package/dist/framework/events/store-compatibility.d.ts +17 -0
- package/dist/framework/events/store-compatibility.js +17 -0
- package/dist/framework/events/types.d.ts +242 -0
- package/dist/framework/events/types.js +39 -0
- package/dist/framework/index.d.ts +7 -0
- package/dist/framework/index.js +7 -0
- package/dist/framework/load-node-sqlite.d.ts +5 -0
- package/dist/framework/load-node-sqlite.js +19 -0
- package/dist/framework/mailbox/coalescer.d.ts +30 -0
- package/dist/framework/mailbox/coalescer.js +45 -0
- package/dist/framework/mailbox/host-notification-sink.d.ts +31 -0
- package/dist/framework/mailbox/host-notification-sink.js +13 -0
- package/dist/framework/mailbox/identity.d.ts +15 -0
- package/dist/framework/mailbox/identity.js +28 -0
- package/dist/framework/mailbox/index.d.ts +7 -0
- package/dist/framework/mailbox/index.js +7 -0
- package/dist/framework/mailbox/mailbox-dispatcher.d.ts +65 -0
- package/dist/framework/mailbox/mailbox-dispatcher.js +242 -0
- package/dist/framework/mailbox/mailbox-repository.d.ts +17 -0
- package/dist/framework/mailbox/mailbox-repository.js +9 -0
- package/dist/framework/mailbox/notification-projector.d.ts +25 -0
- package/dist/framework/mailbox/notification-projector.js +50 -0
- package/dist/framework/mailbox/types.d.ts +128 -0
- package/dist/framework/mailbox/types.js +1 -0
- package/dist/framework/modules/runtime-module-loader-hooks.mjs +156 -0
- package/dist/framework/modules/runtime-module-loader.d.ts +14 -0
- package/dist/framework/modules/runtime-module-loader.js +64 -0
- package/dist/framework/modules/runtime-module-output.d.ts +7 -0
- package/dist/framework/modules/runtime-module-output.js +15 -0
- package/dist/framework/modules/runtime-module-worker-bootstrap.mjs +23 -0
- package/dist/framework/participation-manager.d.ts +94 -0
- package/dist/framework/participation-manager.js +185 -0
- package/dist/framework/persistence/async-sqlite-persistence-worker.d.ts +1 -0
- package/dist/framework/persistence/async-sqlite-persistence-worker.js +62 -0
- package/dist/framework/persistence/memory-first-persistence.d.ts +36 -0
- package/dist/framework/persistence/memory-first-persistence.js +459 -0
- package/dist/framework/plugins/contracts.d.ts +345 -0
- package/dist/framework/plugins/contracts.js +1 -0
- package/dist/framework/plugins/index.d.ts +4 -0
- package/dist/framework/plugins/index.js +4 -0
- package/dist/framework/plugins/runtime-event-identity.d.ts +3 -0
- package/dist/framework/plugins/runtime-event-identity.js +11 -0
- package/dist/framework/plugins/runtime-input-journal.d.ts +85 -0
- package/dist/framework/plugins/runtime-input-journal.js +716 -0
- package/dist/framework/plugins/runtime-plugin-scheduler.d.ts +188 -0
- package/dist/framework/plugins/runtime-plugin-scheduler.js +1660 -0
- package/dist/framework/runtime.d.ts +264 -0
- package/dist/framework/runtime.js +1811 -0
- package/dist/framework/serial-task-queue.d.ts +6 -0
- package/dist/framework/serial-task-queue.js +12 -0
- package/dist/framework/state/contracts.d.ts +30 -0
- package/dist/framework/state/contracts.js +1 -0
- package/dist/framework/state/current-state-store.d.ts +17 -0
- package/dist/framework/state/current-state-store.js +153 -0
- package/dist/framework/state/durable-agent-state-snapshot.d.ts +61 -0
- package/dist/framework/state/durable-agent-state-snapshot.js +162 -0
- package/dist/framework/state/freshness.d.ts +7 -0
- package/dist/framework/state/freshness.js +52 -0
- package/dist/framework/state/history/contracts.d.ts +133 -0
- package/dist/framework/state/history/contracts.js +1 -0
- package/dist/framework/state/history/history-writer.d.ts +55 -0
- package/dist/framework/state/history/history-writer.js +157 -0
- package/dist/framework/state/history/memory-state-history-repository.d.ts +25 -0
- package/dist/framework/state/history/memory-state-history-repository.js +199 -0
- package/dist/framework/state/history/sqlite-state-history-repository.d.ts +28 -0
- package/dist/framework/state/history/sqlite-state-history-repository.js +565 -0
- package/dist/framework/state/history/trajectory-projector.d.ts +53 -0
- package/dist/framework/state/history/trajectory-projector.js +130 -0
- package/dist/framework/state/index.d.ts +12 -0
- package/dist/framework/state/index.js +12 -0
- package/dist/framework/state/state-ingress.d.ts +18 -0
- package/dist/framework/state/state-ingress.js +68 -0
- package/dist/framework/state/state-provider.d.ts +11 -0
- package/dist/framework/state/state-provider.js +56 -0
- package/dist/framework/state/types.d.ts +107 -0
- package/dist/framework/state/types.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mailbox/adapters/claude-channel-adapter.d.ts +34 -0
- package/dist/mailbox/adapters/claude-channel-adapter.js +71 -0
- package/dist/mailbox/adapters/claude-channel-socket.d.ts +56 -0
- package/dist/mailbox/adapters/claude-channel-socket.js +279 -0
- package/dist/mailbox/adapters/desktop-event-socket.d.ts +81 -0
- package/dist/mailbox/adapters/desktop-event-socket.js +339 -0
- package/dist/mailbox/agent-mailbox-coordinator.d.ts +104 -0
- package/dist/mailbox/agent-mailbox-coordinator.js +412 -0
- package/dist/mailbox/host-monitor-rate-gate.d.ts +60 -0
- package/dist/mailbox/host-monitor-rate-gate.js +93 -0
- package/dist/mailbox/mailbox-event-batch-delivery.d.ts +73 -0
- package/dist/mailbox/mailbox-event-batch-delivery.js +251 -0
- package/dist/mailbox/mailbox-host-relay.d.ts +52 -0
- package/dist/mailbox/mailbox-host-relay.js +299 -0
- package/dist/mailbox/mailbox-plugin.d.ts +56 -0
- package/dist/mailbox/mailbox-plugin.js +111 -0
- package/dist/mailbox/mailbox-service.d.ts +128 -0
- package/dist/mailbox/mailbox-service.js +582 -0
- package/dist/memory/contracts.d.ts +12 -0
- package/dist/memory/contracts.js +1 -0
- package/dist/memory/strategy-memory-rpc.d.ts +21 -0
- package/dist/memory/strategy-memory-rpc.js +86 -0
- package/dist/memory/strategy-memory.d.ts +15 -0
- package/dist/memory/strategy-memory.js +95 -0
- package/dist/observability/detail-capture.d.ts +25 -0
- package/dist/observability/detail-capture.js +136 -0
- package/dist/observability/index.d.ts +5 -0
- package/dist/observability/index.js +5 -0
- package/dist/observability/process-timing.d.ts +14 -0
- package/dist/observability/process-timing.js +56 -0
- package/dist/observability/recorder.d.ts +56 -0
- package/dist/observability/recorder.js +202 -0
- package/dist/observability/redaction.d.ts +30 -0
- package/dist/observability/redaction.js +166 -0
- package/dist/observability/reporter.d.ts +32 -0
- package/dist/observability/reporter.js +140 -0
- package/dist/observability/sinks.d.ts +36 -0
- package/dist/observability/sinks.js +121 -0
- package/dist/observability/types.d.ts +81 -0
- package/dist/observability/types.js +1 -0
- package/dist/owner/control-channel.d.ts +42 -0
- package/dist/owner/control-channel.js +188 -0
- package/dist/owner/parent-process-watch.d.ts +15 -0
- package/dist/owner/parent-process-watch.js +40 -0
- package/dist/owner/process-identity.d.ts +10 -0
- package/dist/owner/process-identity.js +65 -0
- package/dist/owner/runtime-lock.d.ts +5 -0
- package/dist/owner/runtime-lock.js +47 -0
- package/dist/perception/binding-resolution.d.ts +9 -0
- package/dist/perception/binding-resolution.js +14 -0
- package/dist/perception/contracts.d.ts +85 -0
- package/dist/perception/contracts.js +1 -0
- package/dist/perception/map-concurrent.d.ts +2 -0
- package/dist/perception/map-concurrent.js +12 -0
- package/dist/perception/perception-host.d.ts +114 -0
- package/dist/perception/perception-host.js +336 -0
- package/dist/perception/perception-worker-host.d.ts +11 -0
- package/dist/perception/perception-worker-host.js +44 -0
- package/dist/perception/perception-worker.d.ts +21 -0
- package/dist/perception/perception-worker.js +77 -0
- package/dist/perception/strategy-names.d.ts +7 -0
- package/dist/perception/strategy-names.js +22 -0
- package/dist/sdk/perception.d.ts +5 -0
- package/dist/sdk/perception.js +6 -0
- package/dist/sdk/strategy.d.ts +6 -0
- package/dist/sdk/strategy.js +3 -0
- package/dist/strategy/activation-manager.d.ts +105 -0
- package/dist/strategy/activation-manager.js +367 -0
- package/dist/strategy/behavior-decision-history.d.ts +20 -0
- package/dist/strategy/behavior-decision-history.js +59 -0
- package/dist/strategy/behavior-instance-snapshot.d.ts +31 -0
- package/dist/strategy/behavior-instance-snapshot.js +145 -0
- package/dist/strategy/contracts.d.ts +189 -0
- package/dist/strategy/contracts.js +1 -0
- package/dist/strategy/control-driver.d.ts +25 -0
- package/dist/strategy/control-driver.js +131 -0
- package/dist/strategy/in-process-runner.d.ts +25 -0
- package/dist/strategy/in-process-runner.js +40 -0
- package/dist/strategy/strategy-host.d.ts +165 -0
- package/dist/strategy/strategy-host.js +1456 -0
- package/dist/strategy/strategy-script-runner.d.ts +81 -0
- package/dist/strategy/strategy-script-runner.js +235 -0
- package/dist/strategy/strategy-worker-host.d.ts +27 -0
- package/dist/strategy/strategy-worker-host.js +96 -0
- package/dist/strategy/thread-strategy-executor.d.ts +120 -0
- package/dist/strategy/thread-strategy-executor.js +778 -0
- package/examples/grid-game.mjs +129 -0
- package/examples/grid-perception-worker.mjs +6 -0
- package/examples/grid-perception.mjs +12 -0
- package/examples/grid-strategy-worker.mjs +11 -0
- package/examples/grid-strategy.mjs +13 -0
- package/examples/run-grid-game.mjs +24 -0
- package/package.json +53 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const WILDCARD_DOMAIN = "*";
|
|
2
|
+
export declare function normalizeDomains(domains: readonly string[]): string[];
|
|
3
|
+
export declare function normalizeNames(values: readonly string[] | undefined): string[];
|
|
4
|
+
export interface SymbolicDomains {
|
|
5
|
+
wildcard: boolean;
|
|
6
|
+
exact: Set<string>;
|
|
7
|
+
/** Exact holes in a wildcard claim. */
|
|
8
|
+
excluded: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
export declare function emptySymbolicDomains(): SymbolicDomains;
|
|
11
|
+
export declare function cloneSymbolicDomains(value: SymbolicDomains): SymbolicDomains;
|
|
12
|
+
export declare function containsDomain(value: SymbolicDomains, domain: string): boolean;
|
|
13
|
+
export declare function containsAllDomains(value: SymbolicDomains, domains: readonly string[]): boolean;
|
|
14
|
+
export declare function symbolicHasAny(value: SymbolicDomains): boolean;
|
|
15
|
+
export declare function symbolicList(value: SymbolicDomains): string[];
|
|
16
|
+
/** Whether two symbolic sets share at least one possible domain. */
|
|
17
|
+
export declare function domainsOverlap(left: SymbolicDomains, right: SymbolicDomains): boolean;
|
|
18
|
+
export declare function requestDomains(domains: readonly string[]): SymbolicDomains;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export const WILDCARD_DOMAIN = '*';
|
|
2
|
+
export function normalizeDomains(domains) {
|
|
3
|
+
const normalized = [...new Set(domains.map((domain) => domain.trim()))];
|
|
4
|
+
if (normalized.length === 0 || normalized.some((domain) => domain.length === 0)) {
|
|
5
|
+
throw new TypeError('Control domains must contain at least one non-empty domain.');
|
|
6
|
+
}
|
|
7
|
+
return normalized.sort();
|
|
8
|
+
}
|
|
9
|
+
export function normalizeNames(values) {
|
|
10
|
+
if (!values)
|
|
11
|
+
return [];
|
|
12
|
+
const normalized = [...new Set(values.map((value) => value.trim()))];
|
|
13
|
+
if (normalized.some((value) => value.length === 0)) {
|
|
14
|
+
throw new TypeError('Control names must not be empty.');
|
|
15
|
+
}
|
|
16
|
+
return normalized.sort();
|
|
17
|
+
}
|
|
18
|
+
export function emptySymbolicDomains() {
|
|
19
|
+
return { wildcard: false, exact: new Set(), excluded: new Set() };
|
|
20
|
+
}
|
|
21
|
+
export function cloneSymbolicDomains(value) {
|
|
22
|
+
return {
|
|
23
|
+
wildcard: value.wildcard,
|
|
24
|
+
exact: new Set(value.exact),
|
|
25
|
+
excluded: new Set(value.excluded),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function containsDomain(value, domain) {
|
|
29
|
+
if (domain === WILDCARD_DOMAIN) {
|
|
30
|
+
return value.wildcard && value.excluded.size === 0;
|
|
31
|
+
}
|
|
32
|
+
return value.exact.has(domain) || (value.wildcard && !value.excluded.has(domain));
|
|
33
|
+
}
|
|
34
|
+
export function containsAllDomains(value, domains) {
|
|
35
|
+
return domains.every((domain) => containsDomain(value, domain));
|
|
36
|
+
}
|
|
37
|
+
export function symbolicHasAny(value) {
|
|
38
|
+
return value.wildcard || value.exact.size > 0;
|
|
39
|
+
}
|
|
40
|
+
export function symbolicList(value) {
|
|
41
|
+
return [
|
|
42
|
+
...(value.wildcard ? [WILDCARD_DOMAIN] : []),
|
|
43
|
+
...[...value.exact].sort(),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
/** Whether two symbolic sets share at least one possible domain. */
|
|
47
|
+
export function domainsOverlap(left, right) {
|
|
48
|
+
for (const domain of left.exact) {
|
|
49
|
+
if (containsDomain(right, domain))
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
for (const domain of right.exact) {
|
|
53
|
+
if (containsDomain(left, domain))
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (!left.wildcard || !right.wildcard)
|
|
57
|
+
return false;
|
|
58
|
+
// Two co-finite wildcard sets always overlap: each has only finite holes.
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
export function requestDomains(domains) {
|
|
62
|
+
const result = emptySymbolicDomains();
|
|
63
|
+
for (const domain of domains) {
|
|
64
|
+
if (domain === WILDCARD_DOMAIN)
|
|
65
|
+
result.wildcard = true;
|
|
66
|
+
else
|
|
67
|
+
result.exact.add(domain);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { BehaviorControlLayer, ScopeRef } from '../contracts.js';
|
|
2
|
+
export type ControllerKind = 'system' | 'agent' | 'user' | 'behavior';
|
|
3
|
+
export type ControllerHoldMode = 'all_or_nothing' | 'per_resource';
|
|
4
|
+
export type ControllerLifecycle = 'persistent' | 'activity_lease' | 'finite';
|
|
5
|
+
export declare const DEFAULT_CONTROLLER_PRIORITY: Readonly<Record<ControllerKind, number>>;
|
|
6
|
+
/** Fixed layer precedence. Only the Behavior Host may register these controllers. */
|
|
7
|
+
export declare const BEHAVIOR_CONTROLLER_PRIORITY: Readonly<Record<BehaviorControlLayer, number>>;
|
|
8
|
+
export interface ControlClock {
|
|
9
|
+
now(): number;
|
|
10
|
+
sleep(milliseconds: number): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface ControllerSpec {
|
|
13
|
+
controllerId: string;
|
|
14
|
+
kind: ControllerKind;
|
|
15
|
+
scope: ScopeRef;
|
|
16
|
+
/** Domains the controller may own. `*` is a real wildcard. */
|
|
17
|
+
domains: string[];
|
|
18
|
+
priority?: number;
|
|
19
|
+
mutexGroups?: string[];
|
|
20
|
+
holdMode?: ControllerHoldMode;
|
|
21
|
+
lifecycle?: ControllerLifecycle;
|
|
22
|
+
/** Required by activity-lease controllers unless a scheduler default exists. */
|
|
23
|
+
activityLeaseMs?: number;
|
|
24
|
+
/** A finite controller must supply one deadline form. */
|
|
25
|
+
deadlineAtMs?: number;
|
|
26
|
+
maxRuntimeMs?: number;
|
|
27
|
+
/** Registered controllers do not participate until ready. */
|
|
28
|
+
ready?: boolean;
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface TouchControllerOptions {
|
|
32
|
+
domains?: string[];
|
|
33
|
+
activityLeaseMs?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ReleaseControllerOptions {
|
|
36
|
+
/** Omit to release the whole controller permanently. */
|
|
37
|
+
domains?: string[];
|
|
38
|
+
reason?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ControllerHandoff {
|
|
41
|
+
fromControllerId: string;
|
|
42
|
+
toControllerId: string;
|
|
43
|
+
domains: string[];
|
|
44
|
+
}
|
|
45
|
+
export type ControllerLifecycleState = 'registered' | 'idle' | 'active' | 'partially_active' | 'held' | 'expired' | 'released';
|
|
46
|
+
export interface ControllerBlockerSnapshot {
|
|
47
|
+
controllerId: string;
|
|
48
|
+
domains: string[];
|
|
49
|
+
mutexGroups: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface ControllerSnapshot {
|
|
52
|
+
controllerId: string;
|
|
53
|
+
kind: ControllerKind;
|
|
54
|
+
scope: ScopeRef;
|
|
55
|
+
priority: number;
|
|
56
|
+
sequence: number;
|
|
57
|
+
epoch: number;
|
|
58
|
+
lifecycle: ControllerLifecycle;
|
|
59
|
+
state: ControllerLifecycleState;
|
|
60
|
+
ready: boolean;
|
|
61
|
+
holdMode: ControllerHoldMode;
|
|
62
|
+
declaredDomains: string[];
|
|
63
|
+
claimedDomains: string[];
|
|
64
|
+
grantedDomains: string[];
|
|
65
|
+
heldDomains: string[];
|
|
66
|
+
excludedDomains: string[];
|
|
67
|
+
mutexGroups: string[];
|
|
68
|
+
blockers: ControllerBlockerSnapshot[];
|
|
69
|
+
registeredAtMs: number;
|
|
70
|
+
lastTouchedAtMs: number;
|
|
71
|
+
nextExpiryAtMs?: number;
|
|
72
|
+
deadlineAtMs?: number;
|
|
73
|
+
releasedAtMs?: number;
|
|
74
|
+
releaseReason?: string;
|
|
75
|
+
metadata?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
export interface InFlightControlSnapshot {
|
|
78
|
+
operationId: number;
|
|
79
|
+
controllerId: string;
|
|
80
|
+
scope: ScopeRef;
|
|
81
|
+
domains: string[];
|
|
82
|
+
submittedAtMs: number;
|
|
83
|
+
}
|
|
84
|
+
export interface ControlSnapshot {
|
|
85
|
+
activeScope?: ScopeRef;
|
|
86
|
+
scopeEpoch: number;
|
|
87
|
+
version: number;
|
|
88
|
+
stopping: boolean;
|
|
89
|
+
nowMs: number;
|
|
90
|
+
controllers: ControllerSnapshot[];
|
|
91
|
+
inFlight: InFlightControlSnapshot[];
|
|
92
|
+
}
|
|
93
|
+
export type ControlDeferredCode = 'CONTROL_HELD' | 'CONTROL_BUSY' | 'CONTROL_SCOPE_CHANGED' | 'CONTROL_STOPPING' | 'CONTROL_NOT_READY' | 'CONTROL_UNKNOWN_CONTROLLER' | 'CONTROL_RELEASED' | 'CONTROL_CANCELLED' | 'CONTROL_AUTHORITY_REVOKED';
|
|
94
|
+
export interface ControlDeferred {
|
|
95
|
+
status: 'deferred';
|
|
96
|
+
code: ControlDeferredCode;
|
|
97
|
+
controllerId: string;
|
|
98
|
+
domains: string[];
|
|
99
|
+
retryable: boolean;
|
|
100
|
+
reason: string;
|
|
101
|
+
blockedBy?: string[];
|
|
102
|
+
}
|
|
103
|
+
export interface ControlExecuted<T> {
|
|
104
|
+
status: 'executed';
|
|
105
|
+
controllerId: string;
|
|
106
|
+
domains: string[];
|
|
107
|
+
value: T;
|
|
108
|
+
}
|
|
109
|
+
export type ControlRunResult<T> = ControlExecuted<T> | ControlDeferred;
|
|
110
|
+
/**
|
|
111
|
+
* A permit bound to one admitted Action attempt.
|
|
112
|
+
*
|
|
113
|
+
* Providers may perform asynchronous, reversible preparation after admission
|
|
114
|
+
* (for example rendering or uploading media). They must revalidate at the
|
|
115
|
+
* final irreversible submission boundary so a released worker, changed scope,
|
|
116
|
+
* or newly-held controller cannot submit a stale Action.
|
|
117
|
+
*/
|
|
118
|
+
export interface ControlExecutionContext {
|
|
119
|
+
revalidate(): ControlDeferred | undefined;
|
|
120
|
+
}
|
|
121
|
+
export interface RunControlledAction<T> {
|
|
122
|
+
controllerId: string;
|
|
123
|
+
scope: ScopeRef;
|
|
124
|
+
domains: string[];
|
|
125
|
+
execute(context: ControlExecutionContext): Promise<T> | T;
|
|
126
|
+
/**
|
|
127
|
+
* Only a higher-priority takeover may wait, and only for already-submitted
|
|
128
|
+
* lower-priority providers. No held Action is ever enqueued.
|
|
129
|
+
*/
|
|
130
|
+
handoffWaitMs?: number;
|
|
131
|
+
/** Activity controllers renew leases for these action domains by default. */
|
|
132
|
+
touchActivityLease?: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface AwaitControlOptions {
|
|
135
|
+
timeoutMs?: number;
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}
|
|
138
|
+
export type AwaitControlResult = {
|
|
139
|
+
status: 'granted';
|
|
140
|
+
controllerId: string;
|
|
141
|
+
domains: string[];
|
|
142
|
+
} | ControlDeferred;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const DEFAULT_CONTROLLER_PRIORITY = {
|
|
2
|
+
system: 400,
|
|
3
|
+
agent: 300,
|
|
4
|
+
user: 300,
|
|
5
|
+
// Scheduler still requires an explicit Behavior priority; this is the long-layer baseline.
|
|
6
|
+
behavior: 100,
|
|
7
|
+
};
|
|
8
|
+
/** Fixed layer precedence. Only the Behavior Host may register these controllers. */
|
|
9
|
+
export const BEHAVIOR_CONTROLLER_PRIORITY = {
|
|
10
|
+
long: 100,
|
|
11
|
+
short: 200,
|
|
12
|
+
reflex: 350,
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility entry point. The implementation is a controller scheduler,
|
|
3
|
+
* not an Action queue; new code may import `ControlScheduler` directly.
|
|
4
|
+
*/
|
|
5
|
+
export { ControlScheduler, ControlScheduler as ControlCoordinator, type ControlSchedulerOptions, } from './control/control-scheduler.js';
|
|
6
|
+
export * from './control/types.js';
|
|
7
|
+
export { WILDCARD_DOMAIN } from './control/domain-set.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility entry point. The implementation is a controller scheduler,
|
|
3
|
+
* not an Action queue; new code may import `ControlScheduler` directly.
|
|
4
|
+
*/
|
|
5
|
+
export { ControlScheduler, ControlScheduler as ControlCoordinator, } from './control/control-scheduler.js';
|
|
6
|
+
export * from './control/types.js';
|
|
7
|
+
export { WILDCARD_DOMAIN } from './control/domain-set.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EventCatalogEntry, EventDeliveryClass, EventProducer } from './types.js';
|
|
2
|
+
export declare class EventProducerMismatchError extends Error {
|
|
3
|
+
readonly eventType: string;
|
|
4
|
+
readonly expected: EventProducer;
|
|
5
|
+
readonly actual: EventProducer;
|
|
6
|
+
constructor(eventType: string, expected: EventProducer, actual: EventProducer);
|
|
7
|
+
}
|
|
8
|
+
export interface EventCatalogOptions {
|
|
9
|
+
unknownDeliveryClass?: EventDeliveryClass;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Game-specific policy registry. The Event Core remains unaware of concrete game
|
|
13
|
+
* event names; a game adapter owns the entries and can extend them at startup.
|
|
14
|
+
*/
|
|
15
|
+
export declare class EventCatalog {
|
|
16
|
+
private readonly entries;
|
|
17
|
+
private readonly unknownDeliveryClass;
|
|
18
|
+
constructor(entries?: Iterable<EventCatalogEntry>, opts?: EventCatalogOptions);
|
|
19
|
+
register(entry: EventCatalogEntry): this;
|
|
20
|
+
get(type: string): EventCatalogEntry | undefined;
|
|
21
|
+
resolve(type: string, producer: EventProducer): EventCatalogEntry;
|
|
22
|
+
monitorAndEventsTypes(): Set<string>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class EventProducerMismatchError extends Error {
|
|
2
|
+
eventType;
|
|
3
|
+
expected;
|
|
4
|
+
actual;
|
|
5
|
+
constructor(eventType, expected, actual) {
|
|
6
|
+
super(`Event "${eventType}" must be produced by ${expected}, not ${actual}.`);
|
|
7
|
+
this.eventType = eventType;
|
|
8
|
+
this.expected = expected;
|
|
9
|
+
this.actual = actual;
|
|
10
|
+
this.name = 'EventProducerMismatchError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Game-specific policy registry. The Event Core remains unaware of concrete game
|
|
15
|
+
* event names; a game adapter owns the entries and can extend them at startup.
|
|
16
|
+
*/
|
|
17
|
+
export class EventCatalog {
|
|
18
|
+
entries = new Map();
|
|
19
|
+
unknownDeliveryClass;
|
|
20
|
+
constructor(entries = [], opts = {}) {
|
|
21
|
+
this.unknownDeliveryClass = opts.unknownDeliveryClass ?? 'internal_only';
|
|
22
|
+
for (const entry of entries)
|
|
23
|
+
this.register(entry);
|
|
24
|
+
}
|
|
25
|
+
register(entry) {
|
|
26
|
+
const existing = this.entries.get(entry.type);
|
|
27
|
+
if (existing && existing.producer !== entry.producer) {
|
|
28
|
+
throw new EventProducerMismatchError(entry.type, existing.producer, entry.producer);
|
|
29
|
+
}
|
|
30
|
+
this.entries.set(entry.type, { ...entry });
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
get(type) {
|
|
34
|
+
const entry = this.entries.get(type);
|
|
35
|
+
return entry ? { ...entry } : undefined;
|
|
36
|
+
}
|
|
37
|
+
resolve(type, producer) {
|
|
38
|
+
const entry = this.entries.get(type);
|
|
39
|
+
if (!entry) {
|
|
40
|
+
return { type, producer, deliveryClass: this.unknownDeliveryClass };
|
|
41
|
+
}
|
|
42
|
+
if (entry.producer !== producer) {
|
|
43
|
+
throw new EventProducerMismatchError(type, entry.producer, producer);
|
|
44
|
+
}
|
|
45
|
+
return { ...entry };
|
|
46
|
+
}
|
|
47
|
+
monitorAndEventsTypes() {
|
|
48
|
+
return new Set([...this.entries.values()]
|
|
49
|
+
.filter((entry) => entry.deliveryClass === 'monitor_and_events')
|
|
50
|
+
.map((entry) => entry.type));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { EventRepository } from './event-repository.js';
|
|
2
|
+
import { type CanonicalEvent, type ConsumerLease, type DetailDeliveryVia, type EventDeliveryRecord } from './types.js';
|
|
3
|
+
export interface PrepareDeliveryOptions {
|
|
4
|
+
consumerId?: string;
|
|
5
|
+
ownerId?: string;
|
|
6
|
+
leaseTtlMs?: number;
|
|
7
|
+
nowMs?: number;
|
|
8
|
+
/** False only for a deliberate suppression; sink delivery defaults to true. */
|
|
9
|
+
recordAttempt?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface PreparedMonitorDelivery {
|
|
12
|
+
event: CanonicalEvent;
|
|
13
|
+
delivery: EventDeliveryRecord;
|
|
14
|
+
lease: ConsumerLease;
|
|
15
|
+
/** Call only after the monitor text has been flushed successfully. */
|
|
16
|
+
ack(deliveredAt?: string, nowMs?: number): boolean;
|
|
17
|
+
suppress(nowMs?: number): boolean;
|
|
18
|
+
release(): boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface PreparedDetailDelivery {
|
|
21
|
+
events: CanonicalEvent[];
|
|
22
|
+
lease: ConsumerLease;
|
|
23
|
+
/** Call only after every returned detail has been flushed successfully. */
|
|
24
|
+
ack(deliveredAt?: string, nowMs?: number): boolean;
|
|
25
|
+
release(): boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Coordinates push deliveries without coupling transport sinks to SQLite. */
|
|
28
|
+
export declare class EventDeliveryService {
|
|
29
|
+
private readonly repository;
|
|
30
|
+
constructor(repository: EventRepository);
|
|
31
|
+
prepareMonitor(eventId: string, opts?: PrepareDeliveryOptions): PreparedMonitorDelivery | null;
|
|
32
|
+
prepareDetails(eventIds: string[], via: DetailDeliveryVia, opts?: PrepareDeliveryOptions): PreparedDetailDelivery | null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { DEFAULT_EVENT_CONSUMER_ID, validateDetailDeliveryVia, } from './types.js';
|
|
3
|
+
/** Coordinates push deliveries without coupling transport sinks to SQLite. */
|
|
4
|
+
export class EventDeliveryService {
|
|
5
|
+
repository;
|
|
6
|
+
constructor(repository) {
|
|
7
|
+
this.repository = repository;
|
|
8
|
+
}
|
|
9
|
+
prepareMonitor(eventId, opts = {}) {
|
|
10
|
+
const event = this.repository.eventById(eventId);
|
|
11
|
+
if (!event)
|
|
12
|
+
return null;
|
|
13
|
+
const consumerId = opts.consumerId ?? DEFAULT_EVENT_CONSUMER_ID;
|
|
14
|
+
this.repository.ensureDeliveries(event.sessionId, consumerId, ['monitor']);
|
|
15
|
+
const delivery = this.repository.delivery(eventId, consumerId);
|
|
16
|
+
if (!delivery || delivery.monitorState !== 'pending')
|
|
17
|
+
return null;
|
|
18
|
+
const lease = this.repository.acquireLease({
|
|
19
|
+
consumerId,
|
|
20
|
+
channel: 'monitor',
|
|
21
|
+
ownerId: opts.ownerId ?? randomUUID(),
|
|
22
|
+
ttlMs: opts.leaseTtlMs ?? 30_000,
|
|
23
|
+
nowMs: opts.nowMs,
|
|
24
|
+
});
|
|
25
|
+
if (!lease)
|
|
26
|
+
return null;
|
|
27
|
+
// State may change between the optimistic read and lease acquisition.
|
|
28
|
+
// Re-read under the lease so two sinks cannot both prepare the same push.
|
|
29
|
+
const leasedDelivery = this.repository.delivery(eventId, consumerId);
|
|
30
|
+
if (!leasedDelivery || leasedDelivery.monitorState !== 'pending') {
|
|
31
|
+
this.repository.releaseLease(lease);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
let attemptedDelivery = leasedDelivery;
|
|
35
|
+
if (opts.recordAttempt !== false) {
|
|
36
|
+
// Persist the attempt before invoking the sink. If the owner crashes
|
|
37
|
+
// between this point and acknowledgement, a new owner can distinguish a
|
|
38
|
+
// failed/in-flight delivery from history that was never sent.
|
|
39
|
+
const attemptedAt = new Date().toISOString();
|
|
40
|
+
if (!this.repository.recordMonitorAttempt({
|
|
41
|
+
eventId,
|
|
42
|
+
consumerId,
|
|
43
|
+
attemptedAt,
|
|
44
|
+
lease,
|
|
45
|
+
nowMs: opts.nowMs,
|
|
46
|
+
})) {
|
|
47
|
+
this.repository.releaseLease(lease);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const recorded = this.repository.delivery(eventId, consumerId);
|
|
51
|
+
if (!recorded) {
|
|
52
|
+
this.repository.releaseLease(lease);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
attemptedDelivery = recorded;
|
|
56
|
+
}
|
|
57
|
+
let closed = false;
|
|
58
|
+
const close = () => {
|
|
59
|
+
if (closed)
|
|
60
|
+
return false;
|
|
61
|
+
closed = true;
|
|
62
|
+
return this.repository.releaseLease(lease);
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
event,
|
|
66
|
+
delivery: attemptedDelivery,
|
|
67
|
+
lease,
|
|
68
|
+
ack: (deliveredAt = new Date().toISOString(), nowMs) => {
|
|
69
|
+
if (closed)
|
|
70
|
+
return false;
|
|
71
|
+
const changed = this.repository.transitionMonitor({
|
|
72
|
+
eventIds: [eventId],
|
|
73
|
+
consumerId,
|
|
74
|
+
from: ['pending'],
|
|
75
|
+
to: 'notified',
|
|
76
|
+
deliveredAt,
|
|
77
|
+
lease,
|
|
78
|
+
nowMs,
|
|
79
|
+
});
|
|
80
|
+
close();
|
|
81
|
+
return changed === 1;
|
|
82
|
+
},
|
|
83
|
+
suppress: (nowMs) => {
|
|
84
|
+
if (closed)
|
|
85
|
+
return false;
|
|
86
|
+
const changed = this.repository.transitionMonitor({
|
|
87
|
+
eventIds: [eventId],
|
|
88
|
+
consumerId,
|
|
89
|
+
from: ['pending'],
|
|
90
|
+
to: 'suppressed',
|
|
91
|
+
lease,
|
|
92
|
+
nowMs,
|
|
93
|
+
});
|
|
94
|
+
close();
|
|
95
|
+
return changed === 1;
|
|
96
|
+
},
|
|
97
|
+
release: close,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
prepareDetails(eventIds, via, opts = {}) {
|
|
101
|
+
validateDetailDeliveryVia(via);
|
|
102
|
+
const events = eventIds
|
|
103
|
+
.map((eventId) => this.repository.eventById(eventId))
|
|
104
|
+
.filter((event) => event !== null);
|
|
105
|
+
if (events.length === 0)
|
|
106
|
+
return null;
|
|
107
|
+
const sessionId = events[0].sessionId;
|
|
108
|
+
if (events.some((event) => event.sessionId !== sessionId)) {
|
|
109
|
+
throw new Error('One detail delivery cannot span multiple sessions.');
|
|
110
|
+
}
|
|
111
|
+
const consumerId = opts.consumerId ?? DEFAULT_EVENT_CONSUMER_ID;
|
|
112
|
+
this.repository.ensureDeliveries(sessionId, consumerId, ['details']);
|
|
113
|
+
const pending = events.filter((event) => {
|
|
114
|
+
const state = this.repository.delivery(event.eventId, consumerId)?.detailState;
|
|
115
|
+
return state === 'pending' || state === 'deferred';
|
|
116
|
+
});
|
|
117
|
+
if (pending.length === 0)
|
|
118
|
+
return null;
|
|
119
|
+
const lease = this.repository.acquireLease({
|
|
120
|
+
consumerId,
|
|
121
|
+
channel: 'details',
|
|
122
|
+
ownerId: opts.ownerId ?? randomUUID(),
|
|
123
|
+
ttlMs: opts.leaseTtlMs ?? 30_000,
|
|
124
|
+
nowMs: opts.nowMs,
|
|
125
|
+
});
|
|
126
|
+
if (!lease)
|
|
127
|
+
return null;
|
|
128
|
+
const leasedPending = pending.filter((event) => {
|
|
129
|
+
const state = this.repository.delivery(event.eventId, consumerId)?.detailState;
|
|
130
|
+
return state === 'pending' || state === 'deferred';
|
|
131
|
+
});
|
|
132
|
+
if (leasedPending.length === 0) {
|
|
133
|
+
this.repository.releaseLease(lease);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
let closed = false;
|
|
137
|
+
const close = () => {
|
|
138
|
+
if (closed)
|
|
139
|
+
return false;
|
|
140
|
+
closed = true;
|
|
141
|
+
return this.repository.releaseLease(lease);
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
events: leasedPending,
|
|
145
|
+
lease,
|
|
146
|
+
ack: (deliveredAt = new Date().toISOString(), nowMs) => {
|
|
147
|
+
if (closed)
|
|
148
|
+
return false;
|
|
149
|
+
const changed = this.repository.transitionDetails({
|
|
150
|
+
eventIds: leasedPending.map((event) => event.eventId),
|
|
151
|
+
consumerId,
|
|
152
|
+
from: ['pending', 'deferred'],
|
|
153
|
+
to: 'delivered',
|
|
154
|
+
deliveredAt,
|
|
155
|
+
deliveryVia: via,
|
|
156
|
+
lease,
|
|
157
|
+
nowMs,
|
|
158
|
+
});
|
|
159
|
+
close();
|
|
160
|
+
return changed === leasedPending.length;
|
|
161
|
+
},
|
|
162
|
+
release: close,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EventCatalog } from './event-catalog.js';
|
|
2
|
+
import type { EventRepository } from './event-repository.js';
|
|
3
|
+
import { type CanonicalEventDraft, type CommitEventResult, type PublishEventInput, type SourceCheckpointRecord, type AgentNotificationSource, type EventDeliveryClass } from './types.js';
|
|
4
|
+
export interface EventIngressOptions {
|
|
5
|
+
/** When present, only host-admitted notifications may enter Agent delivery. */
|
|
6
|
+
notificationPolicy?: (input: Readonly<PublishEventInput>) => {
|
|
7
|
+
source: AgentNotificationSource;
|
|
8
|
+
deliveryClass?: EventDeliveryClass;
|
|
9
|
+
wakeAgent?: boolean;
|
|
10
|
+
content?: import('./types.js').EventNotificationContent;
|
|
11
|
+
} | undefined;
|
|
12
|
+
/** Consumers that should receive a delivery row as part of the Event commit. */
|
|
13
|
+
consumerIds?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
/** The sole write entrance for canonical game events. */
|
|
16
|
+
export declare class EventIngress {
|
|
17
|
+
private readonly repository;
|
|
18
|
+
private readonly catalog;
|
|
19
|
+
private readonly opts;
|
|
20
|
+
private readonly consumerIds;
|
|
21
|
+
constructor(repository: EventRepository, catalog: EventCatalog, opts?: EventIngressOptions);
|
|
22
|
+
publish(input: PublishEventInput): Promise<CommitEventResult>;
|
|
23
|
+
/** Build the canonical immutable draft without making it externally visible. */
|
|
24
|
+
prepare(input: PublishEventInput): {
|
|
25
|
+
event: CanonicalEventDraft;
|
|
26
|
+
checkpoint?: SourceCheckpointRecord;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { cloneRecord, DEFAULT_EVENT_CONSUMER_ID, } from './types.js';
|
|
3
|
+
function normalizeSourceSequence(sequence) {
|
|
4
|
+
if (sequence === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
return String(sequence);
|
|
7
|
+
}
|
|
8
|
+
/** The sole write entrance for canonical game events. */
|
|
9
|
+
export class EventIngress {
|
|
10
|
+
repository;
|
|
11
|
+
catalog;
|
|
12
|
+
opts;
|
|
13
|
+
consumerIds;
|
|
14
|
+
constructor(repository, catalog, opts = {}) {
|
|
15
|
+
this.repository = repository;
|
|
16
|
+
this.catalog = catalog;
|
|
17
|
+
this.opts = opts;
|
|
18
|
+
this.consumerIds = [...new Set(opts.consumerIds ?? [DEFAULT_EVENT_CONSUMER_ID])];
|
|
19
|
+
}
|
|
20
|
+
async publish(input) {
|
|
21
|
+
const prepared = this.prepare(input);
|
|
22
|
+
return this.repository.commitEvent({
|
|
23
|
+
event: prepared.event,
|
|
24
|
+
consumerIds: this.consumerIds,
|
|
25
|
+
checkpoint: prepared.checkpoint,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Build the canonical immutable draft without making it externally visible. */
|
|
29
|
+
prepare(input) {
|
|
30
|
+
const policy = this.catalog.resolve(input.type, input.producer);
|
|
31
|
+
const receivedAt = input.receivedAt ?? new Date().toISOString();
|
|
32
|
+
const eventId = input.eventId ?? randomUUID();
|
|
33
|
+
const notification = this.opts.notificationPolicy?.(input);
|
|
34
|
+
const content = notification?.content ?? input.notificationContent;
|
|
35
|
+
const wakeAgent = notification?.wakeAgent ?? policy.wakeAgent ?? input.wakeAgent;
|
|
36
|
+
const draft = {
|
|
37
|
+
...(content && (!this.opts.notificationPolicy || notification)
|
|
38
|
+
? { notificationContent: cloneRecord(content) } : {}),
|
|
39
|
+
...(notification ? { notificationSource: notification.source } : {}),
|
|
40
|
+
...(input.notificationOf ? { notificationOf: input.notificationOf } : {}),
|
|
41
|
+
...(input.epochSeq === undefined ? {} : { epochSeq: input.epochSeq }),
|
|
42
|
+
eventId,
|
|
43
|
+
sessionId: input.sessionId,
|
|
44
|
+
segmentId: input.segmentId,
|
|
45
|
+
type: input.type,
|
|
46
|
+
producer: input.producer,
|
|
47
|
+
...(input.producerPluginId === undefined
|
|
48
|
+
? {}
|
|
49
|
+
: { producerPluginId: input.producerPluginId }),
|
|
50
|
+
...(input.producerOutputIndex === undefined
|
|
51
|
+
? {}
|
|
52
|
+
: { producerOutputIndex: input.producerOutputIndex }),
|
|
53
|
+
...(wakeAgent === undefined ? {} : { wakeAgent }),
|
|
54
|
+
deliveryClass: this.opts.notificationPolicy && !notification ? 'internal_only'
|
|
55
|
+
: notification?.deliveryClass ?? policy.deliveryClass,
|
|
56
|
+
occurredAt: input.occurredAt ?? receivedAt,
|
|
57
|
+
receivedAt,
|
|
58
|
+
payload: cloneRecord(input.payload ?? {}),
|
|
59
|
+
sourceId: input.source.sourceId,
|
|
60
|
+
sourceEventId: input.source.eventId,
|
|
61
|
+
sourceSequence: normalizeSourceSequence(input.source.sequence),
|
|
62
|
+
connectionId: input.source.connectionId,
|
|
63
|
+
replayed: input.source.replayed === true,
|
|
64
|
+
};
|
|
65
|
+
const checkpoint = input.source.checkpoint
|
|
66
|
+
? {
|
|
67
|
+
sourceId: input.source.sourceId,
|
|
68
|
+
checkpoint: input.source.checkpoint,
|
|
69
|
+
sourceSequence: draft.sourceSequence,
|
|
70
|
+
eventId,
|
|
71
|
+
committedAt: receivedAt,
|
|
72
|
+
}
|
|
73
|
+
: undefined;
|
|
74
|
+
return { event: draft, ...(checkpoint ? { checkpoint } : {}) };
|
|
75
|
+
}
|
|
76
|
+
}
|