dfhack-remote-node 2.0.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/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "dfhack-remote-node",
3
+ "version": "2.0.0",
4
+ "description": "Node client for the DFHack Remote RPC protocol (protobuf over TCP)",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=18"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "build/proto.json",
21
+ "proto",
22
+ "README.md",
23
+ "LICENSE.md"
24
+ ],
25
+ "scripts": {
26
+ "build": "npm run gen-proto && tsup",
27
+ "gen-proto": "pbjs proto/*.proto -t json -o build/proto.json",
28
+ "typecheck": "tsc --noEmit",
29
+ "lint": "eslint .",
30
+ "format": "prettier --write .",
31
+ "test": "node scripts/mock-server-test.js",
32
+ "spike": "node scripts/m0-spike.js",
33
+ "prepare": "npm run build"
34
+ },
35
+ "keywords": [
36
+ "dwarf",
37
+ "fortress",
38
+ "dfhack",
39
+ "remote",
40
+ "RemoteFortressReader"
41
+ ],
42
+ "author": "Alexander Olvera",
43
+ "license": "ISC",
44
+ "dependencies": {
45
+ "protobufjs": "^7.4.0"
46
+ },
47
+ "devDependencies": {
48
+ "@eslint/js": "^9.0.0",
49
+ "@types/node": "^24.0.0",
50
+ "eslint": "^9.0.0",
51
+ "eslint-config-prettier": "^10.0.0",
52
+ "prettier": "^3.0.0",
53
+ "protobufjs-cli": "^1.1.3",
54
+ "tsup": "^8.0.0",
55
+ "typescript": "^5.6.0",
56
+ "typescript-eslint": "^8.0.0"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/alexanderolvera/dfhack-remote-node.git"
61
+ },
62
+ "homepage": "https://github.com/alexanderolvera/dfhack-remote-node#readme",
63
+ "bugs": {
64
+ "url": "https://github.com/alexanderolvera/dfhack-remote-node/issues"
65
+ }
66
+ }
@@ -0,0 +1,109 @@
1
+ syntax = "proto2";
2
+
3
+ //Attempts to provide a complete framework for reading everything from a fortress needed for vizualization
4
+ package AdventureControl;
5
+
6
+ option optimize_for = LITE_RUNTIME;
7
+
8
+ import "RemoteFortressReader.proto";
9
+
10
+ // Plugin: RemoteFortressReader
11
+
12
+ enum AdvmodeMenu
13
+ {
14
+ Default = 0;
15
+ Look = 1;
16
+ ConversationAddress = 2;
17
+ ConversationSelect = 3;
18
+ ConversationSpeak = 4;
19
+ Inventory = 5;
20
+ Drop = 6;
21
+ ThrowItem = 7;
22
+ Wear = 8;
23
+ Remove = 9;
24
+ Interact = 10;
25
+ Put = 11;
26
+ PutContainer = 12;
27
+ Eat = 13;
28
+ ThrowAim = 14;
29
+ Fire = 15;
30
+ Get = 16;
31
+ Unk17 = 17;
32
+ CombatPrefs = 18;
33
+ Companions = 19;
34
+ MovementPrefs = 20;
35
+ SpeedPrefs = 21;
36
+ InteractAction = 22;
37
+ MoveCarefully = 23;
38
+ Announcements = 24;
39
+ UseBuilding = 25;
40
+ Travel = 26;
41
+ Unk27 = 27;
42
+ Unk28 = 28;
43
+ SleepConfirm = 29;
44
+ SelectInteractionTarget = 30;
45
+ Unk31 = 31;
46
+ Unk32 = 32;
47
+ FallAction = 33;
48
+ ViewTracks = 34;
49
+ Jump = 35;
50
+ Unk36 = 36;
51
+ AttackConfirm = 37;
52
+ AttackType = 38;
53
+ AttackBodypart = 39;
54
+ AttackStrike = 40;
55
+ Unk41 = 41;
56
+ Unk42 = 42;
57
+ DodgeDirection = 43;
58
+ Unk44 = 44;
59
+ Unk45 = 45;
60
+ Build = 46;
61
+ }
62
+
63
+ enum CarefulMovementType
64
+ {
65
+ DEFAULT_MOVEMENT = 0;
66
+ RELEASE_ITEM_HOLD = 1;
67
+ RELEASE_TILE_HOLD = 2;
68
+ ATTACK_CREATURE = 3;
69
+ HOLD_TILE = 4;
70
+ MOVE = 5;
71
+ CLIMB = 6;
72
+ HOLD_ITEM = 7;
73
+ BUILDING_INTERACT = 8;
74
+ ITEM_INTERACT = 9;
75
+ ITEM_INTERACT_GUIDE = 10;
76
+ ITEM_INTERACT_RIDE = 11;
77
+ ITEM_INTERACT_PUSH = 12;
78
+ }
79
+
80
+ enum MiscMoveType
81
+ {
82
+ SET_CLIMB = 0;
83
+ SET_STAND = 1;
84
+ SET_CANCEL = 2;
85
+ }
86
+
87
+ message MoveCommandParams
88
+ {
89
+ optional RemoteFortressReader.Coord direction = 1;
90
+ }
91
+
92
+ message MovementOption
93
+ {
94
+ optional RemoteFortressReader.Coord dest = 1;
95
+ optional RemoteFortressReader.Coord source = 2;
96
+ optional RemoteFortressReader.Coord grab = 3;
97
+ optional CarefulMovementType movement_type = 4;
98
+ }
99
+
100
+ message MenuContents
101
+ {
102
+ optional AdvmodeMenu current_menu = 1;
103
+ repeated MovementOption movements = 2;
104
+ }
105
+
106
+ message MiscMoveParams
107
+ {
108
+ optional MiscMoveType type = 1;
109
+ }
@@ -0,0 +1,207 @@
1
+ syntax = "proto2";
2
+
3
+ package dfproto;
4
+
5
+ option optimize_for = LITE_RUNTIME;
6
+
7
+ message EnumItemName {
8
+ required int32 value = 1;
9
+ optional string name = 2;
10
+
11
+ // For bitfield members
12
+ optional int32 bit_size = 3 [default = 1];
13
+ };
14
+
15
+ message BasicMaterialId {
16
+ required int32 type = 1;
17
+ required sint32 index = 2;
18
+ };
19
+
20
+ message BasicMaterialInfo {
21
+ required int32 type = 1;
22
+ required sint32 index = 2;
23
+
24
+ // The raw token
25
+ required string token = 3;
26
+
27
+ // IF mask.flags:
28
+ // List of material_flags indices
29
+ repeated int32 flags = 4;
30
+
31
+ // Material type/index expanded:
32
+ optional int32 subtype = 5 [default = -1];
33
+ optional int32 creature_id = 6 [default = -1];
34
+ optional int32 plant_id = 7 [default = -1];
35
+ optional int32 histfig_id = 8 [default = -1];
36
+
37
+ optional string name_prefix = 9 [default = ""];
38
+
39
+ // IF mask.states: in listed order;
40
+ // ELSE: one state matching mask.temperature
41
+ repeated fixed32 state_color = 10;
42
+ repeated string state_name = 11;
43
+ repeated string state_adj = 12;
44
+
45
+ // IF mask.reaction:
46
+ message Product {
47
+ required string id = 1;
48
+ required int32 type = 2;
49
+ required sint32 index = 3;
50
+ };
51
+ repeated string reaction_class = 13;
52
+ repeated Product reaction_product = 14;
53
+
54
+ // IF mask.flags:
55
+ repeated int32 inorganic_flags = 15;
56
+ };
57
+
58
+ message BasicMaterialInfoMask {
59
+ enum StateType {
60
+ Solid = 0;
61
+ Liquid = 1;
62
+ Gas = 2;
63
+ Powder = 3;
64
+ Paste = 4;
65
+ Pressed = 5;
66
+ };
67
+ repeated StateType states = 1;
68
+ optional int32 temperature = 4 [default = 10015];
69
+
70
+ optional bool flags = 2 [default = false];
71
+ optional bool reaction = 3 [default = false];
72
+ };
73
+
74
+ message JobSkillAttr {
75
+ required int32 id = 1;
76
+ required string key = 2;
77
+
78
+ optional string caption = 3;
79
+ optional string caption_noun = 4;
80
+
81
+ optional int32 profession = 5;
82
+ optional int32 labor = 6;
83
+ optional string type = 7;
84
+ };
85
+
86
+ message ProfessionAttr {
87
+ required int32 id = 1;
88
+ required string key = 2;
89
+
90
+ optional string caption = 3;
91
+ optional bool military = 4;
92
+ optional bool can_assign_labor = 5;
93
+
94
+ optional int32 parent = 6;
95
+ };
96
+
97
+ message UnitLaborAttr {
98
+ required int32 id = 1;
99
+ required string key = 2;
100
+
101
+ optional string caption = 3;
102
+ };
103
+
104
+ message NameInfo {
105
+ optional string first_name = 1;
106
+ optional string nickname = 2;
107
+
108
+ optional int32 language_id = 3 [default = -1];
109
+
110
+ optional string last_name = 4;
111
+ optional string english_name = 5;
112
+ };
113
+
114
+ message NameTriple {
115
+ required string normal = 1;
116
+ optional string plural = 2;
117
+ optional string adjective = 3;
118
+ };
119
+
120
+ message UnitCurseInfo {
121
+ required fixed32 add_tags1 = 1;
122
+ required fixed32 rem_tags1 = 2;
123
+ required fixed32 add_tags2 = 3;
124
+ required fixed32 rem_tags2 = 4;
125
+
126
+ optional NameTriple name = 5;
127
+ };
128
+
129
+ message SkillInfo {
130
+ required int32 id = 1;
131
+ required int32 level = 2;
132
+ required int32 experience = 3;
133
+ };
134
+
135
+ message UnitMiscTrait {
136
+ required int32 id = 1;
137
+ required int32 value = 2;
138
+ };
139
+
140
+ message BasicUnitInfo {
141
+ required int32 unit_id = 1;
142
+
143
+ required int32 pos_x = 13;
144
+ required int32 pos_y = 14;
145
+ required int32 pos_z = 15;
146
+
147
+ optional NameInfo name = 2;
148
+
149
+ required fixed32 flags1 = 3;
150
+ required fixed32 flags2 = 4;
151
+ required fixed32 flags3 = 5;
152
+
153
+ required int32 race = 6;
154
+ required int32 caste = 7;
155
+ optional int32 gender = 8 [default = -1];
156
+
157
+ optional int32 civ_id = 9 [default = -1];
158
+ optional int32 histfig_id = 10 [default = -1];
159
+
160
+ optional int32 death_id = 17 [default = -1];
161
+ optional uint32 death_flags = 18;
162
+
163
+ // IF mask.profession:
164
+ optional int32 squad_id = 19 [default = -1];
165
+ optional int32 squad_position = 20 [default = -1];
166
+
167
+ optional int32 profession = 22 [default = -1];
168
+ optional string custom_profession = 23;
169
+
170
+ // IF mask.labors:
171
+ repeated int32 labors = 11;
172
+
173
+ // IF mask.skills:
174
+ repeated SkillInfo skills = 12;
175
+
176
+ // IF mask.misc_traits:
177
+ repeated UnitMiscTrait misc_traits = 24;
178
+
179
+ optional UnitCurseInfo curse = 16;
180
+
181
+ repeated int32 burrows = 21;
182
+ };
183
+
184
+ message BasicUnitInfoMask {
185
+ optional bool labors = 1 [default = false];
186
+ optional bool skills = 2 [default = false];
187
+ optional bool profession = 3 [default = false];
188
+ optional bool misc_traits = 4 [default = false];
189
+ };
190
+
191
+ message BasicSquadInfo {
192
+ required int32 squad_id = 1;
193
+
194
+ optional NameInfo name = 2;
195
+
196
+ // A special field completely overriding the name:
197
+ optional string alias = 3;
198
+
199
+ // Member histfig ids:
200
+ repeated sint32 members = 4;
201
+ };
202
+
203
+ message UnitLaborState {
204
+ required int32 unit_id = 1;
205
+ required int32 labor = 2;
206
+ required bool value = 3;
207
+ };
@@ -0,0 +1,109 @@
1
+ syntax = "proto2";
2
+
3
+ package dfproto;
4
+
5
+ option optimize_for = LITE_RUNTIME;
6
+
7
+ import "Basic.proto";
8
+
9
+ // RPC GetVersion : EmptyMessage -> StringMessage
10
+ // RPC GetDFVersion : EmptyMessage -> StringMessage
11
+
12
+ // RPC GetWorldInfo : EmptyMessage -> GetWorldInfoOut
13
+ message GetWorldInfoOut {
14
+ enum Mode {
15
+ MODE_DWARF = 1;
16
+ MODE_ADVENTURE = 2;
17
+ MODE_LEGENDS = 3;
18
+ };
19
+ required Mode mode = 1;
20
+
21
+ required string save_dir = 2;
22
+ optional NameInfo world_name = 3;
23
+
24
+ // Dwarf mode
25
+ optional int32 civ_id = 4;
26
+ optional int32 site_id = 5;
27
+ optional int32 group_id = 6;
28
+ optional int32 race_id = 7;
29
+
30
+ // Adventure mode
31
+ optional int32 player_unit_id = 8;
32
+ optional int32 player_histfig_id = 9;
33
+ repeated int32 companion_histfig_ids = 10;
34
+ };
35
+
36
+ // RPC ListEnums : EmptyMessage -> ListEnumsOut
37
+ message ListEnumsOut {
38
+ repeated EnumItemName material_flags = 1;
39
+ repeated EnumItemName inorganic_flags = 2;
40
+
41
+ repeated EnumItemName unit_flags1 = 3;
42
+ repeated EnumItemName unit_flags2 = 4;
43
+ repeated EnumItemName unit_flags3 = 5;
44
+
45
+ repeated EnumItemName unit_labor = 6;
46
+ repeated EnumItemName job_skill = 7;
47
+
48
+ repeated EnumItemName cie_add_tag_mask1 = 8;
49
+ repeated EnumItemName cie_add_tag_mask2 = 9;
50
+
51
+ repeated EnumItemName death_info_flags = 10;
52
+
53
+ repeated EnumItemName profession = 11;
54
+ };
55
+
56
+ // RPC ListJobSkills : EmptyMessage -> ListJobSkillsOut
57
+ message ListJobSkillsOut {
58
+ repeated JobSkillAttr skill = 1;
59
+ repeated ProfessionAttr profession = 2;
60
+ repeated UnitLaborAttr labor = 3;
61
+ };
62
+
63
+ // RPC ListMaterials : ListMaterialsIn -> ListMaterialsOut
64
+ message ListMaterialsIn {
65
+ optional BasicMaterialInfoMask mask = 1;
66
+
67
+ // Specific materials:
68
+ repeated BasicMaterialId id_list = 2;
69
+
70
+ // Complete list by type:
71
+ optional bool builtin = 3;
72
+ optional bool inorganic = 4;
73
+ optional bool creatures = 5;
74
+ optional bool plants = 6;
75
+ };
76
+ message ListMaterialsOut {
77
+ repeated BasicMaterialInfo value = 1;
78
+ };
79
+
80
+ // RPC ListUnits : ListUnitsIn -> ListUnitsOut
81
+ message ListUnitsIn {
82
+ optional BasicUnitInfoMask mask = 1;
83
+
84
+ // Specific units:
85
+ repeated int32 id_list = 2;
86
+
87
+ // All units matching:
88
+ optional bool scan_all = 5;
89
+
90
+ optional int32 race = 3;
91
+ optional int32 civ_id = 4;
92
+ optional bool dead = 6; // i.e. passive corpse
93
+ optional bool alive = 7; // i.e. not dead or undead
94
+ optional bool sane = 8; // not dead, ghost, zombie, or insane
95
+ };
96
+ message ListUnitsOut {
97
+ repeated BasicUnitInfo value = 1;
98
+ };
99
+
100
+ // RPC ListSquads : ListSquadsIn -> ListSquadsOut
101
+ message ListSquadsIn {}
102
+ message ListSquadsOut {
103
+ repeated BasicSquadInfo value = 1;
104
+ };
105
+
106
+ // RPC SetUnitLabors : SetUnitLaborsIn -> EmptyMessage
107
+ message SetUnitLaborsIn {
108
+ repeated UnitLaborState change = 1;
109
+ };
@@ -0,0 +1,92 @@
1
+ syntax = "proto2";
2
+
3
+ package dfproto;
4
+
5
+ option optimize_for = LITE_RUNTIME;
6
+
7
+ message CoreTextFragment {
8
+ required string text = 1;
9
+
10
+ enum Color {
11
+ COLOR_BLACK = 0;
12
+ COLOR_BLUE = 1;
13
+ COLOR_GREEN = 2;
14
+ COLOR_CYAN = 3;
15
+ COLOR_RED = 4;
16
+ COLOR_MAGENTA = 5;
17
+ COLOR_BROWN = 6;
18
+ COLOR_GREY = 7;
19
+ COLOR_DARKGREY = 8;
20
+ COLOR_LIGHTBLUE = 9;
21
+ COLOR_LIGHTGREEN = 10;
22
+ COLOR_LIGHTCYAN = 11;
23
+ COLOR_LIGHTRED = 12;
24
+ COLOR_LIGHTMAGENTA = 13;
25
+ COLOR_YELLOW = 14;
26
+ COLOR_WHITE = 15;
27
+ };
28
+ optional Color color = 2;
29
+ }
30
+
31
+ message CoreTextNotification {
32
+ repeated CoreTextFragment fragments = 1;
33
+ }
34
+
35
+ message CoreErrorNotification {
36
+ enum ErrorCode {
37
+ CR_LINK_FAILURE = -3;
38
+ CR_WOULD_BREAK = -2;
39
+ CR_NOT_IMPLEMENTED = -1;
40
+ CR_OK = 0;
41
+ CR_FAILURE = 1;
42
+ CR_WRONG_USAGE = 2;
43
+ CR_NOT_FOUND = 3;
44
+ };
45
+
46
+ required ErrorCode code = 1;
47
+ }
48
+
49
+ message EmptyMessage {}
50
+
51
+ message IntMessage {
52
+ required int32 value = 1;
53
+ }
54
+
55
+ message IntListMessage {
56
+ repeated int32 value = 1;
57
+ }
58
+
59
+ message StringMessage {
60
+ required string value = 1;
61
+ }
62
+
63
+ message StringListMessage {
64
+ repeated string value = 1;
65
+ }
66
+
67
+ // RPC BindMethod : CoreBindRequest -> CoreBindReply
68
+ message CoreBindRequest {
69
+ required string method = 1;
70
+ required string input_msg = 2;
71
+ required string output_msg = 3;
72
+ optional string plugin = 4;
73
+ }
74
+ message CoreBindReply {
75
+ required int32 assigned_id = 1;
76
+ }
77
+
78
+ // RPC RunCommand : CoreRunCommandRequest -> EmptyMessage
79
+ message CoreRunCommandRequest {
80
+ required string command = 1;
81
+ repeated string arguments = 2;
82
+ }
83
+
84
+ // RPC CoreSuspend : EmptyMessage -> IntMessage
85
+ // RPC CoreResume : EmptyMessage -> IntMessage
86
+
87
+ // RPC RunLua : CoreRunLuaRequest -> StringListMessage
88
+ message CoreRunLuaRequest {
89
+ required string module = 1;
90
+ required string function = 2;
91
+ repeated string arguments = 3;
92
+ }
@@ -0,0 +1,97 @@
1
+ syntax = "proto2";
2
+
3
+ //Attempts to provide a complete framework for reading everything from a fortress needed for vizualization
4
+ package DwarfControl;
5
+
6
+ option optimize_for = LITE_RUNTIME;
7
+
8
+ // Plugin: RemoteFortressReader
9
+
10
+ import "ui_sidebar_mode.proto";
11
+ import "RemoteFortressReader.proto";
12
+
13
+ // RPC GetSideMenu : EmptyMessage -> SidebarState
14
+ // RPC SetSideMenu : SidebarCommand -> EmptyMessage
15
+
16
+
17
+ enum BuildCategory
18
+ {
19
+ NotCategory = 0;
20
+ SiegeEngines = 1;
21
+ Traps = 2;
22
+ Workshops = 3;
23
+ Furnaces = 4;
24
+ Constructions = 5;
25
+ MachineComponents = 6;
26
+ Track = 7;
27
+ }
28
+
29
+ enum MenuAction
30
+ {
31
+ MenuNone = 0;
32
+ MenuSelect = 1;
33
+ MenuCancel = 2;
34
+ MenuSelectAll = 3;
35
+ }
36
+
37
+ enum BuildSelectorStage
38
+ {
39
+ StageNoMat = 0;
40
+ StagePlace = 1;
41
+ StageItemSelect = 2;
42
+ }
43
+
44
+ message SidebarState
45
+ {
46
+ optional proto.enums.ui_sidebar_mode.ui_sidebar_mode mode = 1;
47
+ repeated MenuItem menu_items = 2;
48
+ optional BuildSelector build_selector = 3;
49
+ }
50
+
51
+ message MenuItem
52
+ {
53
+ optional RemoteFortressReader.BuildingType building_type = 1;
54
+ optional int32 existing_count = 2;
55
+ optional BuildCategory build_category = 3;
56
+ }
57
+
58
+ message SidebarCommand
59
+ {
60
+ optional proto.enums.ui_sidebar_mode.ui_sidebar_mode mode = 1;
61
+ optional int32 menu_index = 2;
62
+ optional MenuAction action = 3;
63
+ optional RemoteFortressReader.Coord selection_coord = 4;
64
+ }
65
+
66
+ message BuiildReqChoice
67
+ {
68
+ optional int32 distance = 1;
69
+ optional string name = 2;
70
+ optional int32 num_candidates = 3;
71
+ optional int32 used_count = 4;
72
+ }
73
+
74
+ message BuildItemReq
75
+ {
76
+ //Put filter here = 1
77
+ optional int32 count_required = 2;
78
+ optional int32 count_max = 3;
79
+ optional int32 count_provided = 4;
80
+ }
81
+
82
+ message BuildSelector
83
+ {
84
+ optional RemoteFortressReader.BuildingType building_type = 1;
85
+ optional BuildSelectorStage stage = 2;
86
+ repeated BuiildReqChoice choices = 3;
87
+ optional int32 sel_index = 4;
88
+ repeated BuildItemReq requirements = 5;
89
+ optional int32 req_index = 6;
90
+ repeated string errors = 7;
91
+ optional int32 radius_x_low = 8;
92
+ optional int32 radius_y_low = 9;
93
+ optional int32 radius_x_high = 10;
94
+ optional int32 radius_y_high = 11;
95
+ optional RemoteFortressReader.Coord cursor = 12;
96
+ repeated int32 tiles = 13;
97
+ }