forked from Keelrleek/Harbor
Several sessions of one app: a session's working folder names its agent when that agent runs in the same app (MCP server and hooks), an i_am tool binds a session explicitly, the doctor checks second sessions against their app's install, and an agent that left the roster can still be uninstalled
This commit is contained in:
1 parent
d755ab8a76
commit
e283e4cc54
6 files changed
+63
-5
No files matched your search
+24
-1
@@ -67,7 +67,9 @@ def harbor():
|
||||
|
||||
def me():
|
||||
h = harbor()
|
||||
agent = os.environ.get("HARBOR_AGENT") or h.project.identity_for(os.getcwd()) or ""
|
||||
# a session bound with i_am, else the agent its working folder names (when it runs in the same app as the
|
||||
# installed one: Codex and Codex2 share the Codex app), else the installed one
|
||||
agent = _state.get("bound") or h.project.session_identity(os.environ.get("HARBOR_AGENT"), os.getcwd()) or ""
|
||||
if agent not in h.project.ai_names:
|
||||
raise HarborError(f"HARBOR_AGENT must be one of {', '.join(h.project.ai_names)} (set it in this server's MCP "
|
||||
"config)")
|
||||
@@ -121,6 +123,27 @@ def run(fn):
|
||||
raise ToolError(str(error)) from None
|
||||
|
||||
|
||||
@mcp.tool
|
||||
def i_am(agent: str) -> dict:
|
||||
"""Say which of the project's agents this session is, when one app runs several (Codex and Codex2). Call it once
|
||||
at the start of the session if your instructions or your working folder name you; only an agent of the same
|
||||
app is accepted, and a server already bound to another agent refuses."""
|
||||
def do(h):
|
||||
pinned = os.environ.get("HARBOR_AGENT") or ""
|
||||
if agent not in h.project.ai_names:
|
||||
raise HarborError(f"{agent} is not one of {', '.join(h.project.ai_names)}")
|
||||
if pinned and h.project.host_of(agent) != h.project.host_of(pinned):
|
||||
raise HarborError(f"{agent} runs in another app ({h.project.host_of(agent) or 'unknown'}), not this one")
|
||||
bound = _state.get("bound")
|
||||
if bound and bound != agent:
|
||||
raise HarborError(f"this Harbor server is already {bound}: the app shares one server between sessions, "
|
||||
"so give each session its own app profile instead")
|
||||
_state["bound"] = agent
|
||||
return {"you_are": agent, "working_folder": os.getcwd(),
|
||||
"folder_says": h.project.identity_for(os.getcwd())}
|
||||
return run(do)
|
||||
|
||||
|
||||
@mcp.tool
|
||||
def brief(mark_read: bool = False) -> str:
|
||||
"""What you need at the start of a session: stop flags, unread messages (urgent first), acknowledgements you
|
||||
|
||||
Reference in new issue
Block a user