@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
|
@@ -1,111 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
RuntimeEpochPluginResult,
|
|
6
|
-
RuntimeEventProposal,
|
|
7
|
-
} from '../../../framework/plugins/index.js';
|
|
8
|
-
import type { StoredStateFrame } from '../../../framework/state/index.js';
|
|
9
|
-
import {
|
|
10
|
-
AbilityStateDerivedEventRule,
|
|
11
|
-
EmergencyCountdownDerivedEventRule,
|
|
12
|
-
MeetingStateDerivedEventRule,
|
|
13
|
-
RoomReadyDerivedEventRule,
|
|
14
|
-
type ClawclawDerivedEventRule,
|
|
15
|
-
} from './derived-event-rules.js';
|
|
16
|
-
|
|
1
|
+
import { PerceptionRuleRunner } from '../system-perception/rule-runner.js';
|
|
2
|
+
import { PlayerChangesDerivedEventRule, TaskChangesDerivedEventRule } from './state-change-rules.js';
|
|
3
|
+
import { AbilityStateDerivedEventRule, EmergencyCountdownDerivedEventRule,
|
|
4
|
+
MeetingStateDerivedEventRule, RoomReadyDerivedEventRule, type ClawclawDerivedEventRule } from './derived-event-rules.js';
|
|
17
5
|
export const CLAWCLAW_DERIVED_EVENT_PLUGIN_ID = 'clawclaw.derived-event';
|
|
18
|
-
|
|
19
|
-
export class ClawclawDerivedEventPlugin
|
|
20
|
-
implements RuntimeEpochPlugin<Record<string, any>> {
|
|
21
|
-
readonly kind = 'epoch' as const;
|
|
22
|
-
readonly id = CLAWCLAW_DERIVED_EVENT_PLUGIN_ID;
|
|
23
|
-
readonly version = '2';
|
|
24
|
-
readonly produces = {
|
|
25
|
-
events: [
|
|
26
|
-
'room_ready_to_start',
|
|
27
|
-
'meeting_state',
|
|
28
|
-
'emergency_countdown_warning',
|
|
29
|
-
'ability.ready',
|
|
30
|
-
'ability.remaining_uses_changed',
|
|
31
|
-
'ability.exhausted',
|
|
32
|
-
],
|
|
33
|
-
} as const;
|
|
34
|
-
readonly catchUp = 'every_epoch' as const;
|
|
35
|
-
readonly timeoutMs = 1_000;
|
|
36
|
-
|
|
37
|
-
private readonly rules: ClawclawDerivedEventRule[];
|
|
38
|
-
private lastFrameSeq = 0;
|
|
39
|
-
|
|
6
|
+
/** Legacy rule harness. The production graph uses independent builtin perceptions. */
|
|
7
|
+
export class ClawclawDerivedEventPlugin extends PerceptionRuleRunner {
|
|
40
8
|
constructor(rules?: readonly ClawclawDerivedEventRule[]) {
|
|
41
|
-
|
|
42
|
-
new AbilityStateDerivedEventRule(),
|
|
43
|
-
new EmergencyCountdownDerivedEventRule(),
|
|
44
|
-
new RoomReadyDerivedEventRule(),
|
|
45
|
-
new MeetingStateDerivedEventRule(),
|
|
46
|
-
])].sort((left, right) => left.id.localeCompare(right.id));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
start(): void {
|
|
50
|
-
this.reset();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
recover(context: RuntimeEpochPluginContext<Record<string, any>>): void {
|
|
54
|
-
const completedThrough = context.progress().completedThroughEpochSeq;
|
|
55
|
-
if (completedThrough <= 0) return;
|
|
56
|
-
this.scanHistory(context, completedThrough, false);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
update(
|
|
60
|
-
input: RuntimeEpochPluginInput<Record<string, any>>,
|
|
61
|
-
context: RuntimeEpochPluginContext<Record<string, any>>,
|
|
62
|
-
): RuntimeEpochPluginResult {
|
|
63
|
-
const events = this.scanHistory(context, input.epoch.epochSeq, true, input.frame.frameSeq);
|
|
64
|
-
return events.length > 0
|
|
65
|
-
? { outcome: 'processed', events }
|
|
66
|
-
: { outcome: 'noop', reason: 'no_derived_event' };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
stop(): void {
|
|
70
|
-
this.reset();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private scanHistory(
|
|
74
|
-
context: RuntimeEpochPluginContext<Record<string, any>>,
|
|
75
|
-
throughEpochSeq: number,
|
|
76
|
-
collect: boolean,
|
|
77
|
-
throughFrameSeq?: number,
|
|
78
|
-
): RuntimeEventProposal[] {
|
|
79
|
-
const proposals: RuntimeEventProposal[] = [];
|
|
80
|
-
let afterFrameSeq = this.lastFrameSeq;
|
|
81
|
-
while (true) {
|
|
82
|
-
const page = context.stateHistory.queryStateFrames({
|
|
83
|
-
scope: context.scope,
|
|
84
|
-
afterFrameSeq,
|
|
85
|
-
toEpochSeq: throughEpochSeq,
|
|
86
|
-
...(throughFrameSeq === undefined ? {} : { beforeFrameSeq: throughFrameSeq + 1 }),
|
|
87
|
-
order: 'asc',
|
|
88
|
-
limit: 500,
|
|
89
|
-
});
|
|
90
|
-
if (page.frames.length === 0) break;
|
|
91
|
-
for (const frame of page.frames) {
|
|
92
|
-
const frameEvents = this.inspectFrame(frame);
|
|
93
|
-
if (collect) proposals.push(...frameEvents);
|
|
94
|
-
afterFrameSeq = frame.frameSeq;
|
|
95
|
-
}
|
|
96
|
-
if (!page.page.hasMore) break;
|
|
97
|
-
}
|
|
98
|
-
return proposals;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private inspectFrame(frame: StoredStateFrame<Record<string, any>>): RuntimeEventProposal[] {
|
|
102
|
-
if (frame.frameSeq <= this.lastFrameSeq) return [];
|
|
103
|
-
this.lastFrameSeq = frame.frameSeq;
|
|
104
|
-
return this.rules.flatMap((rule) => rule.inspect(frame));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private reset(): void {
|
|
108
|
-
this.lastFrameSeq = 0;
|
|
109
|
-
for (const rule of this.rules) rule.reset();
|
|
9
|
+
super(CLAWCLAW_DERIVED_EVENT_PLUGIN_ID, rules ?? [new PlayerChangesDerivedEventRule(),
|
|
10
|
+
new TaskChangesDerivedEventRule(), new AbilityStateDerivedEventRule(),
|
|
11
|
+
new EmergencyCountdownDerivedEventRule(), new RoomReadyDerivedEventRule(), new MeetingStateDerivedEventRule()]);
|
|
110
12
|
}
|
|
111
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import type { RuntimeEventProposal } from '../../../framework/plugins/index.js';
|
|
2
|
+
import type { RuntimeEventProposal, RuntimeSourceEvent } from '../../../framework/plugins/index.js';
|
|
3
3
|
import type { StoredStateFrame } from '../../../framework/state/index.js';
|
|
4
4
|
import { isClawclawRuntimeState } from '../../runtime-state.js';
|
|
5
5
|
import {
|
|
@@ -12,8 +12,9 @@ type UnknownRecord = Record<string, unknown>;
|
|
|
12
12
|
export interface ClawclawDerivedEventRule {
|
|
13
13
|
readonly id: string;
|
|
14
14
|
readonly eventTypes: readonly string[];
|
|
15
|
+
readonly consumes?: readonly string[];
|
|
15
16
|
reset(): void;
|
|
16
|
-
inspect(frame: StoredStateFrame<Record<string, any
|
|
17
|
+
inspect(frame: StoredStateFrame<Record<string, any>>, events?: readonly RuntimeSourceEvent[]): RuntimeEventProposal[];
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
function record(value: unknown): UnknownRecord | null {
|
|
@@ -42,7 +43,7 @@ function roomSnapshot(
|
|
|
42
43
|
frame: StoredStateFrame<Record<string, any>>,
|
|
43
44
|
): UnknownRecord | null | undefined {
|
|
44
45
|
const state = frame.state;
|
|
45
|
-
if (!isClawclawRuntimeState(state) || state.
|
|
46
|
+
if (!isClawclawRuntimeState(state) || state.stage !== 'room') return undefined;
|
|
46
47
|
return record(record(state.room)?.room);
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -115,7 +116,7 @@ function freshGameSnapshot(
|
|
|
115
116
|
): UnknownRecord | null | undefined {
|
|
116
117
|
const state = frame.state;
|
|
117
118
|
if (!isClawclawRuntimeState(state)) return record(state);
|
|
118
|
-
if (state.game_snapshot.status !== 'fresh') return undefined;
|
|
119
|
+
if ((state.game_snapshot.status !== 'fresh' && state.game_snapshot.status !== 'cached')) return undefined;
|
|
119
120
|
return record(state.game_snapshot.state);
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { prepareNotificationContent } from '../perception/notification-content.js';
|
|
2
|
+
import { isNotificationTurn } from '../../notification-turn.js';
|
|
1
3
|
import type { RuntimeEpochPlugin, RuntimeEpochPluginContext, RuntimeEpochPluginInput, RuntimeEpochPluginResult } from '../../../framework/plugins/index.js';
|
|
2
4
|
import type { RuntimeEventProposal } from '../../../framework/plugins/index.js';
|
|
3
|
-
import type { ReminderInput, ReminderResult, ReminderTopic
|
|
5
|
+
import type { ReminderInput, ReminderResult, ReminderTopic } from '../../../../sdk/perception-plugin/reminder.js';
|
|
4
6
|
import type { ResolvedClawclawPerceptionSource } from '../perception/perception-source.js';
|
|
5
|
-
import {
|
|
7
|
+
import { clawclawComputationGameState } from '../../runtime-state.js';
|
|
6
8
|
import { createCanonicalGameState } from '../../behavior-input.js';
|
|
7
9
|
import { projectTaskChoiceEventPayload } from '../../task-choice-projection.js';
|
|
8
10
|
import { ObservationFrameProjector } from '../../observation-frame-projector.js';
|
|
@@ -10,22 +12,26 @@ import { REMINDER_EVENT_TYPES, REMINDER_EVENT_TYPE_BY_TOPIC, REMINDER_FACT_TYPES
|
|
|
10
12
|
import { ReminderRunner } from './reminder-runner.js';
|
|
11
13
|
import { resolveClawclawResourceMetadata } from '../../../../sdk/resource-metadata.js';
|
|
12
14
|
|
|
15
|
+
import { comparePerceptionTasks, type PerceptionTaskBaseline } from '../perception/task-baseline.js';
|
|
16
|
+
|
|
13
17
|
export const CLAWCLAW_REMINDER_PLUGIN_ID = 'clawclaw.derived-event.reminders';
|
|
14
18
|
export interface ReminderPluginOptions {
|
|
15
19
|
/** Already selected by the ordinary local/Hub perception loadout. No separate settings. */
|
|
16
20
|
sources?: readonly ResolvedClawclawPerceptionSource[];
|
|
17
21
|
}
|
|
18
22
|
interface Checkpoint {
|
|
23
|
+
taskBaseline?: PerceptionTaskBaseline;
|
|
19
24
|
gameId?: string;
|
|
20
25
|
previousTick?: number; previousConnectionId?: string;
|
|
21
26
|
states: Partial<Record<ReminderTopic, { provider: string; value: unknown }>>;
|
|
22
27
|
}
|
|
23
28
|
function empty(): Checkpoint { return { states: {} }; }
|
|
24
29
|
export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string, any>> {
|
|
30
|
+
readonly agentNotificationProducer = true;
|
|
25
31
|
readonly kind = 'epoch' as const;
|
|
26
32
|
readonly id = CLAWCLAW_REMINDER_PLUGIN_ID;
|
|
27
33
|
readonly version = '2';
|
|
28
|
-
readonly after = [
|
|
34
|
+
readonly after: readonly string[] = [];
|
|
29
35
|
readonly consumes = { events: REMINDER_FACT_TYPES };
|
|
30
36
|
readonly produces = { events: REMINDER_EVENT_TYPES } as const;
|
|
31
37
|
readonly catchUp = 'strict_ordered' as const;
|
|
@@ -57,7 +63,7 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
|
|
|
57
63
|
recover(context: RuntimeEpochPluginContext<Record<string, any>>): void {
|
|
58
64
|
const checkpoint = context.checkpoint() as Checkpoint | undefined;
|
|
59
65
|
if (checkpoint?.states) this.checkpoint = structuredClone({
|
|
60
|
-
gameId: checkpoint.gameId, previousTick: checkpoint.previousTick,
|
|
66
|
+
taskBaseline: checkpoint.taskBaseline, gameId: checkpoint.gameId, previousTick: checkpoint.previousTick,
|
|
61
67
|
previousConnectionId: checkpoint.previousConnectionId,
|
|
62
68
|
states: Object.fromEntries(REMINDER_TOPICS.filter(topic => checkpoint.states[topic])
|
|
63
69
|
.map(topic => [topic, checkpoint.states[topic]])),
|
|
@@ -71,7 +77,10 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
|
|
|
71
77
|
));
|
|
72
78
|
}
|
|
73
79
|
async update(input: RuntimeEpochPluginInput<Record<string, any>>, context: RuntimeEpochPluginContext<Record<string, any>>): Promise<RuntimeEpochPluginResult> {
|
|
74
|
-
|
|
80
|
+
if (isNotificationTurn(input.epoch.state)) return { outcome: 'noop', reason: 'notification_only' };
|
|
81
|
+
if (this.sources.size === 0) return { outcome: 'noop', reason: 'no_reminder_modules',
|
|
82
|
+
...(input.pendingEvents.length ? {consumeEventsThroughCommitSeq: input.pendingEvents.at(-1)!.commitSeq} : {}) };
|
|
83
|
+
const snapshot = clawclawComputationGameState(input.frame.state);
|
|
75
84
|
const game = snapshot ? createCanonicalGameState(snapshot, input.frame.backendTick) : null;
|
|
76
85
|
let next = structuredClone(this.checkpoint);
|
|
77
86
|
const initial = !!game && next.gameId !== game.game_id;
|
|
@@ -91,21 +100,19 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
|
|
|
91
100
|
next.previousTick = undefined; next.previousConnectionId = undefined;
|
|
92
101
|
}
|
|
93
102
|
next.previousConnectionId = input.epoch.connectionId;
|
|
94
|
-
const facts = input.pendingEvents.map(event => ({ ...event,
|
|
103
|
+
const facts = input.pendingEvents.filter(event => !event.notificationOf && event.producerPluginId === undefined).map(event => ({ ...event,
|
|
95
104
|
payload: projectTaskChoiceEventPayload(game, event.type, event.payload) }));
|
|
96
105
|
const events: RuntimeEventProposal[] = [];
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
} as ReminderTaskChange));
|
|
103
|
-
});
|
|
104
|
-
for (const topic of REMINDER_TOPICS) {
|
|
106
|
+
const comparison = comparePerceptionTasks(next.taskBaseline, input, boundary);
|
|
107
|
+
next.taskBaseline = comparison.baseline;
|
|
108
|
+
const taskChanges = comparison.changes;
|
|
109
|
+
const outputs = await Promise.all(REMINDER_TOPICS.map(async topic => {
|
|
110
|
+
const events: RuntimeEventProposal[] = [];
|
|
105
111
|
const selected = this.sources.get(topic)?.[0];
|
|
106
|
-
if (!selected || this.failed.has(topic))
|
|
112
|
+
if (!selected || this.failed.has(topic)) return events;
|
|
107
113
|
const previous = next.states[topic];
|
|
108
114
|
const moduleInput: ReminderInput = {
|
|
115
|
+
...(input.epoch.state.cycle ? { cycle: input.epoch.state.cycle } : {}),
|
|
109
116
|
scope: input.epoch.scope, frame, gameState: game, taskChanges, boundary,
|
|
110
117
|
facts: facts.filter(e => topic !== 'speech' || !e.replayed)
|
|
111
118
|
.map(e => ({ eventId: e.eventId, epochId: e.epochSeq, type: e.type,
|
|
@@ -138,9 +145,12 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
|
|
|
138
145
|
if (game && (topic === 'speech' || !boundary)) events.push(...accepted);
|
|
139
146
|
next.states[topic] = { provider: selected.id, value: structuredClone(result.state) };
|
|
140
147
|
} catch (error) { this.markFailed(topic, context, error); }
|
|
141
|
-
|
|
148
|
+
return events;
|
|
149
|
+
}));
|
|
150
|
+
events.push(...outputs.flat());
|
|
142
151
|
this.checkpoint = next;
|
|
143
|
-
return { outcome: 'processed', events
|
|
152
|
+
return { outcome: 'processed', events: events.map(event => ({ ...event,
|
|
153
|
+
notificationContent: prepareNotificationContent(event.type, event.payload, game, 'custom') })), checkpoint: next,
|
|
144
154
|
...(input.pendingEvents.length ? { consumeEventsThroughCommitSeq: input.pendingEvents.at(-1)!.commitSeq } : {}) };
|
|
145
155
|
}
|
|
146
156
|
private markFailed(topic: ReminderTopic, context: RuntimeEpochPluginContext<Record<string, any>>, error: unknown): void {
|
|
@@ -14,6 +14,7 @@ export class ReminderRunner {
|
|
|
14
14
|
if (!source.reminder) throw new Error('Not a reminder perception source.');
|
|
15
15
|
}
|
|
16
16
|
async start(): Promise<{ manifest: ClawclawReminderManifest; config: Record<string, unknown> }> {
|
|
17
|
+
if (this.source.compatibilityError) throw new Error(this.source.compatibilityError);
|
|
17
18
|
const loader = runtimeModuleThreadLoaderConfig();
|
|
18
19
|
const promise = this.wait(8_000);
|
|
19
20
|
this.worker = new Worker(new URL('../../../framework/modules/runtime-module-worker-bootstrap.mjs', import.meta.url), {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { RuntimeEventProposal, RuntimeSourceEvent } from '../../../framework/plugins/index.js';
|
|
2
|
+
import type { StoredStateFrame } from '../../../framework/state/index.js';
|
|
3
|
+
import type { PlayerProjection } from '../../../../pipeline/player-projection.js';
|
|
4
|
+
import { CLAWCLAW_GAME_STREAM_BACKEND_EVENT_TYPES } from '../../../clawclaw-event-catalog.js';
|
|
5
|
+
import { clawclawComputationGameState, isClawclawRuntimeState } from '../../runtime-state.js';
|
|
6
|
+
import type { ClawclawDerivedEventRule } from './derived-event-rules.js';
|
|
7
|
+
import { nextPlayerProjection, type PlayerSnapshot } from './player-change-tracker.js';
|
|
8
|
+
import { nextTaskProjection, type TaskSnapshot } from './task-change-tracker.js';
|
|
9
|
+
|
|
10
|
+
/** Adapt validated canonical Source facts to the existing player projection's PlayerRef inputs. */
|
|
11
|
+
function trackerFacts(events: readonly RuntimeSourceEvent[]): Array<Record<string, any>> {
|
|
12
|
+
return events.filter(event => event.producer !== 'local_synth').map(event => {
|
|
13
|
+
const value: Record<string, any> = { ...event.payload, type: event.type };
|
|
14
|
+
for (const [field, name, seat] of [
|
|
15
|
+
['actor','actor_name','actor_seat'], ['target','target_name','target_seat'],
|
|
16
|
+
['caller','meeting_caller_name','meeting_caller_seat'], ['resolver','resolver_name','resolver_seat'],
|
|
17
|
+
['current_speaker','current_speaker','current_speaker_seat'], ['result_target','result_target','result_target_seat'],
|
|
18
|
+
]) {
|
|
19
|
+
if (typeof value[name] === 'string' && Number.isInteger(value[seat])) {
|
|
20
|
+
value[field] = { name: value[name], seat: value[seat] };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (value.killer_kind === 'player' && typeof value.killer_name === 'string' && Number.isInteger(value.killer_seat)) {
|
|
24
|
+
value.killer = { kind: 'player', player: { name: value.killer_name, seat: value.killer_seat } };
|
|
25
|
+
} else if (value.killer_kind === 'system' && typeof value.killer_name === 'string') {
|
|
26
|
+
value.killer = { kind: 'system', name: value.killer_name };
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function gameState(frame: StoredStateFrame<Record<string, any>>): Record<string, any> | null {
|
|
33
|
+
const game = clawclawComputationGameState(frame.state);
|
|
34
|
+
if (!game) return null;
|
|
35
|
+
return { ...game, ...(frame.backendTick === undefined ? {} : { tick: frame.backendTick }) };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function proposal(type: string, frame: StoredStateFrame<Record<string, any>>, payload: Record<string, unknown>,
|
|
39
|
+
sourceEvents: readonly RuntimeSourceEvent[]): RuntimeEventProposal[] {
|
|
40
|
+
// An open epoch written by the previous Source implementation may already contain this fact.
|
|
41
|
+
// Rebuild rule state, but keep its original Source identity and delivery instead of publishing it twice.
|
|
42
|
+
if (sourceEvents.some(event => event.type === type && event.producer === 'local_synth')) return [];
|
|
43
|
+
return [{ type, payload, dedupeKey: `${type}:${frame.sourceKey}`, dedupeScope: 'segment',
|
|
44
|
+
occurredAt: new Date(frame.observedAtMs ?? frame.receivedAtMs).toISOString() }];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class PlayerChangesDerivedEventRule implements ClawclawDerivedEventRule {
|
|
48
|
+
readonly id = 'player-changes';
|
|
49
|
+
readonly eventTypes = ['players_changed'] as const;
|
|
50
|
+
readonly consumes = [...CLAWCLAW_GAME_STREAM_BACKEND_EVENT_TYPES, 'players_changed'];
|
|
51
|
+
private initialized = false;
|
|
52
|
+
private projection: PlayerProjection[] = [];
|
|
53
|
+
private snapshots: PlayerSnapshot[] = [];
|
|
54
|
+
reset(): void { this.initialized = false; this.projection = []; this.snapshots = []; }
|
|
55
|
+
inspect(frame: StoredStateFrame<Record<string, any>>, events: readonly RuntimeSourceEvent[] = []): RuntimeEventProposal[] {
|
|
56
|
+
const game = gameState(frame);
|
|
57
|
+
if (!game) return [];
|
|
58
|
+
const update = nextPlayerProjection({ previous: this.projection, previousSnapshots: this.snapshots,
|
|
59
|
+
initialized: this.initialized, summary: game, events: trackerFacts(events),
|
|
60
|
+
selfName: game.you?.player?.name ?? game.you?.name });
|
|
61
|
+
this.projection = update.projection; this.snapshots = update.snapshots; this.initialized = true;
|
|
62
|
+
return update.payload ? proposal('players_changed', frame, update.payload, events) : [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class TaskChangesDerivedEventRule implements ClawclawDerivedEventRule {
|
|
67
|
+
readonly id = 'task-changes';
|
|
68
|
+
readonly eventTypes = ['tasks_changed'] as const;
|
|
69
|
+
readonly consumes = [...CLAWCLAW_GAME_STREAM_BACKEND_EVENT_TYPES, 'tasks_changed'];
|
|
70
|
+
private initialized = false;
|
|
71
|
+
private projection: TaskSnapshot[] = [];
|
|
72
|
+
reset(): void { this.initialized = false; this.projection = []; }
|
|
73
|
+
inspect(frame: StoredStateFrame<Record<string, any>>, events: readonly RuntimeSourceEvent[] = []): RuntimeEventProposal[] {
|
|
74
|
+
const game = gameState(frame);
|
|
75
|
+
if (!game) return [];
|
|
76
|
+
const state = frame.state;
|
|
77
|
+
const update = nextTaskProjection({ previous: this.projection, initialized: this.initialized, summary: game,
|
|
78
|
+
events: trackerFacts(events), selfName: game.you?.player?.name ?? game.you?.name,
|
|
79
|
+
allowUntickedInitialRole: isClawclawRuntimeState(state) && (state.game_snapshot.status === 'fresh' || state.game_snapshot.status === 'cached')
|
|
80
|
+
&& state.game_snapshot.origin === 'update' });
|
|
81
|
+
this.projection = update.projection; this.initialized = update.initialized;
|
|
82
|
+
return update.payload ? proposal('tasks_changed', frame, update.payload, events) : [];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../../sdk/perception-plugin/task-change-tracker.js';
|
|
@@ -127,12 +127,12 @@ export class ClawclawGameQueryPlugin implements RuntimeEpochPlugin<Record<string
|
|
|
127
127
|
}
|
|
128
128
|
const snapshot = queryContext.stateFrame;
|
|
129
129
|
if (!snapshot || !isClawclawRuntimeState(snapshot.state)
|
|
130
|
-
|| snapshot.state.game_snapshot.status !== 'fresh') {
|
|
130
|
+
|| (snapshot.state.game_snapshot.status !== 'fresh' && snapshot.state.game_snapshot.status !== 'cached')) {
|
|
131
131
|
return { state: null, receivedAt: null };
|
|
132
132
|
}
|
|
133
133
|
return {
|
|
134
134
|
state: snapshot.state.game_snapshot.state,
|
|
135
|
-
receivedAt: new Date(snapshot.receivedAtMs).toISOString(),
|
|
135
|
+
receivedAt: new Date(snapshot.state.cycle?.stateReceivedAtMs ?? snapshot.receivedAtMs).toISOString(),
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -234,9 +234,9 @@ export class ClawclawGameQueryPlugin implements RuntimeEpochPlugin<Record<string
|
|
|
234
234
|
}
|
|
235
235
|
const runtimeState = input.epoch.state;
|
|
236
236
|
if (isClawclawRuntimeState(runtimeState)
|
|
237
|
-
&& runtimeState.game_snapshot.status === 'fresh') {
|
|
237
|
+
&& (runtimeState.game_snapshot.status === 'fresh' || runtimeState.game_snapshot.status === 'cached')) {
|
|
238
238
|
this.latestFreshGameState = structuredClone(runtimeState.game_snapshot.state);
|
|
239
|
-
this.latestFreshReceivedAt = new Date(input.frame.receivedAtMs).toISOString();
|
|
239
|
+
this.latestFreshReceivedAt = new Date(runtimeState.cycle?.stateReceivedAtMs ?? input.frame.receivedAtMs).toISOString();
|
|
240
240
|
}
|
|
241
241
|
return { outcome: 'noop', reason: 'query_provider' };
|
|
242
242
|
}
|
|
@@ -1,102 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from '../../../../../pipeline/canonical-event-presentation.js';
|
|
4
|
-
import type { CanonicalEvent, EventRepository } from '../../../../framework/events/index.js';
|
|
5
|
-
import type { RuntimeReadyView } from '../../../../framework/runtime.js';
|
|
6
|
-
import {
|
|
7
|
-
AgentMailboxCoordinator,
|
|
8
|
-
type PreparedAgentMailboxBatch,
|
|
9
|
-
} from '../agent-mailbox-coordinator.js';
|
|
1
|
+
import { ClaudeChannelMailboxAdapter as CoreAdapter, type ClaudeChannelMailboxAdapterOptions as CoreOptions } from '@myclaw163/game-agent-runtime/mailbox/adapters/claude-channel-adapter.js';
|
|
2
|
+
import { isClawclawAgentNotification } from '../../../notification-policy.js';
|
|
3
|
+
import { presentCanonicalEventForChannel } from '../../../../../pipeline/canonical-event-presentation.js';
|
|
10
4
|
import { CLAUDE_CHANNEL_MAILBOX_CONSUMER_ID } from '../consumer-ids.js';
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
export { CLAUDE_CHANNEL_COALESCE_MS } from '@myclaw163/game-agent-runtime/mailbox/adapters/claude-channel-adapter.js';
|
|
13
6
|
export const CLAUDE_CHANNEL_ADAPTER_ID = 'clawclaw.mailbox.adapter.claude-channel';
|
|
14
7
|
export const CLAUDE_CHANNEL_CONSUMER_ID = CLAUDE_CHANNEL_MAILBOX_CONSUMER_ID;
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readyView: () => RuntimeReadyView;
|
|
21
|
-
consumerId?: string;
|
|
22
|
-
now?: () => number;
|
|
23
|
-
diagnostic?: (name: string, attributes?: Record<string, unknown>) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Mailbox projection and delivery state for the Claude Channel consumer.
|
|
28
|
-
* Transport is handled separately by the Owner-side Channel socket sink.
|
|
29
|
-
*/
|
|
30
|
-
export class ClaudeChannelMailboxAdapter implements ClawclawMailboxDriver {
|
|
31
|
-
readonly consumerId: string;
|
|
32
|
-
readonly adapter: ClawclawMailboxDriver['adapter'];
|
|
33
|
-
private readonly coordinator: AgentMailboxCoordinator;
|
|
34
|
-
|
|
35
|
-
constructor(options: ClaudeChannelMailboxAdapterOptions) {
|
|
36
|
-
this.consumerId = options.consumerId ?? CLAUDE_CHANNEL_CONSUMER_ID;
|
|
37
|
-
this.adapter = {
|
|
38
|
-
id: CLAUDE_CHANNEL_ADAPTER_ID,
|
|
39
|
-
acknowledgement: 'on_delivery',
|
|
40
|
-
consumerId: this.consumerId,
|
|
41
|
-
};
|
|
42
|
-
this.coordinator = new AgentMailboxCoordinator({
|
|
43
|
-
onDelivered: options.onDelivered,
|
|
44
|
-
repository: options.repository,
|
|
45
|
-
readyView: options.readyView,
|
|
46
|
-
presentEvent: presentCanonicalEventForChannel,
|
|
47
|
-
// Channel v2 is Event-only. Other Mailbox adapters keep their own
|
|
48
|
-
// compatibility projections instead of repeating Ready State here.
|
|
49
|
-
compactState: () => null,
|
|
50
|
-
consumerId: this.consumerId,
|
|
51
|
-
coalesceMs: CLAUDE_CHANNEL_COALESCE_MS,
|
|
52
|
-
now: options.now,
|
|
53
|
-
diagnostic: options.diagnostic,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
prepare(readyView?: RuntimeReadyView): PreparedAgentMailboxBatch {
|
|
58
|
-
const prepared = this.coordinator.prepareEvents({
|
|
59
|
-
readyView,
|
|
60
|
-
deliveryVia: 'claude_channel',
|
|
61
|
-
ownerIdPrefix: 'claude_channel',
|
|
62
|
-
});
|
|
63
|
-
return {
|
|
64
|
-
...prepared,
|
|
65
|
-
batch: {
|
|
66
|
-
...prepared.batch,
|
|
67
|
-
// The repository selects newest-first for legacy pull consumers.
|
|
68
|
-
// Channel Events must be applied in occurrence order now that there is
|
|
69
|
-
// no repeated State snapshot masking backwards transitions.
|
|
70
|
-
events: [...prepared.batch.events].reverse(),
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
ack(deliveryToken: string): boolean {
|
|
76
|
-
return this.coordinator.ack(deliveryToken);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
renew(deliveryToken: string): boolean {
|
|
80
|
-
return this.coordinator.renew(deliveryToken);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
release(deliveryToken: string): boolean {
|
|
84
|
-
return this.coordinator.release(deliveryToken);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
observeEvents(events: readonly CanonicalEvent[]): void {
|
|
88
|
-
this.coordinator.observeEvents(events);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
flush(): Promise<void> {
|
|
92
|
-
return this.coordinator.flush();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
waitForDrain(shouldAbort: () => boolean = () => false): Promise<boolean> {
|
|
96
|
-
return this.coordinator.waitForDrain(shouldAbort);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
stop(): Promise<void> {
|
|
100
|
-
return this.coordinator.stop();
|
|
8
|
+
export interface ClaudeChannelMailboxAdapterOptions extends Omit<CoreOptions,'id'|'presentEvent'|'admitEvent'|'consumerId'> { notificationOnly?:boolean; consumerId?:string }
|
|
9
|
+
export class ClaudeChannelMailboxAdapter extends CoreAdapter {
|
|
10
|
+
constructor(options:ClaudeChannelMailboxAdapterOptions) {
|
|
11
|
+
super({...options,id:CLAUDE_CHANNEL_ADAPTER_ID,consumerId:options.consumerId ?? CLAUDE_CHANNEL_CONSUMER_ID,
|
|
12
|
+
presentEvent:presentCanonicalEventForChannel,admitEvent:options.notificationOnly ? isClawclawAgentNotification : undefined});
|
|
101
13
|
}
|
|
102
14
|
}
|