maka-agent 0.2.0-dev.3.20260830 → 0.2.0-dev.5.20260830
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/cli-core.js +1 -0
- package/dist/eval-bundle-path.js +1 -1
- package/dist/pi-tui-runner.js +3 -1
- package/dist/runtime-host-cli.js +37 -3
- package/dist/runtime-host-onboarding.js +10 -1
- package/dist/runtime-host-peer-mesh-management-command.js +17 -0
- package/dist/runtime-host-setup-command.js +33 -15
- package/dist/runtime-host-systemd-service.js +9 -3
- package/dist/runtime-host-tui-context.js +2 -6
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/node_modules/@maka/eval/dist/external-subject.js +1 -1
- package/node_modules/@maka/eval/dist/harbor-external-subject.js +2 -2
- package/node_modules/@maka/runtime/dist/sandbox/macos-seatbelt.js +68 -9
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +22 -3
- package/node_modules/@maka/runtime-host/dist/operator/peer-mesh-management-frame.js +14 -0
- package/{packages/eval/dist/index.js → node_modules/@maka/runtime-host/dist/peer-mesh/display-name.js} +12 -10
- package/node_modules/@maka/runtime-host/dist/peer-mesh/model.js +32 -21
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +207 -47
- package/node_modules/@maka/runtime-host/dist/peer-mesh/owner.js +2 -0
- package/node_modules/@maka/runtime-host/dist/peer-mesh/store.js +18 -5
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/peer-mesh.js +59 -2
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +11 -7
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-service.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/peer-mesh-authority.js +19 -0
- package/package.json +1 -2
- package/packages/eval/dist/attempt-store.js +0 -138
- package/packages/eval/dist/cli.js +0 -119
- package/packages/eval/dist/experiment-directory.js +0 -59
- package/packages/eval/dist/experiment.js +0 -49
- package/packages/eval/dist/external-subject.js +0 -488
- package/packages/eval/dist/harbor-external-subject.js +0 -929
- package/packages/eval/dist/harbor-maka-subject.js +0 -83
- package/packages/eval/dist/harness-environment.js +0 -80
- package/packages/eval/dist/harness-executor.js +0 -1013
- package/packages/eval/dist/install-preflight.js +0 -201
- package/packages/eval/dist/maka-artifacts.js +0 -126
- package/packages/eval/dist/maka-runtime-policy.js +0 -42
- package/packages/eval/dist/maka-subject.js +0 -268
- package/packages/eval/dist/metering-checkpoint.js +0 -80
- package/packages/eval/dist/provider-admission.js +0 -39
- package/packages/eval/dist/provider-metering.js +0 -67
- package/packages/eval/dist/provider-web-tool-surface.js +0 -74
- package/packages/eval/dist/relay-result-frame.js +0 -38
- package/packages/eval/dist/result.js +0 -94
- package/packages/eval/dist/runner.js +0 -290
- package/packages/eval/dist/spec.js +0 -135
- package/packages/eval/dist/toolchain-verification.js +0 -130
- package/packages/eval/harbor/deepseek-codex-models.json +0 -69
- package/packages/eval/harbor/deepseek-harness-profile/cordis.patch.yml +0 -140
- package/packages/eval/harbor/deepseek-harness-profile/cordis.yml +0 -18
- package/packages/eval/harbor/deepseek-harness-profile/package.json +0 -10
- package/packages/eval/harbor/docker-compose-egress-proxy.yaml +0 -57
- package/packages/eval/harbor/egress-proxy/Dockerfile +0 -25
- package/packages/eval/harbor/egress-proxy/entrypoint.sh +0 -62
- package/packages/eval/harbor/egress-proxy/network-policy +0 -148
- package/packages/eval/harbor/egress_filter.py +0 -435
- package/packages/eval/harbor/eval_framework.py +0 -40
- package/packages/eval/harbor/relay_agent.py +0 -686
- package/packages/eval/harbor/run_trial.py +0 -223
- package/packages/eval/package.json +0 -20
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
|
3
|
-
# distributed with this work for additional information
|
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
|
6
|
-
# "License"); you may not use this file except in compliance
|
|
7
|
-
# with the License. You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
|
12
|
-
# software distributed under the License is distributed on an
|
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
# KIND, either express or implied. See the License for the
|
|
15
|
-
# specific language governing permissions and limitations
|
|
16
|
-
# under the License.
|
|
17
|
-
|
|
18
|
-
"""Run exactly one pinned Harbor or Pier Trial."""
|
|
19
|
-
|
|
20
|
-
import asyncio
|
|
21
|
-
import contextlib
|
|
22
|
-
import fcntl
|
|
23
|
-
import hashlib
|
|
24
|
-
import importlib
|
|
25
|
-
import importlib.metadata
|
|
26
|
-
import json
|
|
27
|
-
import os
|
|
28
|
-
import signal
|
|
29
|
-
import sys
|
|
30
|
-
from pathlib import Path
|
|
31
|
-
from typing import AsyncIterator
|
|
32
|
-
|
|
33
|
-
FRAMEWORK_VERSION_MISMATCH_EXIT_CODE = 78
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class FrameworkVersionMismatch(Exception):
|
|
37
|
-
pass
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
TASK_CACHE_PROTOCOL_VERSION = 1
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@contextlib.asynccontextmanager
|
|
44
|
-
async def task_cache_lock(cache_dir: Path, identity: str) -> AsyncIterator[None]:
|
|
45
|
-
lock_dir = cache_dir / ".maka-locks"
|
|
46
|
-
lock_dir.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
47
|
-
lock_path = lock_dir / f"{hashlib.sha256(identity.encode()).hexdigest()}.lock"
|
|
48
|
-
flags = os.O_CREAT | os.O_RDWR | getattr(os, "O_NOFOLLOW", 0)
|
|
49
|
-
descriptor = os.open(lock_path, flags, 0o600)
|
|
50
|
-
acquired = False
|
|
51
|
-
try:
|
|
52
|
-
os.fchmod(descriptor, 0o600)
|
|
53
|
-
while not acquired:
|
|
54
|
-
try:
|
|
55
|
-
fcntl.flock(descriptor, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
56
|
-
acquired = True
|
|
57
|
-
except BlockingIOError:
|
|
58
|
-
await asyncio.sleep(0.05)
|
|
59
|
-
yield
|
|
60
|
-
finally:
|
|
61
|
-
if acquired:
|
|
62
|
-
fcntl.flock(descriptor, fcntl.LOCK_UN)
|
|
63
|
-
os.close(descriptor)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def ready_task(cache_dir: Path, identity: str) -> tuple[Path, Path | None]:
|
|
67
|
-
namespace = cache_dir / ".maka-tasks" / hashlib.sha256(identity.encode()).hexdigest()
|
|
68
|
-
marker = namespace / "ready.json"
|
|
69
|
-
try:
|
|
70
|
-
value = json.loads(marker.read_text())
|
|
71
|
-
if set(value) != {"version", "target"}:
|
|
72
|
-
return namespace, None
|
|
73
|
-
if value["version"] != TASK_CACHE_PROTOCOL_VERSION or not isinstance(
|
|
74
|
-
value["target"], str
|
|
75
|
-
):
|
|
76
|
-
return namespace, None
|
|
77
|
-
target = (namespace / value["target"]).resolve()
|
|
78
|
-
if (
|
|
79
|
-
not target.is_relative_to(namespace.resolve())
|
|
80
|
-
or not target.is_dir()
|
|
81
|
-
or not any(target.iterdir())
|
|
82
|
-
):
|
|
83
|
-
return namespace, None
|
|
84
|
-
return namespace, target
|
|
85
|
-
except (OSError, TypeError, ValueError):
|
|
86
|
-
return namespace, None
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def publish_ready_task(namespace: Path, target: Path) -> None:
|
|
90
|
-
resolved_namespace = namespace.resolve()
|
|
91
|
-
resolved_target = target.resolve()
|
|
92
|
-
if not resolved_target.is_relative_to(resolved_namespace):
|
|
93
|
-
raise RuntimeError("Harbor task cache target escaped its Maka namespace")
|
|
94
|
-
relative_target = resolved_target.relative_to(resolved_namespace).as_posix()
|
|
95
|
-
marker = namespace / "ready.json"
|
|
96
|
-
temporary = namespace / ".ready.tmp"
|
|
97
|
-
descriptor = os.open(
|
|
98
|
-
temporary,
|
|
99
|
-
os.O_CREAT | os.O_WRONLY | os.O_TRUNC | getattr(os, "O_NOFOLLOW", 0),
|
|
100
|
-
0o600,
|
|
101
|
-
)
|
|
102
|
-
try:
|
|
103
|
-
with os.fdopen(descriptor, "w") as stream:
|
|
104
|
-
descriptor = -1
|
|
105
|
-
json.dump(
|
|
106
|
-
{"version": TASK_CACHE_PROTOCOL_VERSION, "target": relative_target},
|
|
107
|
-
stream,
|
|
108
|
-
)
|
|
109
|
-
stream.write("\n")
|
|
110
|
-
stream.flush()
|
|
111
|
-
os.fsync(stream.fileno())
|
|
112
|
-
os.replace(temporary, marker)
|
|
113
|
-
finally:
|
|
114
|
-
if descriptor >= 0:
|
|
115
|
-
os.close(descriptor)
|
|
116
|
-
temporary.unlink(missing_ok=True)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
async def run_trial(framework: str, expected_version: str, config_file: Path) -> None:
|
|
120
|
-
from eval_framework import install
|
|
121
|
-
|
|
122
|
-
install(framework)
|
|
123
|
-
distribution = {"harbor": "harbor", "pier": "datacurve-pier"}[framework]
|
|
124
|
-
if importlib.metadata.version(distribution) != expected_version:
|
|
125
|
-
raise FrameworkVersionMismatch
|
|
126
|
-
try:
|
|
127
|
-
config_type = importlib.import_module(f"{framework}.models.trial.config").TrialConfig
|
|
128
|
-
trial_type = importlib.import_module(f"{framework}.trial.trial").Trial
|
|
129
|
-
config = config_type.model_validate_json(config_file.read_text())
|
|
130
|
-
config_file.unlink()
|
|
131
|
-
if framework == "harbor":
|
|
132
|
-
from harbor.constants import TASK_CACHE_DIR
|
|
133
|
-
|
|
134
|
-
task_identity = config.task.get_task_id().model_dump_json()
|
|
135
|
-
async with task_cache_lock(TASK_CACHE_DIR, task_identity):
|
|
136
|
-
namespace, ready = ready_task(TASK_CACHE_DIR, task_identity)
|
|
137
|
-
namespace.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
138
|
-
config.task.download_dir = namespace
|
|
139
|
-
config.task.overwrite = ready is None
|
|
140
|
-
trial = await create_harbor_trial(trial_type, config)
|
|
141
|
-
target = Path(trial.task.task_dir)
|
|
142
|
-
if ready is not None and target.resolve() != ready:
|
|
143
|
-
raise RuntimeError("Harbor task cache target changed for one identity")
|
|
144
|
-
if ready is None:
|
|
145
|
-
publish_ready_task(namespace, target)
|
|
146
|
-
else:
|
|
147
|
-
trial = await trial_type.create(config)
|
|
148
|
-
await trial.run()
|
|
149
|
-
finally:
|
|
150
|
-
config_file.unlink(missing_ok=True)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def apply_subject_egress_policy(task: object) -> None:
|
|
154
|
-
required = os.environ.get("MAKA_EVAL_EGRESS_REQUIRED") == "1"
|
|
155
|
-
allowed_host = os.environ.get("MAKA_EVAL_EGRESS_ALLOWED_HOST")
|
|
156
|
-
if not required:
|
|
157
|
-
return
|
|
158
|
-
if not allowed_host:
|
|
159
|
-
raise RuntimeError("required Eval egress proxy host is unavailable")
|
|
160
|
-
agent = task.config.agent
|
|
161
|
-
agent.network_mode = "allowlist"
|
|
162
|
-
agent.allowed_hosts = [allowed_host]
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
async def create_harbor_trial(trial_type: type, config: object) -> object:
|
|
166
|
-
trial_type._resolve_agent_skills(config)
|
|
167
|
-
task, task_download_result = await trial_type._load_task(config)
|
|
168
|
-
apply_subject_egress_policy(task)
|
|
169
|
-
if task.has_steps:
|
|
170
|
-
from harbor.trial.multi_step import MultiStepTrial
|
|
171
|
-
|
|
172
|
-
return MultiStepTrial(
|
|
173
|
-
config,
|
|
174
|
-
_task=task,
|
|
175
|
-
_task_download_result=task_download_result,
|
|
176
|
-
)
|
|
177
|
-
from harbor.trial.single_step import SingleStepTrial
|
|
178
|
-
|
|
179
|
-
return SingleStepTrial(
|
|
180
|
-
config,
|
|
181
|
-
_task=task,
|
|
182
|
-
_task_download_result=task_download_result,
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
async def main() -> None:
|
|
187
|
-
from eval_framework import install
|
|
188
|
-
|
|
189
|
-
framework, expected_version, config_path = sys.argv[1:]
|
|
190
|
-
install(framework)
|
|
191
|
-
task = asyncio.current_task()
|
|
192
|
-
assert task is not None
|
|
193
|
-
loop = asyncio.get_running_loop()
|
|
194
|
-
teardown_requested = False
|
|
195
|
-
|
|
196
|
-
def request_teardown() -> None:
|
|
197
|
-
nonlocal teardown_requested
|
|
198
|
-
if teardown_requested:
|
|
199
|
-
return
|
|
200
|
-
teardown_requested = True
|
|
201
|
-
try:
|
|
202
|
-
from relay_agent import request_host_teardown
|
|
203
|
-
request_host_teardown()
|
|
204
|
-
finally:
|
|
205
|
-
task.cancel()
|
|
206
|
-
|
|
207
|
-
for host_signal in (signal.SIGINT, signal.SIGTERM):
|
|
208
|
-
loop.add_signal_handler(host_signal, request_teardown)
|
|
209
|
-
try:
|
|
210
|
-
try:
|
|
211
|
-
await run_trial(framework, expected_version, Path(config_path))
|
|
212
|
-
except FrameworkVersionMismatch:
|
|
213
|
-
raise SystemExit(FRAMEWORK_VERSION_MISMATCH_EXIT_CODE) from None
|
|
214
|
-
except asyncio.CancelledError:
|
|
215
|
-
if not teardown_requested:
|
|
216
|
-
raise
|
|
217
|
-
finally:
|
|
218
|
-
for host_signal in (signal.SIGINT, signal.SIGTERM):
|
|
219
|
-
loop.remove_signal_handler(host_signal)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if __name__ == "__main__":
|
|
223
|
-
asyncio.run(main())
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@maka/eval",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Minimal experiment semantics for Maka evaluation.",
|
|
5
|
-
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"default": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"./harbor": "./dist/harness-executor.js",
|
|
13
|
-
"./pier": "./dist/harness-executor.js"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@maka/core": "0.1.0",
|
|
17
|
-
"@maka/runtime-host": "0.1.0",
|
|
18
|
-
"undici": "^8.7.0"
|
|
19
|
-
}
|
|
20
|
-
}
|