fsanyoto commited on
Commit
ac0af3b
·
verified ·
1 Parent(s): 0de30a1

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "e60f096",
3
  "releases": [
4
  {
5
  "version": "v75",
 
1
  {
2
+ "current": "c43ab43",
3
  "releases": [
4
  {
5
  "version": "v75",
VERSION CHANGED
@@ -1 +1 @@
1
- e60f096
 
1
+ c43ab43
api/routes_external.py CHANGED
@@ -2972,7 +2972,51 @@ def _mcp_content(rid, out):
2972
  "content": [{"type": "text", "text": encoded}], "isError": not out.get("ok", False)}}
2973
 
2974
 
2975
- def _handle_mcp(req, session: Session):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2976
  """One HTTP request object; the stdio precedent's JSON-RPC and content envelopes."""
2977
  def protocol_error(rid, code, message):
2978
  return {"jsonrpc": "2.0", "id": rid, "error": {"code": code, "message": message}}
@@ -3001,15 +3045,18 @@ def _handle_mcp(req, session: Session):
3001
  return protocol_error(rid, -32602, "The protocol version must be a safe string.")
3002
  return {"jsonrpc": "2.0", "id": rid, "result": {
3003
  "protocolVersion": protocol, "capabilities": {"tools": {}},
3004
- "serverInfo": {"name": "loopable-external", "version": "1.0.0"}}}
 
3005
  if method == "ping":
3006
  return {"jsonrpc": "2.0", "id": rid, "result": {}}
3007
  if method == "tools/list":
3008
- return {"jsonrpc": "2.0", "id": rid, "result": {"tools": [
3009
- {"name": key, "description": tool["description"], "inputSchema": tool["inputSchema"]}
3010
- for key, tool in external_tools.TOOLS.items()]}}
3011
  if method != "tools/call":
3012
  return protocol_error(rid, -32601, "The requested MCP method was not found.")
 
 
 
 
3013
  arguments = params.get("arguments", {})
3014
  for database in _databases_in_arguments(arguments):
3015
  _assert_database_scope(session, database)
@@ -3059,7 +3106,7 @@ async def external_mcp(request: Request, session: Session = Depends(require_exte
3059
  except (ValueError, UnicodeError):
3060
  return {"jsonrpc": "2.0", "id": None,
3061
  "error": {"code": -32700, "message": "The request body must be valid JSON."}}
3062
- reply = await run_in_threadpool(_handle_mcp, req, session)
3063
  return Response(status_code=204) if reply is None else reply
3064
 
3065
 
 
2972
  "content": [{"type": "text", "text": encoded}], "isError": not out.get("ok", False)}}
2973
 
2974
 
2975
+ # ⭐⭐ HOTFIX 2026-09-24 — WHAT AN MCP CLIENT IS TOLD, AND WHERE IT READS THE REST. Owner: does
2976
+ # ChatGPT "have access to Loopable skill so it knows best practice in tool calling". It did not:
2977
+ # skill.md is only offered to coding agents, and `initialize` sent no guidance. Two doors, because
2978
+ # clients differ: `instructions` on initialize (the MCP field; Claude reads it) and a read-only
2979
+ # `loopable_guide` tool (every client can call a tool). ⛔ Model-facing text is user-facing copy:
2980
+ # no em or en dashes here.
2981
+ MCP_GUIDE_TOOL = "loopable_guide"
2982
+ MCP_INSTRUCTIONS = "\n".join([
2983
+ "Loopable is a governed business data workspace: databases, saved Views, Sheet workbooks and "
2984
+ "Apps. Every call runs as the signed-in user, with that user's own permissions.",
2985
+ "1. Call loopable_guide once at the start. It returns this user's databases, their fields and "
2986
+ "the full rules for every tool.",
2987
+ "2. Discover before you query: list_databases, then describe_database for the database you "
2988
+ "need. Use only field keys that describe_database returns; never guess a field name.",
2989
+ "3. Read with query_database. Filter and sort on the server, ask only for the fields you need, "
2990
+ "and follow the cursor for more pages instead of reading everything. Report totals from the "
2991
+ "counts the tool returns, not from the rows you happened to read.",
2992
+ "4. Every write returns a preview first. Show the user what will change and call "
2993
+ "confirm_change only after they agree. A destructive change needs the exact phrase the "
2994
+ "preview names.",
2995
+ "5. A refusal (ok: false) names its code and reason. Tell the user the reason; do not retry "
2996
+ "the same call with a wider scope.",
2997
+ "6. Never ask for, print or store a credential.",
2998
+ ])
2999
+ _MCP_GUIDE_SPEC = {
3000
+ "name": MCP_GUIDE_TOOL,
3001
+ "description": ("Read this first. The Loopable guide for this user: their databases and "
3002
+ "fields, and the rules for calling every other tool."),
3003
+ "inputSchema": {"type": "object", "properties": {}, "required": [],
3004
+ "additionalProperties": False},
3005
+ "annotations": {"title": "Loopable guide", "readOnlyHint": True, "openWorldHint": False},
3006
+ }
3007
+
3008
+
3009
+ def _mcp_tool_specs() -> list[dict]:
3010
+ """tools/list: the guide first, then the registry, each with its read or write hint."""
3011
+ specs = [_MCP_GUIDE_SPEC]
3012
+ for key, tool in external_tools.TOOLS.items():
3013
+ specs.append({"name": key, "description": tool["description"],
3014
+ "inputSchema": tool["inputSchema"],
3015
+ "annotations": {"readOnlyHint": not tool["write"], "openWorldHint": False}})
3016
+ return specs
3017
+
3018
+
3019
+ def _handle_mcp(req, session: Session, base_url: str = ""):
3020
  """One HTTP request object; the stdio precedent's JSON-RPC and content envelopes."""
3021
  def protocol_error(rid, code, message):
3022
  return {"jsonrpc": "2.0", "id": rid, "error": {"code": code, "message": message}}
 
3045
  return protocol_error(rid, -32602, "The protocol version must be a safe string.")
3046
  return {"jsonrpc": "2.0", "id": rid, "result": {
3047
  "protocolVersion": protocol, "capabilities": {"tools": {}},
3048
+ "serverInfo": {"name": "loopable-external", "version": "1.0.0"},
3049
+ "instructions": MCP_INSTRUCTIONS}}
3050
  if method == "ping":
3051
  return {"jsonrpc": "2.0", "id": rid, "result": {}}
3052
  if method == "tools/list":
3053
+ return {"jsonrpc": "2.0", "id": rid, "result": {"tools": _mcp_tool_specs()}}
 
 
3054
  if method != "tools/call":
3055
  return protocol_error(rid, -32601, "The requested MCP method was not found.")
3056
+ if name == MCP_GUIDE_TOOL:
3057
+ return _mcp_content(rid, {"ok": True, "data": {
3058
+ "instructions": MCP_INSTRUCTIONS,
3059
+ "guide": _portable_skill_document(session, base_url or "https://runloopable.com")}})
3060
  arguments = params.get("arguments", {})
3061
  for database in _databases_in_arguments(arguments):
3062
  _assert_database_scope(session, database)
 
3106
  except (ValueError, UnicodeError):
3107
  return {"jsonrpc": "2.0", "id": None,
3108
  "error": {"code": -32700, "message": "The request body must be valid JSON."}}
3109
+ reply = await run_in_threadpool(_handle_mcp, req, session, str(request.base_url))
3110
  return Response(status_code=204) if reply is None else reply
3111
 
3112
 
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 4fecb566f7ed03ef9116291760b9f8beb2c7c6c8812734f419470e260ddd7182
 
1
+ c95e0a242c3f168a10a80641c90d511bcf1235add210caf05c490a2b2a454af8
web/src/index.css CHANGED
@@ -13941,3 +13941,30 @@ input.conn-odoo-v:disabled { background: var(--lp-surface-2); color: var(--lp-mu
13941
  .cg-overlay.sheet-ribbon-view {
13942
  overflow-y: auto;
13943
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13941
  .cg-overlay.sheet-ribbon-view {
13942
  overflow-y: auto;
13943
  }
13944
+
13945
+
13946
+ /* HOTFIX 2026-09-24 — AI API: the AI connections list wears the Data grid's look (owner: "make it
13947
+ look like a Grid view"). Values mirror `customer-grid/theme.ts::lightTheme`: washed header in
13948
+ 600 weight ink, --lp-fs-xs cells, 1px --lp-line hairlines, muted row numbers, a status bubble. */
13949
+ .ea-grid { overflow-x: auto; margin-top: 12px; border: 1px solid var(--lp-line); border-radius: 8px;
13950
+ background: var(--lp-surface); }
13951
+ .ea-grid-table { width: 100%; border-collapse: collapse; font-size: var(--lp-fs-xs); color: var(--lp-ink); }
13952
+ .ea-grid-table th, .ea-grid-table td { height: 34px; padding: 0 8px; text-align: left; white-space: nowrap;
13953
+ border-right: 1px solid var(--lp-line); border-bottom: 1px solid var(--lp-line); }
13954
+ .ea-grid-table th:last-child, .ea-grid-table td:last-child { border-right: 0; }
13955
+ .ea-grid-table tbody tr:last-child td { border-bottom: 0; }
13956
+ .ea-grid-table th { background: #fafbfc; font-weight: 600; }
13957
+ .ea-grid-table tbody tr:hover td { background: #f6f7f9; }
13958
+ .ea-grid-num { width: 36px; text-align: center !important; color: var(--lp-muted); font-size: var(--lp-fs-3xs);
13959
+ font-variant-numeric: tabular-nums; }
13960
+ .ea-grid-act { width: 1%; text-align: right !important; }
13961
+ .ea-grid-app { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
13962
+ .ea-grid-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--lp-fs-2xs); line-height: 18px;
13963
+ background: var(--lp-line); color: var(--lp-ink); }
13964
+ .ea-grid-pill.is-connected { background: #ebf6ef; color: #35754e; }
13965
+ .ea-grid-pill.is-expired { background: #fbf4e0; color: #7e6428; }
13966
+ .ea-grid-btn { font: inherit; font-size: var(--lp-fs-2xs); padding: 3px 10px; border-radius: 6px; cursor: pointer;
13967
+ border: 1px solid var(--lp-line); background: var(--lp-surface); color: #a3453c; }
13968
+ .ea-grid-btn:hover:not(:disabled) { background: #fceeec; border-color: #f3d6d2; }
13969
+ .ea-grid-btn:disabled { opacity: .5; cursor: default; }
13970
+ .ea-grid-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
web/src/settings/ExternalAccessPane.tsx CHANGED
@@ -129,6 +129,8 @@ interface ExternalConnection {
129
  last_used: string | null;
130
  expires_at: string | null;
131
  disconnected_at: string | null;
 
 
132
  }
133
 
134
  interface KeyListResponse { keys: ExternalKeyMetadata[]; can_mint: boolean }
@@ -235,6 +237,10 @@ function parseConnection(value: unknown): ExternalConnection | null {
235
  last_used: typeof row.last_used === "string" ? row.last_used : null,
236
  expires_at,
237
  disconnected_at,
 
 
 
 
238
  };
239
  }
240
 
@@ -1084,24 +1090,53 @@ export default function ExternalAccessPane() {
1084
  {revealCard}
1085
 
1086
  {connections.length > 0 ? (
 
 
 
1087
  <section className="set-card">
1088
  <h2 className="set-h4">AI connections</h2>
1089
- {connections.map((connection) => (
1090
- <div key={connection.id} style={{ marginTop: 16 }}>
1091
- <div className="pg-drill-row"><span className="pg-drill-key">{connection.label || "Unnamed AI app"}</span>
1092
- <span className="pg-drill-val">{connectionLabel(connection)}</span></div>
1093
- <div className="pg-drill-row"><span className="pg-drill-key">Last used</span>
1094
- <span className="pg-drill-val">{when(connection.last_used)}</span></div>
1095
- {connection.status === "connected" ? (
1096
- <div className="set-actions">
1097
- <button type="button" className="set-secondary kc-danger" disabled={busy !== ""}
1098
- onClick={() => void disconnect(connection)}>
1099
- {busy === `disconnect:${connection.client}` ? "Disconnecting…" : "Disconnect"}
1100
- </button>
1101
- </div>
1102
- ) : null}
1103
- </div>
1104
- ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1105
  </section>
1106
  ) : null}
1107
 
 
129
  last_used: string | null;
130
  expires_at: string | null;
131
  disconnected_at: string | null;
132
+ access: Access | null;
133
+ databases: ResourceScope | null;
134
  }
135
 
136
  interface KeyListResponse { keys: ExternalKeyMetadata[]; can_mint: boolean }
 
237
  last_used: typeof row.last_used === "string" ? row.last_used : null,
238
  expires_at,
239
  disconnected_at,
240
+ access: row.access === "read" || row.access === "readwrite" ? row.access : null,
241
+ databases: row.databases === "all" ? "all"
242
+ : Array.isArray(row.databases) ? row.databases.filter((item): item is string => typeof item === "string")
243
+ : null,
244
  };
245
  }
246
 
 
1090
  {revealCard}
1091
 
1092
  {connections.length > 0 ? (
1093
+ /* HOTFIX 2026-09-24 (owner: the AI connections list "is really ugly, let's make it look
1094
+ like a Grid view"). One row per connection in the Data grid's own look: row numbers,
1095
+ a washed header, hairline cells and a status pill (`index.css` `.ea-grid`). */
1096
  <section className="set-card">
1097
  <h2 className="set-h4">AI connections</h2>
1098
+ <div className="ea-grid" role="region" aria-label="AI connections" tabIndex={0}>
1099
+ <table className="ea-grid-table">
1100
+ <thead>
1101
+ <tr>
1102
+ <th scope="col" className="ea-grid-num"><span className="ea-grid-sr">Row</span></th>
1103
+ <th scope="col">AI app</th>
1104
+ <th scope="col">Status</th>
1105
+ <th scope="col">Access</th>
1106
+ <th scope="col">Databases</th>
1107
+ <th scope="col">Connected</th>
1108
+ <th scope="col">Last used</th>
1109
+ <th scope="col" className="ea-grid-act"><span className="ea-grid-sr">Actions</span></th>
1110
+ </tr>
1111
+ </thead>
1112
+ <tbody>
1113
+ {connections.map((connection, index) => (
1114
+ <tr key={connection.id}>
1115
+ <td className="ea-grid-num">{index + 1}</td>
1116
+ <td>
1117
+ <span className="ea-grid-app">
1118
+ {connection.clientId ? <AiClientMark id={connection.clientId} size={16} /> : null}
1119
+ <span>{connection.label || "Unnamed AI app"}</span>
1120
+ </span>
1121
+ </td>
1122
+ <td><span className={`ea-grid-pill is-${connection.status}`}>{connectionLabel(connection)}</span></td>
1123
+ <td>{connection.access === null ? "" : connection.access === "read" ? "Read only" : "Read and write"}</td>
1124
+ <td>{connection.databases === null ? "" : databaseLabels(connection.databases)}</td>
1125
+ <td>{when(connection.created)}</td>
1126
+ <td>{when(connection.last_used)}</td>
1127
+ <td className="ea-grid-act">
1128
+ {connection.status === "connected" ? (
1129
+ <button type="button" className="ea-grid-btn" disabled={busy !== ""}
1130
+ onClick={() => void disconnect(connection)}>
1131
+ {busy === `disconnect:${connection.client}` ? "Disconnecting…" : "Disconnect"}
1132
+ </button>
1133
+ ) : null}
1134
+ </td>
1135
+ </tr>
1136
+ ))}
1137
+ </tbody>
1138
+ </table>
1139
+ </div>
1140
  </section>
1141
  ) : null}
1142