@myclaw163/clawclaw-cli 0.9.1 → 0.10.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/QUICKSTART_OTHER.md +5 -5
- package/README.md +7 -8
- package/bin/clawclaw-channel.mjs +2 -2
- package/bin/clawclaw-cli.mjs +2 -2
- package/docs/configuration.md +25 -99
- package/docs/custom-modules/README.md +27 -40
- package/docs/custom-modules/api-reference.md +132 -273
- package/docs/custom-modules/behavior.md +185 -75
- package/docs/custom-modules/examples/auto-escape.ts +41 -0
- package/docs/custom-modules/examples/go-to-point.ts +11 -11
- package/docs/custom-modules/examples/nearby-reflex.ts +22 -0
- package/docs/custom-modules/examples/task-reminder.ts +4 -5
- package/docs/custom-modules/perception.md +46 -806
- package/docs/custom-modules/skill.md +1 -1
- package/docs/desktop-event-push.md +3 -3
- package/docs/runtime/README.md +18 -19
- package/docs/runtime/agent-notifications.md +31 -12
- package/docs/runtime/behavior-runtime.md +54 -48
- package/docs/runtime/components-and-boundaries.md +87 -137
- package/docs/runtime/events-and-state.md +52 -17
- package/docs/runtime/framework-package.md +73 -0
- package/docs/runtime/official-perception-modules.md +5 -5
- package/docs/runtime/owner-lifecycle-and-observability.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +8 -9
- package/docs/user-guide/README.md +12 -9
- package/docs/user-guide/api-reference.md +132 -180
- package/docs/user-guide/behavior.md +175 -65
- package/docs/user-guide/installation.md +7 -7
- package/docs/user-guide/perception.md +46 -789
- package/docs/user-guide/skill.md +1 -1
- package/package.json +24 -9
- package/scripts/check-framework-boundaries.mjs +27 -0
- package/scripts/check-skill-command-surface.mjs +9 -14
- package/scripts/install-local-runtime.mjs +35 -0
- package/scripts/qa-install.mjs +105 -0
- package/skills/clawclaw/SKILL.md +50 -48
- package/skills/clawclaw/references/BEHAVIORS.md +45 -65
- package/skills/clawclaw/references/CHANNELS.md +2 -2
- package/skills/clawclaw/references/COMMANDS.md +65 -87
- package/skills/clawclaw/references/CUSTOM-BEHAVIOR-DEVELOPMENT.md +185 -75
- package/skills/clawclaw/references/CUSTOM-MODULE-API.md +145 -198
- package/skills/clawclaw/references/CUSTOM-MODULES.md +28 -29
- package/skills/clawclaw/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +46 -811
- package/skills/clawclaw/references/CUSTOM-SKILL-DEVELOPMENT.md +1 -1
- package/skills/clawclaw/references/HUB.md +1 -1
- package/skills/clawclaw/references/STREAM.md +8 -8
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/src/channel/claude-channel-ipc-server.ts +1 -0
- package/src/cli.ts +4 -2
- package/src/commands/behavior.ts +49 -104
- package/src/commands/capability.ts +3 -3
- package/src/commands/load.ts +18 -25
- package/src/commands/module-runtime-control.ts +113 -0
- package/src/commands/perception.ts +23 -4
- package/src/commands/strategy.ts +2 -0
- package/src/commands/trigger.ts +1 -1
- package/src/lib/capability-load-diagnostics.ts +3 -3
- package/src/lib/perception-config.ts +18 -6
- package/src/lib/runtime-cadence-config.ts +16 -0
- package/src/lib/workspace-runtime-lock.ts +3 -46
- package/src/pipeline/canonical-event-presentation.ts +23 -124
- package/src/pipeline/event-format.ts +12 -21
- package/src/pipeline/event-hints.ts +6 -6
- package/src/pipeline/game-sync-event-normalization.ts +57 -63
- package/src/runtime/clawclaw/behavior-decision.ts +7 -3
- package/src/runtime/clawclaw/behavior-input.ts +8 -4
- package/src/runtime/clawclaw/behavior-observation-memory.ts +3 -2
- package/src/runtime/clawclaw/behavior-read-api.ts +4 -0
- package/src/runtime/clawclaw/behavior-reflex-control.ts +74 -0
- package/src/runtime/clawclaw/notification-policy.ts +42 -0
- package/src/runtime/clawclaw/notification-turn.ts +19 -0
- package/src/runtime/clawclaw/observation-frame-projector.ts +3 -3
- package/src/runtime/clawclaw/owner.ts +67 -8
- package/src/runtime/clawclaw/perception-module-manifest.ts +22 -8
- package/src/runtime/clawclaw/perception-strategy-names.ts +17 -0
- package/src/runtime/clawclaw/persistence-compatibility.ts +36 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +3 -3
- package/src/runtime/clawclaw/plugins/assembly.ts +29 -41
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +1 -482
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +17 -186
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +2 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.ts +1 -123
- package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +3 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +126 -1707
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +13 -271
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +2 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +8 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +3 -180
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.ts +13 -960
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.ts +9 -107
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-rules.ts +5 -4
- package/src/runtime/clawclaw/plugins/derived-event/reminder-plugin.ts +27 -17
- package/src/runtime/clawclaw/plugins/derived-event/reminder-runner.ts +1 -0
- package/src/runtime/clawclaw/plugins/derived-event/state-change-rules.ts +84 -0
- package/src/runtime/clawclaw/plugins/derived-event/task-change-tracker.ts +1 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +4 -4
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +9 -97
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +8 -343
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +60 -572
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +6 -434
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +1 -266
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +6 -161
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +4 -23
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +49 -752
- package/src/runtime/clawclaw/plugins/perception/map-concurrent.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/notification-content.ts +60 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-plugin.ts +136 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-runner.ts +13 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-worker.ts +13 -24
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +19 -8
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +23 -15
- package/src/runtime/clawclaw/plugins/perception/task-baseline.ts +29 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +8 -103
- package/src/runtime/clawclaw/plugins/system-perception/rule-runner.ts +107 -0
- package/src/runtime/clawclaw/plugins/system-perception/system-perceptions.ts +107 -0
- package/src/runtime/clawclaw/plugins/trigger/contracts.ts +3 -1
- package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +5 -2
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +69 -13
- package/src/runtime/clawclaw/plugins/trigger/trigger-thread-pool.ts +13 -1
- package/src/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +4 -0
- package/src/runtime/clawclaw/reaction-behavior-resolution.ts +1 -23
- package/src/runtime/clawclaw/reaction-manifest.ts +18 -12
- package/src/runtime/clawclaw/reminder-manifest.ts +5 -2
- package/src/runtime/clawclaw/runtime-cadence.ts +24 -0
- package/src/runtime/clawclaw/runtime-state.ts +12 -1
- package/src/runtime/clawclaw/runtime.ts +11 -3
- package/src/runtime/clawclaw/strategy-memory-rpc.ts +1 -0
- package/src/runtime/clawclaw/strategy-memory.ts +1 -0
- package/src/runtime/clawclaw-event-catalog.ts +17 -17
- package/src/runtime/framework/action-diagnostics.ts +3 -83
- package/src/runtime/framework/capability-registry.ts +2 -395
- package/src/runtime/framework/contracts.ts +2 -144
- package/src/runtime/framework/control/control-scheduler.ts +2 -1268
- package/src/runtime/framework/control/domain-set.ts +2 -81
- package/src/runtime/framework/control/index.ts +1 -3
- package/src/runtime/framework/control/types.ts +2 -191
- package/src/runtime/framework/control-coordinator.ts +2 -11
- package/src/runtime/framework/events/event-catalog.ts +2 -74
- package/src/runtime/framework/events/event-delivery-service.ts +2 -200
- package/src/runtime/framework/events/event-ingress.ts +2 -99
- package/src/runtime/framework/events/event-repository.ts +2 -82
- package/src/runtime/framework/events/index.ts +2 -7
- package/src/runtime/framework/events/memory-event-repository.ts +2 -1100
- package/src/runtime/framework/events/runtime-resume.ts +2 -20
- package/src/runtime/framework/events/sqlite-event-repository.ts +5 -2280
- package/src/runtime/framework/events/test-helpers.ts +1 -1
- package/src/runtime/framework/events/types.ts +2 -312
- package/src/runtime/framework/index.ts +3 -7
- package/src/runtime/framework/load-node-sqlite.ts +2 -17
- package/src/runtime/framework/mailbox/coalescer.ts +2 -83
- package/src/runtime/framework/mailbox/host-notification-sink.ts +2 -44
- package/src/runtime/framework/mailbox/identity.ts +2 -38
- package/src/runtime/framework/mailbox/index.ts +1 -7
- package/src/runtime/framework/mailbox/mailbox-dispatcher.ts +2 -282
- package/src/runtime/framework/mailbox/mailbox-repository.ts +2 -44
- package/src/runtime/framework/mailbox/notification-projector.ts +2 -65
- package/src/runtime/framework/mailbox/types.ts +2 -145
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -154
- package/src/runtime/framework/modules/runtime-module-loader.ts +7 -51
- package/src/runtime/framework/modules/runtime-module-output.ts +2 -24
- package/src/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -23
- package/src/runtime/framework/participation-manager.ts +2 -253
- package/src/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -77
- package/src/runtime/framework/persistence/memory-first-persistence.ts +4 -489
- package/src/runtime/framework/plugins/contracts.ts +2 -388
- package/src/runtime/framework/plugins/index.ts +1 -4
- package/src/runtime/framework/plugins/runtime-event-identity.ts +2 -17
- package/src/runtime/framework/plugins/runtime-input-journal.ts +2 -866
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +2 -2060
- package/src/runtime/framework/runtime.ts +5 -1843
- package/src/runtime/framework/serial-task-queue.ts +2 -14
- package/src/runtime/framework/state/contracts.ts +2 -49
- package/src/runtime/framework/state/current-state-store.ts +2 -184
- package/src/runtime/framework/state/durable-agent-state-snapshot.ts +2 -209
- package/src/runtime/framework/state/freshness.ts +2 -72
- package/src/runtime/framework/state/history/contracts.ts +2 -158
- package/src/runtime/framework/state/history/history-writer.ts +2 -194
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +2 -230
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +2 -648
- package/src/runtime/framework/state/history/trajectory-projector.ts +2 -209
- package/src/runtime/framework/state/index.ts +1 -13
- package/src/runtime/framework/state/state-ingress.ts +2 -95
- package/src/runtime/framework/state/state-provider.ts +2 -62
- package/src/runtime/framework/state/types.ts +2 -155
- package/src/runtime/host-monitor-rate-gate.ts +1 -123
- package/src/runtime/mailbox-host-relay.ts +1 -326
- package/src/runtime/observability/detail-capture.ts +4 -108
- package/src/runtime/observability/process-timing.ts +2 -59
- package/src/runtime/observability/recorder.ts +2 -238
- package/src/runtime/observability/redaction.ts +2 -181
- package/src/runtime/observability/reporter.ts +2 -154
- package/src/runtime/observability/sinks.ts +2 -135
- package/src/runtime/observability/types.ts +2 -92
- package/src/runtime/owner-control.ts +45 -315
- package/src/runtime/parent-process-watch.ts +1 -51
- package/src/runtime/process-identity.ts +1 -72
- package/src/sdk/behavior-plugin/index.ts +13 -4
- package/src/sdk/index.ts +44 -3
- package/src/sdk/module-input/index.ts +5 -0
- package/src/sdk/perception-plugin/index.ts +9 -5
- package/src/sdk/perception-plugin/module.ts +25 -6
- package/src/sdk/perception-plugin/reaction.ts +1 -1
- package/src/sdk/perception-plugin/reminder-rules.ts +8 -42
- package/src/sdk/perception-plugin/reminder.ts +2 -1
- package/src/{runtime/clawclaw/plugins/source → sdk/perception-plugin}/task-change-tracker.ts +1 -2
- package/src/sdk/strategy-memory.ts +1 -0
- package/src/sdk/strategy-plugin/index.ts +36 -0
- package/src/sdk/trigger-plugin/index.ts +4 -3
- package/docs/custom-modules/examples/nearby-escape.ts +0 -56
- package/docs/custom-modules/examples/nearby-notice.ts +0 -36
- package/docs/custom-modules/trigger.md +0 -295
- package/src/runtime/clawclaw/behavior-activation-capability.ts +0 -21
- package/src/runtime/clawclaw/plugins/perception/reaction-plugin.ts +0 -233
- package/src/runtime/clawclaw/plugins/perception/reaction-runner.ts +0 -49
- package/src/runtime/clawclaw/plugins/perception/reaction-worker.ts +0 -26
- /package/src/runtime/clawclaw/plugins/{source → derived-event}/player-change-tracker.ts +0 -0
|
@@ -43,7 +43,7 @@ export function seedScope(
|
|
|
43
43
|
export function testCatalog(): EventCatalog {
|
|
44
44
|
return new EventCatalog([
|
|
45
45
|
{ type: 'speech', producer: 'backend_push', deliveryClass: 'monitor_and_events' },
|
|
46
|
-
{ type: 'vote', producer: 'backend_push', deliveryClass: '
|
|
46
|
+
{ type: 'vote', producer: 'backend_push', deliveryClass: 'monitor_and_events', wakeAgent: false },
|
|
47
47
|
{ type: 'client_notice', producer: 'local_synth', deliveryClass: 'monitor_and_events' },
|
|
48
48
|
]);
|
|
49
49
|
}
|
|
@@ -1,312 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type EventProducer = 'backend_push' | 'local_synth';
|
|
4
|
-
|
|
5
|
-
export type EventDeliveryClass =
|
|
6
|
-
| 'monitor_and_events'
|
|
7
|
-
| 'events_only'
|
|
8
|
-
| 'internal_only';
|
|
9
|
-
|
|
10
|
-
/** Delivery metadata may be resolved before Ready; factual identity/payload never change. */
|
|
11
|
-
export interface EventDeliveryDecision {
|
|
12
|
-
eventId: string;
|
|
13
|
-
deliveryClass: EventDeliveryClass;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type MonitorDeliveryState =
|
|
17
|
-
| 'not_applicable'
|
|
18
|
-
| 'pending'
|
|
19
|
-
| 'notified'
|
|
20
|
-
| 'suppressed';
|
|
21
|
-
|
|
22
|
-
export type DetailDeliveryState =
|
|
23
|
-
| 'not_applicable'
|
|
24
|
-
| 'pending'
|
|
25
|
-
| 'deferred'
|
|
26
|
-
| 'delivered';
|
|
27
|
-
|
|
28
|
-
/** Stable output-adapter identifier persisted with a durable detail ACK. */
|
|
29
|
-
export type DetailDeliveryVia = string;
|
|
30
|
-
|
|
31
|
-
const DETAIL_DELIVERY_VIA_PATTERN = /^[a-z0-9][a-z0-9._-]{0,119}$/;
|
|
32
|
-
|
|
33
|
-
export function validateDetailDeliveryVia(value: string): DetailDeliveryVia {
|
|
34
|
-
if (!DETAIL_DELIVERY_VIA_PATTERN.test(value)) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
'Detail delivery adapter id must be 1-120 lowercase ASCII characters using a-z, 0-9, dot, underscore, or hyphen.',
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type LeaseChannel = 'monitor' | 'details';
|
|
43
|
-
|
|
44
|
-
export interface PlaySessionRecord {
|
|
45
|
-
sessionId: string;
|
|
46
|
-
adapterId: string;
|
|
47
|
-
accountId: string;
|
|
48
|
-
/** Stable remote participation identity used to reattach after owner restart. */
|
|
49
|
-
resumeKey?: string;
|
|
50
|
-
mode?: string;
|
|
51
|
-
status: 'open' | 'sealed';
|
|
52
|
-
isCurrent: boolean;
|
|
53
|
-
openedAt: string;
|
|
54
|
-
sealedAt?: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface EventSegmentRecord {
|
|
58
|
-
segmentId: string;
|
|
59
|
-
sessionId: string;
|
|
60
|
-
sequence: number;
|
|
61
|
-
kind: string;
|
|
62
|
-
scopeRef?: string;
|
|
63
|
-
status: 'open' | 'closed';
|
|
64
|
-
isCurrent: boolean;
|
|
65
|
-
openedAt: string;
|
|
66
|
-
closedAt?: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface CurrentEventScope {
|
|
70
|
-
session: PlaySessionRecord;
|
|
71
|
-
segment: EventSegmentRecord;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface EventAccountScope {
|
|
75
|
-
adapterId: string;
|
|
76
|
-
accountId: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface EventSourceRef {
|
|
80
|
-
/** Stable logical source. It must not change for an ordinary reconnect. */
|
|
81
|
-
sourceId: string;
|
|
82
|
-
/** Stable backend identity, when the protocol supplies one. */
|
|
83
|
-
eventId?: string;
|
|
84
|
-
/** Per-source ordering identity, scoped to the target session and segment. */
|
|
85
|
-
sequence?: string | number;
|
|
86
|
-
/** Physical connection identity. It is diagnostic and never defines a segment. */
|
|
87
|
-
connectionId?: string;
|
|
88
|
-
replayed?: boolean;
|
|
89
|
-
/** Opaque resume token committed atomically with the event. */
|
|
90
|
-
checkpoint?: string;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface PublishEventInput {
|
|
94
|
-
/** Whether this Event may initiate Agent delivery; omitted means true. */
|
|
95
|
-
readonly wakeAgent?: boolean;
|
|
96
|
-
/** Runtime epoch that admitted or derived this Event. */
|
|
97
|
-
epochSeq?: number;
|
|
98
|
-
type: string;
|
|
99
|
-
producer: EventProducer;
|
|
100
|
-
/** Set by Runtime for Epoch Plugin output; absent for Source/backend input. */
|
|
101
|
-
producerPluginId?: string;
|
|
102
|
-
/** Stable position in that plugin's output list for this epoch. */
|
|
103
|
-
producerOutputIndex?: number;
|
|
104
|
-
sessionId: string;
|
|
105
|
-
segmentId: string;
|
|
106
|
-
payload?: Record<string, unknown>;
|
|
107
|
-
occurredAt?: string;
|
|
108
|
-
receivedAt?: string;
|
|
109
|
-
eventId?: string;
|
|
110
|
-
source: EventSourceRef;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface CanonicalEvent {
|
|
114
|
-
/** Whether this Event may initiate Agent delivery; omitted means true. */
|
|
115
|
-
readonly wakeAgent?: boolean;
|
|
116
|
-
commitSeq: number;
|
|
117
|
-
/** Absent only for records written before the epoch runtime migration. */
|
|
118
|
-
epochSeq?: number;
|
|
119
|
-
eventId: string;
|
|
120
|
-
sessionId: string;
|
|
121
|
-
segmentId: string;
|
|
122
|
-
type: string;
|
|
123
|
-
producer: EventProducer;
|
|
124
|
-
producerPluginId?: string;
|
|
125
|
-
producerOutputIndex?: number;
|
|
126
|
-
deliveryClass: EventDeliveryClass;
|
|
127
|
-
occurredAt: string;
|
|
128
|
-
receivedAt: string;
|
|
129
|
-
payload: Record<string, unknown>;
|
|
130
|
-
sourceId: string;
|
|
131
|
-
sourceEventId?: string;
|
|
132
|
-
sourceSequence?: string;
|
|
133
|
-
connectionId?: string;
|
|
134
|
-
replayed: boolean;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export interface CanonicalEventDraft extends Omit<CanonicalEvent, 'commitSeq'> {}
|
|
138
|
-
|
|
139
|
-
export interface EventDeliveryRecord {
|
|
140
|
-
eventId: string;
|
|
141
|
-
consumerId: string;
|
|
142
|
-
monitorState: MonitorDeliveryState;
|
|
143
|
-
/** Persisted before the Monitor sink is invoked, enabling owner recovery. */
|
|
144
|
-
monitorAttemptCount: number;
|
|
145
|
-
monitorLastAttemptAt?: string;
|
|
146
|
-
monitorDeliveredAt?: string;
|
|
147
|
-
detailState: DetailDeliveryState;
|
|
148
|
-
detailDeliveredAt?: string;
|
|
149
|
-
detailDeliveryVia?: DetailDeliveryVia;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface EventWithDelivery {
|
|
153
|
-
event: CanonicalEvent;
|
|
154
|
-
delivery: EventDeliveryRecord;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface SourceCheckpointRecord {
|
|
158
|
-
sourceId: string;
|
|
159
|
-
checkpoint: string;
|
|
160
|
-
sourceSequence?: string;
|
|
161
|
-
eventId: string;
|
|
162
|
-
committedAt: string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export interface CommitEventRequest {
|
|
166
|
-
event: CanonicalEventDraft;
|
|
167
|
-
consumerIds: string[];
|
|
168
|
-
checkpoint?: SourceCheckpointRecord;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export interface CommitEventResult {
|
|
172
|
-
inserted: boolean;
|
|
173
|
-
event: CanonicalEvent;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export interface EventListFilter {
|
|
177
|
-
sessionId: string;
|
|
178
|
-
segmentId?: string;
|
|
179
|
-
excludeSegmentId?: string;
|
|
180
|
-
types?: string[];
|
|
181
|
-
deliveryClasses?: EventDeliveryClass[];
|
|
182
|
-
detailStates?: DetailDeliveryState[];
|
|
183
|
-
monitorStates?: MonitorDeliveryState[];
|
|
184
|
-
maxCommitSeq?: number;
|
|
185
|
-
/** Excludes Events produced by epochs newer than an immutable Ready View. */
|
|
186
|
-
maxEpochSeq?: number;
|
|
187
|
-
order?: 'asc' | 'desc';
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** Read-only journal query. It deliberately has no consumer or delivery fields. */
|
|
191
|
-
export interface CommittedEventListFilter {
|
|
192
|
-
sessionId: string;
|
|
193
|
-
segmentId?: string;
|
|
194
|
-
types?: string[];
|
|
195
|
-
/** Return only Events produced by this exact Runtime epoch. */
|
|
196
|
-
epochSeq?: number;
|
|
197
|
-
/** Return only events committed strictly after this cursor. */
|
|
198
|
-
afterCommitSeq?: number;
|
|
199
|
-
maxCommitSeq?: number;
|
|
200
|
-
/** Legacy Events without an epoch remain visible; current Runtime Events are bounded. */
|
|
201
|
-
maxEpochSeq?: number;
|
|
202
|
-
order?: 'asc' | 'desc';
|
|
203
|
-
/** Apply the bound in the repository, before payloads are materialized. */
|
|
204
|
-
limit?: number;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export interface LatestEventScopeOptions {
|
|
208
|
-
/** When supplied, select the newest matching segment in the chosen session. */
|
|
209
|
-
segmentKinds?: string[];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface BacklogSummary {
|
|
213
|
-
unreadCount: number;
|
|
214
|
-
segmentCount: number;
|
|
215
|
-
oldestAt?: string;
|
|
216
|
-
newestAt?: string;
|
|
217
|
-
available: boolean;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export interface ConsumerLease {
|
|
221
|
-
consumerId: string;
|
|
222
|
-
channel: LeaseChannel;
|
|
223
|
-
ownerId: string;
|
|
224
|
-
expiresAt: number;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export interface AcquireLeaseRequest {
|
|
228
|
-
consumerId: string;
|
|
229
|
-
channel: LeaseChannel;
|
|
230
|
-
ownerId: string;
|
|
231
|
-
ttlMs: number;
|
|
232
|
-
nowMs?: number;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export interface DetailStateTransition {
|
|
236
|
-
eventIds: string[];
|
|
237
|
-
consumerId: string;
|
|
238
|
-
from: DetailDeliveryState[];
|
|
239
|
-
to: DetailDeliveryState;
|
|
240
|
-
deliveredAt?: string;
|
|
241
|
-
deliveryVia?: DetailDeliveryVia;
|
|
242
|
-
lease?: ConsumerLease;
|
|
243
|
-
nowMs?: number;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export interface MonitorStateTransition {
|
|
247
|
-
eventIds: string[];
|
|
248
|
-
consumerId: string;
|
|
249
|
-
from: MonitorDeliveryState[];
|
|
250
|
-
to: MonitorDeliveryState;
|
|
251
|
-
deliveredAt?: string;
|
|
252
|
-
lease?: ConsumerLease;
|
|
253
|
-
nowMs?: number;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export interface MonitorDeliveryAttempt {
|
|
257
|
-
eventId: string;
|
|
258
|
-
consumerId: string;
|
|
259
|
-
attemptedAt: string;
|
|
260
|
-
lease: ConsumerLease;
|
|
261
|
-
nowMs?: number;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export interface EventCatalogEntry {
|
|
265
|
-
type: string;
|
|
266
|
-
producer: EventProducer;
|
|
267
|
-
deliveryClass: EventDeliveryClass;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export function initialDeliveryFor(
|
|
271
|
-
event: Pick<CanonicalEvent, 'eventId' | 'deliveryClass'>,
|
|
272
|
-
consumerId: string,
|
|
273
|
-
channels: readonly LeaseChannel[] = ['monitor', 'details'],
|
|
274
|
-
): EventDeliveryRecord {
|
|
275
|
-
let delivery: EventDeliveryRecord;
|
|
276
|
-
switch (event.deliveryClass) {
|
|
277
|
-
case 'monitor_and_events':
|
|
278
|
-
delivery = {
|
|
279
|
-
eventId: event.eventId,
|
|
280
|
-
consumerId,
|
|
281
|
-
monitorState: 'pending',
|
|
282
|
-
monitorAttemptCount: 0,
|
|
283
|
-
detailState: 'pending',
|
|
284
|
-
};
|
|
285
|
-
break;
|
|
286
|
-
case 'events_only':
|
|
287
|
-
delivery = {
|
|
288
|
-
eventId: event.eventId,
|
|
289
|
-
consumerId,
|
|
290
|
-
monitorState: 'not_applicable',
|
|
291
|
-
monitorAttemptCount: 0,
|
|
292
|
-
detailState: 'pending',
|
|
293
|
-
};
|
|
294
|
-
break;
|
|
295
|
-
case 'internal_only':
|
|
296
|
-
delivery = {
|
|
297
|
-
eventId: event.eventId,
|
|
298
|
-
consumerId,
|
|
299
|
-
monitorState: 'not_applicable',
|
|
300
|
-
monitorAttemptCount: 0,
|
|
301
|
-
detailState: 'not_applicable',
|
|
302
|
-
};
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
if (!channels.includes('monitor')) delivery.monitorState = 'not_applicable';
|
|
306
|
-
if (!channels.includes('details')) delivery.detailState = 'not_applicable';
|
|
307
|
-
return delivery;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export function cloneRecord<T>(value: T): T {
|
|
311
|
-
return structuredClone(value);
|
|
312
|
-
}
|
|
1
|
+
// Compatibility facade; implementation lives in the game-neutral runtime package.
|
|
2
|
+
export * from '@myclaw163/game-agent-runtime/framework/events/types.js';
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export * from './events/index.js';
|
|
5
|
-
export * from './mailbox/index.js';
|
|
6
|
-
export * from './state/index.js';
|
|
7
|
-
export * from './capability-registry.js';
|
|
1
|
+
export * from '@myclaw163/game-agent-runtime/framework/index.js';
|
|
2
|
+
export { Runtime } from './runtime.js';
|
|
3
|
+
export { SqliteEventRepository } from './events/sqlite-event-repository.js';
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* into Agent-facing stderr. Other warnings keep their normal behavior.
|
|
4
|
-
*/
|
|
5
|
-
export function loadNodeSqliteModule<T>(requireModule: (id: string) => unknown): T {
|
|
6
|
-
const original = process.emitWarning;
|
|
7
|
-
process.emitWarning = ((warning: string | Error, ...args: any[]) => {
|
|
8
|
-
const message = warning instanceof Error ? warning.message : String(warning);
|
|
9
|
-
if (message.includes('SQLite is an experimental feature')) return;
|
|
10
|
-
return (original as any).call(process, warning, ...args);
|
|
11
|
-
}) as typeof process.emitWarning;
|
|
12
|
-
try {
|
|
13
|
-
return requireModule('node:sqlite') as T;
|
|
14
|
-
} finally {
|
|
15
|
-
process.emitWarning = original;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
1
|
+
// Compatibility facade; implementation lives in the game-neutral runtime package.
|
|
2
|
+
export * from '@myclaw163/game-agent-runtime/framework/load-node-sqlite.js';
|
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface MailboxNotification<TPayload = unknown> {
|
|
5
|
-
notificationId: string;
|
|
6
|
-
consumerId: string;
|
|
7
|
-
sessionId: string;
|
|
8
|
-
segmentId: string;
|
|
9
|
-
mode: MailboxDeliveryMode;
|
|
10
|
-
formatterVersion: string;
|
|
11
|
-
coalesceKey: string;
|
|
12
|
-
itemIds: string[];
|
|
13
|
-
eventIds: string[];
|
|
14
|
-
firstEventCommitSeq: number;
|
|
15
|
-
lastEventCommitSeq: number;
|
|
16
|
-
payload: TPayload;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A coalescer only shapes already-presented Mailbox payloads. It never reads
|
|
21
|
-
* game Event types, decides when to wake an Agent, or changes delivery state.
|
|
22
|
-
*/
|
|
23
|
-
export interface MailboxCoalescer<TItemPayload = unknown, TNotificationPayload = TItemPayload> {
|
|
24
|
-
/** Passed to Repository.claimMailbox; the repository still enforces FIFO. */
|
|
25
|
-
readonly maxItems: number;
|
|
26
|
-
coalesce(items: readonly MailboxItem<TItemPayload>[]): MailboxNotification<TNotificationPayload>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function assertOneClaimGroup<T>(items: readonly MailboxItem<T>[]): MailboxItem<T> {
|
|
30
|
-
const first = items[0];
|
|
31
|
-
if (!first) throw new Error('Cannot coalesce an empty Mailbox claim.');
|
|
32
|
-
|
|
33
|
-
for (const item of items.slice(1)) {
|
|
34
|
-
if (
|
|
35
|
-
item.consumerId !== first.consumerId
|
|
36
|
-
|| item.sessionId !== first.sessionId
|
|
37
|
-
|| item.segmentId !== first.segmentId
|
|
38
|
-
|| item.mode !== first.mode
|
|
39
|
-
|| item.formatterVersion !== first.formatterVersion
|
|
40
|
-
|| item.coalesceKey !== first.coalesceKey
|
|
41
|
-
) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
'A Mailbox claim may only contain one consumer, segment, mode, formatter version, and coalesce key.',
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return first;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function mailboxNotification<TItemPayload, TNotificationPayload>(
|
|
51
|
-
items: readonly MailboxItem<TItemPayload>[],
|
|
52
|
-
payload: TNotificationPayload,
|
|
53
|
-
): MailboxNotification<TNotificationPayload> {
|
|
54
|
-
const first = assertOneClaimGroup(items);
|
|
55
|
-
const last = items[items.length - 1] ?? first;
|
|
56
|
-
return {
|
|
57
|
-
notificationId: stableMailboxNotificationId(items.map((item) => item.itemId)),
|
|
58
|
-
consumerId: first.consumerId,
|
|
59
|
-
sessionId: first.sessionId,
|
|
60
|
-
segmentId: first.segmentId,
|
|
61
|
-
mode: first.mode,
|
|
62
|
-
formatterVersion: first.formatterVersion,
|
|
63
|
-
coalesceKey: first.coalesceKey,
|
|
64
|
-
itemIds: items.map((item) => item.itemId),
|
|
65
|
-
eventIds: items.map((item) => item.eventId),
|
|
66
|
-
firstEventCommitSeq: first.eventCommitSeq,
|
|
67
|
-
lastEventCommitSeq: last.eventCommitSeq,
|
|
68
|
-
payload,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Default policy: claim and deliver exactly one durable item at a time. */
|
|
73
|
-
export class IdentityMailboxCoalescer<TPayload = unknown>
|
|
74
|
-
implements MailboxCoalescer<TPayload, TPayload> {
|
|
75
|
-
readonly maxItems = 1;
|
|
76
|
-
|
|
77
|
-
coalesce(items: readonly MailboxItem<TPayload>[]): MailboxNotification<TPayload> {
|
|
78
|
-
if (items.length !== 1) {
|
|
79
|
-
throw new Error(`IdentityMailboxCoalescer expected one item, received ${items.length}.`);
|
|
80
|
-
}
|
|
81
|
-
return mailboxNotification(items, items[0]!.payload);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
1
|
+
// Compatibility facade; implementation lives in the game-neutral runtime package.
|
|
2
|
+
export * from '@myclaw163/game-agent-runtime/framework/mailbox/coalescer.js';
|
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returning means this adapter completed the handoff level named by
|
|
6
|
-
* acceptanceLevel. Implementations must not wait for the Agent's resulting
|
|
7
|
-
* turn to finish, and stdout-like sinks must not claim Host acceptance.
|
|
8
|
-
*/
|
|
9
|
-
export interface HostNotificationAcceptance {
|
|
10
|
-
acceptedAt: string;
|
|
11
|
-
receiptId?: string;
|
|
12
|
-
/**
|
|
13
|
-
* `sink_emitted` is the conservative default for stdout-like transports.
|
|
14
|
-
* `host_accepted` means the Host durably acknowledged its own input queue.
|
|
15
|
-
*/
|
|
16
|
-
acceptanceLevel?: MailboxAcceptanceLevel;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** A Host rejected this notification with an explicit retry policy. */
|
|
20
|
-
export class HostNotificationDeliveryError extends Error {
|
|
21
|
-
readonly retryable: boolean;
|
|
22
|
-
readonly code: string;
|
|
23
|
-
readonly httpStatus?: number;
|
|
24
|
-
|
|
25
|
-
constructor(options: {
|
|
26
|
-
message: string;
|
|
27
|
-
retryable: boolean;
|
|
28
|
-
code: string;
|
|
29
|
-
httpStatus?: number;
|
|
30
|
-
}) {
|
|
31
|
-
super(options.message);
|
|
32
|
-
this.name = 'HostNotificationDeliveryError';
|
|
33
|
-
this.retryable = options.retryable;
|
|
34
|
-
this.code = options.code;
|
|
35
|
-
this.httpStatus = options.httpStatus;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface HostNotificationSink<TPayload = unknown> {
|
|
40
|
-
deliver(
|
|
41
|
-
notification: MailboxNotification<TPayload>,
|
|
42
|
-
signal: AbortSignal,
|
|
43
|
-
): Promise<HostNotificationAcceptance>;
|
|
44
|
-
}
|
|
1
|
+
// Compatibility facade; implementation lives in the game-neutral runtime package.
|
|
2
|
+
export * from '@myclaw163/game-agent-runtime/framework/mailbox/host-notification-sink.js';
|
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface StableMailboxItemIdentity {
|
|
5
|
-
consumerId: string;
|
|
6
|
-
sessionId: string;
|
|
7
|
-
eventId: string;
|
|
8
|
-
mode: MailboxDeliveryMode;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Builds the durable identity of one Event delivery without including mutable
|
|
13
|
-
* presentation or retry fields. Re-projecting the same Event is therefore an
|
|
14
|
-
* idempotent enqueue even after a process restart or formatter upgrade.
|
|
15
|
-
*/
|
|
16
|
-
export function stableMailboxItemId(identity: StableMailboxItemIdentity): string {
|
|
17
|
-
const digest = createHash('sha256')
|
|
18
|
-
.update(JSON.stringify([
|
|
19
|
-
'ccl.mailbox.item.v1',
|
|
20
|
-
identity.consumerId,
|
|
21
|
-
identity.sessionId,
|
|
22
|
-
identity.eventId,
|
|
23
|
-
identity.mode,
|
|
24
|
-
]))
|
|
25
|
-
.digest('hex');
|
|
26
|
-
return `mbx_${digest}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Stable for one ordered item set; reliable Hosts should also dedupe itemIds. */
|
|
30
|
-
export function stableMailboxNotificationId(itemIds: readonly string[]): string {
|
|
31
|
-
if (itemIds.length === 0) {
|
|
32
|
-
throw new Error('A mailbox notification must contain at least one item.');
|
|
33
|
-
}
|
|
34
|
-
const digest = createHash('sha256')
|
|
35
|
-
.update(JSON.stringify(['ccl.mailbox.notification.v1', ...itemIds]))
|
|
36
|
-
.digest('hex');
|
|
37
|
-
return `mbn_${digest}`;
|
|
38
|
-
}
|
|
1
|
+
// Compatibility facade; implementation lives in the game-neutral runtime package.
|
|
2
|
+
export * from '@myclaw163/game-agent-runtime/framework/mailbox/identity.js';
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './mailbox-repository.js';
|
|
3
|
-
export * from './identity.js';
|
|
4
|
-
export * from './notification-projector.js';
|
|
5
|
-
export * from './coalescer.js';
|
|
6
|
-
export * from './host-notification-sink.js';
|
|
7
|
-
export * from './mailbox-dispatcher.js';
|
|
1
|
+
export * from '@myclaw163/game-agent-runtime/framework/mailbox/index.js';
|