@myclaw163/game-agent-runtime 0.0.0-stage → 0.1.1
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 +244 -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 +58 -0
- package/dist/mailbox/mailbox-plugin.js +128 -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 +338 -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,11 @@
|
|
|
1
|
+
import type { CurrentEventScope } from './types.js';
|
|
2
|
+
export interface RuntimeResumeSelection {
|
|
3
|
+
resume?: boolean;
|
|
4
|
+
resumeKey?: string;
|
|
5
|
+
initialSegment: {
|
|
6
|
+
kind: string;
|
|
7
|
+
identity?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** Shared by startup hydration and Runtime; never hydrate a scope Runtime will reject. */
|
|
11
|
+
export declare function canResumeRuntimeScope(current: CurrentEventScope | null, options: RuntimeResumeSelection): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Shared by startup hydration and Runtime; never hydrate a scope Runtime will reject. */
|
|
2
|
+
export function canResumeRuntimeScope(current, options) {
|
|
3
|
+
return !!options.resume && !!current && current.session.status === 'open' && ((options.resumeKey !== undefined && current.session.resumeKey === options.resumeKey)
|
|
4
|
+
|| (options.initialSegment.identity !== undefined
|
|
5
|
+
&& current.segment.kind === options.initialSegment.kind
|
|
6
|
+
&& current.segment.scopeRef === options.initialSegment.identity));
|
|
7
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type EventStoreCompatibility } from './store-compatibility.js';
|
|
2
|
+
import type { MailboxRepository } from '../mailbox/mailbox-repository.js';
|
|
3
|
+
import type { EventRepositorySnapshot } from './memory-event-repository.js';
|
|
4
|
+
import type { AckMailboxClaimRequest, AckMailboxClaimResult, ClaimMailboxItemsRequest, EnqueueMailboxItem, EnqueueMailboxResult, MailboxClaim, MailboxDeliveryMode, MailboxItem, MailboxPeekFilter, NackMailboxClaimRequest, NackMailboxClaimResult, SuppressMailboxItemsFilter } from '../mailbox/types.js';
|
|
5
|
+
import { type EventRepository } from './event-repository.js';
|
|
6
|
+
import { type AcquireLeaseRequest, type BacklogSummary, type CanonicalEvent, type CommittedEventListFilter, type CommitEventRequest, type CommitEventResult, type ConsumerLease, type CurrentEventScope, type DetailStateTransition, type EventAccountScope, type EventDeliveryRecord, type EventListFilter, type EventSegmentRecord, type EventWithDelivery, type LatestEventScopeOptions, type MonitorDeliveryAttempt, type MonitorStateTransition, type PlaySessionRecord, type SourceCheckpointRecord } from './types.js';
|
|
7
|
+
export interface SqliteUnavailable {
|
|
8
|
+
code: 'SQLITE_UNAVAILABLE' | 'SQLITE_OPEN_FAILED';
|
|
9
|
+
message: string;
|
|
10
|
+
cause?: string;
|
|
11
|
+
}
|
|
12
|
+
export type SqliteRepositoryOpenResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
repository: SqliteEventRepository;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
unavailable: SqliteUnavailable;
|
|
18
|
+
};
|
|
19
|
+
export declare function detectSqliteAvailability(): SqliteUnavailable | null;
|
|
20
|
+
export declare class SqliteEventRepository implements EventRepository, MailboxRepository {
|
|
21
|
+
private readonly db;
|
|
22
|
+
private readonly compatibility;
|
|
23
|
+
static open(path: string, compatibility?: EventStoreCompatibility): SqliteRepositoryOpenResult;
|
|
24
|
+
private constructor();
|
|
25
|
+
close(): void;
|
|
26
|
+
/** Full startup image for the memory-primary runtime. This is never used on a hot tick. */
|
|
27
|
+
snapshot(sessionId?: string | null): EventRepositorySnapshot;
|
|
28
|
+
schemaVersion(): number;
|
|
29
|
+
journalMode(): string;
|
|
30
|
+
saveSession(session: PlaySessionRecord): void;
|
|
31
|
+
saveSegment(segment: EventSegmentRecord): void;
|
|
32
|
+
currentScope(account?: EventAccountScope): CurrentEventScope | null;
|
|
33
|
+
latestScope(account: EventAccountScope, options?: LatestEventScopeOptions): CurrentEventScope | null;
|
|
34
|
+
resolveEventDelivery(decision: import('./types.js').EventDeliveryDecision): void;
|
|
35
|
+
commitEvent(request: CommitEventRequest): CommitEventResult;
|
|
36
|
+
/** Indexed cold-archive identity check; never materializes the historical ledger. */
|
|
37
|
+
archivedEventIdentities(event: CommitEventRequest['event'], loadedSessionId: string | null, throughCommitSeq: number): Array<{
|
|
38
|
+
event: CanonicalEvent;
|
|
39
|
+
deliveries: EventDeliveryRecord[];
|
|
40
|
+
}>;
|
|
41
|
+
eventById(eventId: string): CanonicalEvent | null;
|
|
42
|
+
latestEventByType(sessionId: string, type: string, segmentId?: string): CanonicalEvent | null;
|
|
43
|
+
highWaterCommitSeq(sessionId: string, segmentId?: string): number;
|
|
44
|
+
listCommittedEvents(filter: CommittedEventListFilter): CanonicalEvent[];
|
|
45
|
+
ensureDeliveries(sessionId: string, consumerId: string, channels?: readonly ConsumerLease['channel'][]): void;
|
|
46
|
+
delivery(eventId: string, consumerId: string): EventDeliveryRecord | null;
|
|
47
|
+
listEvents(filter: EventListFilter, consumerId: string, channels?: readonly ConsumerLease['channel'][]): EventWithDelivery[];
|
|
48
|
+
backlogSummary(sessionId: string, consumerId: string): BacklogSummary;
|
|
49
|
+
transitionDetails(transition: DetailStateTransition): number;
|
|
50
|
+
transitionMonitor(transition: MonitorStateTransition): number;
|
|
51
|
+
recordMonitorAttempt(attempt: MonitorDeliveryAttempt): boolean;
|
|
52
|
+
acquireLease(request: AcquireLeaseRequest): ConsumerLease | null;
|
|
53
|
+
leaseIsValid(lease: ConsumerLease, nowMs?: number): boolean;
|
|
54
|
+
releaseLease(lease: ConsumerLease): boolean;
|
|
55
|
+
enqueueMailboxItem<T = unknown>(request: EnqueueMailboxItem<T>): EnqueueMailboxResult<T>;
|
|
56
|
+
mailboxItem<T = unknown>(itemId: string): MailboxItem<T> | null;
|
|
57
|
+
mailboxItemForEvent<T = unknown>(consumerId: string, eventId: string, mode: MailboxDeliveryMode): MailboxItem<T> | null;
|
|
58
|
+
peekMailbox<T = unknown>(filter: MailboxPeekFilter): MailboxItem<T>[];
|
|
59
|
+
claimMailbox<T = unknown>(request: ClaimMailboxItemsRequest): MailboxClaim<T> | null;
|
|
60
|
+
ackMailboxClaim(request: AckMailboxClaimRequest): AckMailboxClaimResult;
|
|
61
|
+
nackMailboxClaim(request: NackMailboxClaimRequest): NackMailboxClaimResult;
|
|
62
|
+
suppressMailboxItems(filter: SuppressMailboxItemsFilter): number;
|
|
63
|
+
sourceCheckpoint(sourceId: string): SourceCheckpointRecord | null;
|
|
64
|
+
private configure;
|
|
65
|
+
private migrate;
|
|
66
|
+
/** One-time storage migration; query-only never enters the current delivery pipeline. */
|
|
67
|
+
private migrateQueryOnlyNotifications;
|
|
68
|
+
/**
|
|
69
|
+
* The Channels release created a divergent schema-v1 ledger: visible Events
|
|
70
|
+
* used `agent_visible`, delivery rows had no Monitor/via columns, and leases
|
|
71
|
+
* only admitted the details channel. Normalize that exact shape before the
|
|
72
|
+
* incremental npm-lineage migrations inspect or copy those columns.
|
|
73
|
+
*/
|
|
74
|
+
private normalizeChannelV1Schema;
|
|
75
|
+
/**
|
|
76
|
+
* Split the old logical Agent cursor into output-specific cursors without
|
|
77
|
+
* treating one transport's acknowledgement as proof for another transport.
|
|
78
|
+
*/
|
|
79
|
+
private seedDedicatedOutputConsumers;
|
|
80
|
+
private seedDedicatedDetailConsumer;
|
|
81
|
+
private insertInitialDelivery;
|
|
82
|
+
private upsertCheckpoint;
|
|
83
|
+
private findByRemoteId;
|
|
84
|
+
private findByRemoteSequence;
|
|
85
|
+
private mailboxSessionIsCurrent;
|
|
86
|
+
private deliveryScopeIsCurrent;
|
|
87
|
+
private retireMailboxScope;
|
|
88
|
+
private sqliteMailboxRowIsClaimable;
|
|
89
|
+
private suppressMailboxEventDeliveryRow;
|
|
90
|
+
private suppressExpiredMailboxClaimsOutsideCurrentSession;
|
|
91
|
+
private addInFilter;
|
|
92
|
+
private assertLeaseIfPresent;
|
|
93
|
+
private transaction;
|
|
94
|
+
}
|