fsanyoto commited on
Commit
8d3a743
·
verified ·
1 Parent(s): 3640562

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "02ef5952b1ed (02ef5952b1ed)",
3
  "releases": [
4
  {
5
  "version": "v81",
 
1
  {
2
+ "current": "6270f90cd2e1 (6270f90cd2e1)",
3
  "releases": [
4
  {
5
  "version": "v81",
VERSION CHANGED
@@ -1 +1 @@
1
- 02ef5952b1ed (02ef5952b1ed)
 
1
+ 6270f90cd2e1 (6270f90cd2e1)
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
@@ -3918,6 +3918,10 @@ def _brain_build_arguments(session, name, arguments, about):
3918
  return {**arguments, "arguments": {**args, "body": body}}
3919
 
3920
 
 
 
 
 
3921
  def _preview_external_write(session, name, arguments, *, issue_token=True, execution=None, purpose=None, about=None):
3922
  from core import write_execution
3923
  if isinstance(arguments, dict) and "about" in arguments:
@@ -4423,6 +4427,8 @@ def _confirm_change(session, args):
4423
  }
4424
  if tool == "views" and arguments.get("action") == "share":
4425
  response.update({key: copy.deepcopy(result[key]) for key in ("view", "audience")})
 
 
4426
  _confirmation_status(fresh_session, operation_id, "committed", response)
4427
  if tool != "database_object" and receipt.get("persisted") is True:
4428
  try:
@@ -4646,7 +4652,7 @@ _MCP_RESULT_OPAQUE = frozenset({
4646
  "revision_before", "revision_after", "filters", "sorts", "config", "binding", "bindings",
4647
  })
4648
  _MCP_RESULT_IDENTIFIERS = frozenset({
4649
- "resourceUri", "deepLink", "src", "websiteUrl", "fileId", "link", "href",
4650
  "id", "ids", "operation_id", "key", "keys", "pid", "pids", "database", "databases", "sourceDatabase",
4651
  "compatibleDatabases", "field", "fields", "field_key", "colId", "metric_key", "groupBy",
4652
  "workbook_id", "worksheet", "tab", "view_id", "app_id", "chart_id", "record_id", "contextId",
@@ -5160,7 +5166,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 +5180,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 +5195,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 +5207,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 +5342,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 +5429,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 +5520,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 +5543,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
 
3918
  return {**arguments, "arguments": {**args, "body": body}}
3919
 
3920
 
3921
+ _CATALOG_BUILD_RESULT_FIELDS = (
3922
+ "app_id", "catalog_id", "productCount", "pageCount", "pages", "deepLink", "pdfLink", "message")
3923
+
3924
+
3925
  def _preview_external_write(session, name, arguments, *, issue_token=True, execution=None, purpose=None, about=None):
3926
  from core import write_execution
3927
  if isinstance(arguments, dict) and "about" in arguments:
 
4427
  }
4428
  if tool == "views" and arguments.get("action") == "share":
4429
  response.update({key: copy.deepcopy(result[key]) for key in ("view", "audience")})
4430
+ if tool == "apps" and arguments.get("action") == "catalog_build":
4431
+ response.update({key: copy.deepcopy(result[key]) for key in _CATALOG_BUILD_RESULT_FIELDS})
4432
  _confirmation_status(fresh_session, operation_id, "committed", response)
4433
  if tool != "database_object" and receipt.get("persisted") is True:
4434
  try:
 
4652
  "revision_before", "revision_after", "filters", "sorts", "config", "binding", "bindings",
4653
  })
4654
  _MCP_RESULT_IDENTIFIERS = frozenset({
4655
+ "resourceUri", "deepLink", "pdfLink", "src", "websiteUrl", "fileId", "link", "href",
4656
  "id", "ids", "operation_id", "key", "keys", "pid", "pids", "database", "databases", "sourceDatabase",
4657
  "compatibleDatabases", "field", "fields", "field_key", "colId", "metric_key", "groupBy",
4658
  "workbook_id", "worksheet", "tab", "view_id", "app_id", "chart_id", "record_id", "contextId",
 
5166
  "Call a group with action and arguments. Each action keeps its own read or write rules.",
5167
  "Every tool accepts optional intent beside action and arguments. Every write requires it, including "
5168
  "previews, confirm_change, requests.send and intelligence.create_wiki. Use 1 to 500 characters. "
5169
+ 'Example: {"intent":"Prepare the weekly sales review"}. Intent is stripped before dispatch. '
5170
+ "A client that cannot send keys beside action and arguments may put intent, about and purpose "
5171
+ "inside arguments. The value beside action and arguments wins.",
5172
  "Each tool call records one external.query event with tool, action, outcome and argument keys and types. "
5173
  "Large shapes continue in argument_shape_1 and later numbered fields. Unknown keys are redacted. "
5174
  "Argument values are never recorded. Intent is retained only when sent, with credential patterns redacted. "
 
5180
  "characters, and one or more distinct tags below. intelligence.create_wiki needs the same about "
5181
  "and still publishes directly. The tool supplies the build kind. Confirmation uses the saved about.",
5182
  "Build tags: " + ", ".join(external_tools.BUILD_TAGS) + ".",
5183
+ "For a previewed build, put optional purpose beside action and arguments. "
5184
  "Use one line of 1 to 240 characters without control characters or long dashes. "
5185
  "Confirmation uses that saved purpose; do not send a new purpose to confirm_change.",
5186
  "Previous tool names remain callable for one release, but are absent from tools/list.", ""]
 
5195
  from tool_groups.data import query_guide
5196
  lines += [query_guide(rows), ""]
5197
  states = {row["action"]: row for row in capabilities if row["group"] == group}
5198
+ uses_filter_node = False
5199
  for action, entry in selected["actions"].items():
5200
  lines += ["### " + action,
5201
  "State: " + states[action]["state"] + "."
 
5207
  lines.append("Previous name: `" + entry["legacy_name"] + "`.")
5208
  schema = copy.deepcopy(entry["schema"])
5209
  schema.get("properties", {}).pop("about", None)
5210
+ schema, collapsed = external_tools.guide_schema(schema)
5211
+ uses_filter_node = uses_filter_node or collapsed
5212
  lines += ["```json", json.dumps(_mcp_schema_copy(schema), ensure_ascii=True, indent=2), "```", ""]
5213
+ if uses_filter_node:
5214
+ lines += [external_tools.filter_node_guide(), ""]
5215
  return _MCPGuideText("\n".join(lines) + "\n")
5216
  lines += ["## Connected AI clients", "",
5217
  "Client names and who connected them in this workspace. No entries means none are connected.",
 
5342
  return reply
5343
  params = req.get("params")
5344
  params = params if isinstance(params, dict) else {}
5345
+ arguments = _mcp_hoist_call_metadata(params.get("name"), params.get("arguments", {}))
5346
+ tool, schema = _mcp_audit_schema(params.get("name"), arguments)
5347
+ limitation_tool, limitation_action = _mcp_limitation_address(tool, arguments)
5348
  try:
5349
  with external_activity.capture_call(session, tool) as call:
5350
  if tool == limitation_tool:
5351
  external_activity.note_action(limitation_action)
5352
+ external_activity.note_arguments(arguments, schema)
5353
  metadata = params.get("_meta")
5354
  call["question"] = metadata.get("loopable/question") if isinstance(metadata, dict) else None
5355
  reply = _dispatch_mcp(req, session, base_url)
 
5429
  return value
5430
 
5431
 
5432
+ def _mcp_hoist_call_metadata(name, arguments):
5433
+ """Return group call arguments with intent, about and purpose lifted out of the inner arguments."""
5434
+ import tool_groups
5435
+ keys = ("intent", "about", "purpose")
5436
+ if (not isinstance(name, str) or name not in tool_groups.groups() or not isinstance(arguments, dict)
5437
+ or not isinstance(arguments.get("arguments"), dict)
5438
+ or not any(key in arguments["arguments"] for key in keys)):
5439
+ return arguments
5440
+ inner = arguments["arguments"]
5441
+ hoisted = {**arguments, "arguments": {key: value for key, value in inner.items() if key not in keys}}
5442
+ # The value beside action and arguments wins over the nested copy.
5443
+ for key in keys:
5444
+ if key in inner and key not in arguments:
5445
+ hoisted[key] = inner[key]
5446
+ return hoisted
5447
+
5448
+
5449
  def _mcp_requires_intent(name, arguments):
5450
  """Classify declared writes before argument validation can mask the intent requirement."""
5451
  if name == "confirm_change":
 
5520
  return {"jsonrpc": "2.0", "id": rid, "result": {"contents": [resource]}}
5521
  if method != "tools/call":
5522
  return protocol_error(rid, -32601, "The requested MCP method was not found.")
5523
+ arguments = _mcp_hoist_call_metadata(name, params.get("arguments", {}))
5524
  intent = _mcp_call_intent(arguments)
5525
  if intent is None and _mcp_requires_intent(name, arguments):
5526
  raise err(400, "call_intent_required", "Send intent explaining why you are making this write.",
 
5543
  purpose = _build_purpose(arguments.pop("purpose"))
5544
  if "about" in metadata_keys:
5545
  about = arguments.pop("about")
 
 
 
 
5546
  _assert_tool_query_filter_bounds(name, arguments)
5547
  resolved = tool_groups.resolve(name, arguments)
5548
  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
- 74bab92206c8d0238b7397140269bb7a20709afebb9165d971aa6ca72d0a9301
 
1
+ a06d76d5a9206ffc431ee1af558442e49023f11bb76c472fea5ddb8b547c1915