@whitesands/agent-player 1.1.0 → 1.3.0
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/CHANGELOG.md +17 -0
- package/README.md +60 -5
- package/dist/index.cjs +887 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +321 -5
- package/dist/index.d.ts +321 -5
- package/dist/index.js +883 -49
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +16 -3
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +31 -3
- package/dist/protocol.d.ts +31 -3
- package/dist/protocol.js +14 -2
- package/dist/protocol.js.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/{types-D0p6GrVs.d.cts → types-BcH7_ozx.d.ts} +43 -2
- package/dist/{types-DXM_HZHu.d.ts → types-gmAkYoQr.d.cts} +43 -2
- package/package.json +4 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
2
|
-
import { TokenUsage, ToolDescriptor, TurnReport } from './protocol.
|
|
2
|
+
import { TokenUsage, StepRecord, Relationship, ToolDescriptor, TurnReport } from './protocol.cjs';
|
|
3
3
|
|
|
4
4
|
type Logger = {
|
|
5
5
|
debug?: (message: string, extra?: unknown) => void;
|
|
@@ -14,6 +14,8 @@ type TurnResult = {
|
|
|
14
14
|
result: unknown;
|
|
15
15
|
attempts: number;
|
|
16
16
|
usage: TokenUsage;
|
|
17
|
+
/** Every action played, when the turn played more than one. */
|
|
18
|
+
steps?: StepRecord[];
|
|
17
19
|
};
|
|
18
20
|
type AgentEvent = {
|
|
19
21
|
type: "action";
|
|
@@ -32,6 +34,21 @@ type AgentEvent = {
|
|
|
32
34
|
error: string;
|
|
33
35
|
action?: string;
|
|
34
36
|
args?: Record<string, unknown>;
|
|
37
|
+
} | {
|
|
38
|
+
/** The character chose to remember a fact. Needs `memory: true`. */
|
|
39
|
+
type: "memory";
|
|
40
|
+
sessionId: string;
|
|
41
|
+
about: string;
|
|
42
|
+
note: string;
|
|
43
|
+
} | {
|
|
44
|
+
/** The character's feelings about someone changed. Needs `memory: true`. */
|
|
45
|
+
type: "relationship";
|
|
46
|
+
sessionId: string;
|
|
47
|
+
about: string;
|
|
48
|
+
affinity: number;
|
|
49
|
+
label: string;
|
|
50
|
+
change: number;
|
|
51
|
+
because: string;
|
|
35
52
|
} | {
|
|
36
53
|
type: "disconnected";
|
|
37
54
|
} | {
|
|
@@ -56,18 +73,42 @@ type AgentHandle = {
|
|
|
56
73
|
stop(): Promise<void>;
|
|
57
74
|
/** Subscribe to this session's action, retry, and failure events. Returns unsubscribe. */
|
|
58
75
|
on(listener: EventListener): () => void;
|
|
76
|
+
/**
|
|
77
|
+
* Tell the character about something that happened, without starting a turn.
|
|
78
|
+
* It is kept in the character's memory. Needs `memory: true`.
|
|
79
|
+
*/
|
|
80
|
+
observe(text: string, about?: string): void;
|
|
81
|
+
/** How the character feels about each person it knows, keyed by lower-case name. */
|
|
82
|
+
relationships(): Record<string, Relationship>;
|
|
59
83
|
};
|
|
60
84
|
type StartOptions = {
|
|
85
|
+
/**
|
|
86
|
+
* Character to play. Copy the id from the Players page.
|
|
87
|
+
* The platform key belongs to the game; this id selects the character.
|
|
88
|
+
*/
|
|
89
|
+
playerId: string;
|
|
61
90
|
/** Label stored with the session. Defaults to the class name. */
|
|
62
91
|
name?: string;
|
|
63
92
|
/** Added to the model prompt for this player only. */
|
|
64
93
|
goal?: string;
|
|
65
94
|
/** Extra instructions appended to the default agent prompt. */
|
|
66
95
|
instructions?: string;
|
|
96
|
+
/** Send only `instructions`, without the default agent prompt. */
|
|
97
|
+
ownInstructions?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Keep the character's memory and relationships on the platform, between
|
|
100
|
+
* sessions and servers. The local `done` list is left out of the view.
|
|
101
|
+
*/
|
|
102
|
+
memory?: boolean;
|
|
103
|
+
/** How many actions one turn may play, 1 to 4. Default 1. */
|
|
104
|
+
maxActions?: number;
|
|
105
|
+
/** false takes the platform's subgoal tools away. */
|
|
106
|
+
subgoals?: boolean;
|
|
67
107
|
};
|
|
68
108
|
type StartSessionRequest = {
|
|
69
109
|
sessionId: string;
|
|
70
110
|
sessionToken: string;
|
|
111
|
+
playerId: string;
|
|
71
112
|
name?: string;
|
|
72
113
|
tools: ToolDescriptor[];
|
|
73
114
|
instructions: string;
|
|
@@ -121,4 +162,4 @@ type AgentServerOptions = {
|
|
|
121
162
|
memoryPath?: string | false;
|
|
122
163
|
};
|
|
123
164
|
|
|
124
|
-
export type { AgentServerOptions as A, EventListener as E, InlinePlatform as I, Logger as L, StartOptions as S,
|
|
165
|
+
export type { AgentServerOptions as A, EventListener as E, InlinePlatform as I, Logger as L, StartOptions as S, TurnResult as T, AgentHandle as a, AgentEvent as b, TurnOptions as c, StartSessionRequest as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whitesands/agent-player",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Start a remote game agent from a player class. The SDK owns the MCP server; the model stays on the platform.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"examples/*"
|
|
47
47
|
],
|
|
48
48
|
"scripts": {
|
|
49
|
-
"build": "tsup && npm run build -w @wsi/forest-example && npm run build -w @wsi/courier-example && npm run build -w @wsi/ferry-example",
|
|
49
|
+
"build": "tsup && npm run build -w @wsi/forest-example && npm run build -w @wsi/courier-example && npm run build -w @wsi/ferry-example && npm run build -w @wsi/town-example",
|
|
50
50
|
"docs": "typedoc",
|
|
51
51
|
"clean": "rm -rf dist docs",
|
|
52
52
|
"release": "tsup && node scripts/publish.mjs",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"test:watch": "vitest",
|
|
55
55
|
"forest": "npm run start -w @wsi/forest-example --",
|
|
56
56
|
"courier": "npm run start -w @wsi/courier-example --",
|
|
57
|
-
"ferry": "npm run start -w @wsi/ferry-example --"
|
|
57
|
+
"ferry": "npm run start -w @wsi/ferry-example --",
|
|
58
|
+
"town": "npm run start -w @wsi/town-example --"
|
|
58
59
|
},
|
|
59
60
|
"engines": {
|
|
60
61
|
"node": ">=20"
|