fsanyoto commited on
Commit
9597330
·
verified ·
1 Parent(s): a0159c4

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "7bcd350e76",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "1d50525cc",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 7bcd350e76
 
1
+ 1d50525cc
api/app_guide.py CHANGED
@@ -225,16 +225,19 @@ def _chart_guidance():
225
 
226
  def _catalog_guidance():
227
  """Append the same template library as the client and the current build argument schema."""
 
228
  from loopy_catalog_tools import build_schema
229
 
230
  library = json.dumps(app_rules.catalog_templates(), ensure_ascii=True, indent=2)
231
- schema = json.dumps(build_schema(), ensure_ascii=True, indent=2)
 
 
232
  return ("\n# Current Catalog template library\n\n"
233
  "These IDs, slots and design defaults also come from GET /api/v1/catalogs/templates.\n"
234
  f"```json\n{library}\n```\n"
235
  "\n# Current catalog_build argument schema\n\n"
236
  "This schema describes arguments only. Put about and intent beside action and arguments.\n"
237
- f"```json\n{schema}\n```\n")
238
 
239
 
240
  def read(section=None):
 
225
 
226
  def _catalog_guidance():
227
  """Append the same template library as the client and the current build argument schema."""
228
+ from core import external_tools
229
  from loopy_catalog_tools import build_schema
230
 
231
  library = json.dumps(app_rules.catalog_templates(), ensure_ascii=True, indent=2)
232
+ collapsed, used = external_tools.guide_schema(build_schema())
233
+ schema = json.dumps(collapsed, ensure_ascii=True, indent=2)
234
+ nodes = "\n" + external_tools.filter_node_guide() + "\n" if used else ""
235
  return ("\n# Current Catalog template library\n\n"
236
  "These IDs, slots and design defaults also come from GET /api/v1/catalogs/templates.\n"
237
  f"```json\n{library}\n```\n"
238
  "\n# Current catalog_build argument schema\n\n"
239
  "This schema describes arguments only. Put about and intent beside action and arguments.\n"
240
+ f"```json\n{schema}\n```\n{nodes}")
241
 
242
 
243
  def read(section=None):
api/routes_external.py CHANGED
@@ -5160,7 +5160,9 @@ def _mcp_guide(session: Session, group=None) -> str:
5160
  "Call a group with action and arguments. Each action keeps its own read or write rules.",
5161
  "Every tool accepts optional intent beside action and arguments. Every write requires it, including "
5162
  "previews, confirm_change, requests.send and intelligence.create_wiki. Use 1 to 500 characters. "
5163
- 'Example: {"intent":"Prepare the weekly sales review"}. Intent is stripped before dispatch.',
 
 
5164
  "Each tool call records one external.query event with tool, action, outcome and argument keys and types. "
5165
  "Large shapes continue in argument_shape_1 and later numbered fields. Unknown keys are redacted. "
5166
  "Argument values are never recorded. Intent is retained only when sent, with credential patterns redacted. "
@@ -5172,7 +5174,7 @@ def _mcp_guide(session: Session, group=None) -> str:
5172
  "characters, and one or more distinct tags below. intelligence.create_wiki needs the same about "
5173
  "and still publishes directly. The tool supplies the build kind. Confirmation uses the saved about.",
5174
  "Build tags: " + ", ".join(external_tools.BUILD_TAGS) + ".",
5175
- "For a previewed build, put optional purpose beside action and arguments, not inside arguments. "
5176
  "Use one line of 1 to 240 characters without control characters or long dashes. "
5177
  "Confirmation uses that saved purpose; do not send a new purpose to confirm_change.",
5178
  "Previous tool names remain callable for one release, but are absent from tools/list.", ""]
@@ -5187,6 +5189,7 @@ def _mcp_guide(session: Session, group=None) -> str:
5187
  from tool_groups.data import query_guide
5188
  lines += [query_guide(rows), ""]
5189
  states = {row["action"]: row for row in capabilities if row["group"] == group}
 
5190
  for action, entry in selected["actions"].items():
