@hmharness/environments 0.20.0 → 0.20.1
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/adapters.js +23 -13
- package/package.json +3 -3
package/dist/adapters.js
CHANGED
|
@@ -210,19 +210,18 @@ export class Arc3Environment {
|
|
|
210
210
|
state: {
|
|
211
211
|
gameId: this.session.gameId,
|
|
212
212
|
guid: this.session.guid,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
levelsCompleted: f.levels_completed ?? 0,
|
|
214
|
+
winLevels: f.win_levels ?? 0,
|
|
215
|
+
gameState: f.state ?? null,
|
|
216
216
|
framePreview: Array.isArray(f.frame) ? f.frame.slice(0, 64) : f.frame,
|
|
217
217
|
steps: this.session.steps,
|
|
218
|
-
totalReward: this.session.totalReward,
|
|
219
218
|
},
|
|
220
|
-
availableActions: this.actionSpecs(),
|
|
219
|
+
availableActions: this.actionSpecs(f.available_actions),
|
|
221
220
|
raw: f,
|
|
222
221
|
};
|
|
223
222
|
}
|
|
224
|
-
actionSpecs() {
|
|
225
|
-
|
|
223
|
+
actionSpecs(available) {
|
|
224
|
+
const all = [
|
|
226
225
|
{ id: 'a1', type: 'ACTION1', description: 'simple action 1 (game-defined, e.g. move up / option A)', cost: 1 },
|
|
227
226
|
{ id: 'a2', type: 'ACTION2', description: 'simple action 2', cost: 1 },
|
|
228
227
|
{ id: 'a3', type: 'ACTION3', description: 'simple action 3', cost: 1 },
|
|
@@ -231,6 +230,13 @@ export class Arc3Environment {
|
|
|
231
230
|
{ id: 'a6', type: 'ACTION6', description: 'coordinate action: click/tap at (x,y) on the 64×64 grid', argsSchema: { x: 'number 0-63', y: 'number 0-63' }, cost: 1 },
|
|
232
231
|
{ id: 'a7', type: 'ACTION7', description: 'undo (games that support it)', cost: 1 },
|
|
233
232
|
];
|
|
233
|
+
// the live frame advertises which actions THIS game accepts — trust it
|
|
234
|
+
// (the API returns action NUMBERS: [6] means only ACTION6)
|
|
235
|
+
if (available && available.length > 0) {
|
|
236
|
+
const set = new Set(available.map((a) => (typeof a === 'number' ? `ACTION${a}` : String(a).toUpperCase())));
|
|
237
|
+
return all.filter((a) => set.has(a.type));
|
|
238
|
+
}
|
|
239
|
+
return all;
|
|
234
240
|
}
|
|
235
241
|
async act(action) {
|
|
236
242
|
const bridge = this.ensureLive();
|
|
@@ -250,13 +256,16 @@ export class Arc3Environment {
|
|
|
250
256
|
else {
|
|
251
257
|
return { actionId: action.id, outcome: 'failure', error: { code: 'E_UNKNOWN_ACTION', message: `unknown ARC action ${action.type}` }, durationMs: Date.now() - started };
|
|
252
258
|
}
|
|
259
|
+
const before = this.session.lastFrame?.levels_completed ?? 0;
|
|
260
|
+
const after = frame.levels_completed ?? 0;
|
|
253
261
|
this.session.lastFrame = frame;
|
|
254
262
|
this.session.steps += 1;
|
|
255
263
|
this.session.totalReward += frame.reward ?? 0;
|
|
256
264
|
return {
|
|
257
265
|
actionId: action.id,
|
|
258
|
-
outcome:
|
|
259
|
-
|
|
266
|
+
// outcome: the call landed; a level win shows as progress
|
|
267
|
+
outcome: frame.status === 'DEAD' ? 'failure' : 'success',
|
|
268
|
+
output: { levelsCompleted: after, levelProgressed: after > before, reward: frame.reward, status: frame.status },
|
|
260
269
|
durationMs: Date.now() - started,
|
|
261
270
|
cost: 1,
|
|
262
271
|
};
|
|
@@ -290,15 +299,16 @@ export class Arc3Environment {
|
|
|
290
299
|
return { environmentId: this.id, metrics: {} };
|
|
291
300
|
const summary = await bridge.getScorecard(this.session.cardId).catch(() => ({}));
|
|
292
301
|
const envs = (summary.environments ?? []);
|
|
293
|
-
const mine = envs.find((e) => e.game_id === this.session?.gameId) ?? summary;
|
|
302
|
+
const mine = envs.find((e) => e.id === this.session?.gameId || e.game_id === this.session?.gameId) ?? summary;
|
|
294
303
|
const num = (v) => (typeof v === 'number' ? v : 0);
|
|
295
304
|
return {
|
|
296
305
|
environmentId: this.id,
|
|
297
306
|
metrics: {
|
|
298
307
|
steps: this.session.steps,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
308
|
+
levelsCompleted: num(mine.levels_completed),
|
|
309
|
+
levelCount: num(mine.level_count),
|
|
310
|
+
actions: num(mine.actions),
|
|
311
|
+
completed: num(mine.completed) || (mine.completed === true ? 1 : 0),
|
|
302
312
|
},
|
|
303
313
|
details: 'ARC-AGI-3 official scorecard',
|
|
304
314
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/environments",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "HMH Cognitive OS environment adapters: Terminal (native), HarmonyOS (via domain-harmony), Browser/Desktop (via host automation bridge), ARC3 (external adapter). Every adapter implements the @hmharness/cognitive Environment protocol and must pass the shared conformance test.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"node": ">=22"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@hmharness/kernel": "0.20.
|
|
30
|
-
"@hmharness/cognitive": "0.20.
|
|
29
|
+
"@hmharness/kernel": "0.20.1",
|
|
30
|
+
"@hmharness/cognitive": "0.20.1"
|
|
31
31
|
}
|
|
32
32
|
}
|