Download src/macjev/mac/RUNTIME_PATCH.diff from VTN-TokenFactory/Telasap-0.8B-v1.0: direct link, hf CLI and curl.
- Browser
- Download file 6.46 kB
-
https://huggingface.co/VTN-TokenFactory/Telasap-0.8B-v1.0/resolve/main/src/macjev/mac/RUNTIME_PATCH.diff
- Command line
-
hf download hf://VTN-TokenFactory/Telasap-0.8B-v1.0/src/macjev/mac/RUNTIME_PATCH.diff
-
curl -L -o RUNTIME_PATCH.diff https://huggingface.co/VTN-TokenFactory/Telasap-0.8B-v1.0/resolve/main/src/macjev/mac/RUNTIME_PATCH.diff
6.46 kB
| --- a/src/mac_laya/assistant.py | |
| +++ b/src/mac_laya/assistant.py | |
| effect_scope=str(TOOL_OWNERS[action["tool"]].validate(action["tool"],arguments,self.context(goal))) | |
| return effect_scope | |
| - def decide_step(self,goal,observation,action): | |
| - """MacJev's execute/inspect/ask decision with the observation shrunk to fit its 4096-token input.""" | |
| - from .model import InputBudgetError | |
| - question={"t":"choice","ins":"Choose the next step that best advances the original user goal with the available information.", | |
| - "crit":{"execute":"Execute the proposed registered action after deterministic scope and precondition checks", | |
| - "inspect":"Inspect the explicitly named app window or approved directory for more information before acting", | |
| - "ask":"Ask the user to resolve missing information or ambiguity"}} | |
| - history=observation.get("previous_results",[]) | |
| - variants=[observation,{**observation,"previous_results":history[-2:]},{**observation,"previous_results":history[-1:]}, | |
| - {k:v for k,v in {**observation,"previous_results":history[-1:]}.items() if k not in {"open_sessions","window_app_aliases","registered_app_ids"}}] | |
| - for variant in variants: | |
| - try:return self.engine.decide({"user_goal":goal,"observation":variant,"proposed_action":action},question) | |
| - except InputBudgetError:continue | |
| - return None | |
| + def decide_step(self,goal,observation,action,history=None): | |
| + """MacJev's execute/inspect/ask decision on the shared scope-relative view (macjev.mac.view). | |
| + The full history is sent within a ~20K-token budget with explicit truncation markers (smaller | |
| + budgets are tried on an input-budget error; nothing is cut silently), the static app registry is | |
| + replaced by the apps the goal/action/history name, and every call is logged to runs/macjev/gate_log/. | |
| + """ | |
| + from macjev.mac import runtime_adapter | |
| + if history is not None: | |
| + observation={**observation,"previous_results":runtime_adapter.stamped(history)} | |
| + return runtime_adapter.gate_call(self.engine,goal,observation,action) | |
| + | |
| def fast_path(self,goal,asr): | |
| """Single-step commands: deterministic parse + one MacJev decision, no 8B planner.""" | |
| from .fast_lane import decide as fast_decide | |
| from .inference import DecisionEngine | |
| if self.engine is None:self.engine=DecisionEngine() | |
| scope=Path(self.scope) | |
| - listing=sorted(p.name for p in scope.iterdir())[:200] if scope.is_dir() else [] | |
| + listing=FileScope(scope).execute("list_files",{"directory":str(scope)}) if scope.is_dir() else {"directory":str(scope),"entries":[],"truncated":False} | |
| fast=fast_decide(goal,scope,self.engine,listing) | |
| if fast is None:return None | |
| if "needs_user" in fast: | |
| if self.fast_lane and start_step==0 and not history: | |
| fast=self.fast_path(goal,asr) | |
| if fast is not None:return fast | |
| + from macjev.mac import runtime_adapter | |
| for step in range(start_step,self.max_steps): | |
| + runtime_adapter.stamped(history) # record receipt times now (before the planner's seconds-long call) | |
| observation={"approved_scope":str(self.scope),"registered_app_ids":sorted(set(APPS.values())), | |
| "window_app_aliases":WINDOW_APPS,"previous_results":history[-4:]} | |
| sessions=self.session_summary(goal) | |
| if action["tool"] not in {"ask_user","done"}: | |
| from .inference import DecisionEngine | |
| if self.engine is None:self.engine=DecisionEngine() | |
| - decision=self.decide_step(goal,observation,action) | |
| + decision=self.decide_step(goal,observation,action,history) | |
| if decision is None: | |
| return {"goal":goal,"asr":asr,"history":history,"needs_user":"The current observation is too large for the local decision model; please narrow the request."} | |
| if decision["answer"]!="execute" and decision["top_probability"]<DECISION_BLOCK_THRESHOLD: | |
| history.append({"action":action,"result":result}) | |
| if "needs_user" in result:return {"goal":goal,"asr":asr,"history":history,"needs_user":result["needs_user"]} | |
| if action["tool"]=="done": | |
| + # Shadow question (logged only; never ends or blocks a task). | |
| + if self.engine is not None: | |
| + from macjev.mac import runtime_adapter | |
| + runtime_adapter.goal_done_shadow(self.engine,goal,{**observation,"previous_results":runtime_adapter.stamped(history[:-1])},action) | |
| return {"goal":goal,"asr":asr,"history":history,"status":"planner_finished_with_observable_results","not_an_independent_whole_goal_success_claim":True} | |
| return {"goal":goal,"asr":asr,"history":history,"needs_user":f"Reached the {self.max_steps}-step bound; inspect the verified results before continuing."} | |
| --- a/src/mac_laya/fast_lane.py | |
| +++ b/src/mac_laya/fast_lane.py | |
| return None | |
| candidate, _, _, absolute = runnable[0] | |
| action = {"tool": candidate["tool"], "arguments": absolute, "reason": "fast lane: " + describe(candidate)} | |
| + result = listing if isinstance(listing, dict) else {"entries": listing} | |
| observation = {"approved_scope": str(scope), "previous_results": [ | |
| - {"action": {"tool": "list_files", "arguments": {"directory": str(scope)}}, "result": {"entries": listing}}]} | |
| - decision = engine.decide({"user_goal": goal, "observation": observation, "proposed_action": action}, STEP_QUESTION) | |
| - if decision["answer"] != "execute" or decision["top_probability"] < MIN_CONFIDENCE: | |
| + {"action": {"tool": "list_files", "arguments": {"directory": str(scope)}}, "result": result}]} | |
| + # Same scope-relative view, question and gate log as the planner loop (macjev.mac.runtime_adapter). | |
| + from macjev.mac import runtime_adapter | |
| + decision = runtime_adapter.gate_call(engine, goal, observation, action) | |
| + if decision is None or decision["answer"] != "execute" or decision["top_probability"] < MIN_CONFIDENCE: | |
| return None | |
| return {"action": action, "decision": decision, "fast_lane": True} | |