@lmmslab/harness 0.0.0-stage → 0.81.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/LICENSE +21 -0
- package/README.md +124 -2
- package/bin/harness.js +71 -0
- package/package.json +34 -4
- package/python/harness/README.md +72 -0
- package/python/harness/__init__.py +8 -0
- package/python/harness/__main__.py +3 -0
- package/python/harness/bench.py +124 -0
- package/python/harness/builtin/benches/README.md +5 -0
- package/python/harness/builtin/benches/none/bench.toml +6 -0
- package/python/harness/builtin/configs/README.md +26 -0
- package/python/harness/builtin/configs/assistant.toml +11 -0
- package/python/harness/builtin/configs/default.toml +33 -0
- package/python/harness/builtin/configs/deploy/example-api.toml +10 -0
- package/python/harness/builtin/configs/models/deepseek-api.toml +21 -0
- package/python/harness/builtin/configs/models/deepseek-flash.toml +12 -0
- package/python/harness/builtin/configs/models/grok-low.toml +8 -0
- package/python/harness/builtin/configs/models/grok-medium.toml +43 -0
- package/python/harness/builtin/configs/models/opus-5.5.toml +11 -0
- package/python/harness/builtin/environment/README.md +53 -0
- package/python/harness/builtin/environment/constraints.txt +31 -0
- package/python/harness/builtin/model-settings.js +143 -0
- package/python/harness/builtin/prompts/conversation/core.md +5 -0
- package/python/harness/builtin/prompts/conversation/pack.toml +12 -0
- package/python/harness/builtin/prompts/core/core.md +88 -0
- package/python/harness/builtin/prompts/core/pack.toml +9 -0
- package/python/harness/builtin/prompts/reflect/core.md +45 -0
- package/python/harness/builtin/prompts/reflect/pack.toml +7 -0
- package/python/harness/builtin/prompts/shared/agent-skills.md +5 -0
- package/python/harness/builtin/prompts/shared/agents.md +14 -0
- package/python/harness/builtin/prompts/shared/checklist.md +21 -0
- package/python/harness/builtin/prompts/shared/entries.md +86 -0
- package/python/harness/builtin/prompts/shared/environments.md +21 -0
- package/python/harness/builtin/prompts/shared/learning-goal.md +31 -0
- package/python/harness/builtin/prompts/shared/learning.md +27 -0
- package/python/harness/builtin/prompts/shared/mcp.md +9 -0
- package/python/harness/builtin/prompts/shared/world.md +1 -0
- package/python/harness/builtin/skills/README.md +10 -0
- package/python/harness/builtin/skills/agents/__init__.py +88 -0
- package/python/harness/builtin/skills/agents/skill.toml +11 -0
- package/python/harness/builtin/skills/checklist/__init__.py +32 -0
- package/python/harness/builtin/skills/checklist/skill.toml +9 -0
- package/python/harness/builtin/skills/conversation/__init__.py +23 -0
- package/python/harness/builtin/skills/conversation/skill.toml +8 -0
- package/python/harness/builtin/skills/entries/__init__.py +62 -0
- package/python/harness/builtin/skills/entries/skill.toml +8 -0
- package/python/harness/builtin/skills/environments/__init__.py +69 -0
- package/python/harness/builtin/skills/environments/skill.toml +9 -0
- package/python/harness/builtin/skills/experience/__init__.py +27 -0
- package/python/harness/builtin/skills/experience/skill.toml +9 -0
- package/python/harness/builtin/skills/instructions/__init__.py +29 -0
- package/python/harness/builtin/skills/instructions/skill.toml +9 -0
- package/python/harness/builtin/skills/learning/__init__.py +189 -0
- package/python/harness/builtin/skills/learning/skill.toml +7 -0
- package/python/harness/builtin/skills/mcp/__init__.py +54 -0
- package/python/harness/builtin/skills/mcp/skill.toml +10 -0
- package/python/harness/builtin/skills/memory/__init__.py +130 -0
- package/python/harness/builtin/skills/memory/skill.toml +13 -0
- package/python/harness/builtin/skills/verify/__init__.py +31 -0
- package/python/harness/builtin/skills/verify/skill.toml +7 -0
- package/python/harness/builtin/third_party/sources.toml +40 -0
- package/python/harness/cli.py +1182 -0
- package/python/harness/config/__init__.py +224 -0
- package/python/harness/config/agent.py +777 -0
- package/python/harness/core/__init__.py +52 -0
- package/python/harness/core/artifacts.py +46 -0
- package/python/harness/core/codec.py +160 -0
- package/python/harness/core/contracts.py +75 -0
- package/python/harness/core/episodes.py +150 -0
- package/python/harness/core/format.py +51 -0
- package/python/harness/core/http.py +124 -0
- package/python/harness/core/lanes.py +324 -0
- package/python/harness/core/linux_sandbox.py +55 -0
- package/python/harness/core/media.py +96 -0
- package/python/harness/core/memory.py +147 -0
- package/python/harness/core/ports.py +63 -0
- package/python/harness/core/procs.py +227 -0
- package/python/harness/core/remote.py +102 -0
- package/python/harness/core/spans.py +166 -0
- package/python/harness/core/trace.py +139 -0
- package/python/harness/core/wait.py +12 -0
- package/python/harness/core/worker.py +388 -0
- package/python/harness/core/worker_pipe.py +119 -0
- package/python/harness/embodiments.py +217 -0
- package/python/harness/extensions.py +112 -0
- package/python/harness/host/__init__.py +397 -0
- package/python/harness/host/client.py +201 -0
- package/python/harness/host/http.py +720 -0
- package/python/harness/host/listing.py +68 -0
- package/python/harness/host/server.py +189 -0
- package/python/harness/host/sessions.py +406 -0
- package/python/harness/host/tasks.py +1356 -0
- package/python/harness/host/workers.py +257 -0
- package/python/harness/host/workspaces.py +256 -0
- package/python/harness/model_list.py +117 -0
- package/python/harness/packages/__init__.py +73 -0
- package/python/harness/packages/addons.py +121 -0
- package/python/harness/packages/archive.py +122 -0
- package/python/harness/packages/describe.py +46 -0
- package/python/harness/packages/environments.py +448 -0
- package/python/harness/packages/fetch.py +57 -0
- package/python/harness/packages/manager.py +587 -0
- package/python/harness/packages/manifest.py +232 -0
- package/python/harness/packages/migrate.py +68 -0
- package/python/harness/packages/provision.py +38 -0
- package/python/harness/packages/registry.py +275 -0
- package/python/harness/packages/resolve.py +89 -0
- package/python/harness/packages/sources.py +141 -0
- package/python/harness/packages/state.py +213 -0
- package/python/harness/packages/versions.py +112 -0
- package/python/harness/paths.py +218 -0
- package/python/harness/providers.py +303 -0
- package/python/harness/runtime/__init__.py +8 -0
- package/python/harness/runtime/decision/__init__.py +1 -0
- package/python/harness/runtime/decision/loop.py +198 -0
- package/python/harness/runtime/decision/messages.py +271 -0
- package/python/harness/runtime/decision/model.py +424 -0
- package/python/harness/runtime/decision/prompts.py +248 -0
- package/python/harness/runtime/decision/protocol.py +169 -0
- package/python/harness/runtime/decision/thoughts.py +199 -0
- package/python/harness/runtime/events.py +213 -0
- package/python/harness/runtime/execution/__init__.py +1 -0
- package/python/harness/runtime/execution/attached.py +96 -0
- package/python/harness/runtime/execution/control.py +211 -0
- package/python/harness/runtime/execution/entries.py +665 -0
- package/python/harness/runtime/execution/kernel.py +811 -0
- package/python/harness/runtime/execution/noenv.py +84 -0
- package/python/harness/runtime/execution/results.py +40 -0
- package/python/harness/runtime/execution/session.py +871 -0
- package/python/harness/runtime/execution/skills.py +436 -0
- package/python/harness/runtime/learning/__init__.py +1 -0
- package/python/harness/runtime/learning/active.py +314 -0
- package/python/harness/runtime/learning/experience.py +48 -0
- package/python/harness/runtime/learning/fixtures.py +167 -0
- package/python/harness/runtime/learning/learner.py +651 -0
- package/python/harness/runtime/learning/library.py +504 -0
- package/python/harness/runtime/learning/reflect.py +151 -0
- package/python/harness/runtime/learning/usage.py +30 -0
- package/python/harness/runtime/learning/views.py +89 -0
- package/python/harness/runtime/reactive/__init__.py +1 -0
- package/python/harness/runtime/reactive/rules.py +549 -0
- package/python/harness/runtime/safety/__init__.py +1 -0
- package/python/harness/runtime/safety/approval.py +131 -0
- package/python/harness/runtime/safety/input.py +62 -0
- package/python/harness/runtime/safety/isolation.py +419 -0
- package/python/harness/runtime/safety/shield.py +129 -0
- package/python/harness/runtime/status.py +23 -0
- package/python/harness/runtime/task/__init__.py +7 -0
- package/python/harness/runtime/task/context.py +431 -0
- package/python/harness/runtime/task/delegation.py +468 -0
- package/python/harness/runtime/task/environments.py +268 -0
- package/python/harness/runtime/task/run.py +2878 -0
- package/python/harness/runtime/tick.py +909 -0
- package/python/harness/sdk/__init__.py +281 -0
- package/python/harness/services/__init__.py +6 -0
- package/python/harness/services/broker.py +35 -0
- package/python/harness/services/connectors.py +88 -0
- package/python/harness/services/mcp.py +298 -0
- package/python/harness/services/mcp_stdio.py +131 -0
- package/python/harness/services/placement.py +82 -0
- package/python/harness/services/registry.py +156 -0
- package/python/harness/settings.py +536 -0
- package/python/harness/terminal.py +79 -0
- package/python/harness/transcript.py +297 -0
- package/python/harness/tui/__init__.py +68 -0
- package/python/harness/tui/chat.py +1181 -0
- package/python/harness/tui/pty.py +81 -0
- package/python/harness/tui/renderer.py +45 -0
- package/python/harness/tui/timeline_rows.py +58 -0
- package/python/harness/tui/views.py +434 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"""harness.sdk: the one module a package imports.
|
|
2
|
+
|
|
3
|
+
A package's skills, benches, workers and services import the harness only from here
|
|
4
|
+
(tools/check.py refuses any other `harness` import), so the harness can change inside
|
|
5
|
+
without breaking them; a change here that breaks a package raises the harness's major
|
|
6
|
+
version. Its names, by what they are for:
|
|
7
|
+
|
|
8
|
+
Skills ClosedLoop, Result, Stop, wait_until, user_message,
|
|
9
|
+
span, spans, control, events, Escalation, Event, ExecutionTrace,
|
|
10
|
+
ProgramFinished, record_kind, ReactiveFault, call_reactive,
|
|
11
|
+
json_list (the JSON list in a model's reply),
|
|
12
|
+
Learner, candidate, entry_key, Library, SECTIONS, WorkingMemory, MemoryKind, memory_entries,
|
|
13
|
+
keep_probe, BUILTIN_ACTIONS, OPEN_GRIPPER, STOP, HOLD, BACK_OFF, Refused
|
|
14
|
+
Sessions EpisodeCore, create_session, session_class (an embodiment kind's kernel
|
|
15
|
+
session builds on the episode core), PhysicalInput, REMEMBER
|
|
16
|
+
Workers WORKER_METHODS, create_server, BenchWorker (what a benchmark's worker
|
|
17
|
+
shares), Action, Observation, Transition, EpisodeCursor, OutcomeToken,
|
|
18
|
+
pid_alive, file_lock, start_detached, data_url, image_data_url, decode_data_url, encode_png, fit_into,
|
|
19
|
+
finite_bounds, validate_vector, validate_position,
|
|
20
|
+
ShieldResult, PASS, REJECTED, finite, in_screen, bounded, reject,
|
|
21
|
+
Lanes, free_port, free_ports, OwnPort, git_revision, now, stamp
|
|
22
|
+
Services service_environment
|
|
23
|
+
Benches BenchSpec, bench_spec (a bench's bench.toml); Bench, load_bench
|
|
24
|
+
(its hooks: the eval package's, imported only there); load_deploy,
|
|
25
|
+
load_embodiment, TaskConfig, scripted_models, apply_sets, load_layered,
|
|
26
|
+
DEFAULT_AGENT, resolve_agent, repo_modules, bench_environment, environments,
|
|
27
|
+
read_toml, parse_set, service_names, embodiment_profile
|
|
28
|
+
Services ensure, McpClient, McpError, McpSession, McpSessionGone, MCP_PROTOCOL_VERSION (an MCP
|
|
29
|
+
session over another transport), load_services, SERVICES_ROOT, ServiceSpec
|
|
30
|
+
Paths ROOT, CHECKOUT_ROOT, home, active_packages, import_roots, python_path, third_party, find,
|
|
31
|
+
atomic_write (a whole file or none)
|
|
32
|
+
Session host Host, HttpServer, sessions (LIVE, ENDED, live, word, ended_status), serve_files;
|
|
33
|
+
TaskHost, TaskServer (the server a package's API handlers are given, and its tests')
|
|
34
|
+
Settings data, Settings, SETTINGS_FILE (the user's configuration file),
|
|
35
|
+
Credentials (the API keys: the environment or [keys]),
|
|
36
|
+
toml_dumps (the one TOML writer)
|
|
37
|
+
Version version (the harness's)
|
|
38
|
+
Agents Trace (an agent's trace: what another harness's agent run as a sub-agent
|
|
39
|
+
writes, runtime/task/delegation.py), read_records (an episode's trace as written)
|
|
40
|
+
HTTP open_url, post_json (a request to a worker, a service or a site)
|
|
41
|
+
Files digest, fetch_verified (a download kept only with the expected hash)
|
|
42
|
+
Media ffmpeg, probe, FRAMES (probe()'s start_from for a start read from the frames)
|
|
43
|
+
Runs run_name, episodes (summary, usage, ending), resolve_run
|
|
44
|
+
Text format (cost, duration, clock, timestamp), transcript, approval (the sensitive kinds,
|
|
45
|
+
request(), and the words of an approval: WORDS, say)
|
|
46
|
+
Evaluation ResolvedAgent, overridden_agent, task_config, bench_names, declares_channels,
|
|
47
|
+
TaskRun, serve_worker, UsageError (a command's usage error: exit status 2),
|
|
48
|
+
cli_output and cli_table (a command's JSON and text table, as the core's print them)
|
|
49
|
+
and the terminal chat's timeline (tui_timeline)
|
|
50
|
+
|
|
51
|
+
Everything here is imported when it is first used, so importing the sdk costs nothing
|
|
52
|
+
and needs nothing beyond the standard library.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
import importlib
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# name -> "module:attribute" (or "module" for a module).
|
|
59
|
+
_NAMES = {
|
|
60
|
+
"Evidence": "harness.core.artifacts:Evidence",
|
|
61
|
+
"WorkspaceProvider": "harness.host.workspaces:WorkspaceProvider",
|
|
62
|
+
"WorkerPool": "harness.host.workers:WorkerPool",
|
|
63
|
+
"Worker": "harness.host.workers:Worker",
|
|
64
|
+
"WorkerCancelled": "harness.host.workers:Cancelled",
|
|
65
|
+
# Skills: bounded executions, events, spans, learning, reactions.
|
|
66
|
+
"ClosedLoop": "harness.runtime.execution.entries:ClosedLoop",
|
|
67
|
+
"Result": "harness.runtime.execution.entries:Result",
|
|
68
|
+
"Stop": "harness.runtime.execution.entries:Stop",
|
|
69
|
+
"wait_until": "harness.core.wait:wait_until",
|
|
70
|
+
"user_message": "harness.runtime.execution.entries:user_message",
|
|
71
|
+
"span": "harness.core.spans:span",
|
|
72
|
+
"spans": "harness.core.spans",
|
|
73
|
+
"control": "harness.runtime.execution.control",
|
|
74
|
+
"events": "harness.runtime.events",
|
|
75
|
+
"Escalation": "harness.runtime.events:Escalation",
|
|
76
|
+
"Event": "harness.runtime.events:Event",
|
|
77
|
+
"ExecutionTrace": "harness.runtime.events:ExecutionTrace",
|
|
78
|
+
"EpisodeEnded": "harness.runtime.events:EpisodeEnded",
|
|
79
|
+
"Tick": "harness.runtime.tick:Tick",
|
|
80
|
+
"WorkerPipe": "harness.core.worker_pipe:WorkerPipe",
|
|
81
|
+
"WorkerRejected": "harness.core.worker_pipe:WorkerRejected",
|
|
82
|
+
"linux_sandbox": "harness.core.linux_sandbox",
|
|
83
|
+
"ProgramFinished": "harness.runtime.events:ProgramFinished",
|
|
84
|
+
"record_kind": "harness.runtime.events:record_kind",
|
|
85
|
+
"ReactiveFault": "harness.runtime.reactive.rules:ReactiveFault",
|
|
86
|
+
"call_reactive": "harness.runtime.reactive.rules:call_reactive",
|
|
87
|
+
"Learner": "harness.runtime.learning.learner:Learner",
|
|
88
|
+
"candidate": "harness.runtime.learning.learner:candidate",
|
|
89
|
+
"entry_key": "harness.runtime.learning.learner:entry_key",
|
|
90
|
+
"Library": "harness.runtime.learning.library:Library",
|
|
91
|
+
"WorkingMemory": "harness.runtime.task.context:WorkingMemory",
|
|
92
|
+
"memory_entries": "harness.runtime.learning.views:library_entries",
|
|
93
|
+
"MemoryKind": "harness.runtime.task.context:Kind",
|
|
94
|
+
"SECTIONS": "harness.runtime.learning.library:SECTIONS",
|
|
95
|
+
"BUILTIN_ACTIONS": "harness.runtime.reactive.rules:BUILTIN_ACTIONS",
|
|
96
|
+
"OPEN_GRIPPER": "harness.runtime.reactive.rules:OPEN_GRIPPER",
|
|
97
|
+
"STOP": "harness.runtime.reactive.rules:STOP",
|
|
98
|
+
"HOLD": "harness.runtime.reactive.rules:HOLD",
|
|
99
|
+
"BACK_OFF": "harness.runtime.reactive.rules:BACK_OFF",
|
|
100
|
+
"Refused": "harness.runtime.tick:Refused",
|
|
101
|
+
"keep_probe": "harness.runtime.learning.active:keep",
|
|
102
|
+
# Sessions: what an embodiment kind's kernel session builds on.
|
|
103
|
+
"EpisodeCore": "harness.runtime.execution.session:EpisodeCore",
|
|
104
|
+
"create_session": "harness.runtime.execution.session:create_session",
|
|
105
|
+
"session_class": "harness.runtime.execution.session:session_class",
|
|
106
|
+
"PhysicalInput": "harness.runtime.safety.input:PhysicalInput",
|
|
107
|
+
"input_sent": "harness.runtime.safety.input:input_sent",
|
|
108
|
+
"REMEMBER": "harness.runtime.safety.input:REMEMBER",
|
|
109
|
+
# Workers: the protocol, what crosses it, the shields.
|
|
110
|
+
"WORKER_METHODS": "harness.core.worker:WORKER_METHODS",
|
|
111
|
+
"create_server": "harness.core.worker:create_server",
|
|
112
|
+
"Action": "harness.core.contracts:Action",
|
|
113
|
+
"Observation": "harness.core.contracts:Observation",
|
|
114
|
+
"RemoteEnvironment": "harness.core.remote:RemoteEnvironment",
|
|
115
|
+
"Place": "harness.runtime.task.delegation:Place",
|
|
116
|
+
"Transition": "harness.core.contracts:Transition",
|
|
117
|
+
"EpisodeCursor": "harness.core.codec:EpisodeCursor",
|
|
118
|
+
"OutcomeToken": "harness.core.codec:OutcomeToken",
|
|
119
|
+
"pid_alive": "harness.core.procs:pid_alive",
|
|
120
|
+
"file_lock": "harness.core.procs:file_lock",
|
|
121
|
+
"SHARED_LOCK_DIR": "harness.core.procs:SHARED_LOCK_DIR",
|
|
122
|
+
"start_detached": "harness.core.procs:start_detached",
|
|
123
|
+
"service_environment": "harness.core.procs:service_environment",
|
|
124
|
+
"data_url": "harness.core.codec:data_url",
|
|
125
|
+
"image_data_url": "harness.core.codec:image_data_url",
|
|
126
|
+
"decode_data_url": "harness.core.codec:decode_data_url",
|
|
127
|
+
"encode_png": "harness.core.codec:encode_png",
|
|
128
|
+
"fit_into": "harness.core.codec:fit_into",
|
|
129
|
+
"finite_bounds": "harness.core.codec:finite_bounds",
|
|
130
|
+
"validate_vector": "harness.core.codec:validate_vector",
|
|
131
|
+
"ShieldResult": "harness.runtime.safety.shield:ShieldResult",
|
|
132
|
+
"finite": "harness.runtime.safety.shield:finite",
|
|
133
|
+
"in_screen": "harness.runtime.safety.shield:in_screen",
|
|
134
|
+
"bounded": "harness.runtime.safety.shield:bounded",
|
|
135
|
+
"reject": "harness.runtime.safety.shield:reject",
|
|
136
|
+
"PASS": "harness.runtime.safety.shield:PASS",
|
|
137
|
+
"REJECTED": "harness.runtime.safety.shield:REJECTED",
|
|
138
|
+
"Lanes": "harness.core.lanes:Lanes",
|
|
139
|
+
# Benches: the hooks, embodiments, configurations, environments.
|
|
140
|
+
# A bench's hooks are the eval package's: a bench's bench.py subclasses Bench, and only
|
|
141
|
+
# the eval package imports it (benches run over tasks and seeds there).
|
|
142
|
+
"BenchWorker": "harness.core.worker:BenchWorker",
|
|
143
|
+
"free_port": "harness.core.ports:free_port",
|
|
144
|
+
"OwnPort": "harness.core.ports:OwnPort",
|
|
145
|
+
"git_revision": "harness.core.trace:git_revision",
|
|
146
|
+
"now": "harness.core.trace:now",
|
|
147
|
+
"stamp": "harness.core.trace:stamp",
|
|
148
|
+
"free_ports": "harness.core.ports:free_ports",
|
|
149
|
+
"Bench": "harness_eval.bench:Bench",
|
|
150
|
+
"load_bench": "harness_eval.bench:load_bench",
|
|
151
|
+
"BenchSpec": "harness.bench:BenchSpec",
|
|
152
|
+
"bench_spec": "harness.bench:bench_spec",
|
|
153
|
+
"load_deploy": "harness.services.placement:load_deploy",
|
|
154
|
+
"load_embodiment": "harness.embodiments:load_embodiment",
|
|
155
|
+
"TaskConfig": "harness.config.agent:TaskConfig",
|
|
156
|
+
"scripted_models": "harness.runtime.decision.model:scripted_models",
|
|
157
|
+
"apply_sets": "harness.config:apply_sets",
|
|
158
|
+
"load_layered": "harness.config:load_layered",
|
|
159
|
+
"DEFAULT_AGENT": "harness.config.agent:DEFAULT_AGENT",
|
|
160
|
+
"resolve_agent": "harness.config.agent:resolve_agent",
|
|
161
|
+
"repo_modules": "harness.runtime.execution.kernel:repo_modules",
|
|
162
|
+
"read_toml": "harness.config:read_toml",
|
|
163
|
+
"toml_dumps": "harness.config:dumps",
|
|
164
|
+
"parse_set": "harness.config:parse_set",
|
|
165
|
+
"service_names": "harness.config.agent:_service_names",
|
|
166
|
+
"embodiment_profile": "harness.embodiments:profile",
|
|
167
|
+
"bench_environment": "harness.packages.provision:bench_environment",
|
|
168
|
+
"environments": "harness.packages.environments",
|
|
169
|
+
# Services.
|
|
170
|
+
"ensure": "harness.services.broker:ensure",
|
|
171
|
+
"StdioServer": "harness.services.mcp_stdio:StdioServer",
|
|
172
|
+
"McpClient": "harness.services.mcp:McpClient",
|
|
173
|
+
"McpError": "harness.services.mcp:McpError",
|
|
174
|
+
"McpSession": "harness.services.mcp:McpSession",
|
|
175
|
+
"McpSessionGone": "harness.services.mcp:SessionGone",
|
|
176
|
+
"MCP_PROTOCOL_VERSION": "harness.services.mcp:PROTOCOL_VERSION",
|
|
177
|
+
"load_services": "harness.services.registry:load_services",
|
|
178
|
+
"SERVICES_ROOT": "harness.services.registry:SERVICES_ROOT",
|
|
179
|
+
"ServiceSpec": "harness.services.registry:ServiceSpec",
|
|
180
|
+
"bench_environment_status": "harness.packages.provision:bench_environment_status",
|
|
181
|
+
"install_bench_environment": "harness.packages.provision:install_bench_environment",
|
|
182
|
+
"providers": "harness.providers",
|
|
183
|
+
"model_list": "harness.model_list",
|
|
184
|
+
"RemoteConversation": "harness.host.client:RemoteConversation",
|
|
185
|
+
# Paths.
|
|
186
|
+
"ROOT": "harness.paths:ROOT",
|
|
187
|
+
"CHECKOUT_ROOT": "harness.paths:CHECKOUT_ROOT",
|
|
188
|
+
"home": "harness.paths:home",
|
|
189
|
+
"import_roots": "harness.paths:import_roots",
|
|
190
|
+
"active_packages": "harness.paths:packages",
|
|
191
|
+
"python_path": "harness.paths:python_path",
|
|
192
|
+
"third_party": "harness.paths:third_party",
|
|
193
|
+
"find": "harness.paths:find",
|
|
194
|
+
# Settings: the user's configuration.
|
|
195
|
+
"data": "harness.paths:data",
|
|
196
|
+
"Settings": "harness.settings:Settings",
|
|
197
|
+
"Credentials": "harness.settings:Credentials",
|
|
198
|
+
"SETTINGS_FILE": "harness.settings:FILE",
|
|
199
|
+
"ffmpeg": "harness.core.media:ffmpeg",
|
|
200
|
+
"digest": "harness.packages.fetch:digest",
|
|
201
|
+
"fetch_verified": "harness.packages.fetch:fetch_verified",
|
|
202
|
+
"open_url": "harness.core.http:open_url",
|
|
203
|
+
"post_json": "harness.core.http:post_json",
|
|
204
|
+
"probe": "harness.core.media:probe",
|
|
205
|
+
"FRAMES": "harness.core.media:FRAMES",
|
|
206
|
+
# The session host: its client and its HTTP server.
|
|
207
|
+
"Host": "harness.host:Host",
|
|
208
|
+
"HttpServer": "harness.host.http:Server",
|
|
209
|
+
"TaskHost": "harness.host.tasks:TaskHost",
|
|
210
|
+
"TaskServer": "harness.host.tasks:TaskServer",
|
|
211
|
+
"sessions": "harness.host.sessions",
|
|
212
|
+
# Evaluation (the eval package): experiments, suites, their command line and pages.
|
|
213
|
+
"ResolvedAgent": "harness.config.agent:ResolvedAgent",
|
|
214
|
+
"overridden_agent": "harness.config.agent:overridden_agent",
|
|
215
|
+
"task_config": "harness.config.agent:task_config",
|
|
216
|
+
"sha256": "harness.core:sha256",
|
|
217
|
+
"bench_names": "harness.bench:bench_names",
|
|
218
|
+
"declares_channels": "harness.bench:declares_channels",
|
|
219
|
+
"locate": "harness.paths:locate",
|
|
220
|
+
"roots": "harness.paths:roots",
|
|
221
|
+
"packages": "harness.paths:packages",
|
|
222
|
+
"PACKAGE": "harness.paths:PACKAGE",
|
|
223
|
+
"KERNEL_PYTHON_ENV": "harness.runtime.execution.kernel:KERNEL_PYTHON_ENV",
|
|
224
|
+
"resolve_skills": "harness.config.agent:resolve_for",
|
|
225
|
+
"LAYER_DEFAULTS": "harness.runtime.execution.skills:LAYER_DEFAULTS",
|
|
226
|
+
"active": "harness.runtime.learning.active",
|
|
227
|
+
"learning_settings": "harness.runtime.learning.learner:settings",
|
|
228
|
+
"TaskRun": "harness.runtime.task.run:TaskRun",
|
|
229
|
+
"think": "harness.runtime.decision.thoughts:think",
|
|
230
|
+
"ChatModel": "harness.runtime.decision.model:ChatModel",
|
|
231
|
+
"USAGE": "harness.runtime.decision.model:USAGE",
|
|
232
|
+
"add_usage": "harness.runtime.decision.model:add_usage",
|
|
233
|
+
"json_list": "harness.runtime.decision.protocol:json_list",
|
|
234
|
+
"load_skills": "harness.runtime.execution.skills:load_skills",
|
|
235
|
+
"write_json": "harness.core.trace:write_json",
|
|
236
|
+
"atomic_write": "harness.core:atomic_write",
|
|
237
|
+
"serve_worker": "harness.core.worker:main",
|
|
238
|
+
"first": "harness.extensions:first",
|
|
239
|
+
"episodes": "harness.core.episodes",
|
|
240
|
+
"resolve_run": "harness.host:resolve_run",
|
|
241
|
+
"UsageError": "harness.cli:UsageError",
|
|
242
|
+
"cli_output": "harness.cli:output",
|
|
243
|
+
"cli_table": "harness.cli:table",
|
|
244
|
+
# The terminal chat's timeline (the app package's harness timeline).
|
|
245
|
+
"tui_timeline": "harness.tui:timeline",
|
|
246
|
+
"serve_files": "harness.host.http:serve_files",
|
|
247
|
+
"version": "harness:__version__",
|
|
248
|
+
"format": "harness.core.format",
|
|
249
|
+
"transcript": "harness.transcript",
|
|
250
|
+
"approval": "harness.runtime.safety.approval",
|
|
251
|
+
"run_name": "harness.core.episodes:new_name",
|
|
252
|
+
# Agents: the trace a sub-agent of another harness writes; any trace, read.
|
|
253
|
+
"Trace": "harness.core.trace:Trace",
|
|
254
|
+
"read_records": "harness.core.episodes:read_records",
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
__all__ = sorted((*_NAMES, "validate_position"))
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def validate_position(arguments, bounds):
|
|
261
|
+
"""Compatibility for callers that supply a position mapping."""
|
|
262
|
+
if set(arguments) != {"position"}:
|
|
263
|
+
raise ValueError("Expected a single position field")
|
|
264
|
+
from ..core.codec import validate_vector
|
|
265
|
+
|
|
266
|
+
return validate_vector(arguments["position"], bounds)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def __getattr__(name):
|
|
270
|
+
if name not in _NAMES:
|
|
271
|
+
raise AttributeError(f"harness.sdk has no {name!r}; its names are listed in its docstring")
|
|
272
|
+
module, _, attribute = _NAMES[name].partition(":")
|
|
273
|
+
value = importlib.import_module(module)
|
|
274
|
+
if attribute:
|
|
275
|
+
value = getattr(value, attribute)
|
|
276
|
+
globals()[name] = value
|
|
277
|
+
return value
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def __dir__():
|
|
281
|
+
return __all__
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Model services: the processes skills and agents call (segmenter, pointer, VLMs,
|
|
2
|
+
policies, world models), how they are described (registry: services/<name>.toml),
|
|
3
|
+
where one machine runs them (deploy: configs/deploy/<machine>.toml), and the tools
|
|
4
|
+
that start, stop, check and fetch them (supervisor, tools). Standard library only;
|
|
5
|
+
the services themselves run in their own processes.
|
|
6
|
+
"""
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""On-demand services, as a client sees them: before each call to a service a deploy runs
|
|
2
|
+
on demand, ensure() asks the deploy's broker to make it answer (the local-models
|
|
3
|
+
package's broker starts it, swaps it on a shared GPU and stops it when idle). Clients ask
|
|
4
|
+
at most every CLIENT_INTERVAL seconds while a service is in use."""
|
|
5
|
+
|
|
6
|
+
import threading
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
from ..core.http import post_json
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
CLIENT_INTERVAL = 2.0 # a client asks the broker at most this often per service
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_LAST: dict[tuple, float] = {}
|
|
16
|
+
_GUARD = threading.Lock()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def ensure(config: dict | None, *, timeout: float = 1800.0) -> None:
|
|
20
|
+
"""Before calling a service: when its client config is on demand, ask the broker to
|
|
21
|
+
make it answer (at most every CLIENT_INTERVAL seconds while it is in use)."""
|
|
22
|
+
on_demand = (config or {}).get("on_demand") if isinstance(config, dict) else None
|
|
23
|
+
if not on_demand:
|
|
24
|
+
return
|
|
25
|
+
key = (on_demand["url"], on_demand["service"])
|
|
26
|
+
with _GUARD:
|
|
27
|
+
if time.monotonic() - _LAST.get(key, -1e9) < CLIENT_INTERVAL:
|
|
28
|
+
return
|
|
29
|
+
try:
|
|
30
|
+
post_json(on_demand["url"].rstrip("/") + "/ensure", {"service": on_demand["service"]}, timeout=timeout)
|
|
31
|
+
except Exception as error:
|
|
32
|
+
detail = getattr(error, "read", lambda: b"")().decode(errors="replace") if hasattr(error, "read") else ""
|
|
33
|
+
raise RuntimeError(f"service {on_demand['service']} could not be started on demand: {error} {detail}") from error
|
|
34
|
+
with _GUARD:
|
|
35
|
+
_LAST[key] = time.monotonic()
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Resolve user-configured MCP connections without installing optional capabilities.
|
|
2
|
+
|
|
3
|
+
The existing connectors settings are shared by headless hosts and optional frontends.
|
|
4
|
+
Catalog entries belong to their installed provider. Generic entries are owned here.
|
|
5
|
+
Secrets resolve only in the host, never in the controller namespace or run manifest.
|
|
6
|
+
"""
|
|
7
|
+
import math
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
|
|
11
|
+
from .mcp import McpError
|
|
12
|
+
|
|
13
|
+
_ID = re.compile(r"^[a-z0-9][a-z0-9-]{0,39}$")
|
|
14
|
+
_FIELD = re.compile(r"\{([A-Z0-9_]+)\}")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def configured_servers(settings, credentials):
|
|
18
|
+
servers = {}
|
|
19
|
+
for record in settings.get("connectors", []):
|
|
20
|
+
if not record.get("enabled", True) or record.get("catalog"):
|
|
21
|
+
continue
|
|
22
|
+
identifier = record.get("id", "")
|
|
23
|
+
if not isinstance(identifier, str) or not _ID.fullmatch(identifier) or identifier in servers:
|
|
24
|
+
raise ValueError("Each MCP connection requires a unique lowercase id (letters, digits, hyphens)")
|
|
25
|
+
|
|
26
|
+
def render(text):
|
|
27
|
+
def field(match):
|
|
28
|
+
key = match[1]
|
|
29
|
+
if key in record.get("secrets", []):
|
|
30
|
+
name = f"HARNESS_MCP_{identifier.upper().replace('-', '_')}_{key}"
|
|
31
|
+
value = credentials.secret(name)
|
|
32
|
+
if not value:
|
|
33
|
+
raise McpError(f"{identifier}: credential {key} is not set")
|
|
34
|
+
return value
|
|
35
|
+
if key not in record.get("fields", {}):
|
|
36
|
+
raise McpError(f"{identifier}: field {key} is not set")
|
|
37
|
+
return os.path.expanduser(str(record["fields"][key]))
|
|
38
|
+
return _FIELD.sub(field, str(text))
|
|
39
|
+
|
|
40
|
+
config = {"connector_id": identifier, "description": str(record.get("description") or record.get("name") or identifier),
|
|
41
|
+
"timeout_seconds": float(record.get("timeout_seconds", 60)),
|
|
42
|
+
"resource": record.get("resource") or identifier}
|
|
43
|
+
if not math.isfinite(config["timeout_seconds"]) or config["timeout_seconds"] <= 0 or not isinstance(config["resource"], str):
|
|
44
|
+
raise ValueError(f"{identifier}: positive timeout and resource name required")
|
|
45
|
+
for key in ("allowed_tools", "read_only_tools", "tools_off"):
|
|
46
|
+
value = record.get(key, [])
|
|
47
|
+
if not isinstance(value, list) or any(not isinstance(item, str) or not item for item in value):
|
|
48
|
+
raise ValueError(f"{identifier}: {key} must be a list of tool names")
|
|
49
|
+
config[key] = list(value)
|
|
50
|
+
transport = record.get("transport")
|
|
51
|
+
if transport == "stdio":
|
|
52
|
+
command, args = record.get("command"), record.get("args", [])
|
|
53
|
+
if not isinstance(command, str) or not command or not isinstance(args, list) or any(
|
|
54
|
+
not isinstance(arg, str) for arg in args):
|
|
55
|
+
raise ValueError(f"{identifier}: stdio requires command and an argv list")
|
|
56
|
+
config.update(command=render(command), args=[render(arg) for arg in args],
|
|
57
|
+
env={key: render(value) for key, value in record.get("env", {}).items()})
|
|
58
|
+
if record.get("cwd"):
|
|
59
|
+
config["cwd"] = render(record["cwd"])
|
|
60
|
+
elif transport == "http":
|
|
61
|
+
url = render(record.get("url", ""))
|
|
62
|
+
if not url.startswith(("http://", "https://")):
|
|
63
|
+
raise ValueError(f"{identifier}: HTTP connection requires an http(s) URL")
|
|
64
|
+
config.update(url=url, headers={key: render(value) for key, value in record.get("headers", {}).items()})
|
|
65
|
+
else:
|
|
66
|
+
raise ValueError(f"{identifier}: transport must be stdio or http")
|
|
67
|
+
servers[identifier] = config
|
|
68
|
+
return servers
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def authorize_connector(settings, credentials, config, tool=None):
|
|
72
|
+
"""Recheck a host-owned connection; never retarget an already-running client."""
|
|
73
|
+
identifier = config.get("connector_id")
|
|
74
|
+
if identifier is None:
|
|
75
|
+
return # Package gateways enforce their own live policy.
|
|
76
|
+
records = [row for row in settings.get("connectors", []) if row.get("id") == identifier]
|
|
77
|
+
current = configured_servers({"connectors": records}, credentials).get(identifier)
|
|
78
|
+
if current is None:
|
|
79
|
+
raise McpError("The MCP connection was disabled or removed")
|
|
80
|
+
policy = {"description", "allowed_tools", "read_only_tools", "tools_off"}
|
|
81
|
+
if ({k: v for k, v in current.items() if k not in policy} !=
|
|
82
|
+
{k: v for k, v in config.items() if k not in policy}):
|
|
83
|
+
raise McpError("The MCP connection or credentials changed; start a new task")
|
|
84
|
+
if tool is not None:
|
|
85
|
+
grants = current.get("allowed_tools", ())
|
|
86
|
+
if tool in current.get("tools_off", ()) or not (
|
|
87
|
+
tool in current.get("read_only_tools", ()) or tool in grants or "*" in grants):
|
|
88
|
+
raise McpError("The MCP tool permission was revoked")
|