@agent-play/sdk 3.3.2 → 3.3.5

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.
@@ -0,0 +1,1120 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Domain types for sessions, journeys, agents, and the shared world map exposed by the SDK and server.
5
+ */
6
+ /** Role for a single line in the interaction log / chat stream. */
7
+ type WorldInteractionRole = "user" | "assistant" | "tool";
8
+ /**
9
+ * Payload for {@link RemotePlayWorld.recordInteraction}.
10
+ *
11
+ * @property playerId - Player id returned from `addAgent` / `addPlayer`.
12
+ * @property role - Who "spoke" the line.
13
+ * @property text - Plain text; may be truncated for display server-side.
14
+ */
15
+ type RecordInteractionInput = {
16
+ playerId: string;
17
+ role: WorldInteractionRole;
18
+ text: string;
19
+ };
20
+ /** How the watch UI should render and coerce a single assist tool argument. */
21
+ type AssistToolFieldType = "string" | "number" | "boolean";
22
+ /**
23
+ * Per-parameter metadata for assist tools. Legacy snapshots may omit `fieldType`; the UI treats that as `"string"`.
24
+ */
25
+ type AssistToolParameterSpec = {
26
+ fieldType: AssistToolFieldType;
27
+ field?: string;
28
+ };
29
+ /**
30
+ * Metadata for a tool whose name starts with `assist_`, shown as assist actions on the watch UI.
31
+ *
32
+ * @property parameters - Derived from Zod object `schema` when present: each key maps to
33
+ * {@link AssistToolParameterSpec} with `fieldType` from schema introspection. May include `_note` when no schema shape exists.
34
+ */
35
+ type AssistToolSpec = {
36
+ name: string;
37
+ description: string;
38
+ parameters: Record<string, unknown>;
39
+ };
40
+ /**
41
+ * Serializable shape returned by {@link langchainRegistration} for agent registration.
42
+ *
43
+ * @property type - Always `"langchain"` for this adapter.
44
+ * @property toolNames - All tool names from the agent (must include `chat_tool`).
45
+ * @property assistTools - Subset of tools with `assist_` prefix, for UI buttons.
46
+ */
47
+ type LangChainAgentRegistration = {
48
+ type: "langchain";
49
+ toolNames: string[];
50
+ assistTools?: AssistToolSpec[];
51
+ };
52
+ /** Minimal player identity in the SDK (without preview URL). */
53
+ type PlayAgentInformation = {
54
+ id: string;
55
+ name: string;
56
+ sid: string;
57
+ createdAt: Date;
58
+ updatedAt: Date;
59
+ };
60
+ /** Input fields for {@link AddAgentInput} / {@link AddPlayerInput} before `agent` is attached. */
61
+ type PlatformAgentInformation = {
62
+ name: string;
63
+ type: string;
64
+ version?: string;
65
+ createdAt?: Date;
66
+ updatedAt?: Date;
67
+ };
68
+ /**
69
+ * Register an automation agent in the world, tied to **agent node identity**.
70
+ *
71
+ * Use **`langchainRegistration(agent)`** for `agent` (requires a **`chat_tool`** tool; `assist_*`
72
+ * tools are indexed for the watch UI).
73
+ *
74
+ * **`nodeId`** is the **agent node id** (from **`agent-play create`** when the server uses a repository).
75
+ * It is sent on the wire as `agentId` for server compatibility; treating it as a node id makes the
76
+ * contract explicit for billing, validation, and event attribution.
77
+ */
78
+ type P2aEnableFlag = "on" | "off";
79
+ type RealtimeWebrtcClientSecret = {
80
+ clientSecret: string;
81
+ expiresAt?: string;
82
+ model: string;
83
+ voice?: string;
84
+ };
85
+ /** OpenAI Realtime minting options used by {@link RemotePlayWorld.initAudio}. */
86
+ type RemotePlayWorldOpenAiAudioOptions = {
87
+ /** Server-side OpenAI key used to mint ephemeral browser client secrets. */
88
+ apiKey?: string;
89
+ /** Realtime model id, defaults to `gpt-realtime`. */
90
+ model?: string;
91
+ /** Realtime voice id, defaults to `marin`. */
92
+ voice?: string;
93
+ /** Explicit system instructions for the realtime session. */
94
+ instructions?: string;
95
+ /** Template fallback for instructions; `{{agentName}}` placeholder is supported. */
96
+ instructionsTemplate?: string;
97
+ };
98
+ /** Configuration payload for enabling SDK-managed realtime audio initialization. */
99
+ type RemotePlayWorldInitAudioOptions = {
100
+ openai: RemotePlayWorldOpenAiAudioOptions;
101
+ };
102
+ type AddAgentInput = PlatformAgentInformation & {
103
+ /** Registration from {@link langchainRegistration}. */
104
+ agent: LangChainAgentRegistration;
105
+ /** Main node id that owns the agent (required on repository-backed servers). */
106
+ mainNodeId?: string;
107
+ /** Agent node id — same value the server stores as registered `agentId`. */
108
+ nodeId: string;
109
+ /**
110
+ * When **`"on"`**, registration enables OpenAI Realtime provisioning for this agent.
111
+ * Omitted or **`"off"`** disables realtime voice for this registration.
112
+ */
113
+ enableP2a?: P2aEnableFlag;
114
+ /**
115
+ * Per-agent instructions for OpenAI Realtime when **`enableP2a`** is **`"on"`** (e.g. from
116
+ * **`personality.txt`**). Ignored when **`initAudio`** was given explicit **`openai.instructions`**,
117
+ * which still wins as a global override.
118
+ */
119
+ realtimeInstructions?: string;
120
+ };
121
+ /**
122
+ * Register a player (agent) in the world.
123
+ *
124
+ * @deprecated Prefer {@link AddAgentInput} and `RemotePlayWorld.prototype.addAgent` for SDK and automation; use `nodeId` there instead of `agentId`.
125
+ *
126
+ * Use **`langchainRegistration(agent)`** for `agent` (requires a **`chat_tool`** tool; `assist_*`
127
+ * tools are indexed for the watch UI).
128
+ *
129
+ * **`agentId`** is required: use an id from **`agent-play create`** when the server uses a repository
130
+ * (with account **`passwHash`** from **`RemotePlayWorld`**), or any stable string for local dev without Redis.
131
+ */
132
+ type AddPlayerInput = PlatformAgentInformation & {
133
+ /** Registration from {@link langchainRegistration}. */
134
+ agent: LangChainAgentRegistration;
135
+ /** Main node id that owns the agent (required on repository-backed servers). */
136
+ mainNodeId?: string;
137
+ /** Registered agent id (or session-local id without Redis). */
138
+ agentId: string;
139
+ /**
140
+ * When **`"on"`**, registration enables OpenAI Realtime provisioning for this agent.
141
+ * Omitted or **`"off"`** disables realtime voice for this registration.
142
+ *
143
+ * Same semantics as {@link AddAgentInput} **`enableP2a`**.
144
+ */
145
+ enableP2a?: P2aEnableFlag;
146
+ /**
147
+ * Same semantics as {@link AddAgentInput} **`realtimeInstructions`**.
148
+ */
149
+ realtimeInstructions?: string;
150
+ };
151
+ /** Zone counter event surfaced on snapshots and signals. */
152
+ type ZoneEventInfo = {
153
+ zoneCount: number;
154
+ flagged?: boolean;
155
+ at: string;
156
+ };
157
+ /** Yield counter event surfaced on snapshots and signals. */
158
+ type YieldEventInfo = {
159
+ yieldCount: number;
160
+ at: string;
161
+ };
162
+ /** Repository-backed summary returned with `addAgent` when the agent is (or maps to) a stored registration. */
163
+ type RegisteredAgentSummary = {
164
+ agentId: string;
165
+ name: string;
166
+ toolNames: string[];
167
+ zoneCount: number;
168
+ yieldCount: number;
169
+ flagged: boolean;
170
+ };
171
+ /** Result of `addAgent` / `addPlayer` including watch URL and registered-agent metadata from the server. */
172
+ type RegisteredPlayer = PlayAgentInformation & {
173
+ previewUrl: string;
174
+ registeredAgent: RegisteredAgentSummary;
175
+ /** Echo of registration-time P2A flag (defaults to **`"off"`**). */
176
+ enableP2a: P2aEnableFlag;
177
+ /** Optional OpenAI Realtime WebRTC client-secret payload for browser-side direct voice. */
178
+ realtimeWebrtc?: RealtimeWebrtcClientSecret;
179
+ connectionId?: string;
180
+ leaseTtlSeconds?: number;
181
+ };
182
+ /** First step of a journey: user message origin. */
183
+ type OriginJourneyStep = {
184
+ type: "origin";
185
+ content: string;
186
+ messageId: string;
187
+ };
188
+ /** Middle step: tool invocation on the map. */
189
+ type StructureJourneyStep = {
190
+ type: "structure";
191
+ toolName: string;
192
+ toolCallId: string;
193
+ args: Record<string, unknown>;
194
+ result?: string;
195
+ };
196
+ /** Final step: assistant reply. */
197
+ type DestinationJourneyStep = {
198
+ type: "destination";
199
+ content: string;
200
+ messageId: string;
201
+ };
202
+ /** Union of journey step shapes. */
203
+ type JourneyStep = OriginJourneyStep | StructureJourneyStep | DestinationJourneyStep;
204
+ /**
205
+ * Ordered journey with timestamps; sent to the server via `recordJourney`.
206
+ *
207
+ * @property steps - Ordered path from origin through tool steps to destination.
208
+ * @property startedAt, completedAt - Wall times for the run (client or server).
209
+ */
210
+ type Journey = {
211
+ steps: JourneyStep[];
212
+ startedAt: Date;
213
+ completedAt: Date;
214
+ };
215
+ /** Journey step after server assigns coordinates (and optional structure id). */
216
+ type PositionedStep = JourneyStep & {
217
+ x?: number;
218
+ y?: number;
219
+ structureId?: string;
220
+ };
221
+ type AgentPlayWorldMapBounds = {
222
+ minX: number;
223
+ minY: number;
224
+ maxX: number;
225
+ maxY: number;
226
+ };
227
+ /**
228
+ * One agent on the world map. Prefer `streetId` with layout-driven placement; `x`/`y` are optional on wire before normalization and act as a denormalized cache after materialize.
229
+ */
230
+ type AgentPlayWorldMapAgentOccupant = {
231
+ kind: "agent";
232
+ nodeId?: string;
233
+ agentId: string;
234
+ name: string;
235
+ streetId?: string;
236
+ x?: number;
237
+ y?: number;
238
+ /**
239
+ * Integration label from addPlayer `type` (e.g. `langchain`). Populated from the snapshot field `platform`. The legacy wire field `agentType` is deprecated and accepted only for backward compatibility when parsing JSON.
240
+ */
241
+ platform?: string;
242
+ toolNames?: string[];
243
+ assistToolNames?: string[];
244
+ assistTools?: AssistToolSpec[];
245
+ hasChatTool?: boolean;
246
+ enableP2a?: P2aEnableFlag;
247
+ realtimeInstructions?: string;
248
+ realtimeWebrtc?: RealtimeWebrtcClientSecret;
249
+ stationary?: boolean;
250
+ lastUpdate?: unknown;
251
+ recentInteractions?: Array<{
252
+ role: WorldInteractionRole;
253
+ text: string;
254
+ at: string;
255
+ seq: number;
256
+ }>;
257
+ zoneCount?: number;
258
+ yieldCount?: number;
259
+ flagged?: boolean;
260
+ onZone?: ZoneEventInfo;
261
+ onYield?: YieldEventInfo;
262
+ };
263
+ /** MCP server shown as a separate map occupant (distinct from LangChain agents). */
264
+ type AgentPlayWorldMapHumanOccupant = {
265
+ kind: "human";
266
+ id: string;
267
+ name: string;
268
+ x: number;
269
+ y: number;
270
+ interactive?: boolean;
271
+ };
272
+ /** MCP server shown as a separate map occupant (distinct from LangChain agents). */
273
+ type AgentPlayWorldMapMcpOccupant = {
274
+ kind: "mcp";
275
+ id: string;
276
+ name: string;
277
+ x: number;
278
+ y: number;
279
+ url?: string;
280
+ };
281
+ type AgentPlaySpaceAmenityKind = "supermarket" | "shop" | "car_wash";
282
+ type AgentPlaySpaceOwner = {
283
+ displayName: string;
284
+ playerId?: string;
285
+ nodeId?: string;
286
+ };
287
+ type AgentPlaySpaceCatalogEntry = {
288
+ id: string;
289
+ name: string;
290
+ description: string;
291
+ designKey: string;
292
+ owner: AgentPlaySpaceOwner;
293
+ amenities: AgentPlaySpaceAmenityKind[];
294
+ activityObjectIds?: string[];
295
+ };
296
+ /** Map anchor linking one or more authored spaces (see {@link AgentPlaySpaceCatalogEntry}). */
297
+ type AgentPlayWorldMapStructureOccupant = {
298
+ kind: "structure";
299
+ id: string;
300
+ name: string;
301
+ x: number;
302
+ y: number;
303
+ worldId: string;
304
+ spaceIds: string[];
305
+ /** When true, the anchor is fixed map furniture (e.g. authored spaces). */
306
+ stationary?: boolean;
307
+ primaryAmenity?: AgentPlaySpaceAmenityKind;
308
+ amenities?: AgentPlaySpaceAmenityKind[];
309
+ };
310
+ /** Spatial index: axis-aligned bounds plus every agent and MCP registration placed on the grid. */
311
+ type AgentPlayWorldMap = {
312
+ bounds: AgentPlayWorldMapBounds;
313
+ occupants: (AgentPlayWorldMapHumanOccupant | AgentPlayWorldMapAgentOccupant | AgentPlayWorldMapMcpOccupant | AgentPlayWorldMapStructureOccupant)[];
314
+ };
315
+ /** Wire shape for seeded world zones (matches server snapshot `worldLayout`). */
316
+ type AgentPlayWorldLayoutZone = {
317
+ id: string;
318
+ streetId: string;
319
+ streetLabel: string;
320
+ rect: AgentPlayWorldMapBounds;
321
+ primaryGroup: "agent" | "space" | "mcp";
322
+ allowedGroups: readonly ("agent" | "space" | "mcp")[];
323
+ };
324
+ type AgentPlayWorldLayout = {
325
+ rev: number;
326
+ bounds: AgentPlayWorldMapBounds;
327
+ zones: AgentPlayWorldLayoutZone[];
328
+ streets: readonly {
329
+ id: string;
330
+ label: string;
331
+ }[];
332
+ };
333
+ /**
334
+ * Session snapshot from {@link RemotePlayWorld.getWorldSnapshot}.
335
+ * Agents and MCP servers appear only under **`worldMap.occupants`** (no separate `players` list).
336
+ */
337
+ type AgentPlaySnapshot = {
338
+ sid: string;
339
+ worldMap: AgentPlayWorldMap;
340
+ worldLayout?: AgentPlayWorldLayout;
341
+ spaces?: AgentPlaySpaceCatalogEntry[];
342
+ mcpServers?: Array<{
343
+ id: string;
344
+ name: string;
345
+ url?: string;
346
+ }>;
347
+ };
348
+ type PlayerChainNotifyNodeRef = {
349
+ stableKey: string;
350
+ leafIndex: number;
351
+ removed?: boolean;
352
+ updatedAt?: string;
353
+ };
354
+ type PlayerChainFanoutNotify = {
355
+ updatedAt: string;
356
+ nodes: PlayerChainNotifyNodeRef[];
357
+ };
358
+ type PlayerChainGenesisStableKey = "__genesis__";
359
+ type PlayerChainHeaderStableKey = "__header__";
360
+ type PlayerChainGenesisNode = {
361
+ kind: "genesis";
362
+ stableKey: PlayerChainGenesisStableKey;
363
+ text: string;
364
+ };
365
+ type PlayerChainHeaderNode = {
366
+ kind: "header";
367
+ stableKey: PlayerChainHeaderStableKey;
368
+ sid: string;
369
+ bounds: AgentPlayWorldMapBounds;
370
+ };
371
+ type PlayerChainOccupantRemovedNode = {
372
+ kind: "occupant";
373
+ stableKey: string;
374
+ removed: true;
375
+ };
376
+ type PlayerChainOccupantPresentNode = {
377
+ kind: "occupant";
378
+ stableKey: string;
379
+ removed: false;
380
+ occupant: AgentPlayWorldMapHumanOccupant | AgentPlayWorldMapAgentOccupant | AgentPlayWorldMapMcpOccupant | AgentPlayWorldMapStructureOccupant;
381
+ };
382
+ type PlayerChainSpaceRemovedNode = {
383
+ kind: "space";
384
+ stableKey: string;
385
+ removed: true;
386
+ };
387
+ type PlayerChainSpacePresentNode = {
388
+ kind: "space";
389
+ stableKey: string;
390
+ removed: false;
391
+ space: AgentPlaySpaceCatalogEntry;
392
+ };
393
+ type PlayerChainNodeResponse = PlayerChainGenesisNode | PlayerChainHeaderNode | PlayerChainOccupantRemovedNode | PlayerChainOccupantPresentNode | PlayerChainSpaceRemovedNode | PlayerChainSpacePresentNode;
394
+ /** Full journey + path update (SSE `world:journey`); coordinates are embedded in `path` steps. */
395
+ type WorldJourneyUpdate = {
396
+ playerId: string;
397
+ journey: Journey;
398
+ path: PositionedStep[];
399
+ };
400
+
401
+ /**
402
+ * Axis-aligned rectangle in world coordinates (grid units). Used by the server to clamp paths
403
+ * and by the watch UI to clamp joystick-driven movement.
404
+ *
405
+ * @remarks **Consumers:** {@link clampWorldPosition}, {@link boundsContain}; server `PlayWorld` and
406
+ * play-ui canvas both import these helpers from `@agent-play/sdk`.
407
+ */
408
+ type WorldBounds = {
409
+ /** Inclusive minimum X. */
410
+ minX: number;
411
+ /** Inclusive minimum Y. */
412
+ minY: number;
413
+ /** Inclusive maximum X. */
414
+ maxX: number;
415
+ /** Inclusive maximum Y. */
416
+ maxY: number;
417
+ };
418
+ /** Minimum playable span aligned with the watch canvas scrolling world (~20×20 cells). */
419
+ declare const MINIMUM_PLAY_WORLD_BOUNDS: WorldBounds;
420
+ /**
421
+ * Default bounds for {@link createVerticalStripSeedLayout} (street / zone map).
422
+ * Shorter on Y than {@link MINIMUM_PLAY_WORLD_BOUNDS}: three vertical strips across span X = 20, height 3.
423
+ */
424
+ declare const MINIMUM_STREET_LAYOUT_BOUNDS: WorldBounds;
425
+ declare function expandBoundsToMinimumPlayArea(bounds: WorldBounds): WorldBounds;
426
+ /**
427
+ * Clamps a point to lie inside `bounds` along both axes.
428
+ *
429
+ * @param p - Position with `x` and `y` in world units.
430
+ * @param bounds - Valid rectangle (`min` ≤ `max` per axis).
431
+ * @returns Same point if inside, otherwise clamped to the nearest edge.
432
+ *
433
+ * @remarks **Callers:** server `PlayWorld` path enrichment; play-ui joystick and preview. **Callees:** `Math.min/Math.max`.
434
+ */
435
+ declare function clampWorldPosition(p: {
436
+ x: number;
437
+ y: number;
438
+ }, bounds: WorldBounds): {
439
+ x: number;
440
+ y: number;
441
+ };
442
+ /**
443
+ * @returns Whether `p` lies inside or on the border of `bounds`.
444
+ *
445
+ * @remarks **Callers:** optional UI checks. **Callees:** none.
446
+ */
447
+ declare function boundsContain(bounds: WorldBounds, p: {
448
+ x: number;
449
+ y: number;
450
+ }): boolean;
451
+
452
+ type OccupancyGridPoint = {
453
+ x: number;
454
+ y: number;
455
+ };
456
+ declare const OCCUPANCY_POINT_MULTIPLIER = 5;
457
+ declare const CONTINUOUS_RENDER_OFFSET = 0.2;
458
+ declare const DEFAULT_AGENT_SPAWN_MIN_DISTANCE = 0.9;
459
+ declare const SPACE_STRUCTURE_ANCHOR_MIN_DISTANCE = 2.1;
460
+ /** @deprecated Prefer {@link WorldLayout} zones from snapshot; quartile geometry is legacy. */
461
+ declare const SPATIAL_ZONE_INDEX_AGENTS = 0;
462
+ /** @deprecated Prefer {@link WorldLayout} zones from snapshot; quartile geometry is legacy. */
463
+ declare const SPATIAL_ZONE_INDEX_SPACES = 2;
464
+ /** @deprecated Prefer layout zone rects; quartile geometry is legacy. */
465
+ declare function spatialZoneBounds(quartileIndex: number): WorldBounds;
466
+ /** @deprecated Prefer {@link centerOfZone} with a layout zone. */
467
+ declare function spatialZoneCenter(quartileIndex: number): OccupancyGridPoint;
468
+ declare function pointCellInRect(wx: number, wy: number, bounds: WorldBounds): boolean;
469
+ declare function listOccupancyPointsInRect(bounds: WorldBounds): readonly OccupancyGridPoint[];
470
+ declare function buildRankedOccupancyPointsInRect(bounds: WorldBounds): OccupancyGridPoint[];
471
+ /** @deprecated Prefer {@link pointCellInZone} with a layout zone. */
472
+ declare function pointCellInSpatialZone(wx: number, wy: number, zoneIndex: number): boolean;
473
+ /** @deprecated Prefer {@link listOccupancyPointsForZone}. */
474
+ declare function listOccupancyPointsForSpatialZone(zoneIndex: number): readonly OccupancyGridPoint[];
475
+ /** @deprecated Prefer {@link occupancyPointsGroupedByZones}. */
476
+ declare function occupancyPointsGroupedBySpatialZone(): readonly (readonly OccupancyGridPoint[])[];
477
+ /** @deprecated Prefer points from the agent primary zone in {@link WorldLayout}. */
478
+ declare function listAllowedOccupancyPoints(): readonly OccupancyGridPoint[];
479
+ declare function occupancyKeyForPosition(x: number, y: number): string;
480
+ /** @deprecated Prefer {@link buildRankedOccupancyPointsForZone}. */
481
+ declare function buildRankedOccupancyPointsForSpatialZone(zoneIndex: number): OccupancyGridPoint[];
482
+ /** Back-compat: agent-zone ranking only. */
483
+ declare function buildRankedOccupancyPoints(): OccupancyGridPoint[];
484
+ declare function boundingWorldRectForOccupancyPoints(points: readonly OccupancyGridPoint[]): {
485
+ minX: number;
486
+ maxX: number;
487
+ minY: number;
488
+ maxY: number;
489
+ } | null;
490
+ declare function isAgentSpawnOccupancyPointAvailableInRect(input: {
491
+ rect: WorldBounds;
492
+ point: OccupancyGridPoint;
493
+ occupiedKeys: ReadonlySet<string>;
494
+ existingOccupants: ReadonlyArray<{
495
+ x: number;
496
+ y: number;
497
+ }>;
498
+ minDistance?: number;
499
+ }): boolean;
500
+ declare function isSpaceAnchorOccupancyPointAvailableInRect(input: {
501
+ rect: WorldBounds;
502
+ point: OccupancyGridPoint;
503
+ occupiedKeys: ReadonlySet<string>;
504
+ existingOccupants: ReadonlyArray<{
505
+ x: number;
506
+ y: number;
507
+ }>;
508
+ structureAnchors: ReadonlyArray<{
509
+ x: number;
510
+ y: number;
511
+ }>;
512
+ minDistance: number;
513
+ structureMinDistance: number;
514
+ }): boolean;
515
+ declare function isAgentSpawnOccupancyPointAvailable(input: {
516
+ point: OccupancyGridPoint;
517
+ occupiedKeys: ReadonlySet<string>;
518
+ existingOccupants: ReadonlyArray<{
519
+ x: number;
520
+ y: number;
521
+ }>;
522
+ minDistance?: number;
523
+ }): boolean;
524
+ declare function isSpaceAnchorOccupancyPointAvailable(input: {
525
+ point: OccupancyGridPoint;
526
+ occupiedKeys: ReadonlySet<string>;
527
+ existingOccupants: ReadonlyArray<{
528
+ x: number;
529
+ y: number;
530
+ }>;
531
+ structureAnchors: ReadonlyArray<{
532
+ x: number;
533
+ y: number;
534
+ }>;
535
+ minDistance: number;
536
+ structureMinDistance: number;
537
+ }): boolean;
538
+
539
+ type StreetPoolEntry = {
540
+ id: string;
541
+ label: string;
542
+ };
543
+ declare const STREET_NAME_POOL: readonly StreetPoolEntry[];
544
+ declare function getStreetPoolEntryById(id: string): StreetPoolEntry | undefined;
545
+
546
+ type OccupantGroup = "agent" | "space" | "mcp";
547
+ type Street = {
548
+ id: string;
549
+ label: string;
550
+ };
551
+ type Zone = {
552
+ id: string;
553
+ streetId: string;
554
+ streetLabel: string;
555
+ rect: WorldBounds;
556
+ primaryGroup: OccupantGroup;
557
+ allowedGroups: readonly OccupantGroup[];
558
+ };
559
+ type WorldLayout = {
560
+ rev: number;
561
+ bounds: WorldBounds;
562
+ zones: readonly Zone[];
563
+ streets: readonly Street[];
564
+ };
565
+ declare function streetFromPoolEntry(entry: StreetPoolEntry): Street;
566
+ declare function zonesForGroup(layout: WorldLayout, group: OccupantGroup): readonly Zone[];
567
+ declare function primaryZoneForGroup(layout: WorldLayout, group: OccupantGroup): Zone | undefined;
568
+ declare function enumerateIntegerCellsInRect(rect: WorldBounds): OccupancyGridPoint[];
569
+ declare function cellsForZone(zone: Zone): readonly OccupancyGridPoint[];
570
+ declare function centerOfZone(zone: Zone): OccupancyGridPoint;
571
+ declare function pointCellInZone(wx: number, wy: number, zone: Zone): boolean;
572
+ declare function listOccupancyPointsForZone(zone: Zone): readonly OccupancyGridPoint[];
573
+ declare function buildRankedOccupancyPointsForZone(zone: Zone): OccupancyGridPoint[];
574
+ declare function occupancyPointsGroupedByZones(layout: WorldLayout): readonly (readonly OccupancyGridPoint[])[];
575
+ declare function nextStreetFromPool(usedStreetIds: ReadonlySet<string>): StreetPoolEntry | undefined;
576
+ declare function pickZoneForGroup(layout: WorldLayout, group: OccupantGroup): Zone;
577
+ declare function availableCellsForZone(zone: Zone, occupiedCellKeys: ReadonlySet<string>): OccupancyGridPoint[];
578
+ declare function isAgentSpawnOccupancyPointAvailableInZone(input: {
579
+ zone: Zone;
580
+ point: OccupancyGridPoint;
581
+ occupiedKeys: ReadonlySet<string>;
582
+ existingOccupants: ReadonlyArray<{
583
+ x: number;
584
+ y: number;
585
+ }>;
586
+ minDistance?: number;
587
+ }): boolean;
588
+ declare function isSpaceAnchorOccupancyPointAvailableInZone(input: {
589
+ zone: Zone;
590
+ point: OccupancyGridPoint;
591
+ occupiedKeys: ReadonlySet<string>;
592
+ existingOccupants: ReadonlyArray<{
593
+ x: number;
594
+ y: number;
595
+ }>;
596
+ structureAnchors: ReadonlyArray<{
597
+ x: number;
598
+ y: number;
599
+ }>;
600
+ minDistance: number;
601
+ structureMinDistance: number;
602
+ }): boolean;
603
+ type WorldLayoutBoundsField = "minX" | "minY" | "maxX" | "maxY";
604
+ declare function migrateWorldLayoutBounds(input: {
605
+ layout: WorldLayout;
606
+ bounds: WorldBounds;
607
+ }): WorldLayout;
608
+ declare function applyBoundsFieldUpdateToLayout(input: {
609
+ layout: WorldLayout;
610
+ field: WorldLayoutBoundsField;
611
+ value: number;
612
+ }): WorldLayout;
613
+ declare function createVerticalStripSeedLayout(input: {
614
+ bounds: WorldBounds;
615
+ streets: readonly [StreetPoolEntry, StreetPoolEntry, StreetPoolEntry];
616
+ }): WorldLayout;
617
+
618
+ /**
619
+ * @packageDocumentation
620
+ * @module @agent-play/sdk/space-content-model
621
+ *
622
+ * Zod schemas and helpers for the **server-authoritative content** a space owns
623
+ * inside each amenity kind, plus the **per-player wallet** that funds purchases.
624
+ *
625
+ * **Scope**
626
+ * - {@link SaleStateSchema}: shared sub-record describing whether an item is
627
+ * still available for purchase or has already been sold (and to whom).
628
+ * - {@link ShopItemSchema}, {@link SupermarketItemSchema}, {@link CarWashCarSchema}:
629
+ * the three amenity-content kinds. Each carries a `sale` block.
630
+ * - {@link PlayerWalletSchema} + {@link createInitialPlayerWallet}: every player
631
+ * starts with **`$70`** ({@link DEFAULT_PLAYER_WALLET_BALANCE_USD}); the wallet
632
+ * is seeded lazily on first read by the server.
633
+ * - {@link PurchaseRecordSchema}: append-only audit row stored per player.
634
+ * - {@link isItemAvailableForPurchase}: pure helper consumed by the `purchase`
635
+ * RPC (server) and the item-tooltip / sprite renderers (client).
636
+ *
637
+ * @see ../../packages/web-ui/src/server/agent-play/session-store.ts for the
638
+ * session-store interface that persists these records.
639
+ * @see ../../packages/web-ui/src/app/api/agent-play/sdk/rpc/route.ts for the
640
+ * RPC handlers that write them.
641
+ */
642
+
643
+ /**
644
+ * Sale state attached to every amenity content record.
645
+ *
646
+ * @remarks
647
+ * Records start as `{ status: "available" }`. The `purchase` RPC flips them
648
+ * to `{ status: "sold", soldToPlayerId, soldAt }` inside a `WATCH`/`MULTI`
649
+ * transaction so concurrent buyers cannot both succeed.
650
+ *
651
+ * @example
652
+ * ```ts
653
+ * SaleStateSchema.parse({ status: "available" });
654
+ * SaleStateSchema.parse({
655
+ * status: "sold",
656
+ * soldToPlayerId: "player-42",
657
+ * soldAt: new Date().toISOString(),
658
+ * });
659
+ * ```
660
+ *
661
+ * @public
662
+ */
663
+ declare const SaleStateSchema: z.ZodObject<{
664
+ status: z.ZodEnum<["available", "sold"]>;
665
+ soldToPlayerId: z.ZodOptional<z.ZodString>;
666
+ soldAt: z.ZodOptional<z.ZodString>;
667
+ }, "strip", z.ZodTypeAny, {
668
+ status: "available" | "sold";
669
+ soldToPlayerId?: string | undefined;
670
+ soldAt?: string | undefined;
671
+ }, {
672
+ status: "available" | "sold";
673
+ soldToPlayerId?: string | undefined;
674
+ soldAt?: string | undefined;
675
+ }>;
676
+ /** Runtime type derived from {@link SaleStateSchema}. @public */
677
+ type SaleState = z.infer<typeof SaleStateSchema>;
678
+ /**
679
+ * Shop amenity item — books, music, coffee.
680
+ *
681
+ * @remarks
682
+ * Inserted by `addShopItem` AQL / RPC. Always starts with
683
+ * `sale.status === "available"`. Client renders this via
684
+ * `sprite-shop-item.ts` and the bookstore amenity stage.
685
+ *
686
+ * @example
687
+ * ```ts
688
+ * ShopItemSchema.parse({
689
+ * id: "shop-1",
690
+ * spaceId: "space-42",
691
+ * type: "book",
692
+ * name: "Hitchhiker's Guide",
693
+ * description: "Don't panic.",
694
+ * priceUsd: 12.5,
695
+ * createdAt: new Date().toISOString(),
696
+ * sale: { status: "available" },
697
+ * });
698
+ * ```
699
+ *
700
+ * @public
701
+ */
702
+ declare const ShopItemSchema: z.ZodObject<{
703
+ id: z.ZodString;
704
+ spaceId: z.ZodString;
705
+ type: z.ZodEnum<["book", "music", "coffee"]>;
706
+ name: z.ZodString;
707
+ description: z.ZodString;
708
+ priceUsd: z.ZodNumber;
709
+ createdAt: z.ZodString;
710
+ sale: z.ZodObject<{
711
+ status: z.ZodEnum<["available", "sold"]>;
712
+ soldToPlayerId: z.ZodOptional<z.ZodString>;
713
+ soldAt: z.ZodOptional<z.ZodString>;
714
+ }, "strip", z.ZodTypeAny, {
715
+ status: "available" | "sold";
716
+ soldToPlayerId?: string | undefined;
717
+ soldAt?: string | undefined;
718
+ }, {
719
+ status: "available" | "sold";
720
+ soldToPlayerId?: string | undefined;
721
+ soldAt?: string | undefined;
722
+ }>;
723
+ }, "strip", z.ZodTypeAny, {
724
+ type: "book" | "music" | "coffee";
725
+ id: string;
726
+ spaceId: string;
727
+ name: string;
728
+ description: string;
729
+ priceUsd: number;
730
+ createdAt: string;
731
+ sale: {
732
+ status: "available" | "sold";
733
+ soldToPlayerId?: string | undefined;
734
+ soldAt?: string | undefined;
735
+ };
736
+ }, {
737
+ type: "book" | "music" | "coffee";
738
+ id: string;
739
+ spaceId: string;
740
+ name: string;
741
+ description: string;
742
+ priceUsd: number;
743
+ createdAt: string;
744
+ sale: {
745
+ status: "available" | "sold";
746
+ soldToPlayerId?: string | undefined;
747
+ soldAt?: string | undefined;
748
+ };
749
+ }>;
750
+ /** Runtime type for {@link ShopItemSchema}. @public */
751
+ type ShopItem = z.infer<typeof ShopItemSchema>;
752
+ /**
753
+ * Supermarket amenity item — laid out on a 4×5 grid of slots.
754
+ *
755
+ * @remarks
756
+ * `row` selects the section (1=Fruits, 2=Mens, 3=Womens, 4=Kids in the
757
+ * client-side stage); `column` is 1..5. If the AQL caller omits `column` the
758
+ * server picks the next free slot in that row.
759
+ *
760
+ * @example
761
+ * ```ts
762
+ * SupermarketItemSchema.parse({
763
+ * id: "sm-1",
764
+ * spaceId: "space-42",
765
+ * row: 1,
766
+ * column: 3,
767
+ * name: "Apple",
768
+ * description: "fresh",
769
+ * priceUsd: 1.25,
770
+ * createdAt: new Date().toISOString(),
771
+ * sale: { status: "available" },
772
+ * });
773
+ * ```
774
+ *
775
+ * @public
776
+ */
777
+ declare const SupermarketItemSchema: z.ZodObject<{
778
+ id: z.ZodString;
779
+ spaceId: z.ZodString;
780
+ row: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
781
+ column: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>]>;
782
+ name: z.ZodString;
783
+ description: z.ZodString;
784
+ priceUsd: z.ZodNumber;
785
+ createdAt: z.ZodString;
786
+ sale: z.ZodObject<{
787
+ status: z.ZodEnum<["available", "sold"]>;
788
+ soldToPlayerId: z.ZodOptional<z.ZodString>;
789
+ soldAt: z.ZodOptional<z.ZodString>;
790
+ }, "strip", z.ZodTypeAny, {
791
+ status: "available" | "sold";
792
+ soldToPlayerId?: string | undefined;
793
+ soldAt?: string | undefined;
794
+ }, {
795
+ status: "available" | "sold";
796
+ soldToPlayerId?: string | undefined;
797
+ soldAt?: string | undefined;
798
+ }>;
799
+ }, "strip", z.ZodTypeAny, {
800
+ id: string;
801
+ spaceId: string;
802
+ name: string;
803
+ description: string;
804
+ priceUsd: number;
805
+ createdAt: string;
806
+ sale: {
807
+ status: "available" | "sold";
808
+ soldToPlayerId?: string | undefined;
809
+ soldAt?: string | undefined;
810
+ };
811
+ row: 2 | 1 | 3 | 4;
812
+ column: 2 | 1 | 5 | 3 | 4;
813
+ }, {
814
+ id: string;
815
+ spaceId: string;
816
+ name: string;
817
+ description: string;
818
+ priceUsd: number;
819
+ createdAt: string;
820
+ sale: {
821
+ status: "available" | "sold";
822
+ soldToPlayerId?: string | undefined;
823
+ soldAt?: string | undefined;
824
+ };
825
+ row: 2 | 1 | 3 | 4;
826
+ column: 2 | 1 | 5 | 3 | 4;
827
+ }>;
828
+ /** Runtime type for {@link SupermarketItemSchema}. @public */
829
+ type SupermarketItem = z.infer<typeof SupermarketItemSchema>;
830
+ /**
831
+ * Car-wash amenity car parked in one of nine slots.
832
+ *
833
+ * @remarks
834
+ * Client renders the car via `sprite-car.ts`, parameterised by `colorHex`.
835
+ * Sold cars flip to a desaturated palette plus a `SOLD` banner overlay.
836
+ *
837
+ * @example
838
+ * ```ts
839
+ * CarWashCarSchema.parse({
840
+ * id: "car-1",
841
+ * spaceId: "space-42",
842
+ * slot: 5,
843
+ * name: "Mustang",
844
+ * model: "GT",
845
+ * year: 2023,
846
+ * priceUsd: 45000,
847
+ * colorHex: "#ff3344",
848
+ * createdAt: new Date().toISOString(),
849
+ * sale: { status: "available" },
850
+ * });
851
+ * ```
852
+ *
853
+ * @public
854
+ */
855
+ declare const CarWashCarSchema: z.ZodObject<{
856
+ id: z.ZodString;
857
+ spaceId: z.ZodString;
858
+ slot: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>, z.ZodLiteral<8>, z.ZodLiteral<9>]>;
859
+ name: z.ZodString;
860
+ model: z.ZodString;
861
+ year: z.ZodNumber;
862
+ priceUsd: z.ZodNumber;
863
+ colorHex: z.ZodString;
864
+ createdAt: z.ZodString;
865
+ sale: z.ZodObject<{
866
+ status: z.ZodEnum<["available", "sold"]>;
867
+ soldToPlayerId: z.ZodOptional<z.ZodString>;
868
+ soldAt: z.ZodOptional<z.ZodString>;
869
+ }, "strip", z.ZodTypeAny, {
870
+ status: "available" | "sold";
871
+ soldToPlayerId?: string | undefined;
872
+ soldAt?: string | undefined;
873
+ }, {
874
+ status: "available" | "sold";
875
+ soldToPlayerId?: string | undefined;
876
+ soldAt?: string | undefined;
877
+ }>;
878
+ }, "strip", z.ZodTypeAny, {
879
+ id: string;
880
+ spaceId: string;
881
+ name: string;
882
+ priceUsd: number;
883
+ createdAt: string;
884
+ sale: {
885
+ status: "available" | "sold";
886
+ soldToPlayerId?: string | undefined;
887
+ soldAt?: string | undefined;
888
+ };
889
+ slot: 2 | 1 | 5 | 3 | 7 | 6 | 4 | 8 | 9;
890
+ model: string;
891
+ year: number;
892
+ colorHex: string;
893
+ }, {
894
+ id: string;
895
+ spaceId: string;
896
+ name: string;
897
+ priceUsd: number;
898
+ createdAt: string;
899
+ sale: {
900
+ status: "available" | "sold";
901
+ soldToPlayerId?: string | undefined;
902
+ soldAt?: string | undefined;
903
+ };
904
+ slot: 2 | 1 | 5 | 3 | 7 | 6 | 4 | 8 | 9;
905
+ model: string;
906
+ year: number;
907
+ colorHex: string;
908
+ }>;
909
+ /** Runtime type for {@link CarWashCarSchema}. @public */
910
+ type CarWashCar = z.infer<typeof CarWashCarSchema>;
911
+ /**
912
+ * Default starting balance, in USD, seeded into every new player wallet.
913
+ *
914
+ * @remarks
915
+ * The session store seeds the wallet lazily on first read via
916
+ * {@link createInitialPlayerWallet} inside an atomic `MULTI`, so two
917
+ * simultaneous first reads still leave the balance at exactly `$70`.
918
+ *
919
+ * @defaultValue 70
920
+ * @public
921
+ */
922
+ declare const DEFAULT_PLAYER_WALLET_BALANCE_USD = 70;
923
+ /**
924
+ * Per-player wallet.
925
+ *
926
+ * @remarks
927
+ * Stored at `agent-play:${hostId}:player:${playerId}:wallet`. Mutated atomically
928
+ * by the `purchase` RPC (decrement) and by the optional AQL `SET WALLET`
929
+ * statement.
930
+ *
931
+ * @public
932
+ */
933
+ declare const PlayerWalletSchema: z.ZodObject<{
934
+ playerId: z.ZodString;
935
+ balanceUsd: z.ZodNumber;
936
+ currency: z.ZodLiteral<"USD">;
937
+ updatedAt: z.ZodString;
938
+ powerUps: z.ZodDefault<z.ZodNumber>;
939
+ }, "strip", z.ZodTypeAny, {
940
+ playerId: string;
941
+ balanceUsd: number;
942
+ currency: "USD";
943
+ updatedAt: string;
944
+ powerUps: number;
945
+ }, {
946
+ playerId: string;
947
+ balanceUsd: number;
948
+ currency: "USD";
949
+ updatedAt: string;
950
+ powerUps?: number | undefined;
951
+ }>;
952
+ /** Runtime type for {@link PlayerWalletSchema}. @public */
953
+ type PlayerWallet = z.infer<typeof PlayerWalletSchema>;
954
+ /**
955
+ * Build a fresh wallet seeded with the {@link DEFAULT_PLAYER_WALLET_BALANCE_USD}
956
+ * balance for an unseen player.
957
+ *
958
+ * @example
959
+ * ```ts
960
+ * const wallet = createInitialPlayerWallet({
961
+ * playerId: "player-42",
962
+ * now: new Date().toISOString(),
963
+ * });
964
+ * // → { playerId: "player-42", balanceUsd: 70, currency: "USD", updatedAt: ... }
965
+ * ```
966
+ *
967
+ * @public
968
+ */
969
+ declare function createInitialPlayerWallet(input: {
970
+ playerId: string;
971
+ now: string;
972
+ }): PlayerWallet;
973
+ declare function createInitialAgentRewardWallet(input: {
974
+ playerId: string;
975
+ now: string;
976
+ }): PlayerWallet;
977
+ /**
978
+ * Audit record appended each time a player completes a purchase.
979
+ *
980
+ * @remarks
981
+ * Stored as a Redis list at `agent-play:${hostId}:player:${playerId}:purchases`
982
+ * with `LPUSH` so the newest entry is at index 0.
983
+ *
984
+ * @public
985
+ */
986
+ declare const PurchaseRecordSchema: z.ZodObject<{
987
+ id: z.ZodString;
988
+ playerId: z.ZodString;
989
+ spaceId: z.ZodString;
990
+ amenityKind: z.ZodEnum<["shop", "supermarket", "car_wash", "talk_time", "wallet_bundle"]>;
991
+ itemRef: z.ZodObject<{
992
+ kind: z.ZodEnum<["shop", "supermarket", "carwash"]>;
993
+ id: z.ZodString;
994
+ }, "strip", z.ZodTypeAny, {
995
+ id: string;
996
+ kind: "supermarket" | "shop" | "carwash";
997
+ }, {
998
+ id: string;
999
+ kind: "supermarket" | "shop" | "carwash";
1000
+ }>;
1001
+ priceUsd: z.ZodNumber;
1002
+ at: z.ZodString;
1003
+ detail: z.ZodOptional<z.ZodString>;
1004
+ powerUpsSpent: z.ZodOptional<z.ZodNumber>;
1005
+ }, "strip", z.ZodTypeAny, {
1006
+ at: string;
1007
+ id: string;
1008
+ spaceId: string;
1009
+ priceUsd: number;
1010
+ playerId: string;
1011
+ amenityKind: "supermarket" | "shop" | "car_wash" | "talk_time" | "wallet_bundle";
1012
+ itemRef: {
1013
+ id: string;
1014
+ kind: "supermarket" | "shop" | "carwash";
1015
+ };
1016
+ detail?: string | undefined;
1017
+ powerUpsSpent?: number | undefined;
1018
+ }, {
1019
+ at: string;
1020
+ id: string;
1021
+ spaceId: string;
1022
+ priceUsd: number;
1023
+ playerId: string;
1024
+ amenityKind: "supermarket" | "shop" | "car_wash" | "talk_time" | "wallet_bundle";
1025
+ itemRef: {
1026
+ id: string;
1027
+ kind: "supermarket" | "shop" | "carwash";
1028
+ };
1029
+ detail?: string | undefined;
1030
+ powerUpsSpent?: number | undefined;
1031
+ }>;
1032
+ /** Runtime type for {@link PurchaseRecordSchema}. @public */
1033
+ type PurchaseRecord = z.infer<typeof PurchaseRecordSchema>;
1034
+ /**
1035
+ * Returns whether an amenity content record can still be purchased.
1036
+ *
1037
+ * @remarks
1038
+ * Server-side, the `purchase` RPC calls this **after** re-reading the item
1039
+ * inside the `WATCH`/`MULTI` block to make the check atomic. Client-side, the
1040
+ * tooltip and sprite renderers call it to decide between the `Buy` button and
1041
+ * the disabled `SOLD` pill.
1042
+ *
1043
+ * @example
1044
+ * ```ts
1045
+ * if (!isItemAvailableForPurchase(item)) {
1046
+ * // render the sold view
1047
+ * }
1048
+ * ```
1049
+ *
1050
+ * @public
1051
+ */
1052
+ declare function isItemAvailableForPurchase(item: {
1053
+ sale: SaleState;
1054
+ }): boolean;
1055
+ /**
1056
+ * Union of all three content kinds, useful for places where the carrier
1057
+ * doesn't need to know the specific amenity.
1058
+ *
1059
+ * @public
1060
+ */
1061
+ type SpaceContentItem = ShopItem | SupermarketItem | CarWashCar;
1062
+ /**
1063
+ * Convert any 24-bit RGB color to its perceptual grey equivalent using the
1064
+ * standard luminance coefficients (`Y = 0.299·R + 0.587·G + 0.114·B`).
1065
+ *
1066
+ * @remarks
1067
+ * Used by every amenity sprite (shop card, grocery item, car) when the
1068
+ * item's `sale.status === 'sold'`. Replacing original fills with the
1069
+ * desaturated grey is the first step of the sold visual treatment;
1070
+ * `drawSoldBadge` then paints the red `SOLD` banner on top.
1071
+ *
1072
+ * The function is bit-pure: it accepts a `0xRRGGBB` integer and returns a
1073
+ * `0xGGGGGG` integer, so it composes cleanly with `pixi.js` color params.
1074
+ *
1075
+ * @example
1076
+ * ```ts
1077
+ * const grey = desaturateColor(0xff3344);
1078
+ * // grey = 0x6e6e6e (approximate)
1079
+ * ```
1080
+ *
1081
+ * @public
1082
+ */
1083
+ declare function desaturateColor(hex: number): number;
1084
+
1085
+ declare const TALK_PRICE_PER_60S_USD = 1.5;
1086
+ declare const TALK_PRICE_PER_SECOND_USD = 0.025;
1087
+ declare const TALK_TICK_SECONDS = 10;
1088
+ declare const costForSeconds: (seconds: number) => number;
1089
+
1090
+ declare const TALK_AGENT_PU_BILLED_SECONDS_PER_UNIT = 10;
1091
+ declare const TALK_AGENT_PU_MAX_PER_LEG = 5;
1092
+ type ComputeTalkAgentPowerUpsEarnedInput = {
1093
+ billedWholeSeconds: number;
1094
+ costUsd: number;
1095
+ };
1096
+ declare const computeTalkAgentPowerUpsEarned: (input: ComputeTalkAgentPowerUpsEarnedInput) => number;
1097
+
1098
+ type WalletBundleId = "bundle-10" | "bundle-20" | "bundle-50" | "bundle-100";
1099
+ type WalletBundleOffer = {
1100
+ readonly id: WalletBundleId;
1101
+ readonly powerUpsCost: number;
1102
+ readonly creditUsd: number;
1103
+ };
1104
+ declare const WALLET_BUNDLE_OFFERS: readonly WalletBundleOffer[];
1105
+ declare const getWalletBundleById: (id: string) => WalletBundleOffer | undefined;
1106
+
1107
+ /**
1108
+ * Parses **`playerChainNotify`** envelopes and merges {@link PlayerChainNodeResponse} slices into {@link AgentPlaySnapshot} (pure functions + fetch ordering for serialized RPC).
1109
+ */
1110
+
1111
+ declare function sortNodeRefsForSerializedFetch(nodes: ReadonlyArray<PlayerChainNotifyNodeRef>): PlayerChainNotifyNodeRef[];
1112
+ declare function parsePlayerChainFanoutNotify(raw: unknown): PlayerChainFanoutNotify | undefined;
1113
+ declare function parsePlayerChainFanoutNotifyFromSsePayload(sseData: unknown): PlayerChainFanoutNotify | undefined;
1114
+ declare function parsePlayerChainNodeRpcBody(json: unknown): PlayerChainNodeResponse;
1115
+ declare function mergeSnapshotWithPlayerChainNode(snapshot: AgentPlaySnapshot, node: PlayerChainNodeResponse): AgentPlaySnapshot;
1116
+
1117
+ declare const PLAYER_CHAIN_GENESIS_STABLE_KEY: "__genesis__";
1118
+ declare const PLAYER_CHAIN_HEADER_STABLE_KEY: "__header__";
1119
+
1120
+ export { SPATIAL_ZONE_INDEX_AGENTS as $, type AgentPlaySnapshot as A, type PlatformAgentInformation as B, CONTINUOUS_RENDER_OFFSET as C, DEFAULT_AGENT_SPAWN_MIN_DISTANCE as D, type PlayAgentInformation as E, type PlayerChainFanoutNotify as F, type PlayerChainGenesisNode as G, type PlayerChainHeaderNode as H, type PlayerChainNotifyNodeRef as I, type Journey as J, type PlayerChainOccupantPresentNode as K, type LangChainAgentRegistration as L, MINIMUM_PLAY_WORLD_BOUNDS as M, type PlayerChainOccupantRemovedNode as N, OCCUPANCY_POINT_MULTIPLIER as O, type PlayerChainNodeResponse as P, type PlayerWallet as Q, type RemotePlayWorldInitAudioOptions as R, PlayerWalletSchema as S, type PositionedStep as T, type PurchaseRecord as U, PurchaseRecordSchema as V, type WorldInteractionRole as W, type RealtimeWebrtcClientSecret as X, type RegisteredAgentSummary as Y, type RemotePlayWorldOpenAiAudioOptions as Z, SPACE_STRUCTURE_ANCHOR_MIN_DISTANCE as _, type AddAgentInput as a, occupancyPointsGroupedBySpatialZone as a$, SPATIAL_ZONE_INDEX_SPACES as a0, STREET_NAME_POOL as a1, type SaleState as a2, SaleStateSchema as a3, type ShopItem as a4, ShopItemSchema as a5, type SpaceContentItem as a6, type Street as a7, type StreetPoolEntry as a8, type StructureJourneyStep as a9, centerOfZone as aA, clampWorldPosition as aB, computeTalkAgentPowerUpsEarned as aC, costForSeconds as aD, createInitialAgentRewardWallet as aE, createInitialPlayerWallet as aF, createVerticalStripSeedLayout as aG, desaturateColor as aH, enumerateIntegerCellsInRect as aI, expandBoundsToMinimumPlayArea as aJ, getStreetPoolEntryById as aK, getWalletBundleById as aL, isAgentSpawnOccupancyPointAvailable as aM, isAgentSpawnOccupancyPointAvailableInRect as aN, isAgentSpawnOccupancyPointAvailableInZone as aO, isItemAvailableForPurchase as aP, isSpaceAnchorOccupancyPointAvailable as aQ, isSpaceAnchorOccupancyPointAvailableInRect as aR, isSpaceAnchorOccupancyPointAvailableInZone as aS, listAllowedOccupancyPoints as aT, listOccupancyPointsForSpatialZone as aU, listOccupancyPointsForZone as aV, listOccupancyPointsInRect as aW, mergeSnapshotWithPlayerChainNode as aX, migrateWorldLayoutBounds as aY, nextStreetFromPool as aZ, occupancyKeyForPosition as a_, type SupermarketItem as aa, SupermarketItemSchema as ab, TALK_AGENT_PU_BILLED_SECONDS_PER_UNIT as ac, TALK_AGENT_PU_MAX_PER_LEG as ad, TALK_PRICE_PER_60S_USD as ae, TALK_PRICE_PER_SECOND_USD as af, TALK_TICK_SECONDS as ag, WALLET_BUNDLE_OFFERS as ah, type WalletBundleId as ai, type WalletBundleOffer as aj, type WorldBounds as ak, type WorldJourneyUpdate as al, type WorldLayout as am, type WorldLayoutBoundsField as an, type YieldEventInfo as ao, type Zone as ap, type ZoneEventInfo as aq, applyBoundsFieldUpdateToLayout as ar, availableCellsForZone as as, boundingWorldRectForOccupancyPoints as at, boundsContain as au, buildRankedOccupancyPoints as av, buildRankedOccupancyPointsForSpatialZone as aw, buildRankedOccupancyPointsForZone as ax, buildRankedOccupancyPointsInRect as ay, cellsForZone as az, type RegisteredPlayer as b, occupancyPointsGroupedByZones as b0, parsePlayerChainFanoutNotify as b1, parsePlayerChainFanoutNotifyFromSsePayload as b2, parsePlayerChainNodeRpcBody as b3, pickZoneForGroup as b4, pointCellInRect as b5, pointCellInSpatialZone as b6, pointCellInZone as b7, primaryZoneForGroup as b8, sortNodeRefsForSerializedFetch as b9, spatialZoneBounds as ba, spatialZoneCenter as bb, streetFromPoolEntry as bc, zonesForGroup as bd, type AddPlayerInput as c, type RecordInteractionInput as d, type AgentPlayWorldLayout as e, type AgentPlayWorldLayoutZone as f, type AgentPlayWorldMap as g, type AgentPlayWorldMapAgentOccupant as h, type AgentPlayWorldMapBounds as i, type AgentPlayWorldMapMcpOccupant as j, type AssistToolFieldType as k, type AssistToolParameterSpec as l, type AssistToolSpec as m, type CarWashCar as n, CarWashCarSchema as o, type ComputeTalkAgentPowerUpsEarnedInput as p, DEFAULT_PLAYER_WALLET_BALANCE_USD as q, type DestinationJourneyStep as r, type JourneyStep as s, MINIMUM_STREET_LAYOUT_BOUNDS as t, type OccupancyGridPoint as u, type OccupantGroup as v, type OriginJourneyStep as w, type P2aEnableFlag as x, PLAYER_CHAIN_GENESIS_STABLE_KEY as y, PLAYER_CHAIN_HEADER_STABLE_KEY as z };