@agent-play/sdk 3.2.2 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/browser-Dpx-0L8A.d.ts +1078 -0
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +107 -3
- package/dist/chunk-VWC7EE2F.js +5104 -0
- package/dist/chunk-VWC7EE2F.js.map +1 -0
- package/dist/index.d.ts +15 -10
- package/dist/index.js +200 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser-CD0Fu-zr.d.ts +0 -387
- package/dist/chunk-U2M7HNYN.js +0 -303
- package/dist/chunk-U2M7HNYN.js.map +0 -1
|
@@ -0,0 +1,1078 @@
|
|
|
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. Coordinates are grid positions; the server enforces unique `(x,y)` per occupant.
|
|
229
|
+
*/
|
|
230
|
+
type AgentPlayWorldMapAgentOccupant = {
|
|
231
|
+
kind: "agent";
|
|
232
|
+
nodeId?: string;
|
|
233
|
+
agentId: string;
|
|
234
|
+
name: string;
|
|
235
|
+
x: number;
|
|
236
|
+
y: number;
|
|
237
|
+
/**
|
|
238
|
+
* 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.
|
|
239
|
+
*/
|
|
240
|
+
platform?: string;
|
|
241
|
+
toolNames?: string[];
|
|
242
|
+
assistToolNames?: string[];
|
|
243
|
+
assistTools?: AssistToolSpec[];
|
|
244
|
+
hasChatTool?: boolean;
|
|
245
|
+
enableP2a?: P2aEnableFlag;
|
|
246
|
+
realtimeInstructions?: string;
|
|
247
|
+
realtimeWebrtc?: RealtimeWebrtcClientSecret;
|
|
248
|
+
stationary?: boolean;
|
|
249
|
+
lastUpdate?: unknown;
|
|
250
|
+
recentInteractions?: Array<{
|
|
251
|
+
role: WorldInteractionRole;
|
|
252
|
+
text: string;
|
|
253
|
+
at: string;
|
|
254
|
+
seq: number;
|
|
255
|
+
}>;
|
|
256
|
+
zoneCount?: number;
|
|
257
|
+
yieldCount?: number;
|
|
258
|
+
flagged?: boolean;
|
|
259
|
+
onZone?: ZoneEventInfo;
|
|
260
|
+
onYield?: YieldEventInfo;
|
|
261
|
+
};
|
|
262
|
+
/** MCP server shown as a separate map occupant (distinct from LangChain agents). */
|
|
263
|
+
type AgentPlayWorldMapHumanOccupant = {
|
|
264
|
+
kind: "human";
|
|
265
|
+
id: string;
|
|
266
|
+
name: string;
|
|
267
|
+
x: number;
|
|
268
|
+
y: number;
|
|
269
|
+
interactive?: boolean;
|
|
270
|
+
};
|
|
271
|
+
/** MCP server shown as a separate map occupant (distinct from LangChain agents). */
|
|
272
|
+
type AgentPlayWorldMapMcpOccupant = {
|
|
273
|
+
kind: "mcp";
|
|
274
|
+
id: string;
|
|
275
|
+
name: string;
|
|
276
|
+
x: number;
|
|
277
|
+
y: number;
|
|
278
|
+
url?: string;
|
|
279
|
+
};
|
|
280
|
+
type AgentPlaySpaceAmenityKind = "supermarket" | "shop" | "car_wash";
|
|
281
|
+
type AgentPlaySpaceOwner = {
|
|
282
|
+
displayName: string;
|
|
283
|
+
playerId?: string;
|
|
284
|
+
nodeId?: string;
|
|
285
|
+
};
|
|
286
|
+
type AgentPlaySpaceCatalogEntry = {
|
|
287
|
+
id: string;
|
|
288
|
+
name: string;
|
|
289
|
+
description: string;
|
|
290
|
+
designKey: string;
|
|
291
|
+
owner: AgentPlaySpaceOwner;
|
|
292
|
+
amenities: AgentPlaySpaceAmenityKind[];
|
|
293
|
+
activityObjectIds?: string[];
|
|
294
|
+
};
|
|
295
|
+
/** Map anchor linking one or more authored spaces (see {@link AgentPlaySpaceCatalogEntry}). */
|
|
296
|
+
type AgentPlayWorldMapStructureOccupant = {
|
|
297
|
+
kind: "structure";
|
|
298
|
+
id: string;
|
|
299
|
+
name: string;
|
|
300
|
+
x: number;
|
|
301
|
+
y: number;
|
|
302
|
+
worldId: string;
|
|
303
|
+
spaceIds: string[];
|
|
304
|
+
/** When true, the anchor is fixed map furniture (e.g. authored spaces). */
|
|
305
|
+
stationary?: boolean;
|
|
306
|
+
primaryAmenity?: AgentPlaySpaceAmenityKind;
|
|
307
|
+
amenities?: AgentPlaySpaceAmenityKind[];
|
|
308
|
+
};
|
|
309
|
+
/** Spatial index: axis-aligned bounds plus every agent and MCP registration placed on the grid. */
|
|
310
|
+
type AgentPlayWorldMap = {
|
|
311
|
+
bounds: AgentPlayWorldMapBounds;
|
|
312
|
+
occupants: (AgentPlayWorldMapHumanOccupant | AgentPlayWorldMapAgentOccupant | AgentPlayWorldMapMcpOccupant | AgentPlayWorldMapStructureOccupant)[];
|
|
313
|
+
};
|
|
314
|
+
/** Wire shape for seeded world zones (matches server snapshot `worldLayout`). */
|
|
315
|
+
type AgentPlayWorldLayoutZone = {
|
|
316
|
+
id: string;
|
|
317
|
+
streetId: string;
|
|
318
|
+
streetLabel: string;
|
|
319
|
+
rect: AgentPlayWorldMapBounds;
|
|
320
|
+
primaryGroup: "agent" | "space" | "mcp";
|
|
321
|
+
allowedGroups: readonly ("agent" | "space" | "mcp")[];
|
|
322
|
+
};
|
|
323
|
+
type AgentPlayWorldLayout = {
|
|
324
|
+
rev: number;
|
|
325
|
+
bounds: AgentPlayWorldMapBounds;
|
|
326
|
+
zones: AgentPlayWorldLayoutZone[];
|
|
327
|
+
streets: readonly {
|
|
328
|
+
id: string;
|
|
329
|
+
label: string;
|
|
330
|
+
}[];
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Session snapshot from {@link RemotePlayWorld.getWorldSnapshot}.
|
|
334
|
+
* Agents and MCP servers appear only under **`worldMap.occupants`** (no separate `players` list).
|
|
335
|
+
*/
|
|
336
|
+
type AgentPlaySnapshot = {
|
|
337
|
+
sid: string;
|
|
338
|
+
worldMap: AgentPlayWorldMap;
|
|
339
|
+
worldLayout?: AgentPlayWorldLayout;
|
|
340
|
+
spaces?: AgentPlaySpaceCatalogEntry[];
|
|
341
|
+
mcpServers?: Array<{
|
|
342
|
+
id: string;
|
|
343
|
+
name: string;
|
|
344
|
+
url?: string;
|
|
345
|
+
}>;
|
|
346
|
+
};
|
|
347
|
+
type PlayerChainNotifyNodeRef = {
|
|
348
|
+
stableKey: string;
|
|
349
|
+
leafIndex: number;
|
|
350
|
+
removed?: boolean;
|
|
351
|
+
updatedAt?: string;
|
|
352
|
+
};
|
|
353
|
+
type PlayerChainFanoutNotify = {
|
|
354
|
+
updatedAt: string;
|
|
355
|
+
nodes: PlayerChainNotifyNodeRef[];
|
|
356
|
+
};
|
|
357
|
+
type PlayerChainGenesisStableKey = "__genesis__";
|
|
358
|
+
type PlayerChainHeaderStableKey = "__header__";
|
|
359
|
+
type PlayerChainGenesisNode = {
|
|
360
|
+
kind: "genesis";
|
|
361
|
+
stableKey: PlayerChainGenesisStableKey;
|
|
362
|
+
text: string;
|
|
363
|
+
};
|
|
364
|
+
type PlayerChainHeaderNode = {
|
|
365
|
+
kind: "header";
|
|
366
|
+
stableKey: PlayerChainHeaderStableKey;
|
|
367
|
+
sid: string;
|
|
368
|
+
bounds: AgentPlayWorldMapBounds;
|
|
369
|
+
};
|
|
370
|
+
type PlayerChainOccupantRemovedNode = {
|
|
371
|
+
kind: "occupant";
|
|
372
|
+
stableKey: string;
|
|
373
|
+
removed: true;
|
|
374
|
+
};
|
|
375
|
+
type PlayerChainOccupantPresentNode = {
|
|
376
|
+
kind: "occupant";
|
|
377
|
+
stableKey: string;
|
|
378
|
+
removed: false;
|
|
379
|
+
occupant: AgentPlayWorldMapHumanOccupant | AgentPlayWorldMapAgentOccupant | AgentPlayWorldMapMcpOccupant | AgentPlayWorldMapStructureOccupant;
|
|
380
|
+
};
|
|
381
|
+
type PlayerChainSpaceRemovedNode = {
|
|
382
|
+
kind: "space";
|
|
383
|
+
stableKey: string;
|
|
384
|
+
removed: true;
|
|
385
|
+
};
|
|
386
|
+
type PlayerChainSpacePresentNode = {
|
|
387
|
+
kind: "space";
|
|
388
|
+
stableKey: string;
|
|
389
|
+
removed: false;
|
|
390
|
+
space: AgentPlaySpaceCatalogEntry;
|
|
391
|
+
};
|
|
392
|
+
type PlayerChainNodeResponse = PlayerChainGenesisNode | PlayerChainHeaderNode | PlayerChainOccupantRemovedNode | PlayerChainOccupantPresentNode | PlayerChainSpaceRemovedNode | PlayerChainSpacePresentNode;
|
|
393
|
+
/** Full journey + path update (SSE `world:journey`); coordinates are embedded in `path` steps. */
|
|
394
|
+
type WorldJourneyUpdate = {
|
|
395
|
+
playerId: string;
|
|
396
|
+
journey: Journey;
|
|
397
|
+
path: PositionedStep[];
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Axis-aligned rectangle in world coordinates (grid units). Used by the server to clamp paths
|
|
402
|
+
* and by the watch UI to clamp joystick-driven movement.
|
|
403
|
+
*
|
|
404
|
+
* @remarks **Consumers:** {@link clampWorldPosition}, {@link boundsContain}; server `PlayWorld` and
|
|
405
|
+
* play-ui canvas both import these helpers from `@agent-play/sdk`.
|
|
406
|
+
*/
|
|
407
|
+
type WorldBounds = {
|
|
408
|
+
/** Inclusive minimum X. */
|
|
409
|
+
minX: number;
|
|
410
|
+
/** Inclusive minimum Y. */
|
|
411
|
+
minY: number;
|
|
412
|
+
/** Inclusive maximum X. */
|
|
413
|
+
maxX: number;
|
|
414
|
+
/** Inclusive maximum Y. */
|
|
415
|
+
maxY: number;
|
|
416
|
+
};
|
|
417
|
+
/** Minimum playable span aligned with the watch canvas scrolling world (~20×20 cells). */
|
|
418
|
+
declare const MINIMUM_PLAY_WORLD_BOUNDS: WorldBounds;
|
|
419
|
+
declare function expandBoundsToMinimumPlayArea(bounds: WorldBounds): WorldBounds;
|
|
420
|
+
/**
|
|
421
|
+
* Clamps a point to lie inside `bounds` along both axes.
|
|
422
|
+
*
|
|
423
|
+
* @param p - Position with `x` and `y` in world units.
|
|
424
|
+
* @param bounds - Valid rectangle (`min` ≤ `max` per axis).
|
|
425
|
+
* @returns Same point if inside, otherwise clamped to the nearest edge.
|
|
426
|
+
*
|
|
427
|
+
* @remarks **Callers:** server `PlayWorld` path enrichment; play-ui joystick and preview. **Callees:** `Math.min/Math.max`.
|
|
428
|
+
*/
|
|
429
|
+
declare function clampWorldPosition(p: {
|
|
430
|
+
x: number;
|
|
431
|
+
y: number;
|
|
432
|
+
}, bounds: WorldBounds): {
|
|
433
|
+
x: number;
|
|
434
|
+
y: number;
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* @returns Whether `p` lies inside or on the border of `bounds`.
|
|
438
|
+
*
|
|
439
|
+
* @remarks **Callers:** optional UI checks. **Callees:** none.
|
|
440
|
+
*/
|
|
441
|
+
declare function boundsContain(bounds: WorldBounds, p: {
|
|
442
|
+
x: number;
|
|
443
|
+
y: number;
|
|
444
|
+
}): boolean;
|
|
445
|
+
|
|
446
|
+
type OccupancyGridPoint = {
|
|
447
|
+
x: number;
|
|
448
|
+
y: number;
|
|
449
|
+
};
|
|
450
|
+
declare const OCCUPANCY_POINT_MULTIPLIER = 5;
|
|
451
|
+
declare const CONTINUOUS_RENDER_OFFSET = 0.2;
|
|
452
|
+
declare const DEFAULT_AGENT_SPAWN_MIN_DISTANCE = 0.9;
|
|
453
|
+
/** @deprecated Prefer {@link WorldLayout} zones from snapshot; quartile geometry is legacy. */
|
|
454
|
+
declare const SPATIAL_ZONE_INDEX_AGENTS = 0;
|
|
455
|
+
/** @deprecated Prefer {@link WorldLayout} zones from snapshot; quartile geometry is legacy. */
|
|
456
|
+
declare const SPATIAL_ZONE_INDEX_SPACES = 2;
|
|
457
|
+
/** @deprecated Prefer layout zone rects; quartile geometry is legacy. */
|
|
458
|
+
declare function spatialZoneBounds(quartileIndex: number): WorldBounds;
|
|
459
|
+
/** @deprecated Prefer {@link centerOfZone} with a layout zone. */
|
|
460
|
+
declare function spatialZoneCenter(quartileIndex: number): OccupancyGridPoint;
|
|
461
|
+
declare function pointCellInRect(wx: number, wy: number, bounds: WorldBounds): boolean;
|
|
462
|
+
declare function listOccupancyPointsInRect(bounds: WorldBounds): readonly OccupancyGridPoint[];
|
|
463
|
+
declare function buildRankedOccupancyPointsInRect(bounds: WorldBounds): OccupancyGridPoint[];
|
|
464
|
+
/** @deprecated Prefer {@link pointCellInZone} with a layout zone. */
|
|
465
|
+
declare function pointCellInSpatialZone(wx: number, wy: number, zoneIndex: number): boolean;
|
|
466
|
+
/** @deprecated Prefer {@link listOccupancyPointsForZone}. */
|
|
467
|
+
declare function listOccupancyPointsForSpatialZone(zoneIndex: number): readonly OccupancyGridPoint[];
|
|
468
|
+
/** @deprecated Prefer {@link occupancyPointsGroupedByZones}. */
|
|
469
|
+
declare function occupancyPointsGroupedBySpatialZone(): readonly (readonly OccupancyGridPoint[])[];
|
|
470
|
+
/** @deprecated Prefer points from the agent primary zone in {@link WorldLayout}. */
|
|
471
|
+
declare function listAllowedOccupancyPoints(): readonly OccupancyGridPoint[];
|
|
472
|
+
declare function occupancyKeyForPosition(x: number, y: number): string;
|
|
473
|
+
/** @deprecated Prefer {@link buildRankedOccupancyPointsForZone}. */
|
|
474
|
+
declare function buildRankedOccupancyPointsForSpatialZone(zoneIndex: number): OccupancyGridPoint[];
|
|
475
|
+
/** Back-compat: agent-zone ranking only. */
|
|
476
|
+
declare function buildRankedOccupancyPoints(): OccupancyGridPoint[];
|
|
477
|
+
declare function boundingWorldRectForOccupancyPoints(points: readonly OccupancyGridPoint[]): {
|
|
478
|
+
minX: number;
|
|
479
|
+
maxX: number;
|
|
480
|
+
minY: number;
|
|
481
|
+
maxY: number;
|
|
482
|
+
} | null;
|
|
483
|
+
declare function isAgentSpawnOccupancyPointAvailableInRect(input: {
|
|
484
|
+
rect: WorldBounds;
|
|
485
|
+
point: OccupancyGridPoint;
|
|
486
|
+
occupiedKeys: ReadonlySet<string>;
|
|
487
|
+
existingOccupants: ReadonlyArray<{
|
|
488
|
+
x: number;
|
|
489
|
+
y: number;
|
|
490
|
+
}>;
|
|
491
|
+
minDistance?: number;
|
|
492
|
+
}): boolean;
|
|
493
|
+
declare function isSpaceAnchorOccupancyPointAvailableInRect(input: {
|
|
494
|
+
rect: WorldBounds;
|
|
495
|
+
point: OccupancyGridPoint;
|
|
496
|
+
occupiedKeys: ReadonlySet<string>;
|
|
497
|
+
existingOccupants: ReadonlyArray<{
|
|
498
|
+
x: number;
|
|
499
|
+
y: number;
|
|
500
|
+
}>;
|
|
501
|
+
structureAnchors: ReadonlyArray<{
|
|
502
|
+
x: number;
|
|
503
|
+
y: number;
|
|
504
|
+
}>;
|
|
505
|
+
minDistance: number;
|
|
506
|
+
structureMinDistance: number;
|
|
507
|
+
}): boolean;
|
|
508
|
+
declare function isAgentSpawnOccupancyPointAvailable(input: {
|
|
509
|
+
point: OccupancyGridPoint;
|
|
510
|
+
occupiedKeys: ReadonlySet<string>;
|
|
511
|
+
existingOccupants: ReadonlyArray<{
|
|
512
|
+
x: number;
|
|
513
|
+
y: number;
|
|
514
|
+
}>;
|
|
515
|
+
minDistance?: number;
|
|
516
|
+
}): boolean;
|
|
517
|
+
declare function isSpaceAnchorOccupancyPointAvailable(input: {
|
|
518
|
+
point: OccupancyGridPoint;
|
|
519
|
+
occupiedKeys: ReadonlySet<string>;
|
|
520
|
+
existingOccupants: ReadonlyArray<{
|
|
521
|
+
x: number;
|
|
522
|
+
y: number;
|
|
523
|
+
}>;
|
|
524
|
+
structureAnchors: ReadonlyArray<{
|
|
525
|
+
x: number;
|
|
526
|
+
y: number;
|
|
527
|
+
}>;
|
|
528
|
+
minDistance: number;
|
|
529
|
+
structureMinDistance: number;
|
|
530
|
+
}): boolean;
|
|
531
|
+
|
|
532
|
+
type StreetPoolEntry = {
|
|
533
|
+
id: string;
|
|
534
|
+
label: string;
|
|
535
|
+
};
|
|
536
|
+
declare const STREET_NAME_POOL: readonly StreetPoolEntry[];
|
|
537
|
+
declare function getStreetPoolEntryById(id: string): StreetPoolEntry | undefined;
|
|
538
|
+
|
|
539
|
+
type OccupantGroup = "agent" | "space" | "mcp";
|
|
540
|
+
type Street = {
|
|
541
|
+
id: string;
|
|
542
|
+
label: string;
|
|
543
|
+
};
|
|
544
|
+
type Zone = {
|
|
545
|
+
id: string;
|
|
546
|
+
streetId: string;
|
|
547
|
+
streetLabel: string;
|
|
548
|
+
rect: WorldBounds;
|
|
549
|
+
primaryGroup: OccupantGroup;
|
|
550
|
+
allowedGroups: readonly OccupantGroup[];
|
|
551
|
+
};
|
|
552
|
+
type WorldLayout = {
|
|
553
|
+
rev: number;
|
|
554
|
+
bounds: WorldBounds;
|
|
555
|
+
zones: readonly Zone[];
|
|
556
|
+
streets: readonly Street[];
|
|
557
|
+
};
|
|
558
|
+
declare function streetFromPoolEntry(entry: StreetPoolEntry): Street;
|
|
559
|
+
declare function zonesForGroup(layout: WorldLayout, group: OccupantGroup): readonly Zone[];
|
|
560
|
+
declare function primaryZoneForGroup(layout: WorldLayout, group: OccupantGroup): Zone | undefined;
|
|
561
|
+
declare function enumerateIntegerCellsInRect(rect: WorldBounds): OccupancyGridPoint[];
|
|
562
|
+
declare function cellsForZone(zone: Zone): readonly OccupancyGridPoint[];
|
|
563
|
+
declare function centerOfZone(zone: Zone): OccupancyGridPoint;
|
|
564
|
+
declare function pointCellInZone(wx: number, wy: number, zone: Zone): boolean;
|
|
565
|
+
declare function listOccupancyPointsForZone(zone: Zone): readonly OccupancyGridPoint[];
|
|
566
|
+
declare function buildRankedOccupancyPointsForZone(zone: Zone): OccupancyGridPoint[];
|
|
567
|
+
declare function occupancyPointsGroupedByZones(layout: WorldLayout): readonly (readonly OccupancyGridPoint[])[];
|
|
568
|
+
declare function nextStreetFromPool(usedStreetIds: ReadonlySet<string>): StreetPoolEntry | undefined;
|
|
569
|
+
declare function pickZoneForGroup(layout: WorldLayout, group: OccupantGroup): Zone;
|
|
570
|
+
declare function availableCellsForZone(zone: Zone, occupiedCellKeys: ReadonlySet<string>): OccupancyGridPoint[];
|
|
571
|
+
declare function isAgentSpawnOccupancyPointAvailableInZone(input: {
|
|
572
|
+
zone: Zone;
|
|
573
|
+
point: OccupancyGridPoint;
|
|
574
|
+
occupiedKeys: ReadonlySet<string>;
|
|
575
|
+
existingOccupants: ReadonlyArray<{
|
|
576
|
+
x: number;
|
|
577
|
+
y: number;
|
|
578
|
+
}>;
|
|
579
|
+
minDistance?: number;
|
|
580
|
+
}): boolean;
|
|
581
|
+
declare function isSpaceAnchorOccupancyPointAvailableInZone(input: {
|
|
582
|
+
zone: Zone;
|
|
583
|
+
point: OccupancyGridPoint;
|
|
584
|
+
occupiedKeys: ReadonlySet<string>;
|
|
585
|
+
existingOccupants: ReadonlyArray<{
|
|
586
|
+
x: number;
|
|
587
|
+
y: number;
|
|
588
|
+
}>;
|
|
589
|
+
structureAnchors: ReadonlyArray<{
|
|
590
|
+
x: number;
|
|
591
|
+
y: number;
|
|
592
|
+
}>;
|
|
593
|
+
minDistance: number;
|
|
594
|
+
structureMinDistance: number;
|
|
595
|
+
}): boolean;
|
|
596
|
+
type WorldLayoutBoundsField = "minX" | "minY" | "maxX" | "maxY";
|
|
597
|
+
declare function migrateWorldLayoutBounds(input: {
|
|
598
|
+
layout: WorldLayout;
|
|
599
|
+
bounds: WorldBounds;
|
|
600
|
+
}): WorldLayout;
|
|
601
|
+
declare function applyBoundsFieldUpdateToLayout(input: {
|
|
602
|
+
layout: WorldLayout;
|
|
603
|
+
field: WorldLayoutBoundsField;
|
|
604
|
+
value: number;
|
|
605
|
+
}): WorldLayout;
|
|
606
|
+
declare function createVerticalStripSeedLayout(input: {
|
|
607
|
+
bounds: WorldBounds;
|
|
608
|
+
streets: readonly [StreetPoolEntry, StreetPoolEntry, StreetPoolEntry];
|
|
609
|
+
}): WorldLayout;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* @packageDocumentation
|
|
613
|
+
* @module @agent-play/sdk/space-content-model
|
|
614
|
+
*
|
|
615
|
+
* Zod schemas and helpers for the **server-authoritative content** a space owns
|
|
616
|
+
* inside each amenity kind, plus the **per-player wallet** that funds purchases.
|
|
617
|
+
*
|
|
618
|
+
* **Scope**
|
|
619
|
+
* - {@link SaleStateSchema}: shared sub-record describing whether an item is
|
|
620
|
+
* still available for purchase or has already been sold (and to whom).
|
|
621
|
+
* - {@link ShopItemSchema}, {@link SupermarketItemSchema}, {@link CarWashCarSchema}:
|
|
622
|
+
* the three amenity-content kinds. Each carries a `sale` block.
|
|
623
|
+
* - {@link PlayerWalletSchema} + {@link createInitialPlayerWallet}: every player
|
|
624
|
+
* starts with **`$70`** ({@link DEFAULT_PLAYER_WALLET_BALANCE_USD}); the wallet
|
|
625
|
+
* is seeded lazily on first read by the server.
|
|
626
|
+
* - {@link PurchaseRecordSchema}: append-only audit row stored per player.
|
|
627
|
+
* - {@link isItemAvailableForPurchase}: pure helper consumed by the `purchase`
|
|
628
|
+
* RPC (server) and the item-tooltip / sprite renderers (client).
|
|
629
|
+
*
|
|
630
|
+
* @see ../../packages/web-ui/src/server/agent-play/session-store.ts for the
|
|
631
|
+
* session-store interface that persists these records.
|
|
632
|
+
* @see ../../packages/web-ui/src/app/api/agent-play/sdk/rpc/route.ts for the
|
|
633
|
+
* RPC handlers that write them.
|
|
634
|
+
*/
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Sale state attached to every amenity content record.
|
|
638
|
+
*
|
|
639
|
+
* @remarks
|
|
640
|
+
* Records start as `{ status: "available" }`. The `purchase` RPC flips them
|
|
641
|
+
* to `{ status: "sold", soldToPlayerId, soldAt }` inside a `WATCH`/`MULTI`
|
|
642
|
+
* transaction so concurrent buyers cannot both succeed.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```ts
|
|
646
|
+
* SaleStateSchema.parse({ status: "available" });
|
|
647
|
+
* SaleStateSchema.parse({
|
|
648
|
+
* status: "sold",
|
|
649
|
+
* soldToPlayerId: "player-42",
|
|
650
|
+
* soldAt: new Date().toISOString(),
|
|
651
|
+
* });
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* @public
|
|
655
|
+
*/
|
|
656
|
+
declare const SaleStateSchema: z.ZodObject<{
|
|
657
|
+
status: z.ZodEnum<["available", "sold"]>;
|
|
658
|
+
soldToPlayerId: z.ZodOptional<z.ZodString>;
|
|
659
|
+
soldAt: z.ZodOptional<z.ZodString>;
|
|
660
|
+
}, "strip", z.ZodTypeAny, {
|
|
661
|
+
status: "available" | "sold";
|
|
662
|
+
soldToPlayerId?: string | undefined;
|
|
663
|
+
soldAt?: string | undefined;
|
|
664
|
+
}, {
|
|
665
|
+
status: "available" | "sold";
|
|
666
|
+
soldToPlayerId?: string | undefined;
|
|
667
|
+
soldAt?: string | undefined;
|
|
668
|
+
}>;
|
|
669
|
+
/** Runtime type derived from {@link SaleStateSchema}. @public */
|
|
670
|
+
type SaleState = z.infer<typeof SaleStateSchema>;
|
|
671
|
+
/**
|
|
672
|
+
* Shop amenity item — books, music, coffee.
|
|
673
|
+
*
|
|
674
|
+
* @remarks
|
|
675
|
+
* Inserted by `addShopItem` AQL / RPC. Always starts with
|
|
676
|
+
* `sale.status === "available"`. Client renders this via
|
|
677
|
+
* `sprite-shop-item.ts` and the bookstore amenity stage.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```ts
|
|
681
|
+
* ShopItemSchema.parse({
|
|
682
|
+
* id: "shop-1",
|
|
683
|
+
* spaceId: "space-42",
|
|
684
|
+
* type: "book",
|
|
685
|
+
* name: "Hitchhiker's Guide",
|
|
686
|
+
* description: "Don't panic.",
|
|
687
|
+
* priceUsd: 12.5,
|
|
688
|
+
* createdAt: new Date().toISOString(),
|
|
689
|
+
* sale: { status: "available" },
|
|
690
|
+
* });
|
|
691
|
+
* ```
|
|
692
|
+
*
|
|
693
|
+
* @public
|
|
694
|
+
*/
|
|
695
|
+
declare const ShopItemSchema: z.ZodObject<{
|
|
696
|
+
id: z.ZodString;
|
|
697
|
+
spaceId: z.ZodString;
|
|
698
|
+
type: z.ZodEnum<["book", "music", "coffee"]>;
|
|
699
|
+
name: z.ZodString;
|
|
700
|
+
description: z.ZodString;
|
|
701
|
+
priceUsd: z.ZodNumber;
|
|
702
|
+
createdAt: z.ZodString;
|
|
703
|
+
sale: z.ZodObject<{
|
|
704
|
+
status: z.ZodEnum<["available", "sold"]>;
|
|
705
|
+
soldToPlayerId: z.ZodOptional<z.ZodString>;
|
|
706
|
+
soldAt: z.ZodOptional<z.ZodString>;
|
|
707
|
+
}, "strip", z.ZodTypeAny, {
|
|
708
|
+
status: "available" | "sold";
|
|
709
|
+
soldToPlayerId?: string | undefined;
|
|
710
|
+
soldAt?: string | undefined;
|
|
711
|
+
}, {
|
|
712
|
+
status: "available" | "sold";
|
|
713
|
+
soldToPlayerId?: string | undefined;
|
|
714
|
+
soldAt?: string | undefined;
|
|
715
|
+
}>;
|
|
716
|
+
}, "strip", z.ZodTypeAny, {
|
|
717
|
+
type: "book" | "music" | "coffee";
|
|
718
|
+
id: string;
|
|
719
|
+
spaceId: string;
|
|
720
|
+
name: string;
|
|
721
|
+
description: string;
|
|
722
|
+
priceUsd: number;
|
|
723
|
+
createdAt: string;
|
|
724
|
+
sale: {
|
|
725
|
+
status: "available" | "sold";
|
|
726
|
+
soldToPlayerId?: string | undefined;
|
|
727
|
+
soldAt?: string | undefined;
|
|
728
|
+
};
|
|
729
|
+
}, {
|
|
730
|
+
type: "book" | "music" | "coffee";
|
|
731
|
+
id: string;
|
|
732
|
+
spaceId: string;
|
|
733
|
+
name: string;
|
|
734
|
+
description: string;
|
|
735
|
+
priceUsd: number;
|
|
736
|
+
createdAt: string;
|
|
737
|
+
sale: {
|
|
738
|
+
status: "available" | "sold";
|
|
739
|
+
soldToPlayerId?: string | undefined;
|
|
740
|
+
soldAt?: string | undefined;
|
|
741
|
+
};
|
|
742
|
+
}>;
|
|
743
|
+
/** Runtime type for {@link ShopItemSchema}. @public */
|
|
744
|
+
type ShopItem = z.infer<typeof ShopItemSchema>;
|
|
745
|
+
/**
|
|
746
|
+
* Supermarket amenity item — laid out on a 4×5 grid of slots.
|
|
747
|
+
*
|
|
748
|
+
* @remarks
|
|
749
|
+
* `row` selects the section (1=Fruits, 2=Mens, 3=Womens, 4=Kids in the
|
|
750
|
+
* client-side stage); `column` is 1..5. If the AQL caller omits `column` the
|
|
751
|
+
* server picks the next free slot in that row.
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* ```ts
|
|
755
|
+
* SupermarketItemSchema.parse({
|
|
756
|
+
* id: "sm-1",
|
|
757
|
+
* spaceId: "space-42",
|
|
758
|
+
* row: 1,
|
|
759
|
+
* column: 3,
|
|
760
|
+
* name: "Apple",
|
|
761
|
+
* description: "fresh",
|
|
762
|
+
* priceUsd: 1.25,
|
|
763
|
+
* createdAt: new Date().toISOString(),
|
|
764
|
+
* sale: { status: "available" },
|
|
765
|
+
* });
|
|
766
|
+
* ```
|
|
767
|
+
*
|
|
768
|
+
* @public
|
|
769
|
+
*/
|
|
770
|
+
declare const SupermarketItemSchema: z.ZodObject<{
|
|
771
|
+
id: z.ZodString;
|
|
772
|
+
spaceId: z.ZodString;
|
|
773
|
+
row: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
|
774
|
+
column: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>]>;
|
|
775
|
+
name: z.ZodString;
|
|
776
|
+
description: z.ZodString;
|
|
777
|
+
priceUsd: z.ZodNumber;
|
|
778
|
+
createdAt: z.ZodString;
|
|
779
|
+
sale: z.ZodObject<{
|
|
780
|
+
status: z.ZodEnum<["available", "sold"]>;
|
|
781
|
+
soldToPlayerId: z.ZodOptional<z.ZodString>;
|
|
782
|
+
soldAt: z.ZodOptional<z.ZodString>;
|
|
783
|
+
}, "strip", z.ZodTypeAny, {
|
|
784
|
+
status: "available" | "sold";
|
|
785
|
+
soldToPlayerId?: string | undefined;
|
|
786
|
+
soldAt?: string | undefined;
|
|
787
|
+
}, {
|
|
788
|
+
status: "available" | "sold";
|
|
789
|
+
soldToPlayerId?: string | undefined;
|
|
790
|
+
soldAt?: string | undefined;
|
|
791
|
+
}>;
|
|
792
|
+
}, "strip", z.ZodTypeAny, {
|
|
793
|
+
id: string;
|
|
794
|
+
spaceId: string;
|
|
795
|
+
name: string;
|
|
796
|
+
description: string;
|
|
797
|
+
priceUsd: number;
|
|
798
|
+
createdAt: string;
|
|
799
|
+
sale: {
|
|
800
|
+
status: "available" | "sold";
|
|
801
|
+
soldToPlayerId?: string | undefined;
|
|
802
|
+
soldAt?: string | undefined;
|
|
803
|
+
};
|
|
804
|
+
row: 1 | 2 | 3 | 4;
|
|
805
|
+
column: 1 | 5 | 2 | 3 | 4;
|
|
806
|
+
}, {
|
|
807
|
+
id: string;
|
|
808
|
+
spaceId: string;
|
|
809
|
+
name: string;
|
|
810
|
+
description: string;
|
|
811
|
+
priceUsd: number;
|
|
812
|
+
createdAt: string;
|
|
813
|
+
sale: {
|
|
814
|
+
status: "available" | "sold";
|
|
815
|
+
soldToPlayerId?: string | undefined;
|
|
816
|
+
soldAt?: string | undefined;
|
|
817
|
+
};
|
|
818
|
+
row: 1 | 2 | 3 | 4;
|
|
819
|
+
column: 1 | 5 | 2 | 3 | 4;
|
|
820
|
+
}>;
|
|
821
|
+
/** Runtime type for {@link SupermarketItemSchema}. @public */
|
|
822
|
+
type SupermarketItem = z.infer<typeof SupermarketItemSchema>;
|
|
823
|
+
/**
|
|
824
|
+
* Car-wash amenity car parked in one of nine slots.
|
|
825
|
+
*
|
|
826
|
+
* @remarks
|
|
827
|
+
* Client renders the car via `sprite-car.ts`, parameterised by `colorHex`.
|
|
828
|
+
* Sold cars flip to a desaturated palette plus a `SOLD` banner overlay.
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```ts
|
|
832
|
+
* CarWashCarSchema.parse({
|
|
833
|
+
* id: "car-1",
|
|
834
|
+
* spaceId: "space-42",
|
|
835
|
+
* slot: 5,
|
|
836
|
+
* name: "Mustang",
|
|
837
|
+
* model: "GT",
|
|
838
|
+
* year: 2023,
|
|
839
|
+
* priceUsd: 45000,
|
|
840
|
+
* colorHex: "#ff3344",
|
|
841
|
+
* createdAt: new Date().toISOString(),
|
|
842
|
+
* sale: { status: "available" },
|
|
843
|
+
* });
|
|
844
|
+
* ```
|
|
845
|
+
*
|
|
846
|
+
* @public
|
|
847
|
+
*/
|
|
848
|
+
declare const CarWashCarSchema: z.ZodObject<{
|
|
849
|
+
id: z.ZodString;
|
|
850
|
+
spaceId: z.ZodString;
|
|
851
|
+
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>]>;
|
|
852
|
+
name: z.ZodString;
|
|
853
|
+
model: z.ZodString;
|
|
854
|
+
year: z.ZodNumber;
|
|
855
|
+
priceUsd: z.ZodNumber;
|
|
856
|
+
colorHex: z.ZodString;
|
|
857
|
+
createdAt: z.ZodString;
|
|
858
|
+
sale: z.ZodObject<{
|
|
859
|
+
status: z.ZodEnum<["available", "sold"]>;
|
|
860
|
+
soldToPlayerId: z.ZodOptional<z.ZodString>;
|
|
861
|
+
soldAt: z.ZodOptional<z.ZodString>;
|
|
862
|
+
}, "strip", z.ZodTypeAny, {
|
|
863
|
+
status: "available" | "sold";
|
|
864
|
+
soldToPlayerId?: string | undefined;
|
|
865
|
+
soldAt?: string | undefined;
|
|
866
|
+
}, {
|
|
867
|
+
status: "available" | "sold";
|
|
868
|
+
soldToPlayerId?: string | undefined;
|
|
869
|
+
soldAt?: string | undefined;
|
|
870
|
+
}>;
|
|
871
|
+
}, "strip", z.ZodTypeAny, {
|
|
872
|
+
id: string;
|
|
873
|
+
spaceId: string;
|
|
874
|
+
name: string;
|
|
875
|
+
priceUsd: number;
|
|
876
|
+
createdAt: string;
|
|
877
|
+
sale: {
|
|
878
|
+
status: "available" | "sold";
|
|
879
|
+
soldToPlayerId?: string | undefined;
|
|
880
|
+
soldAt?: string | undefined;
|
|
881
|
+
};
|
|
882
|
+
slot: 1 | 5 | 2 | 3 | 7 | 6 | 4 | 8 | 9;
|
|
883
|
+
model: string;
|
|
884
|
+
year: number;
|
|
885
|
+
colorHex: string;
|
|
886
|
+
}, {
|
|
887
|
+
id: string;
|
|
888
|
+
spaceId: string;
|
|
889
|
+
name: string;
|
|
890
|
+
priceUsd: number;
|
|
891
|
+
createdAt: string;
|
|
892
|
+
sale: {
|
|
893
|
+
status: "available" | "sold";
|
|
894
|
+
soldToPlayerId?: string | undefined;
|
|
895
|
+
soldAt?: string | undefined;
|
|
896
|
+
};
|
|
897
|
+
slot: 1 | 5 | 2 | 3 | 7 | 6 | 4 | 8 | 9;
|
|
898
|
+
model: string;
|
|
899
|
+
year: number;
|
|
900
|
+
colorHex: string;
|
|
901
|
+
}>;
|
|
902
|
+
/** Runtime type for {@link CarWashCarSchema}. @public */
|
|
903
|
+
type CarWashCar = z.infer<typeof CarWashCarSchema>;
|
|
904
|
+
/**
|
|
905
|
+
* Default starting balance, in USD, seeded into every new player wallet.
|
|
906
|
+
*
|
|
907
|
+
* @remarks
|
|
908
|
+
* The session store seeds the wallet lazily on first read via
|
|
909
|
+
* {@link createInitialPlayerWallet} inside an atomic `MULTI`, so two
|
|
910
|
+
* simultaneous first reads still leave the balance at exactly `$70`.
|
|
911
|
+
*
|
|
912
|
+
* @defaultValue 70
|
|
913
|
+
* @public
|
|
914
|
+
*/
|
|
915
|
+
declare const DEFAULT_PLAYER_WALLET_BALANCE_USD = 70;
|
|
916
|
+
/**
|
|
917
|
+
* Per-player wallet.
|
|
918
|
+
*
|
|
919
|
+
* @remarks
|
|
920
|
+
* Stored at `agent-play:${hostId}:player:${playerId}:wallet`. Mutated atomically
|
|
921
|
+
* by the `purchase` RPC (decrement) and by the optional AQL `SET WALLET`
|
|
922
|
+
* statement.
|
|
923
|
+
*
|
|
924
|
+
* @public
|
|
925
|
+
*/
|
|
926
|
+
declare const PlayerWalletSchema: z.ZodObject<{
|
|
927
|
+
playerId: z.ZodString;
|
|
928
|
+
balanceUsd: z.ZodNumber;
|
|
929
|
+
currency: z.ZodLiteral<"USD">;
|
|
930
|
+
updatedAt: z.ZodString;
|
|
931
|
+
}, "strip", z.ZodTypeAny, {
|
|
932
|
+
playerId: string;
|
|
933
|
+
balanceUsd: number;
|
|
934
|
+
currency: "USD";
|
|
935
|
+
updatedAt: string;
|
|
936
|
+
}, {
|
|
937
|
+
playerId: string;
|
|
938
|
+
balanceUsd: number;
|
|
939
|
+
currency: "USD";
|
|
940
|
+
updatedAt: string;
|
|
941
|
+
}>;
|
|
942
|
+
/** Runtime type for {@link PlayerWalletSchema}. @public */
|
|
943
|
+
type PlayerWallet = z.infer<typeof PlayerWalletSchema>;
|
|
944
|
+
/**
|
|
945
|
+
* Build a fresh wallet seeded with the {@link DEFAULT_PLAYER_WALLET_BALANCE_USD}
|
|
946
|
+
* balance for an unseen player.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```ts
|
|
950
|
+
* const wallet = createInitialPlayerWallet({
|
|
951
|
+
* playerId: "player-42",
|
|
952
|
+
* now: new Date().toISOString(),
|
|
953
|
+
* });
|
|
954
|
+
* // → { playerId: "player-42", balanceUsd: 70, currency: "USD", updatedAt: ... }
|
|
955
|
+
* ```
|
|
956
|
+
*
|
|
957
|
+
* @public
|
|
958
|
+
*/
|
|
959
|
+
declare function createInitialPlayerWallet(input: {
|
|
960
|
+
playerId: string;
|
|
961
|
+
now: string;
|
|
962
|
+
}): PlayerWallet;
|
|
963
|
+
/**
|
|
964
|
+
* Audit record appended each time a player completes a purchase.
|
|
965
|
+
*
|
|
966
|
+
* @remarks
|
|
967
|
+
* Stored as a Redis list at `agent-play:${hostId}:player:${playerId}:purchases`
|
|
968
|
+
* with `LPUSH` so the newest entry is at index 0.
|
|
969
|
+
*
|
|
970
|
+
* @public
|
|
971
|
+
*/
|
|
972
|
+
declare const PurchaseRecordSchema: z.ZodObject<{
|
|
973
|
+
id: z.ZodString;
|
|
974
|
+
playerId: z.ZodString;
|
|
975
|
+
spaceId: z.ZodString;
|
|
976
|
+
amenityKind: z.ZodEnum<["shop", "supermarket", "car_wash"]>;
|
|
977
|
+
itemRef: z.ZodObject<{
|
|
978
|
+
kind: z.ZodEnum<["shop", "supermarket", "carwash"]>;
|
|
979
|
+
id: z.ZodString;
|
|
980
|
+
}, "strip", z.ZodTypeAny, {
|
|
981
|
+
id: string;
|
|
982
|
+
kind: "supermarket" | "shop" | "carwash";
|
|
983
|
+
}, {
|
|
984
|
+
id: string;
|
|
985
|
+
kind: "supermarket" | "shop" | "carwash";
|
|
986
|
+
}>;
|
|
987
|
+
priceUsd: z.ZodNumber;
|
|
988
|
+
at: z.ZodString;
|
|
989
|
+
}, "strip", z.ZodTypeAny, {
|
|
990
|
+
at: string;
|
|
991
|
+
id: string;
|
|
992
|
+
spaceId: string;
|
|
993
|
+
priceUsd: number;
|
|
994
|
+
playerId: string;
|
|
995
|
+
amenityKind: "supermarket" | "shop" | "car_wash";
|
|
996
|
+
itemRef: {
|
|
997
|
+
id: string;
|
|
998
|
+
kind: "supermarket" | "shop" | "carwash";
|
|
999
|
+
};
|
|
1000
|
+
}, {
|
|
1001
|
+
at: string;
|
|
1002
|
+
id: string;
|
|
1003
|
+
spaceId: string;
|
|
1004
|
+
priceUsd: number;
|
|
1005
|
+
playerId: string;
|
|
1006
|
+
amenityKind: "supermarket" | "shop" | "car_wash";
|
|
1007
|
+
itemRef: {
|
|
1008
|
+
id: string;
|
|
1009
|
+
kind: "supermarket" | "shop" | "carwash";
|
|
1010
|
+
};
|
|
1011
|
+
}>;
|
|
1012
|
+
/** Runtime type for {@link PurchaseRecordSchema}. @public */
|
|
1013
|
+
type PurchaseRecord = z.infer<typeof PurchaseRecordSchema>;
|
|
1014
|
+
/**
|
|
1015
|
+
* Returns whether an amenity content record can still be purchased.
|
|
1016
|
+
*
|
|
1017
|
+
* @remarks
|
|
1018
|
+
* Server-side, the `purchase` RPC calls this **after** re-reading the item
|
|
1019
|
+
* inside the `WATCH`/`MULTI` block to make the check atomic. Client-side, the
|
|
1020
|
+
* tooltip and sprite renderers call it to decide between the `Buy` button and
|
|
1021
|
+
* the disabled `SOLD` pill.
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```ts
|
|
1025
|
+
* if (!isItemAvailableForPurchase(item)) {
|
|
1026
|
+
* // render the sold view
|
|
1027
|
+
* }
|
|
1028
|
+
* ```
|
|
1029
|
+
*
|
|
1030
|
+
* @public
|
|
1031
|
+
*/
|
|
1032
|
+
declare function isItemAvailableForPurchase(item: {
|
|
1033
|
+
sale: SaleState;
|
|
1034
|
+
}): boolean;
|
|
1035
|
+
/**
|
|
1036
|
+
* Union of all three content kinds, useful for places where the carrier
|
|
1037
|
+
* doesn't need to know the specific amenity.
|
|
1038
|
+
*
|
|
1039
|
+
* @public
|
|
1040
|
+
*/
|
|
1041
|
+
type SpaceContentItem = ShopItem | SupermarketItem | CarWashCar;
|
|
1042
|
+
/**
|
|
1043
|
+
* Convert any 24-bit RGB color to its perceptual grey equivalent using the
|
|
1044
|
+
* standard luminance coefficients (`Y = 0.299·R + 0.587·G + 0.114·B`).
|
|
1045
|
+
*
|
|
1046
|
+
* @remarks
|
|
1047
|
+
* Used by every amenity sprite (shop card, grocery item, car) when the
|
|
1048
|
+
* item's `sale.status === 'sold'`. Replacing original fills with the
|
|
1049
|
+
* desaturated grey is the first step of the sold visual treatment;
|
|
1050
|
+
* `drawSoldBadge` then paints the red `SOLD` banner on top.
|
|
1051
|
+
*
|
|
1052
|
+
* The function is bit-pure: it accepts a `0xRRGGBB` integer and returns a
|
|
1053
|
+
* `0xGGGGGG` integer, so it composes cleanly with `pixi.js` color params.
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
* ```ts
|
|
1057
|
+
* const grey = desaturateColor(0xff3344);
|
|
1058
|
+
* // grey = 0x6e6e6e (approximate)
|
|
1059
|
+
* ```
|
|
1060
|
+
*
|
|
1061
|
+
* @public
|
|
1062
|
+
*/
|
|
1063
|
+
declare function desaturateColor(hex: number): number;
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Parses **`playerChainNotify`** envelopes and merges {@link PlayerChainNodeResponse} slices into {@link AgentPlaySnapshot} (pure functions + fetch ordering for serialized RPC).
|
|
1067
|
+
*/
|
|
1068
|
+
|
|
1069
|
+
declare function sortNodeRefsForSerializedFetch(nodes: ReadonlyArray<PlayerChainNotifyNodeRef>): PlayerChainNotifyNodeRef[];
|
|
1070
|
+
declare function parsePlayerChainFanoutNotify(raw: unknown): PlayerChainFanoutNotify | undefined;
|
|
1071
|
+
declare function parsePlayerChainFanoutNotifyFromSsePayload(sseData: unknown): PlayerChainFanoutNotify | undefined;
|
|
1072
|
+
declare function parsePlayerChainNodeRpcBody(json: unknown): PlayerChainNodeResponse;
|
|
1073
|
+
declare function mergeSnapshotWithPlayerChainNode(snapshot: AgentPlaySnapshot, node: PlayerChainNodeResponse): AgentPlaySnapshot;
|
|
1074
|
+
|
|
1075
|
+
declare const PLAYER_CHAIN_GENESIS_STABLE_KEY: "__genesis__";
|
|
1076
|
+
declare const PLAYER_CHAIN_HEADER_STABLE_KEY: "__header__";
|
|
1077
|
+
|
|
1078
|
+
export { type SaleState as $, type AgentPlaySnapshot as A, type PlayerChainFanoutNotify as B, CONTINUOUS_RENDER_OFFSET as C, DEFAULT_AGENT_SPAWN_MIN_DISTANCE as D, type PlayerChainGenesisNode as E, type PlayerChainHeaderNode as F, type PlayerChainNotifyNodeRef as G, type PlayerChainOccupantPresentNode as H, type PlayerChainOccupantRemovedNode as I, type Journey as J, type PlayerWallet as K, type LangChainAgentRegistration as L, MINIMUM_PLAY_WORLD_BOUNDS as M, PlayerWalletSchema as N, OCCUPANCY_POINT_MULTIPLIER as O, type PlayerChainNodeResponse as P, type PositionedStep as Q, type RemotePlayWorldInitAudioOptions as R, type PurchaseRecord as S, PurchaseRecordSchema as T, type RealtimeWebrtcClientSecret as U, type RegisteredAgentSummary as V, type WorldInteractionRole as W, type RemotePlayWorldOpenAiAudioOptions as X, SPATIAL_ZONE_INDEX_AGENTS as Y, SPATIAL_ZONE_INDEX_SPACES as Z, STREET_NAME_POOL as _, type AddAgentInput as a, SaleStateSchema as a0, type ShopItem as a1, ShopItemSchema as a2, type SpaceContentItem as a3, type Street as a4, type StreetPoolEntry as a5, type StructureJourneyStep as a6, type SupermarketItem as a7, SupermarketItemSchema as a8, type WorldBounds as a9, isItemAvailableForPurchase as aA, isSpaceAnchorOccupancyPointAvailable as aB, isSpaceAnchorOccupancyPointAvailableInRect as aC, isSpaceAnchorOccupancyPointAvailableInZone as aD, listAllowedOccupancyPoints as aE, listOccupancyPointsForSpatialZone as aF, listOccupancyPointsForZone as aG, listOccupancyPointsInRect as aH, mergeSnapshotWithPlayerChainNode as aI, migrateWorldLayoutBounds as aJ, nextStreetFromPool as aK, occupancyKeyForPosition as aL, occupancyPointsGroupedBySpatialZone as aM, occupancyPointsGroupedByZones as aN, parsePlayerChainFanoutNotify as aO, parsePlayerChainFanoutNotifyFromSsePayload as aP, parsePlayerChainNodeRpcBody as aQ, pickZoneForGroup as aR, pointCellInRect as aS, pointCellInSpatialZone as aT, pointCellInZone as aU, primaryZoneForGroup as aV, sortNodeRefsForSerializedFetch as aW, spatialZoneBounds as aX, spatialZoneCenter as aY, streetFromPoolEntry as aZ, zonesForGroup as a_, type WorldJourneyUpdate as aa, type WorldLayout as ab, type WorldLayoutBoundsField as ac, type YieldEventInfo as ad, type Zone as ae, type ZoneEventInfo as af, applyBoundsFieldUpdateToLayout as ag, availableCellsForZone as ah, boundingWorldRectForOccupancyPoints as ai, boundsContain as aj, buildRankedOccupancyPoints as ak, buildRankedOccupancyPointsForSpatialZone as al, buildRankedOccupancyPointsForZone as am, buildRankedOccupancyPointsInRect as an, cellsForZone as ao, centerOfZone as ap, clampWorldPosition as aq, createInitialPlayerWallet as ar, createVerticalStripSeedLayout as as, desaturateColor as at, enumerateIntegerCellsInRect as au, expandBoundsToMinimumPlayArea as av, getStreetPoolEntryById as aw, isAgentSpawnOccupancyPointAvailable as ax, isAgentSpawnOccupancyPointAvailableInRect as ay, isAgentSpawnOccupancyPointAvailableInZone as az, type RegisteredPlayer as b, 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, DEFAULT_PLAYER_WALLET_BALANCE_USD as p, type DestinationJourneyStep as q, type JourneyStep as r, type OccupancyGridPoint as s, type OccupantGroup as t, type OriginJourneyStep as u, type P2aEnableFlag as v, PLAYER_CHAIN_GENESIS_STABLE_KEY as w, PLAYER_CHAIN_HEADER_STABLE_KEY as x, type PlatformAgentInformation as y, type PlayAgentInformation as z };
|