5191
  lines += ["### " + action,
5192
  "State: " + states[action]["state"] + "."
@@ -5198,7 +5201,11 @@ def _mcp_guide(session: Session, group=None) -> str:
5198
  lines.append("Previous name: `" + entry["legacy_name"] + "`.")
5199
  schema = copy.deepcopy(entry["schema"])
5200
  schema.get("properties", {}).pop("about", None)
 
 
5201
  lines += ["```json", json.dumps(_mcp_schema_copy(schema), ensure_ascii=True, indent=2), "```", ""]
 
 
5202
  return _MCPGuideText("\n".join(lines) + "\n")
5203
  lines += ["## Connected AI clients", "",
5204
  "Client names and who connected them in this workspace. No entries means none are connected.",
@@ -5329,13 +5336,14 @@ def _handle_mcp(req, session: Session, base_url: str = ""):
5329
  return reply
5330
  params = req.get("params")
5331
  params = params if isinstance(params, dict) else {}
5332
- tool, schema = _mcp_audit_schema(params.get("name"), params.get("arguments"))
5333
- limitation_tool, limitation_action = _mcp_limitation_address(tool, params.get("arguments"))
 
5334
  try:
5335
  with external_activity.capture_call(session, tool) as call:
5336
  if tool == limitation_tool:
5337
  external_activity.note_action(limitation_action)
5338
- external_activity.note_arguments(params.get("arguments", {}), schema)
5339
  metadata = params.get("_meta")
5340
  call["question"] = metadata.get("loopable/question") if isinstance(metadata, dict) else None
5341
  reply = _dispatch_mcp(req, session, base_url)
@@ -5415,6 +5423,23 @@ def _mcp_call_intent(arguments):
5415
  return value
5416
 
5417
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5418
  def _mcp_requires_intent(name, arguments):
5419
  """Classify declared writes before argument validation can mask the intent requirement."""
5420
  if name == "confirm_change":
@@ -5489,7 +5514,7 @@ def _dispatch_mcp(req, session: Session, base_url: str = ""):
5489
  return {"jsonrpc": "2.0", "id": rid, "result": {"contents": [resource]}}
5490
  if method != "tools/call":
5491
  return protocol_error(rid, -32601, "The requested MCP method was not found.")
5492
- arguments = params.get("arguments", {})
5493
  intent = _mcp_call_intent(arguments)
5494
  if intent is None and _mcp_requires_intent(name, arguments):
5495
  raise err(400, "call_intent_required", "Send intent explaining why you are making this write.",
@@ -5512,10 +5537,6 @@ def _dispatch_mcp(req, session: Session, base_url: str = ""):
5512
  purpose = _build_purpose(arguments.pop("purpose"))
5513
  if "about" in metadata_keys:
5514
  about = arguments.pop("about")
5515
- if (name in tool_groups.groups() and isinstance(arguments, dict)
5516
- and isinstance(arguments.get("arguments"), dict)
5517
- and {"about", "purpose", "intent"} & arguments["arguments"].keys()):
5518
- raise err(400, "tool_arguments_invalid", "Send intent and build metadata beside action and arguments.")
5519
  _assert_tool_query_filter_bounds(name, arguments)
5520
  resolved = tool_groups.resolve(name, arguments)
5521
  confirm = True
 
5160
  "Call a group with action and arguments. Each action keeps its own read or write rules.",
5161
  "Every tool accepts optional intent beside action and arguments. Every write requires it, including "
5162
  "previews, confirm_change, requests.send and intelligence.create_wiki. Use 1 to 500 characters. "
5163
+ 'Example: {"intent":"Prepare the weekly sales review"}. Intent is stripped before dispatch. '
5164
+ "A client that cannot send keys beside action and arguments may put intent, about and purpose "
5165
+ "inside arguments. The value beside action and arguments wins.",
5166
  "Each tool call records one external.query event with tool, action, outcome and argument keys and types. "
5167
  "Large shapes continue in argument_shape_1 and later numbered fields. Unknown keys are redacted. "
5168
  "Argument values are never recorded. Intent is retained only when sent, with credential patterns redacted. "
 
5174
  "characters, and one or more distinct tags below. intelligence.create_wiki needs the same about "
5175
  "and still publishes directly. The tool supplies the build kind. Confirmation uses the saved about.",
5176
  "Build tags: " + ", ".join(external_tools.BUILD_TAGS) + ".",
5177
+ "For a previewed build, put optional purpose beside action and arguments. "
5178
  "Use one line of 1 to 240 characters without control characters or long dashes. "
5179
  "Confirmation uses that saved purpose; do not send a new purpose to confirm_change.",
5180
  "Previous tool names remain callable for one release, but are absent from tools/list.", ""]
 
5189
  from tool_groups.data import query_guide
5190
  lines += [query_guide(rows), ""]
5191
  states = {row["action"]: row for row in capabilities if row["group"] == group}
5192
+ uses_filter_node = False
5193
  for action, entry in selected["actions"].items():
5194
  lines += ["### " + action,
5195
  "State: " + states[action]["state"] + "."
 
5201
  lines.append("Previous name: `" + entry["legacy_name"] + "`.")
5202
  schema = copy.deepcopy(entry["schema"])
5203
  schema.get("properties", {}).pop("about", None)
5204
+ schema, collapsed = external_tools.guide_schema(schema)
5205
+ uses_filter_node = uses_filter_node or collapsed
5206
  lines += ["```json", json.dumps(_mcp_schema_copy(schema), ensure_ascii=True, indent=2), "```", ""]
5207
+ if uses_filter_node:
5208
+ lines += [external_tools.filter_node_guide(), ""]
5209
  return _MCPGuideText("\n".join(lines) + "\n")
5210
  lines += ["## Connected AI clients", "",
5211
  "Client names and who connected them in this workspace. No entries means none are connected.",
 
5336
  return reply
5337
  params = req.get("params")
5338
  params = params if isinstance(params, dict) else {}
5339
+ arguments = _mcp_hoist_call_metadata(params.get("name"), params.get("arguments", {}))
5340
+ tool, schema = _mcp_audit_schema(params.get("name"), arguments)
5341
+ limitation_tool, limitation_action = _mcp_limitation_address(tool, arguments)
5342
  try:
5343
  with external_activity.capture_call(session, tool) as call:
5344
  if tool == limitation_tool:
5345
  external_activity.note_action(limitation_action)
5346
+ external_activity.note_arguments(arguments, schema)
5347
  metadata = params.get("_meta")
5348
  call["question"] = metadata.get("loopable/question") if isinstance(metadata, dict) else None
5349
  reply = _dispatch_mcp(req, session, base_url)
 
5423
  return value
5424
 
5425
 
5426
+ def _mcp_hoist_call_metadata(name, arguments):
5427
+ """Return group call arguments with intent, about and purpose lifted out of the inner arguments."""
5428
+ import tool_groups
5429
+ keys = ("intent", "about", "purpose")
5430
+ if (not isinstance(name, str) or name not in tool_groups.groups() or not isinstance(arguments, dict)
5431
+ or not isinstance(arguments.get("arguments"), dict)
5432
+ or not any(key in arguments["arguments"] for key in keys)):
5433
+ return arguments
5434
+ inner = arguments["arguments"]
5435
+ hoisted = {**arguments, "arguments": {key: value for key, value in inner.items() if key not in keys}}
5436
+ # The value beside action and arguments wins over the nested copy.
5437
+ for key in keys:
5438
+ if key in inner and key not in arguments:
5439
+ hoisted[key] = inner[key]
5440
+ return hoisted
5441
+
5442
+
5443
  def _mcp_requires_intent(name, arguments):
5444
  """Classify declared writes before argument validation can mask the intent requirement."""
5445
  if name == "confirm_change":
 
5514
  return {"jsonrpc": "2.0", "id": rid, "result": {"contents": [resource]}}
5515
  if method != "tools/call":
5516
  return protocol_error(rid, -32601, "The requested MCP method was not found.")
5517
+ arguments = _mcp_hoist_call_metadata(name, params.get("arguments", {}))
5518
  intent = _mcp_call_intent(arguments)
5519
  if intent is None and _mcp_requires_intent(name, arguments):
5520
  raise err(400, "call_intent_required", "Send intent explaining why you are making this write.",
 
5537
  purpose = _build_purpose(arguments.pop("purpose"))
5538
  if "about" in metadata_keys:
5539
  about = arguments.pop("about")
 
 
 
 
5540
  _assert_tool_query_filter_bounds(name, arguments)
5541
  resolved = tool_groups.resolve(name, arguments)
5542
  confirm = True
platform/core/external_tools.py CHANGED
@@ -140,6 +140,46 @@ _QUERY_FILTER = {"oneOf": [
140
  _object({"link": _STRING, "where": _query_filter_node(allow_link=False)},
141
  ("link", "where"), additionalProperties=False),
142
  ]}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  _BINDING = _object({
144
  "database": _STRING,
145
  "aggregate": _object({"fn": _STRING, "field": _STRING, "metric_key": _STRING}),
 
140
  _object({"link": _STRING, "where": _query_filter_node(allow_link=False)},
141
  ("link", "where"), additionalProperties=False),
142
  ]}
143
+ FILTER_NODE_REF = "#/$defs/filter_node"
144
+ FILTER_NODE_EXAMPLE = {"conj": "and", "nodes": [
145
+ {"colId": "status", "op": "eq", "value": "open"},
146
+ {"conj": "or", "children": [{"colId": "amount", "op": "gt", "value": 100},
147
+ {"colId": "region", "op": "eq", "value": "West"}]},
148
+ ]}
149
+
150
+
151
+ def _is_filter_node(value):
152
+ """Tell a published query filter node from any other schema."""
153
+ branches = value.get("oneOf") if isinstance(value, dict) and set(value) == {"oneOf"} else None
154
+ first = branches[0] if isinstance(branches, list) and branches and isinstance(branches[0], dict) else {}
155
+ properties = first.get("properties")
156
+ return isinstance(properties, dict) and "colId" in properties and "op" in properties
157
+
158
+
159
+ def guide_schema(schema):
160
+ """Return a guide copy with each query filter node replaced by one reference, and whether any was."""
161
+ if _is_filter_node(schema):
162
+ return {"$ref": FILTER_NODE_REF}, True
163
+ if isinstance(schema, list):
164
+ pairs = [guide_schema(item) for item in schema]
165
+ return [item for item, _ in pairs], any(used for _, used in pairs)
166
+ if not isinstance(schema, dict):
167
+ return copy.deepcopy(schema), False
168
+ pairs = {key: guide_schema(child) for key, child in schema.items()}
169
+ return {key: item for key, (item, _) in pairs.items()}, any(used for _, used in pairs.values())
170
+
171
+
172
+ def filter_node_guide():
173
+ """Return the one markdown section that defines the filter_node reference in a guide."""
174
+ node = {"oneOf": [guide_schema(branch)[0] for branch in _QUERY_FILTER_NODE["oneOf"]]}
175
+ return ("## filter_node\n\n"
176
+ "A filter_node is a condition {colId, op, ...}, a group {conj, children: 1 to 50 filter_node}, "
177
+ "or a link {link, where}.\n"
178
+ "Groups nest at most two deep inside one node. A link's where holds no link.\n"
179
+ "Example filter: `" + json.dumps(FILTER_NODE_EXAMPLE, ensure_ascii=True) + "`\n"
180
+ "```json\n" + json.dumps({"$defs": {"filter_node": node}}, ensure_ascii=True, indent=2) + "\n```")
181
+
182
+
183
  _BINDING = _object({
184
  "database": _STRING,
185
  "aggregate": _object({"fn": _STRING, "field": _STRING, "metric_key": _STRING}),
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- ad48a01a9480a16ac38c4a3ceb0670d5814fb93c6839aafec854b6bb18a5b9de
 
1
+ a209ac43c8734d99aa929b85612fb05eec2cfbb8bd90c61c53708f232f74af0e