@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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { W as WorldInteractionRole, L as LangChainAgentRegistration, R as RemotePlayWorldInitAudioOptions, A as AgentPlaySnapshot, P as PlayerChainNodeResponse, a as AddAgentInput, b as RegisteredPlayer, c as AddPlayerInput, d as RecordInteractionInput, J as Journey } from './browser-BQR40I8R.js';
2
- export { e as AgentPlayWorldMap, f as AgentPlayWorldMapAgentOccupant, g as AgentPlayWorldMapBounds, h as AgentPlayWorldMapMcpOccupant, i as AssistToolFieldType, j as AssistToolParameterSpec, k as AssistToolSpec, C as CONTINUOUS_RENDER_OFFSET, D as DEFAULT_AGENT_SPAWN_MIN_DISTANCE, l as DestinationJourneyStep, m as JourneyStep, M as MINIMUM_PLAY_WORLD_BOUNDS, O as OCCUPANCY_POINT_MULTIPLIER, n as OccupancyGridPoint, o as OriginJourneyStep, p as P2aEnableFlag, q as PLAYER_CHAIN_GENESIS_STABLE_KEY, r as PLAYER_CHAIN_HEADER_STABLE_KEY, s as PlatformAgentInformation, t as PlayAgentInformation, u as PlayerChainFanoutNotify, v as PlayerChainGenesisNode, w as PlayerChainHeaderNode, x as PlayerChainNotifyNodeRef, y as PlayerChainOccupantPresentNode, z as PlayerChainOccupantRemovedNode, B as PositionedStep, E as RealtimeWebrtcClientSecret, F as RegisteredAgentSummary, G as RemotePlayWorldOpenAiAudioOptions, S as SPATIAL_ZONE_INDEX_AGENTS, H as SPATIAL_ZONE_INDEX_SPACES, I as StructureJourneyStep, K as WorldBounds, N as WorldJourneyUpdate, Y as YieldEventInfo, Z as ZoneEventInfo, Q as boundingWorldRectForOccupancyPoints, T as boundsContain, U as buildRankedOccupancyPoints, V as buildRankedOccupancyPointsForSpatialZone, X as clampWorldPosition, _ as expandBoundsToMinimumPlayArea, $ as isAgentSpawnOccupancyPointAvailable, a0 as isSpaceAnchorOccupancyPointAvailable, a1 as listAllowedOccupancyPoints, a2 as listOccupancyPointsForSpatialZone, a3 as mergeSnapshotWithPlayerChainNode, a4 as occupancyKeyForPosition, a5 as occupancyPointsGroupedBySpatialZone, a6 as parsePlayerChainFanoutNotify, a7 as parsePlayerChainFanoutNotifyFromSsePayload, a8 as parsePlayerChainNodeRpcBody, a9 as pointCellInSpatialZone, aa as sortNodeRefsForSerializedFetch, ab as spatialZoneBounds, ac as spatialZoneCenter } from './browser-BQR40I8R.js';
1
+ import { W as WorldInteractionRole, L as LangChainAgentRegistration, R as RemotePlayWorldInitAudioOptions, A as AgentPlaySnapshot, P as PlayerChainNodeResponse, a as AddAgentInput, b as RegisteredPlayer, c as AddPlayerInput, d as RecordInteractionInput, J as Journey } from './browser-da9E-kSP.js';
2
+ export { e as AgentPlayWorldLayout, f as AgentPlayWorldLayoutZone, g as AgentPlayWorldMap, h as AgentPlayWorldMapAgentOccupant, i as AgentPlayWorldMapBounds, j as AgentPlayWorldMapMcpOccupant, k as AssistToolFieldType, l as AssistToolParameterSpec, m as AssistToolSpec, C as CONTINUOUS_RENDER_OFFSET, n as CarWashCar, o as CarWashCarSchema, p as ComputeTalkAgentPowerUpsEarnedInput, D as DEFAULT_AGENT_SPAWN_MIN_DISTANCE, q as DEFAULT_PLAYER_WALLET_BALANCE_USD, r as DestinationJourneyStep, s as JourneyStep, M as MINIMUM_PLAY_WORLD_BOUNDS, t as MINIMUM_STREET_LAYOUT_BOUNDS, O as OCCUPANCY_POINT_MULTIPLIER, u as OccupancyGridPoint, v as OccupantGroup, w as OriginJourneyStep, x as P2aEnableFlag, y as PLAYER_CHAIN_GENESIS_STABLE_KEY, z as PLAYER_CHAIN_HEADER_STABLE_KEY, B as PlatformAgentInformation, E as PlayAgentInformation, F as PlayerChainFanoutNotify, G as PlayerChainGenesisNode, H as PlayerChainHeaderNode, I as PlayerChainNotifyNodeRef, K as PlayerChainOccupantPresentNode, N as PlayerChainOccupantRemovedNode, Q as PlayerWallet, S as PlayerWalletSchema, T as PositionedStep, U as PurchaseRecord, V as PurchaseRecordSchema, X as RealtimeWebrtcClientSecret, Y as RegisteredAgentSummary, Z as RemotePlayWorldOpenAiAudioOptions, _ as SPACE_STRUCTURE_ANCHOR_MIN_DISTANCE, $ as SPATIAL_ZONE_INDEX_AGENTS, a0 as SPATIAL_ZONE_INDEX_SPACES, a1 as STREET_NAME_POOL, a2 as SaleState, a3 as SaleStateSchema, a4 as ShopItem, a5 as ShopItemSchema, a6 as SpaceContentItem, a7 as Street, a8 as StreetPoolEntry, a9 as StructureJourneyStep, aa as SupermarketItem, ab as SupermarketItemSchema, ac as TALK_AGENT_PU_BILLED_SECONDS_PER_UNIT, ad as TALK_AGENT_PU_MAX_PER_LEG, ae as TALK_PRICE_PER_60S_USD, af as TALK_PRICE_PER_SECOND_USD, ag as TALK_TICK_SECONDS, ah as WALLET_BUNDLE_OFFERS, ai as WalletBundleId, aj as WalletBundleOffer, ak as WorldBounds, al as WorldJourneyUpdate, am as WorldLayout, an as WorldLayoutBoundsField, ao as YieldEventInfo, ap as Zone, aq as ZoneEventInfo, ar as applyBoundsFieldUpdateToLayout, as as availableCellsForZone, at as boundingWorldRectForOccupancyPoints, au as boundsContain, av as buildRankedOccupancyPoints, aw as buildRankedOccupancyPointsForSpatialZone, ax as buildRankedOccupancyPointsForZone, ay as buildRankedOccupancyPointsInRect, az as cellsForZone, aA as centerOfZone, aB as clampWorldPosition, aC as computeTalkAgentPowerUpsEarned, aD as costForSeconds, aE as createInitialAgentRewardWallet, aF as createInitialPlayerWallet, aG as createVerticalStripSeedLayout, aH as desaturateColor, aI as enumerateIntegerCellsInRect, aJ as expandBoundsToMinimumPlayArea, aK as getStreetPoolEntryById, aL as getWalletBundleById, aM as isAgentSpawnOccupancyPointAvailable, aN as isAgentSpawnOccupancyPointAvailableInRect, aO as isAgentSpawnOccupancyPointAvailableInZone, aP as isItemAvailableForPurchase, aQ as isSpaceAnchorOccupancyPointAvailable, aR as isSpaceAnchorOccupancyPointAvailableInRect, aS as isSpaceAnchorOccupancyPointAvailableInZone, aT as listAllowedOccupancyPoints, aU as listOccupancyPointsForSpatialZone, aV as listOccupancyPointsForZone, aW as listOccupancyPointsInRect, aX as mergeSnapshotWithPlayerChainNode, aY as migrateWorldLayoutBounds, aZ as nextStreetFromPool, a_ as occupancyKeyForPosition, a$ as occupancyPointsGroupedBySpatialZone, b0 as occupancyPointsGroupedByZones, b1 as parsePlayerChainFanoutNotify, b2 as parsePlayerChainFanoutNotifyFromSsePayload, b3 as parsePlayerChainNodeRpcBody, b4 as pickZoneForGroup, b5 as pointCellInRect, b6 as pointCellInSpatialZone, b7 as pointCellInZone, b8 as primaryZoneForGroup, b9 as sortNodeRefsForSerializedFetch, ba as spatialZoneBounds, bb as spatialZoneCenter, bc as streetFromPoolEntry, bd as zonesForGroup } from './browser-da9E-kSP.js';
3
3
  import { WorldIntercomEventPayload, IntercomResponsePayload } from '@agent-play/intercom';
4
4
  export { AgentPlayAgentNodeEntry, AgentPlayCredentialsFile, NodeCredentialMaterial, createNodeCredentialMaterial, loadAgentPlayCredentialsFileFromPath, loadAgentPlayCredentialsFileFromPathSync, loadRootKey, nodeCredentialFromHumanPhrase, nodeCredentialFromPasswHash, nodeCredentialsMaterialFromHumanPassphrase, parseAgentPlayCredentialsJson, resolveAgentPlayCredentialsPath, verifyStoredNodeCredential } from '@agent-play/node-tools';
5
+ import 'zod';
5
6
 
6
7
  /**
7
8
  * String constants and payload shapes for SSE and in-process world events.
package/dist/index.js CHANGED
@@ -1,25 +1,66 @@
1
1
  import {
2
2
  CONTINUOUS_RENDER_OFFSET,
3
+ CarWashCarSchema,
3
4
  DEFAULT_AGENT_SPAWN_MIN_DISTANCE,
5
+ DEFAULT_PLAYER_WALLET_BALANCE_USD,
4
6
  MINIMUM_PLAY_WORLD_BOUNDS,
7
+ MINIMUM_STREET_LAYOUT_BOUNDS,
5
8
  OCCUPANCY_POINT_MULTIPLIER,
6
9
  PLAYER_CHAIN_GENESIS_STABLE_KEY,
7
10
  PLAYER_CHAIN_HEADER_STABLE_KEY,
11
+ PlayerWalletSchema,
12
+ PurchaseRecordSchema,
13
+ SPACE_STRUCTURE_ANCHOR_MIN_DISTANCE,
8
14
  SPATIAL_ZONE_INDEX_AGENTS,
9
15
  SPATIAL_ZONE_INDEX_SPACES,
16
+ STREET_NAME_POOL,
17
+ SaleStateSchema,
18
+ ShopItemSchema,
19
+ SupermarketItemSchema,
20
+ TALK_AGENT_PU_BILLED_SECONDS_PER_UNIT,
21
+ TALK_AGENT_PU_MAX_PER_LEG,
22
+ TALK_PRICE_PER_60S_USD,
23
+ TALK_PRICE_PER_SECOND_USD,
24
+ TALK_TICK_SECONDS,
25
+ WALLET_BUNDLE_OFFERS,
26
+ applyBoundsFieldUpdateToLayout,
27
+ availableCellsForZone,
10
28
  boundingWorldRectForOccupancyPoints,
11
29
  boundsContain,
12
30
  buildRankedOccupancyPoints,
13
31
  buildRankedOccupancyPointsForSpatialZone,
32
+ buildRankedOccupancyPointsForZone,
33
+ buildRankedOccupancyPointsInRect,
34
+ cellsForZone,
35
+ centerOfZone,
14
36
  clampWorldPosition,
37
+ computeTalkAgentPowerUpsEarned,
38
+ costForSeconds,
39
+ createInitialAgentRewardWallet,
40
+ createInitialPlayerWallet,
41
+ createVerticalStripSeedLayout,
42
+ desaturateColor,
43
+ enumerateIntegerCellsInRect,
15
44
  expandBoundsToMinimumPlayArea,
45
+ getStreetPoolEntryById,
46
+ getWalletBundleById,
16
47
  isAgentSpawnOccupancyPointAvailable,
48
+ isAgentSpawnOccupancyPointAvailableInRect,
49
+ isAgentSpawnOccupancyPointAvailableInZone,
50
+ isItemAvailableForPurchase,
17
51
  isSpaceAnchorOccupancyPointAvailable,
52
+ isSpaceAnchorOccupancyPointAvailableInRect,
53
+ isSpaceAnchorOccupancyPointAvailableInZone,
18
54
  listAllowedOccupancyPoints,
19
55
  listOccupancyPointsForSpatialZone,
56
+ listOccupancyPointsForZone,
57
+ listOccupancyPointsInRect,
20
58
  mergeSnapshotWithPlayerChainNode,
59
+ migrateWorldLayoutBounds,
60
+ nextStreetFromPool,
21
61
  occupancyKeyForPosition,
22
62
  occupancyPointsGroupedBySpatialZone,
63
+ occupancyPointsGroupedByZones,
23
64
  parseAgentOccupantRow,
24
65
  parseHumanOccupantRow,
25
66
  parseMcpOccupantRow,
@@ -28,11 +69,17 @@ import {
28
69
  parsePlayerChainNodeRpcBody,
29
70
  parseSpaceCatalogEntry,
30
71
  parseStructureOccupantRow,
72
+ pickZoneForGroup,
73
+ pointCellInRect,
31
74
  pointCellInSpatialZone,
75
+ pointCellInZone,
76
+ primaryZoneForGroup,
32
77
  sortNodeRefsForSerializedFetch,
33
78
  spatialZoneBounds,
34
- spatialZoneCenter
35
- } from "./chunk-WWIEHWZZ.js";
79
+ spatialZoneCenter,
80
+ streetFromPoolEntry,
81
+ zonesForGroup
82
+ } from "./chunk-BCDEUIYP.js";
36
83
 
37
84
  // src/world-events.ts
38
85
  var SESSION_CONNECTED_EVENT = "session:connected";
@@ -281,6 +328,10 @@ function resolveRealtimeInstructions(options) {
281
328
  if (explicit !== void 0 && explicit.length > 0) {
282
329
  return explicit;
283
330
  }
331
+ const perAgent = options.perAgentInstructions?.trim();
332
+ if (perAgent !== void 0 && perAgent.length > 0) {
333
+ return perAgent;
334
+ }
284
335
  const template = options.openai.instructionsTemplate?.trim();
285
336
  if (template !== void 0 && template.length > 0) {
286
337
  return template.replaceAll("{{agentName}}", options.agentName);
@@ -414,6 +465,12 @@ function parseAgentPlaySnapshot(snapshot) {
414
465
  }
415
466
  const worldMap = parseWorldMap(snapshot.worldMap);
416
467
  const out = { sid: snapshot.sid, worldMap };
468
+ if ("worldLayout" in snapshot && isRecord(snapshot.worldLayout)) {
469
+ const wl = snapshot.worldLayout;
470
+ if (typeof wl.rev === "number" && isRecord(wl.bounds) && Array.isArray(wl.zones) && Array.isArray(wl.streets)) {
471
+ out.worldLayout = wl;
472
+ }
473
+ }
417
474
  if ("mcpServers" in snapshot && Array.isArray(snapshot.mcpServers)) {
418
475
  const servers = [];
419
476
  for (const m of snapshot.mcpServers) {
@@ -922,25 +979,23 @@ var RemotePlayWorld = class {
922
979
  const connectionId = randomUUID();
923
980
  const leaseTtlSeconds = 45;
924
981
  let realtimeWebrtcFromInit;
925
- let realtimeInstructionsFromInit;
982
+ let resolvedRealtimeInstructions;
926
983
  if (input.enableP2a === "on" && this.audioInitOptions !== null) {
927
- console.log("resolving realtime instructions for agent", input.name);
928
- realtimeInstructionsFromInit = resolveRealtimeInstructions({
929
- openai: this.audioInitOptions,
930
- agentName: input.name
931
- });
932
- realtimeWebrtcFromInit = await mintOpenAiRealtimeClientSecretForSdk({
984
+ const resolveOpts = {
933
985
  openai: this.audioInitOptions,
934
- agentName: input.name
935
- });
986
+ agentName: input.name,
987
+ perAgentInstructions: input.realtimeInstructions ?? ""
988
+ };
989
+ resolvedRealtimeInstructions = resolveRealtimeInstructions(resolveOpts);
990
+ realtimeWebrtcFromInit = await mintOpenAiRealtimeClientSecretForSdk(resolveOpts);
936
991
  this.logTransport("addAgent:p2a_enabled", {
937
992
  agentName: input.name,
938
993
  model: this.audioInitOptions.model,
939
994
  voice: this.audioInitOptions.voice
940
995
  });
941
996
  }
942
- console.log("realtimeWebrtcFromInit", realtimeWebrtcFromInit);
943
- console.log("realtimeInstructionsFromInit", realtimeInstructionsFromInit);
997
+ const callerRealtimeInstructions = typeof input.realtimeInstructions === "string" && input.realtimeInstructions.trim().length > 0 ? input.realtimeInstructions : void 0;
998
+ const forwardedRealtimeInstructions = resolvedRealtimeInstructions ?? callerRealtimeInstructions;
944
999
  const requestPayload = {
945
1000
  name: input.name,
946
1001
  type: input.type,
@@ -952,7 +1007,7 @@ var RemotePlayWorld = class {
952
1007
  leaseTtlSeconds,
953
1008
  ...input.enableP2a !== void 0 ? { enableP2a: input.enableP2a } : {},
954
1009
  ...realtimeWebrtcFromInit !== void 0 ? { realtimeWebrtc: realtimeWebrtcFromInit } : {},
955
- ...realtimeInstructionsFromInit !== void 0 ? { realtimeInstructions: realtimeInstructionsFromInit } : {}
1010
+ ...forwardedRealtimeInstructions !== void 0 ? { realtimeInstructions: forwardedRealtimeInstructions } : {}
956
1011
  };
957
1012
  this.logTransport("addAgent:request_payload", {
958
1013
  url,
@@ -1054,6 +1109,9 @@ var RemotePlayWorld = class {
1054
1109
  if (input.mainNodeId !== void 0) {
1055
1110
  payload.mainNodeId = input.mainNodeId;
1056
1111
  }
1112
+ if (input.realtimeInstructions !== void 0) {
1113
+ payload.realtimeInstructions = input.realtimeInstructions;
1114
+ }
1057
1115
  return this.addAgent(payload);
1058
1116
  }
1059
1117
  async recordInteraction(input) {
@@ -1421,58 +1479,105 @@ import {
1421
1479
  } from "@agent-play/node-tools";
1422
1480
  export {
1423
1481
  CONTINUOUS_RENDER_OFFSET,
1482
+ CarWashCarSchema,
1424
1483
  DEFAULT_AGENT_SPAWN_MIN_DISTANCE,
1484
+ DEFAULT_PLAYER_WALLET_BALANCE_USD,
1425
1485
  MINIMUM_PLAY_WORLD_BOUNDS,
1486
+ MINIMUM_STREET_LAYOUT_BOUNDS,
1426
1487
  OCCUPANCY_POINT_MULTIPLIER,
1427
1488
  PLAYER_ADDED_EVENT,
1428
1489
  PLAYER_CHAIN_GENESIS_STABLE_KEY,
1429
1490
  PLAYER_CHAIN_HEADER_STABLE_KEY,
1491
+ PlayerWalletSchema,
1492
+ PurchaseRecordSchema,
1430
1493
  RemotePlayWorld,
1431
1494
  SESSION_CLOSED_EVENT,
1432
1495
  SESSION_CONNECTED_EVENT,
1433
1496
  SESSION_INVALID_EVENT,
1434
1497
  SESSION_SSE_ERROR_EVENT,
1435
1498
  SESSION_SSE_OPEN_EVENT,
1499
+ SPACE_STRUCTURE_ANCHOR_MIN_DISTANCE,
1436
1500
  SPATIAL_ZONE_INDEX_AGENTS,
1437
1501
  SPATIAL_ZONE_INDEX_SPACES,
1502
+ STREET_NAME_POOL,
1503
+ SaleStateSchema,
1504
+ ShopItemSchema,
1505
+ SupermarketItemSchema,
1506
+ TALK_AGENT_PU_BILLED_SECONDS_PER_UNIT,
1507
+ TALK_AGENT_PU_MAX_PER_LEG,
1508
+ TALK_PRICE_PER_60S_USD,
1509
+ TALK_PRICE_PER_SECOND_USD,
1510
+ TALK_TICK_SECONDS,
1511
+ WALLET_BUNDLE_OFFERS,
1438
1512
  WORLD_AGENT_SIGNAL_EVENT,
1439
1513
  WORLD_INTERACTION_EVENT,
1440
1514
  WORLD_JOURNEY_EVENT,
1441
1515
  agentPlayDebug,
1516
+ applyBoundsFieldUpdateToLayout,
1517
+ availableCellsForZone,
1442
1518
  boundingWorldRectForOccupancyPoints,
1443
1519
  boundsContain,
1444
1520
  buildRankedOccupancyPoints,
1445
1521
  buildRankedOccupancyPointsForSpatialZone,
1522
+ buildRankedOccupancyPointsForZone,
1523
+ buildRankedOccupancyPointsInRect,
1524
+ cellsForZone,
1525
+ centerOfZone,
1446
1526
  clampWorldPosition,
1527
+ computeTalkAgentPowerUpsEarned,
1447
1528
  configureAgentPlayDebug,
1529
+ costForSeconds,
1530
+ createInitialAgentRewardWallet,
1531
+ createInitialPlayerWallet,
1448
1532
  createNodeCredentialMaterial,
1533
+ createVerticalStripSeedLayout,
1534
+ desaturateColor,
1535
+ enumerateIntegerCellsInRect,
1449
1536
  expandBoundsToMinimumPlayArea,
1537
+ getStreetPoolEntryById,
1538
+ getWalletBundleById,
1450
1539
  intercomResultRecordFromLangChainInvokeOutput,
1451
1540
  isAgentPlayDebugEnabled,
1452
1541
  isAgentSpawnOccupancyPointAvailable,
1542
+ isAgentSpawnOccupancyPointAvailableInRect,
1543
+ isAgentSpawnOccupancyPointAvailableInZone,
1544
+ isItemAvailableForPurchase,
1453
1545
  isSpaceAnchorOccupancyPointAvailable,
1546
+ isSpaceAnchorOccupancyPointAvailableInRect,
1547
+ isSpaceAnchorOccupancyPointAvailableInZone,
1454
1548
  langchainRegistration,
1455
1549
  listAllowedOccupancyPoints,
1456
1550
  listOccupancyPointsForSpatialZone,
1551
+ listOccupancyPointsForZone,
1552
+ listOccupancyPointsInRect,
1457
1553
  loadAgentPlayCredentialsFileFromPath,
1458
1554
  loadAgentPlayCredentialsFileFromPathSync2 as loadAgentPlayCredentialsFileFromPathSync,
1459
1555
  loadRootKey2 as loadRootKey,
1460
1556
  mergeSnapshotWithPlayerChainNode,
1557
+ migrateWorldLayoutBounds,
1558
+ nextStreetFromPool,
1461
1559
  nodeCredentialFromHumanPhrase2 as nodeCredentialFromHumanPhrase,
1462
1560
  nodeCredentialFromPasswHash,
1463
1561
  nodeCredentialsMaterialFromHumanPassphrase,
1464
1562
  occupancyKeyForPosition,
1465
1563
  occupancyPointsGroupedBySpatialZone,
1564
+ occupancyPointsGroupedByZones,
1466
1565
  parseAgentPlayCredentialsJson,
1467
1566
  parsePlayerChainFanoutNotify,
1468
1567
  parsePlayerChainFanoutNotifyFromSsePayload,
1469
1568
  parsePlayerChainNodeRpcBody,
1569
+ pickZoneForGroup,
1570
+ pointCellInRect,
1470
1571
  pointCellInSpatialZone,
1572
+ pointCellInZone,
1573
+ primaryZoneForGroup,
1471
1574
  resetAgentPlayDebug,
1472
1575
  resolveAgentPlayCredentialsPath2 as resolveAgentPlayCredentialsPath,
1473
1576
  sortNodeRefsForSerializedFetch,
1474
1577
  spatialZoneBounds,
1475
1578
  spatialZoneCenter,
1476
- verifyStoredNodeCredential
1579
+ streetFromPoolEntry,
1580
+ verifyStoredNodeCredential,
1581
+ zonesForGroup
1477
1582
  };
1478
1583
  //# sourceMappingURL=index.js.map