feat(harness): authority, turn contract, tools, clean_agent_preview

Chat/agent harness work: request-authority model, turn contract, tool
policy/parsing/execution, clean_agent_preview streaming/thinking, ask_user
persistence, session probes, and scheduler.

Source: vendor/photocraft (ad1cff44) harness files, 3-way merged onto
upstream/dev (a8c147b2). Harness core files were independently developed
in both lineages; resolution policy documented in pr_work/C_conflicts.md
(vendor kept where ahead, upstream kept where vendor is behind; full delta
preserved in pr_work/C_upstream_delta.patch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pewdiepie-archdaemon
2026-10-13 13:41:53 +00:00
co-authored by Claude Opus 5.5
parent a8c147b238
commit 364229f2dc
60 changed files with 2778 additions and 696 deletions
+5
View File
@@ -29,6 +29,7 @@ from .interaction_tools import AskUserTool, UpdatePlanTool
from .model_interaction_tools import ChatWithModelTool, AskTeacherTool, ListModelsTool
from .bg_job_tools import ManageBgJobsTool
from .session_tools import CreateSessionTool, ListSessionsTool, SendToSessionTool, ManageSessionTool
from .editor_tools import PlanEditTool, RunEditorCommandTool, GetEditorScreenshotTool, AiEditImageTool
from .admin_tools import (
ADMIN_TOOL_HANDLERS,
do_manage_endpoints, do_manage_mcp, do_manage_webhooks,
@@ -72,6 +73,10 @@ TOOL_HANDLERS = {
"list_sessions": ListSessionsTool().execute,
"send_to_session": SendToSessionTool().execute,
"manage_session": ManageSessionTool().execute,
"plan_edit": PlanEditTool().execute,
"run_editor_command": RunEditorCommandTool().execute,
"get_editor_screenshot": GetEditorScreenshotTool().execute,
"ai_edit_image": AiEditImageTool().execute,
}
# Config/integration admin tools (manage_endpoints/mcp/webhooks/tokens/settings).
TOOL_HANDLERS.update(ADMIN_TOOL_HANDLERS)
+6
View File
@@ -496,6 +496,7 @@ def _create_pdf_text_derivative(db, *, source_doc, content: str, owner: Optional
"content": clean,
"version": 1,
"source_doc_id": getattr(source_doc, "id", None),
"exit_code": 0,
}
@@ -618,6 +619,7 @@ class CreateDocumentTool:
"language": language,
"content": content,
"version": 1,
"exit_code": 0,
}
except Exception as e:
db.rollback()
@@ -708,6 +710,7 @@ class UpdateDocumentTool:
"language": doc.language,
"content": new_content,
"version": new_ver,
"exit_code": 0,
}
except Exception as e:
db.rollback()
@@ -863,6 +866,7 @@ class EditDocumentTool:
"version": new_ver,
"applied": applied,
"skipped": skipped,
"exit_code": 0,
}
return {"error": "No edits applied — FIND text cannot be blank"}
@@ -968,6 +972,7 @@ class EditDocumentTool:
"version": new_ver,
"applied": applied,
"skipped": skipped,
"exit_code": 0,
}
if partial_edits:
result.update({
@@ -1059,6 +1064,7 @@ class SuggestDocumentTool:
"partial": bool(invalid),
"rejected": len(invalid),
"invalid_suggestions": invalid,
"exit_code": 0,
}
finally:
db.close()
+5 -1
View File
@@ -14,6 +14,7 @@ import tempfile
import time
import html
import hashlib
import pwd
import urllib.parse
import urllib.request
import uuid
@@ -31,7 +32,10 @@ _ACTIVE_BROWSER_SESSIONS: set[str] = set()
def _service_home() -> Path:
"""Return the account home even when a task overrides ``HOME``."""
return platform_compat.service_home()
try:
return Path(pwd.getpwuid(os.getuid()).pw_dir)
except (KeyError, OSError):
return Path.home()
def _host_npm_roots() -> list[Path]: