@lmmslab/harness 0.85.1 → 0.86.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.
Files changed (93) hide show
  1. package/package.json +1 -1
  2. package/python/harness/__init__.py +2 -2
  3. package/python/harness/bench.py +2 -2
  4. package/python/harness/builtin/benches/README.md +1 -2
  5. package/python/harness/builtin/configs/default.toml +4 -19
  6. package/python/harness/builtin/configs/deploy/example-api.toml +1 -1
  7. package/python/harness/builtin/configs/models/deepseek-flash.toml +1 -1
  8. package/python/harness/builtin/configs/models/grok-low.toml +1 -1
  9. package/python/harness/builtin/configs/models/grok-medium.toml +3 -6
  10. package/python/harness/builtin/environment/README.md +8 -25
  11. package/python/harness/builtin/prompts/conversation/core.md +6 -5
  12. package/python/harness/builtin/prompts/core/core.md +147 -203
  13. package/python/harness/builtin/prompts/core/pack.toml +0 -1
  14. package/python/harness/builtin/prompts/reflect/core.md +8 -32
  15. package/python/harness/builtin/prompts/reflect/pack.toml +2 -4
  16. package/python/harness/builtin/prompts/shared/agent-skills.md +5 -3
  17. package/python/harness/builtin/prompts/shared/agents.md +20 -10
  18. package/python/harness/builtin/prompts/shared/checklist.md +13 -17
  19. package/python/harness/builtin/prompts/shared/environments.md +20 -15
  20. package/python/harness/builtin/prompts/shared/learning-goal.md +2 -3
  21. package/python/harness/builtin/prompts/shared/learning.md +73 -23
  22. package/python/harness/builtin/prompts/shared/mcp.md +11 -6
  23. package/python/harness/builtin/prompts/shared/reflex-method.md +243 -0
  24. package/python/harness/builtin/prompts/shared/units.md +138 -0
  25. package/python/harness/builtin/prompts/shared/web.md +5 -6
  26. package/python/harness/builtin/skills/agents/__init__.py +18 -3
  27. package/python/harness/builtin/skills/agents/skill.toml +3 -3
  28. package/python/harness/builtin/skills/checklist/__init__.py +34 -32
  29. package/python/harness/builtin/skills/checklist/skill.toml +9 -9
  30. package/python/harness/builtin/skills/environments/__init__.py +9 -5
  31. package/python/harness/builtin/skills/environments/skill.toml +1 -1
  32. package/python/harness/builtin/skills/experience/skill.toml +1 -1
  33. package/python/harness/builtin/skills/learning/__init__.py +19 -5
  34. package/python/harness/builtin/skills/mcp/skill.toml +1 -1
  35. package/python/harness/builtin/skills/memory/__init__.py +4 -1
  36. package/python/harness/builtin/skills/memory/skill.toml +0 -5
  37. package/python/harness/builtin/skills/verify/skill.toml +1 -0
  38. package/python/harness/builtin/skills/web/__init__.py +4 -1
  39. package/python/harness/builtin/third_party/sources.toml +2 -40
  40. package/python/harness/cli.py +16 -25
  41. package/python/harness/config/__init__.py +2 -2
  42. package/python/harness/config/agent.py +59 -47
  43. package/python/harness/core/__init__.py +1 -1
  44. package/python/harness/core/codec.py +4 -4
  45. package/python/harness/core/contracts.py +1 -1
  46. package/python/harness/core/media.py +1 -1
  47. package/python/harness/core/ports.py +2 -2
  48. package/python/harness/core/procs.py +1 -1
  49. package/python/harness/core/remote.py +1 -1
  50. package/python/harness/core/worker.py +19 -13
  51. package/python/harness/embodiments.py +53 -44
  52. package/python/harness/extensions.py +22 -0
  53. package/python/harness/host/__init__.py +1 -1
  54. package/python/harness/host/http.py +6 -12
  55. package/python/harness/host/sessions.py +1 -1
  56. package/python/harness/host/tasks.py +15 -11
  57. package/python/harness/host/workspaces.py +36 -8
  58. package/python/harness/packages/__init__.py +5 -5
  59. package/python/harness/packages/environments.py +30 -18
  60. package/python/harness/packages/manager.py +1 -1
  61. package/python/harness/packages/manifest.py +6 -6
  62. package/python/harness/packages/provision.py +1 -1
  63. package/python/harness/packages/sources.py +1 -1
  64. package/python/harness/paths.py +1 -1
  65. package/python/harness/runtime/decision/loop.py +95 -5
  66. package/python/harness/runtime/decision/messages.py +128 -2
  67. package/python/harness/runtime/decision/model.py +4 -5
  68. package/python/harness/runtime/decision/prompts.py +20 -32
  69. package/python/harness/runtime/events.py +7 -5
  70. package/python/harness/runtime/execution/attached.py +3 -3
  71. package/python/harness/runtime/execution/entries.py +189 -8
  72. package/python/harness/runtime/execution/kernel.py +26 -1
  73. package/python/harness/runtime/execution/results.py +2 -3
  74. package/python/harness/runtime/execution/session.py +417 -32
  75. package/python/harness/runtime/execution/skills.py +63 -16
  76. package/python/harness/runtime/learning/active.py +7 -7
  77. package/python/harness/runtime/learning/learner.py +3 -2
  78. package/python/harness/runtime/learning/library.py +9 -4
  79. package/python/harness/runtime/learning/reflect.py +10 -9
  80. package/python/harness/runtime/reactive/rules.py +4 -4
  81. package/python/harness/runtime/reactive/tree.py +506 -25
  82. package/python/harness/runtime/safety/input.py +1 -1
  83. package/python/harness/runtime/safety/isolation.py +3 -3
  84. package/python/harness/runtime/safety/shield.py +4 -50
  85. package/python/harness/runtime/task/delegation.py +5 -5
  86. package/python/harness/runtime/task/environments.py +10 -0
  87. package/python/harness/runtime/task/run.py +222 -27
  88. package/python/harness/runtime/tick.py +24 -1
  89. package/python/harness/sdk/__init__.py +2 -5
  90. package/python/harness/services/registry.py +23 -19
  91. package/python/harness/settings.py +9 -9
  92. package/python/harness/builtin/environment/constraints.txt +0 -31
  93. package/python/harness/builtin/prompts/shared/world.md +0 -1
