Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/external_activity.py +7 -0
- api/loopy_catalog_tools.py +4 -1
- api/routes_external.py +62 -7
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "20cdbcf88",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
20cdbcf88
|
api/external_activity.py
CHANGED
|
@@ -76,6 +76,13 @@ def note_action(action):
|
|
| 76 |
call["action"] = _text(action)
|
| 77 |
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
def note_database(database):
|
| 80 |
"""Accept database identities only from permissioned server metadata."""
|
| 81 |
call = _CALL.get()
|
|
|
|
| 76 |
call["action"] = _text(action)
|
| 77 |
|
| 78 |
|
| 79 |
+
def note_saved_intent(intent):
|
| 80 |
+
"""Record a preview's saved intent for a confirmation sent without its own intent."""
|
| 81 |
+
call = _CALL.get()
|
| 82 |
+
if call is not None and "intent" not in call:
|
| 83 |
+
call["intent"] = audit.redact_intent(intent)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
def note_database(database):
|
| 87 |
"""Accept database identities only from permissioned server metadata."""
|
| 88 |
call = _CALL.get()
|
api/loopy_catalog_tools.py
CHANGED
|
@@ -38,7 +38,10 @@ def _build_app(ctx, args):
|
|
| 38 |
if exc.status_code not in (403, 404):
|
| 39 |
raise
|
| 40 |
if app is None:
|
| 41 |
-
_build_refusal("catalog_app_unavailable",
|
|
|
|
|
|
|
|
|
|
| 42 |
fields = {field["key"] for field in schema["fields"]}
|
| 43 |
if any(field not in fields for field in app["fieldMap"].values()):
|
| 44 |
_build_refusal("catalog_fields_forbidden", "The Catalog App uses unavailable fields. Rebind it to readable source fields.")
|
|
|
|
| 38 |
if exc.status_code not in (403, 404):
|
| 39 |
raise
|
| 40 |
if app is None:
|
| 41 |
+
_build_refusal("catalog_app_unavailable", (
|
| 42 |
+
"No editable Catalog App is available for this source. Create one with apps.apply_template "
|
| 43 |
+
"using templateKind catalog and a fieldMap that maps key and title to field keys of this source, "
|
| 44 |
+
"for example {\"key\": \"sku\", \"title\": \"name\"}. apps.templates lists the optional roles."))
|
| 45 |
fields = {field["key"] for field in schema["fields"]}
|
| 46 |
if any(field not in fields for field in app["fieldMap"].values()):
|
| 47 |
_build_refusal("catalog_fields_forbidden", "The Catalog App uses unavailable fields. Rebind it to readable source fields.")
|
api/routes_external.py
CHANGED
|
@@ -3897,8 +3897,41 @@ def _build_about(value):
|
|
| 3897 |
except (sheets.SheetRefusal, TypeError, ValueError, KeyError) as exc:
|
| 3898 |
if isinstance(exc, sheets.SheetRefusal) and exc.code == "credential_in_arguments":
|
| 3899 |
raise
|
| 3900 |
-
|
| 3901 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3902 |
return cleaned
|
| 3903 |
|
| 3904 |
|
|
@@ -3943,7 +3976,8 @@ _CATALOG_BUILD_RESULT_FIELDS = (
|
|
| 3943 |
"app_id", "catalog_id", "productCount", "pageCount", "pages", "deepLink", "pdfLink", "message")
|
| 3944 |
|
| 3945 |
|
| 3946 |
-
def _preview_external_write(session, name, arguments, *, issue_token=True, execution=None, purpose=None, about=None
|
|
|
|
| 3947 |
from core import write_execution
|
| 3948 |
if isinstance(arguments, dict) and "about" in arguments:
|
| 3949 |
if about is not None:
|
|
@@ -4051,7 +4085,7 @@ def _preview_external_write(session, name, arguments, *, issue_token=True, execu
|
|
| 4051 |
response["confirmation_phrase"] = _CONFIRMATION_PHRASE
|
| 4052 |
if issue_token:
|
| 4053 |
response["confirmation_token"] = _confirmation_token(payload)
|
| 4054 |
-
_store_operation(session, payload, response, preview_runtime)
|
| 4055 |
response["_confirmation"] = payload
|
| 4056 |
response["_plan"] = plan
|
| 4057 |
return response
|
|
@@ -4078,7 +4112,7 @@ def _prune_operations(raw):
|
|
| 4078 |
return doc
|
| 4079 |
|
| 4080 |
|
| 4081 |
-
def _store_operation(session, payload, preview, staged):
|
| 4082 |
"""Keep the preview identity outside every affected object's revision."""
|
| 4083 |
operation_id = payload["operation_id"]
|
| 4084 |
access = {
|
|
@@ -4102,6 +4136,9 @@ def _store_operation(session, payload, preview, staged):
|
|
| 4102 |
item = {"payload": copy.deepcopy(payload), "access": access, "status": "preview",
|
| 4103 |
"retain_until": time.time() + _OPERATION_RETENTION_SECONDS,
|
| 4104 |
"affected": copy.deepcopy(preview["affected"])}
|
|
|
|
|
|
|
|
|
|
| 4105 |
def save(raw):
|
| 4106 |
doc = _prune_operations(raw)
|
| 4107 |
if operation_id in doc["claims"]:
|
|
@@ -4579,7 +4616,8 @@ MCP_RESULT_CODES.update({
|
|
| 4579 |
"operation_unavailable": _OPERATION_UNAVAILABLE_MESSAGE,
|
| 4580 |
"credential_in_arguments": "Remove credential values from the arguments.",
|
| 4581 |
"build_about_required": "Send about with title, description of 20 to 240 characters, and tags from the guide. See missing and example.",
|
| 4582 |
-
"build_about_invalid": "Use a nonempty title, a description of 20 to 240 characters,
|
|
|
|
| 4583 |
"call_intent_required": "Send intent explaining why you are making this write. See example.",
|
| 4584 |
"call_intent_invalid": "Send intent as a string of 1 to 500 characters. See example.",
|
| 4585 |
"invalid_external_credential": "The credential is invalid, expired, or revoked.",
|
|
@@ -5459,6 +5497,19 @@ def _mcp_call_intent(arguments):
|
|
| 5459 |
return value
|
| 5460 |
|
| 5461 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5462 |
def _mcp_hoist_call_metadata(name, arguments):
|
| 5463 |
"""Return group call arguments with intent, about and purpose lifted out of the inner arguments."""
|
| 5464 |
import tool_groups
|
|
@@ -5552,6 +5603,10 @@ def _dispatch_mcp(req, session: Session, base_url: str = ""):
|
|
| 5552 |
return protocol_error(rid, -32601, "The requested MCP method was not found.")
|
| 5553 |
arguments = _mcp_hoist_call_metadata(name, params.get("arguments", {}))
|
| 5554 |
intent = _mcp_call_intent(arguments)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5555 |
if intent is None and _mcp_requires_intent(name, arguments):
|
| 5556 |
raise err(400, "call_intent_required", "Send intent explaining why you are making this write.",
|
| 5557 |
{"example": {"intent": "Prepare the weekly sales review"}})
|
|
@@ -5598,7 +5653,7 @@ def _dispatch_mcp(req, session: Session, base_url: str = ""):
|
|
| 5598 |
elif writing:
|
| 5599 |
_assert_write_scope(session, name, arguments)
|
| 5600 |
if confirm:
|
| 5601 |
-
data = _preview_external_write(session, name, arguments, purpose=purpose, about=about)
|
| 5602 |
data.pop("_confirmation", None)
|
| 5603 |
data.pop("_plan", None)
|
| 5604 |
else:
|
|
|
|
| 3897 |
except (sheets.SheetRefusal, TypeError, ValueError, KeyError) as exc:
|
| 3898 |
if isinstance(exc, sheets.SheetRefusal) and exc.code == "credential_in_arguments":
|
| 3899 |
raise
|
| 3900 |
+
rules = external_tools.ABOUT_SCHEMA["properties"]
|
| 3901 |
+
tags = list(external_tools.BUILD_TAGS)
|
| 3902 |
+
|
| 3903 |
+
def text_ok(key, text, collapse=False):
|
| 3904 |
+
spec = rules[key]
|
| 3905 |
+
if not isinstance(text, str) or not spec["minLength"] <= len(text) <= spec["maxLength"]:
|
| 3906 |
+
return False
|
| 3907 |
+
if not re.search(spec["pattern"], text):
|
| 3908 |
+
return False
|
| 3909 |
+
return not collapse or len(" ".join(text.split())) >= spec["minLength"]
|
| 3910 |
+
|
| 3911 |
+
if not isinstance(value, dict):
|
| 3912 |
+
invalid = ["about"]
|
| 3913 |
+
else:
|
| 3914 |
+
invalid = [field for field, ok in (
|
| 3915 |
+
("about.title", text_ok("title", value.get("title"))),
|
| 3916 |
+
("about.description", text_ok("description", value.get("description"), collapse=True)),
|
| 3917 |
+
("about.tags", isinstance(value.get("tags"), list) and bool(value["tags"])
|
| 3918 |
+
and all(isinstance(tag, str) and tag in tags for tag in value["tags"])
|
| 3919 |
+
and len(set(value["tags"])) == len(value["tags"])),
|
| 3920 |
+
) if not ok]
|
| 3921 |
+
# Echo only short identifier keys back across the bearer seam.
|
| 3922 |
+
invalid += ["about." + (key if isinstance(key, str) and re.fullmatch(r"[A-Za-z][A-Za-z0-9_]{0,39}", key)
|
| 3923 |
+
else "[unknown]") for key in value if key not in rules]
|
| 3924 |
+
invalid = invalid or ["about"]
|
| 3925 |
+
details = {"missing": missing, "invalid": invalid, "example": example}
|
| 3926 |
+
message = ("Send about with title, description and tags." if missing
|
| 3927 |
+
else "Fix " + ", ".join(invalid) + ".")
|
| 3928 |
+
if not isinstance(value, dict) or "about.tags" in invalid or "about.tags" in missing:
|
| 3929 |
+
details["allowed"] = tags
|
| 3930 |
+
message += " Use tags from this list, each once: " + ", ".join(tags) + "."
|
| 3931 |
+
if "about.title" in invalid or "about.description" in invalid:
|
| 3932 |
+
message += (" Use a title of 1 to 240 characters and a description of 20 to 240 characters,"
|
| 3933 |
+
" without em or en dashes.")
|
| 3934 |
+
raise err(400, "build_about_required" if missing else "build_about_invalid", message, details) from None
|
| 3935 |
return cleaned
|
| 3936 |
|
| 3937 |
|
|
|
|
| 3976 |
"app_id", "catalog_id", "productCount", "pageCount", "pages", "deepLink", "pdfLink", "message")
|
| 3977 |
|
| 3978 |
|
| 3979 |
+
def _preview_external_write(session, name, arguments, *, issue_token=True, execution=None, purpose=None, about=None,
|
| 3980 |
+
intent=None):
|
| 3981 |
from core import write_execution
|
| 3982 |
if isinstance(arguments, dict) and "about" in arguments:
|
| 3983 |
if about is not None:
|
|
|
|
| 4085 |
response["confirmation_phrase"] = _CONFIRMATION_PHRASE
|
| 4086 |
if issue_token:
|
| 4087 |
response["confirmation_token"] = _confirmation_token(payload)
|
| 4088 |
+
_store_operation(session, payload, response, preview_runtime, intent=intent)
|
| 4089 |
response["_confirmation"] = payload
|
| 4090 |
response["_plan"] = plan
|
| 4091 |
return response
|
|
|
|
| 4112 |
return doc
|
| 4113 |
|
| 4114 |
|
| 4115 |
+
def _store_operation(session, payload, preview, staged, intent=None):
|
| 4116 |
"""Keep the preview identity outside every affected object's revision."""
|
| 4117 |
operation_id = payload["operation_id"]
|
| 4118 |
access = {
|
|
|
|
| 4136 |
item = {"payload": copy.deepcopy(payload), "access": access, "status": "preview",
|
| 4137 |
"retain_until": time.time() + _OPERATION_RETENTION_SECONDS,
|
| 4138 |
"affected": copy.deepcopy(preview["affected"])}
|
| 4139 |
+
if isinstance(intent, str):
|
| 4140 |
+
# Intent stays outside the signed payload, redacted, so confirm_change can reuse it.
|
| 4141 |
+
item["intent"] = audit.redact_intent(intent)
|
| 4142 |
def save(raw):
|
| 4143 |
doc = _prune_operations(raw)
|
| 4144 |
if operation_id in doc["claims"]:
|
|
|
|
| 4616 |
"operation_unavailable": _OPERATION_UNAVAILABLE_MESSAGE,
|
| 4617 |
"credential_in_arguments": "Remove credential values from the arguments.",
|
| 4618 |
"build_about_required": "Send about with title, description of 20 to 240 characters, and tags from the guide. See missing and example.",
|
| 4619 |
+
"build_about_invalid": ("Fix the fields in invalid. Use a nonempty title, a description of 20 to 240 characters, "
|
| 4620 |
+
"and tags from allowed, each once: " + ", ".join(external_tools.BUILD_TAGS) + "."),
|
| 4621 |
"call_intent_required": "Send intent explaining why you are making this write. See example.",
|
| 4622 |
"call_intent_invalid": "Send intent as a string of 1 to 500 characters. See example.",
|
| 4623 |
"invalid_external_credential": "The credential is invalid, expired, or revoked.",
|
|
|
|
| 5497 |
return value
|
| 5498 |
|
| 5499 |
|
| 5500 |
+
def _mcp_saved_intent(session, arguments):
|
| 5501 |
+
"""Return the intent saved with the preview the signed token names, or None."""
|
| 5502 |
+
try:
|
| 5503 |
+
payload = _read_confirmation_token(arguments.get("confirmation_token"))
|
| 5504 |
+
_, stored = _load_operation(session, payload.get("operation_id", ""), confirming=True)
|
| 5505 |
+
if stored["payload"] != payload:
|
| 5506 |
+
return None
|
| 5507 |
+
except Exception:
|
| 5508 |
+
return None
|
| 5509 |
+
intent = stored.get("intent")
|
| 5510 |
+
return intent if isinstance(intent, str) and intent.strip() else None
|
| 5511 |
+
|
| 5512 |
+
|
| 5513 |
def _mcp_hoist_call_metadata(name, arguments):
|
| 5514 |
"""Return group call arguments with intent, about and purpose lifted out of the inner arguments."""
|
| 5515 |
import tool_groups
|
|
|
|
| 5603 |
return protocol_error(rid, -32601, "The requested MCP method was not found.")
|
| 5604 |
arguments = _mcp_hoist_call_metadata(name, params.get("arguments", {}))
|
| 5605 |
intent = _mcp_call_intent(arguments)
|
| 5606 |
+
if intent is None and name == "confirm_change" and isinstance(arguments, dict):
|
| 5607 |
+
intent = _mcp_saved_intent(session, arguments)
|
| 5608 |
+
if intent is not None:
|
| 5609 |
+
external_activity.note_saved_intent(intent)
|
| 5610 |
if intent is None and _mcp_requires_intent(name, arguments):
|
| 5611 |
raise err(400, "call_intent_required", "Send intent explaining why you are making this write.",
|
| 5612 |
{"example": {"intent": "Prepare the weekly sales review"}})
|
|
|
|
| 5653 |
elif writing:
|
| 5654 |
_assert_write_scope(session, name, arguments)
|
| 5655 |
if confirm:
|
| 5656 |
+
data = _preview_external_write(session, name, arguments, purpose=purpose, about=about, intent=intent)
|
| 5657 |
data.pop("_confirmation", None)
|
| 5658 |
data.pop("_plan", None)
|
| 5659 |
else:
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
dd931791387b20061c0dc1081f72009ea88afb4107d6ce0eaf912a5af3ab35d9
|