@agent-play/sdk 3.3.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 +73 -3
- package/dist/chunk-VWC7EE2F.js +5104 -0
- package/dist/chunk-VWC7EE2F.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +96 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser-BQR40I8R.d.ts +0 -480
- package/dist/chunk-WWIEHWZZ.js +0 -649
- package/dist/chunk-WWIEHWZZ.js.map +0 -1
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-
|
|
2
|
-
export { e as
|
|
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-Dpx-0L8A.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, D as DEFAULT_AGENT_SPAWN_MIN_DISTANCE, p as DEFAULT_PLAYER_WALLET_BALANCE_USD, q as DestinationJourneyStep, r as JourneyStep, M as MINIMUM_PLAY_WORLD_BOUNDS, O as OCCUPANCY_POINT_MULTIPLIER, s as OccupancyGridPoint, t as OccupantGroup, u as OriginJourneyStep, v as P2aEnableFlag, w as PLAYER_CHAIN_GENESIS_STABLE_KEY, x as PLAYER_CHAIN_HEADER_STABLE_KEY, y as PlatformAgentInformation, z as PlayAgentInformation, B as PlayerChainFanoutNotify, E as PlayerChainGenesisNode, F as PlayerChainHeaderNode, G as PlayerChainNotifyNodeRef, H as PlayerChainOccupantPresentNode, I as PlayerChainOccupantRemovedNode, K as PlayerWallet, N as PlayerWalletSchema, Q as PositionedStep, S as PurchaseRecord, T as PurchaseRecordSchema, U as RealtimeWebrtcClientSecret, V as RegisteredAgentSummary, X as RemotePlayWorldOpenAiAudioOptions, Y as SPATIAL_ZONE_INDEX_AGENTS, Z as SPATIAL_ZONE_INDEX_SPACES, _ as STREET_NAME_POOL, $ as SaleState, a0 as SaleStateSchema, a1 as ShopItem, a2 as ShopItemSchema, a3 as SpaceContentItem, a4 as Street, a5 as StreetPoolEntry, a6 as StructureJourneyStep, a7 as SupermarketItem, a8 as SupermarketItemSchema, a9 as WorldBounds, aa as WorldJourneyUpdate, ab as WorldLayout, ac as WorldLayoutBoundsField, ad as YieldEventInfo, ae as Zone, af as ZoneEventInfo, ag as applyBoundsFieldUpdateToLayout, ah as availableCellsForZone, ai as boundingWorldRectForOccupancyPoints, aj as boundsContain, ak as buildRankedOccupancyPoints, al as buildRankedOccupancyPointsForSpatialZone, am as buildRankedOccupancyPointsForZone, an as buildRankedOccupancyPointsInRect, ao as cellsForZone, ap as centerOfZone, aq as clampWorldPosition, ar as createInitialPlayerWallet, as as createVerticalStripSeedLayout, at as desaturateColor, au as enumerateIntegerCellsInRect, av as expandBoundsToMinimumPlayArea, aw as getStreetPoolEntryById, ax as isAgentSpawnOccupancyPointAvailable, ay as isAgentSpawnOccupancyPointAvailableInRect, az as isAgentSpawnOccupancyPointAvailableInZone, aA as isItemAvailableForPurchase, aB as isSpaceAnchorOccupancyPointAvailable, aC as isSpaceAnchorOccupancyPointAvailableInRect, aD as isSpaceAnchorOccupancyPointAvailableInZone, aE as listAllowedOccupancyPoints, aF as listOccupancyPointsForSpatialZone, aG as listOccupancyPointsForZone, aH as listOccupancyPointsInRect, aI as mergeSnapshotWithPlayerChainNode, aJ as migrateWorldLayoutBounds, aK as nextStreetFromPool, aL as occupancyKeyForPosition, aM as occupancyPointsGroupedBySpatialZone, aN as occupancyPointsGroupedByZones, aO as parsePlayerChainFanoutNotify, aP as parsePlayerChainFanoutNotifyFromSsePayload, aQ as parsePlayerChainNodeRpcBody, aR as pickZoneForGroup, aS as pointCellInRect, aT as pointCellInSpatialZone, aU as pointCellInZone, aV as primaryZoneForGroup, aW as sortNodeRefsForSerializedFetch, aX as spatialZoneBounds, aY as spatialZoneCenter, aZ as streetFromPoolEntry, a_ as zonesForGroup } from './browser-Dpx-0L8A.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,54 @@
|
|
|
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,
|
|
5
7
|
OCCUPANCY_POINT_MULTIPLIER,
|
|
6
8
|
PLAYER_CHAIN_GENESIS_STABLE_KEY,
|
|
7
9
|
PLAYER_CHAIN_HEADER_STABLE_KEY,
|
|
10
|
+
PlayerWalletSchema,
|
|
11
|
+
PurchaseRecordSchema,
|
|
8
12
|
SPATIAL_ZONE_INDEX_AGENTS,
|
|
9
13
|
SPATIAL_ZONE_INDEX_SPACES,
|
|
14
|
+
STREET_NAME_POOL,
|
|
15
|
+
SaleStateSchema,
|
|
16
|
+
ShopItemSchema,
|
|
17
|
+
SupermarketItemSchema,
|
|
18
|
+
applyBoundsFieldUpdateToLayout,
|
|
19
|
+
availableCellsForZone,
|
|
10
20
|
boundingWorldRectForOccupancyPoints,
|
|
11
21
|
boundsContain,
|
|
12
22
|
buildRankedOccupancyPoints,
|
|
13
23
|
buildRankedOccupancyPointsForSpatialZone,
|
|
24
|
+
buildRankedOccupancyPointsForZone,
|
|
25
|
+
buildRankedOccupancyPointsInRect,
|
|
26
|
+
cellsForZone,
|
|
27
|
+
centerOfZone,
|
|
14
28
|
clampWorldPosition,
|
|
29
|
+
createInitialPlayerWallet,
|
|
30
|
+
createVerticalStripSeedLayout,
|
|
31
|
+
desaturateColor,
|
|
32
|
+
enumerateIntegerCellsInRect,
|
|
15
33
|
expandBoundsToMinimumPlayArea,
|
|
34
|
+
getStreetPoolEntryById,
|
|
16
35
|
isAgentSpawnOccupancyPointAvailable,
|
|
36
|
+
isAgentSpawnOccupancyPointAvailableInRect,
|
|
37
|
+
isAgentSpawnOccupancyPointAvailableInZone,
|
|
38
|
+
isItemAvailableForPurchase,
|
|
17
39
|
isSpaceAnchorOccupancyPointAvailable,
|
|
40
|
+
isSpaceAnchorOccupancyPointAvailableInRect,
|
|
41
|
+
isSpaceAnchorOccupancyPointAvailableInZone,
|
|
18
42
|
listAllowedOccupancyPoints,
|
|
19
43
|
listOccupancyPointsForSpatialZone,
|
|
44
|
+
listOccupancyPointsForZone,
|
|
45
|
+
listOccupancyPointsInRect,
|
|
20
46
|
mergeSnapshotWithPlayerChainNode,
|
|
47
|
+
migrateWorldLayoutBounds,
|
|
48
|
+
nextStreetFromPool,
|
|
21
49
|
occupancyKeyForPosition,
|
|
22
50
|
occupancyPointsGroupedBySpatialZone,
|
|
51
|
+
occupancyPointsGroupedByZones,
|
|
23
52
|
parseAgentOccupantRow,
|
|
24
53
|
parseHumanOccupantRow,
|
|
25
54
|
parseMcpOccupantRow,
|
|
@@ -28,11 +57,17 @@ import {
|
|
|
28
57
|
parsePlayerChainNodeRpcBody,
|
|
29
58
|
parseSpaceCatalogEntry,
|
|
30
59
|
parseStructureOccupantRow,
|
|
60
|
+
pickZoneForGroup,
|
|
61
|
+
pointCellInRect,
|
|
31
62
|
pointCellInSpatialZone,
|
|
63
|
+
pointCellInZone,
|
|
64
|
+
primaryZoneForGroup,
|
|
32
65
|
sortNodeRefsForSerializedFetch,
|
|
33
66
|
spatialZoneBounds,
|
|
34
|
-
spatialZoneCenter
|
|
35
|
-
|
|
67
|
+
spatialZoneCenter,
|
|
68
|
+
streetFromPoolEntry,
|
|
69
|
+
zonesForGroup
|
|
70
|
+
} from "./chunk-VWC7EE2F.js";
|
|
36
71
|
|
|
37
72
|
// src/world-events.ts
|
|
38
73
|
var SESSION_CONNECTED_EVENT = "session:connected";
|
|
@@ -281,6 +316,10 @@ function resolveRealtimeInstructions(options) {
|
|
|
281
316
|
if (explicit !== void 0 && explicit.length > 0) {
|
|
282
317
|
return explicit;
|
|
283
318
|
}
|
|
319
|
+
const perAgent = options.perAgentInstructions?.trim();
|
|
320
|
+
if (perAgent !== void 0 && perAgent.length > 0) {
|
|
321
|
+
return perAgent;
|
|
322
|
+
}
|
|
284
323
|
const template = options.openai.instructionsTemplate?.trim();
|
|
285
324
|
if (template !== void 0 && template.length > 0) {
|
|
286
325
|
return template.replaceAll("{{agentName}}", options.agentName);
|
|
@@ -414,6 +453,12 @@ function parseAgentPlaySnapshot(snapshot) {
|
|
|
414
453
|
}
|
|
415
454
|
const worldMap = parseWorldMap(snapshot.worldMap);
|
|
416
455
|
const out = { sid: snapshot.sid, worldMap };
|
|
456
|
+
if ("worldLayout" in snapshot && isRecord(snapshot.worldLayout)) {
|
|
457
|
+
const wl = snapshot.worldLayout;
|
|
458
|
+
if (typeof wl.rev === "number" && isRecord(wl.bounds) && Array.isArray(wl.zones) && Array.isArray(wl.streets)) {
|
|
459
|
+
out.worldLayout = wl;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
417
462
|
if ("mcpServers" in snapshot && Array.isArray(snapshot.mcpServers)) {
|
|
418
463
|
const servers = [];
|
|
419
464
|
for (const m of snapshot.mcpServers) {
|
|
@@ -922,25 +967,23 @@ var RemotePlayWorld = class {
|
|
|
922
967
|
const connectionId = randomUUID();
|
|
923
968
|
const leaseTtlSeconds = 45;
|
|
924
969
|
let realtimeWebrtcFromInit;
|
|
925
|
-
let
|
|
970
|
+
let resolvedRealtimeInstructions;
|
|
926
971
|
if (input.enableP2a === "on" && this.audioInitOptions !== null) {
|
|
927
|
-
|
|
928
|
-
realtimeInstructionsFromInit = resolveRealtimeInstructions({
|
|
929
|
-
openai: this.audioInitOptions,
|
|
930
|
-
agentName: input.name
|
|
931
|
-
});
|
|
932
|
-
realtimeWebrtcFromInit = await mintOpenAiRealtimeClientSecretForSdk({
|
|
972
|
+
const resolveOpts = {
|
|
933
973
|
openai: this.audioInitOptions,
|
|
934
|
-
agentName: input.name
|
|
935
|
-
|
|
974
|
+
agentName: input.name,
|
|
975
|
+
perAgentInstructions: input.realtimeInstructions ?? ""
|
|
976
|
+
};
|
|
977
|
+
resolvedRealtimeInstructions = resolveRealtimeInstructions(resolveOpts);
|
|
978
|
+
realtimeWebrtcFromInit = await mintOpenAiRealtimeClientSecretForSdk(resolveOpts);
|
|
936
979
|
this.logTransport("addAgent:p2a_enabled", {
|
|
937
980
|
agentName: input.name,
|
|
938
981
|
model: this.audioInitOptions.model,
|
|
939
982
|
voice: this.audioInitOptions.voice
|
|
940
983
|
});
|
|
941
984
|
}
|
|
942
|
-
|
|
943
|
-
|
|
985
|
+
const callerRealtimeInstructions = typeof input.realtimeInstructions === "string" && input.realtimeInstructions.trim().length > 0 ? input.realtimeInstructions : void 0;
|
|
986
|
+
const forwardedRealtimeInstructions = resolvedRealtimeInstructions ?? callerRealtimeInstructions;
|
|
944
987
|
const requestPayload = {
|
|
945
988
|
name: input.name,
|
|
946
989
|
type: input.type,
|
|
@@ -952,7 +995,7 @@ var RemotePlayWorld = class {
|
|
|
952
995
|
leaseTtlSeconds,
|
|
953
996
|
...input.enableP2a !== void 0 ? { enableP2a: input.enableP2a } : {},
|
|
954
997
|
...realtimeWebrtcFromInit !== void 0 ? { realtimeWebrtc: realtimeWebrtcFromInit } : {},
|
|
955
|
-
...
|
|
998
|
+
...forwardedRealtimeInstructions !== void 0 ? { realtimeInstructions: forwardedRealtimeInstructions } : {}
|
|
956
999
|
};
|
|
957
1000
|
this.logTransport("addAgent:request_payload", {
|
|
958
1001
|
url,
|
|
@@ -1054,6 +1097,9 @@ var RemotePlayWorld = class {
|
|
|
1054
1097
|
if (input.mainNodeId !== void 0) {
|
|
1055
1098
|
payload.mainNodeId = input.mainNodeId;
|
|
1056
1099
|
}
|
|
1100
|
+
if (input.realtimeInstructions !== void 0) {
|
|
1101
|
+
payload.realtimeInstructions = input.realtimeInstructions;
|
|
1102
|
+
}
|
|
1057
1103
|
return this.addAgent(payload);
|
|
1058
1104
|
}
|
|
1059
1105
|
async recordInteraction(input) {
|
|
@@ -1421,12 +1467,16 @@ import {
|
|
|
1421
1467
|
} from "@agent-play/node-tools";
|
|
1422
1468
|
export {
|
|
1423
1469
|
CONTINUOUS_RENDER_OFFSET,
|
|
1470
|
+
CarWashCarSchema,
|
|
1424
1471
|
DEFAULT_AGENT_SPAWN_MIN_DISTANCE,
|
|
1472
|
+
DEFAULT_PLAYER_WALLET_BALANCE_USD,
|
|
1425
1473
|
MINIMUM_PLAY_WORLD_BOUNDS,
|
|
1426
1474
|
OCCUPANCY_POINT_MULTIPLIER,
|
|
1427
1475
|
PLAYER_ADDED_EVENT,
|
|
1428
1476
|
PLAYER_CHAIN_GENESIS_STABLE_KEY,
|
|
1429
1477
|
PLAYER_CHAIN_HEADER_STABLE_KEY,
|
|
1478
|
+
PlayerWalletSchema,
|
|
1479
|
+
PurchaseRecordSchema,
|
|
1430
1480
|
RemotePlayWorld,
|
|
1431
1481
|
SESSION_CLOSED_EVENT,
|
|
1432
1482
|
SESSION_CONNECTED_EVENT,
|
|
@@ -1435,44 +1485,75 @@ export {
|
|
|
1435
1485
|
SESSION_SSE_OPEN_EVENT,
|
|
1436
1486
|
SPATIAL_ZONE_INDEX_AGENTS,
|
|
1437
1487
|
SPATIAL_ZONE_INDEX_SPACES,
|
|
1488
|
+
STREET_NAME_POOL,
|
|
1489
|
+
SaleStateSchema,
|
|
1490
|
+
ShopItemSchema,
|
|
1491
|
+
SupermarketItemSchema,
|
|
1438
1492
|
WORLD_AGENT_SIGNAL_EVENT,
|
|
1439
1493
|
WORLD_INTERACTION_EVENT,
|
|
1440
1494
|
WORLD_JOURNEY_EVENT,
|
|
1441
1495
|
agentPlayDebug,
|
|
1496
|
+
applyBoundsFieldUpdateToLayout,
|
|
1497
|
+
availableCellsForZone,
|
|
1442
1498
|
boundingWorldRectForOccupancyPoints,
|
|
1443
1499
|
boundsContain,
|
|
1444
1500
|
buildRankedOccupancyPoints,
|
|
1445
1501
|
buildRankedOccupancyPointsForSpatialZone,
|
|
1502
|
+
buildRankedOccupancyPointsForZone,
|
|
1503
|
+
buildRankedOccupancyPointsInRect,
|
|
1504
|
+
cellsForZone,
|
|
1505
|
+
centerOfZone,
|
|
1446
1506
|
clampWorldPosition,
|
|
1447
1507
|
configureAgentPlayDebug,
|
|
1508
|
+
createInitialPlayerWallet,
|
|
1448
1509
|
createNodeCredentialMaterial,
|
|
1510
|
+
createVerticalStripSeedLayout,
|
|
1511
|
+
desaturateColor,
|
|
1512
|
+
enumerateIntegerCellsInRect,
|
|
1449
1513
|
expandBoundsToMinimumPlayArea,
|
|
1514
|
+
getStreetPoolEntryById,
|
|
1450
1515
|
intercomResultRecordFromLangChainInvokeOutput,
|
|
1451
1516
|
isAgentPlayDebugEnabled,
|
|
1452
1517
|
isAgentSpawnOccupancyPointAvailable,
|
|
1518
|
+
isAgentSpawnOccupancyPointAvailableInRect,
|
|
1519
|
+
isAgentSpawnOccupancyPointAvailableInZone,
|
|
1520
|
+
isItemAvailableForPurchase,
|
|
1453
1521
|
isSpaceAnchorOccupancyPointAvailable,
|
|
1522
|
+
isSpaceAnchorOccupancyPointAvailableInRect,
|
|
1523
|
+
isSpaceAnchorOccupancyPointAvailableInZone,
|
|
1454
1524
|
langchainRegistration,
|
|
1455
1525
|
listAllowedOccupancyPoints,
|
|
1456
1526
|
listOccupancyPointsForSpatialZone,
|
|
1527
|
+
listOccupancyPointsForZone,
|
|
1528
|
+
listOccupancyPointsInRect,
|
|
1457
1529
|
loadAgentPlayCredentialsFileFromPath,
|
|
1458
1530
|
loadAgentPlayCredentialsFileFromPathSync2 as loadAgentPlayCredentialsFileFromPathSync,
|
|
1459
1531
|
loadRootKey2 as loadRootKey,
|
|
1460
1532
|
mergeSnapshotWithPlayerChainNode,
|
|
1533
|
+
migrateWorldLayoutBounds,
|
|
1534
|
+
nextStreetFromPool,
|
|
1461
1535
|
nodeCredentialFromHumanPhrase2 as nodeCredentialFromHumanPhrase,
|
|
1462
1536
|
nodeCredentialFromPasswHash,
|
|
1463
1537
|
nodeCredentialsMaterialFromHumanPassphrase,
|
|
1464
1538
|
occupancyKeyForPosition,
|
|
1465
1539
|
occupancyPointsGroupedBySpatialZone,
|
|
1540
|
+
occupancyPointsGroupedByZones,
|
|
1466
1541
|
parseAgentPlayCredentialsJson,
|
|
1467
1542
|
parsePlayerChainFanoutNotify,
|
|
1468
1543
|
parsePlayerChainFanoutNotifyFromSsePayload,
|
|
1469
1544
|
parsePlayerChainNodeRpcBody,
|
|
1545
|
+
pickZoneForGroup,
|
|
1546
|
+
pointCellInRect,
|
|
1470
1547
|
pointCellInSpatialZone,
|
|
1548
|
+
pointCellInZone,
|
|
1549
|
+
primaryZoneForGroup,
|
|
1471
1550
|
resetAgentPlayDebug,
|
|
1472
1551
|
resolveAgentPlayCredentialsPath2 as resolveAgentPlayCredentialsPath,
|
|
1473
1552
|
sortNodeRefsForSerializedFetch,
|
|
1474
1553
|
spatialZoneBounds,
|
|
1475
1554
|
spatialZoneCenter,
|
|
1476
|
-
|
|
1555
|
+
streetFromPoolEntry,
|
|
1556
|
+
verifyStoredNodeCredential,
|
|
1557
|
+
zonesForGroup
|
|
1477
1558
|
};
|
|
1478
1559
|
//# sourceMappingURL=index.js.map
|