@@ -47,7 +47,7 @@ class PhysicalInput:
47
47
 
48
48
  def input_sent(command) -> dict:
49
49
  """What a step sent, for its `input` note: the command's fields but its type (the keys
50
- and buttons a game's state input holds down, its pointer motion), a typed text by its
50
+ and buttons a state input holds down, its pointer motion), a typed text by its
51
51
  length only."""
52
52
  sent = {}
53
53
  for name, value in command.items():
@@ -23,7 +23,7 @@ sandbox cannot run, and inside it covers what the sandbox leaves visible: direct
23
23
  outside the hidden roots, such as another run's results on a data disk. Whether a path
24
24
  exists is not hidden.
25
25
 
26
- A worker's private files (its profile's `private_paths`, e.g. a game's instance) are
26
+ A worker's private files (its profile's `private_paths`) are
27
27
  refused to programs whether or not the kernel is isolated, and each attempt is reported
28
28
  to the host, which records it in the trace (`file_access`).
29
29
 
@@ -108,7 +108,7 @@ def sandbox_command(command: list[str], *, keep: list[Path], read_only: list[Pat
108
108
 
109
109
 
110
110
  # Packages the kernel imports that may be installed outside the Python prefix
111
- # (editable installs): the policy client of XPolicyLab.
111
+ # (editable installs): a package's own client code.
112
112
  KERNEL_PACKAGES = ("client_server",)
113
113
  # Modules imported before the network guard is installed: importing them loads
114
114
  # native code through ctypes, which programs may not do.
@@ -297,7 +297,7 @@ def install_network_guard(allowed: set[tuple[str, int]]) -> None:
297
297
 
298
298
  def install_private_guard(paths: list, report) -> list[str]:
299
299
  """Refuse opening, listing and changing anything under `paths` (the worker's private
300
- files, e.g. a game's instance) for the rest of the process's life, with or without the
300
+ files) for the rest of the process's life, with or without the
301
301
  rest of the isolation, and call `report(event, path)` first for each attempt (the
302
302
  trace records it). Paths are compared resolved and, on Windows, without case. Returns
303
303
  the guarded roots."""
@@ -6,53 +6,8 @@ embodiment's shield has the same interface, the core's (CommandShield):
6
6
  it judges one command against the measured state, and the command passes unchanged or is
7
7
  rejected with the reasons; it never shortens, clamps or otherwise alters a command, since
8
8
  a program whose command was quietly changed does not learn it was wrong. A tick's
9
- `shield` field is its ShieldResult. The shields of the robot, a computer and a game are
10
- described here; each is in the package of its embodiment.
11
-
12
- Shield (the robot package, harness_robot/shield.py) is the robot's. It sees absolute
13
- joint position commands and, when the worker supplies forward kinematics, the
14
- end-effector positions those commands imply. It catches commands that are bugs, and
15
- nothing else. Rejected are:
16
-
17
- - a malformed command (wrong length, a value that is not finite);
18
- - a joint outside its limits, or an end effector outside the workspace box,
19
- further than the robot already is (contact can push a measured joint or hand
20
- slightly out; holding there or moving back in is not a bug);
21
- - a jump: an arm's joints more than max_joint_jump_rad, or its end effector more
22
- than max_cartesian_jump_m, from both the previous accepted command and the
23
- measured state. One control tick of a real motion moves far less; a jump is an
24
- IK solution on another branch, a target in the wrong frame, a controller that
25
- diverged. A smooth sequence is never rejected for running ahead of an arm that
26
- lags behind it, and a command from where the arm is (a hold, the next skill's
27
- first waypoint, a retreat) is never rejected for where the last one went.
28
-
29
- Speed and acceleration are not the shield's: the skills time their own motions,
30
- and a physical robot's controller enforces its own rate limits.
31
-
32
- DesktopShield (the computer package, harness_computer/shield.py) is a computer's. It
33
- sees one input step (DESKTOP_COMMANDS) and rejects an unknown command, field or key, a
34
- point off the screen, text the keyboard cannot type, and a scroll, wait or drag out of
35
- its bounds. A step into one window (its `window` field) has its points in that window's
36
- picture, which the worker checks; an element action (act) names an element id and one of
37
- its actions. Where several agents share a computer it also rejects a step into a window
38
- another agent owns (owner(): the machine-wide ownership of the computer package's
39
- coordination.py), and claims an unowned one for the agent.
40
-
41
- GameShield (the game package, harness_game/shield.py) is a game's. It sees one generic
42
- input (GAME_COMMANDS: those of GameScientist's action protocol, in screen pixels) and
43
- rejects what that protocol would: an unknown command, field, key or button, a point off
44
- the screen, a duration, wait, relative motion or scroll out of its bounds, too many or
45
- repeated keys. An embodiment may also block keys a game's rules forbid (its `blocked`
46
- table: the key and the rule, such as Minecraft's chat and pause keys during a speedrun).
47
- A game that declares channels (its [channels]: who holds which keys, buttons, pointer
48
- use and wheel at a time) also takes a state input, the one its kernel's tick merges
49
- every period from what each entry holds (runtime/tick.py), checked channel by channel.
50
- The fairness caps ([shield.fairness], graded: FAIRNESS) bound what a person could match:
51
- button presses a second, the view's turn a period, keys down together. Text typed into a
52
- text field (a text input, or a state's `text` on the channel that types) passes only
53
- with the game's [shield.text]: its characters, its length, the screen read now among its
54
- screens (Minecraft: the recipe book's search, where a letter is the field's, never a key
55
- such as the blocked T), and alone: no key pressed, or let go, in the same input.
9
+ `shield` field is its ShieldResult. Each kind's shield is in its package, which says what it
10
+ rejects.
56
11
 
57
12
  The checks every shield shares are here, one rule each: finite (a finite number, never a
58
13
  bool), in_screen (a point of the picture: 0 <= x < width, 0 <= y < height), bounded (a
@@ -73,7 +28,7 @@ REJECTED = "rejected"
73
28
  class ShieldResult:
74
29
  """The verdict on one command: "pass" with the command unchanged, or "rejected" with
75
30
  no command and the reason (the failed check and the values it compared). The command
76
- is the embodiment's: a robot's joint vector."""
31
+ is the embodiment's."""
77
32
 
78
33
  verdict: str
79
34
  command: Any
@@ -86,8 +41,7 @@ class ShieldResult:
86
41
 
87
42
  class CommandShield(Protocol):
88
43
  """The shield of one worker, whatever the embodiment: a fixed check of every command
89
- against the measured state (`current`) and what else the worker knows (`context`, such
90
- as a robot's forward kinematics), passing it unchanged or rejecting it with reasons."""
44
+ against the measured state (`current`) and what else the worker knows (`context`), passing it unchanged or rejecting it with reasons."""
91
45
 
92
46
  def reset(self) -> None:
93
47
  """Forget what earlier commands of the episode established."""
@@ -7,10 +7,10 @@ the session's Agents (this module) starts a sub-agent: a conversation of its own
7
7
  directory (agents/<id>/: the trace is a tree of directories), registered in the session's
8
8
  tree (host/sessions.py) and run in a workspace the session's Place gives it:
9
9
 
10
- new a workspace of its own, of the parent's kind (or "browser", "desktop", "apps",
11
- "display": a new one of that kind)
10
+ new a workspace of its own, of the parent's kind (or the name of another kind the
11
+ installed packages give: a new one of that kind)
12
12
  share the windows the parent holds now are handed over (the session's window
13
- ownership, `windows`: the computer package's WindowOwners.transfer): the
13
+ ownership, `windows`: its transfer): the
14
14
  sub-agent owns them while a turn of it runs, the parent cannot use them
15
15
  meanwhile, and they come back to the parent when the turn ends (a message to
16
16
  the sub-agent hands them over again).
@@ -171,8 +171,8 @@ def external_agent(name: str):
171
171
  class Agents:
172
172
  """The sub-agents of one session (one Agents is shared by all its agents). `place`
173
173
  gives them workspaces (Place); `sessions` (host/sessions.py) lists them in the session's
174
- tree; `windows` is who owns which window of the computer, which `share` hands windows
175
- over in (held(owner), transfer(window, owner, to): the computer package's WindowOwners;
174
+ tree; `windows` is who owns which window, which `share` hands windows
175
+ over in (held(owner), transfer(window, owner, to): a package's window ownership;
176
176
  None: no windows to share); `max_depth` how deep agents nest."""
177
177
 
178
178
  def __init__(self, place: Place | None = None, *, sessions=None, windows=None, max_depth: int = DEFAULT_DEPTH):
@@ -83,6 +83,8 @@ class Environments:
83
83
  value = self.release(str(request.get("environment") or ""), failed=request.get("failed"))
84
84
  elif action == "agents":
85
85
  value = self.enable_agents(str(request.get("why") or ""), asked_by="model")
86
+ elif action == "kinds":
87
+ value = self.kinds()
86
88
  else:
87
89
  raise Refused(f"no operation {action!r}")
88
90
  except Refused as error:
@@ -91,6 +93,14 @@ class Environments:
91
93
  return {"error": f"{type(error).__name__}: {error}"}
92
94
  return {"value": value}
93
95
 
96
+ def kinds(self) -> list:
97
+ """The kinds this conversation can take, as the installed packages describe them:
98
+ [{"kind", "about", "folder" (it works in a folder: use_environment needs one)}],
99
+ without the kind it works in already."""
100
+ primary = self.conversation.workspace_kind
101
+ return [{"kind": kind, "about": row.get("about") or row.get("label") or kind, "folder": bool(row.get("folder"))}
102
+ for kind, row in self.place.kinds().items() if kind != primary]
103
+
94
104
  def of(self, name):
95
105
  """The attached environment `name`: {"env", "plain", "episode", "slot"}, or Refused."""
96
106
  found = self.attached.get(name)