@qingflow-tech/qingflow-cli 1.1.42 → 1.1.43-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +4 -4
  2. package/package.json +2 -1
  3. package/pyproject.toml +3 -2
  4. package/src/qingflow_mcp/app_form_compat.py +115 -0
  5. package/src/qingflow_mcp/app_form_validator.py +199 -0
  6. package/src/qingflow_mcp/builder_facade/app_form.py +2836 -0
  7. package/src/qingflow_mcp/builder_facade/app_form_schema.py +269 -0
  8. package/src/qingflow_mcp/builder_facade/schemas/app_form/manifest.json +37 -0
  9. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/complete.json +1766 -0
  10. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/address.json +76 -0
  11. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/amount.json +76 -0
  12. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/attachment.json +76 -0
  13. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/code_block.json +223 -0
  14. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/data_relation.json +538 -0
  15. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/date.json +76 -0
  16. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/datetime.json +76 -0
  17. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/department.json +149 -0
  18. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/email.json +76 -0
  19. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/link.json +76 -0
  20. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/long_text.json +76 -0
  21. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/member.json +76 -0
  22. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/multi_select.json +92 -0
  23. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/number.json +76 -0
  24. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/phone.json +76 -0
  25. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/q_linker.json +338 -0
  26. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/relation.json +137 -0
  27. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/single_choice.json +92 -0
  28. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/single_select.json +92 -0
  29. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/subtable.json +810 -0
  30. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/text.json +76 -0
  31. package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/summary.json +713 -0
  32. package/src/qingflow_mcp/builder_facade/service.py +5 -2
  33. package/src/qingflow_mcp/cli/commands/builder.py +91 -28
  34. package/src/qingflow_mcp/cli/json_io.py +21 -2
  35. package/src/qingflow_mcp/cli/main.py +3 -39
  36. package/src/qingflow_mcp/cloud_oauth_proxy.py +96 -3
  37. package/src/qingflow_mcp/public_surface.py +5 -2
  38. package/src/qingflow_mcp/response_trim.py +8 -0
  39. package/src/qingflow_mcp/server_app_builder.py +38 -86
  40. package/src/qingflow_mcp/server_cloud.py +66 -1
  41. package/src/qingflow_mcp/tools/ai_builder_tools.py +93 -100
  42. package/src/qingflow_mcp/tools/app_tools.py +46 -65
@@ -37,14 +37,14 @@ def build_builder_server() -> FastMCP:
37
37
  "Use solution_install when the user explicitly wants to install a packaged solution/template by solution_key, optionally copying bundled demo data. "
38
38
  "Use package_list to find visible app packages by keyword and package_get to read package detail before editing; if creating or updating an app package may be appropriate, use package_apply with explicit user intent; otherwise use app_resolve to locate app resources, "
39
39
  "Use workspace_icon_catalog_get before creating app packages, apps, or portals when supported icon/color candidates are needed; new workspace resources require explicit non-template icon + color, and the CLI validates choices without inferring business defaults. "
40
- "app_get as the default app map read, then app_get_fields/app_repair_code_blocks/app_get_layout/app_get_views/app_get_flow/app_get_charts/portal_list/portal_get/view_get/chart_get for focused configuration reads, "
40
+ "app_form_schema plus app_form_get for versioned form work, using being_draft=true only for editing and the published default for relation or record consumers; use app_get as the default non-form app map read, then app_get_fields/app_repair_code_blocks/app_get_layout/app_get_views/app_get_flow/app_get_charts/portal_list/portal_get/view_get/chart_get for focused compatibility or non-form reads, "
41
41
  "member_search/role_search/role_create when workflow assignees must come from the directory or role catalog, preferring roles over explicit members unless the user explicitly names members, "
42
- "then app_schema_apply/app_layout_apply/app_flow_apply/app_views_apply/app_associated_resources_apply/app_charts_apply/portal_apply/portal_delete to execute normalized patches; app_custom_buttons_apply is maintenance-only for explicit standalone button work outside normal view design. These apply/delete tools perform basic validation, normalization, writes, and readback verification where applicable. Schema/layout/views noop requests skip publish, app_custom_buttons_apply and app_associated_resources_apply publish after at least one write succeeds and expose no draft-only parameter, charts are immediate-live without publish and resolve targets by chart_id first then exact unique chart name, portal updates use replace semantics only when sections are supplied and edit-mode base-info-only updates may omit sections, portal delete separates DELETE execution from readback verification, portal pc layout is a 24-column grid and mobile is a 6-column grid so omit position or use layout_preset when unsure, publish=false only guarantees draft/base-info updates for tools that still expose that parameter, and flow should use publish=false whenever you only want draft/precheck behavior. "
42
+ "then app_form_apply for complete app form targets, explicit app_delete for application deletion, and app_flow_apply/app_views_apply/app_associated_resources_apply/app_charts_apply/portal_apply/portal_delete for non-form patches. app_custom_buttons_apply is maintenance-only for explicit standalone button work outside normal view design. These apply/delete tools perform validation, normalization, writes, and readback verification where applicable. AppForm publishes only after a draft change or when the published form lags behind; views noop requests skip publish, app_custom_buttons_apply and app_associated_resources_apply publish after at least one write succeeds and expose no draft-only parameter, charts are immediate-live without publish and resolve targets by chart_id first then exact unique chart name, portal updates use replace semantics only when sections are supplied and edit-mode base-info-only updates may omit sections, portal delete separates DELETE execution from readback verification, portal pc layout is a 24-column grid and mobile is a 6-column grid so omit position or use layout_preset when unsure, publish=false only guarantees draft/base-info updates for tools that still expose that parameter, and flow should use publish=false whenever you only want draft/precheck behavior. "
43
43
  "Builder apply/write outputs include schema_version, operation, summary, and resources[]; use resources[].id/key/name/ids/parent as the stable UI and agent display entry, and keep legacy fields such as field_diff/views_diff/chart_results only for compatibility or troubleshooting. "
44
44
  "For existing object parameter replacement, prefer patch_views, patch_buttons, patch_resources, and patch_charts with set/unset; the tool reads current config and full-saves internally, while upsert_* is for creation or full target configuration and should not be used as an incomplete partial update. "
45
45
  "For builder delete/remove apply results, separate delete execution from readback verification: after DELETE is sent, resources expose delete_executed, readback_status, and safe_to_retry_delete=false. If readback_status is unavailable or still_exists, do not blindly repeat the delete; confirm later with app_get/view_get/chart_get or the relevant apply readback. Views/buttons use single-item readback; associated resources use one app-level resource-pool readback because there is no confirmed single-item GET. "
46
46
  "For builder write/apply results, separate write execution from final readback verification: status=partial_success with write_executed=true and safe_to_retry=false means the write was sent or succeeded, while final readback, publish verification, or metadata confirmation is pending or permission-restricted. Report it as written but unverified; do not repeat the same write blindly. "
47
- "For app_schema_apply, configure data title and data cover directly in field JSON with as_data_title=true and as_data_cover=true; data title is required and exactly one field may be marked, while data cover is optional and must be a top-level attachment field. For multi-app creation, pass apps[]/--apps-file on app_schema_apply; each item may have client_key, and relation fields may use target_app_ref to point at another same-call client_key. "
47
+ "For app_form_apply, pin the version from app_form_schema, validate the JSON declaration with the qingflow-app-form Skill command, preserve the complete body and existing IDs from a draft get, and use dataTitle/dataCover on canonical fields; exactly one top-level dataTitle is required for a non-empty body, while dataCover is optional and must be a top-level attachment field. A root appKey means update and may include packageId; no appKey means create and requires packageId plus spec.appName, spec.icon, and spec.color selected from workspace_icon_catalog_get, with template forbidden. "
48
48
  "For app_views_apply, keep fixed saved filters in filters and configure the frontend query panel separately with query_conditions; query_conditions.rows is a matrix of field names compiled to backend queryCondition queIds. New views default associated report/view display to visible with limit_type=all; existing views preserve their current associated display unless associated_resources is explicitly patched. View writes use ViewManagementAuth (beingViewManageStatus), falling back to DataManageAuth when advanced app permissions are not enabled. "
49
49
  "For ordinary business buttons, declare them on the target view with app_views_apply.views[].action_buttons; app_views_apply writes the view first, then creates/binds the button. Use app_custom_buttons_apply only when the user explicitly asks to maintain existing standalone buttons outside view design, such as custom style/icon changes, cross-view reuse, deleting button bodies, bulk binding reorder, or exact qRobot/wings config. Button body writes require EditAppAuth; view_configs placement writes require ViewManagementAuth, matching the backend viewConfig route. For addData buttons, prefer action_buttons.target_app_key + field_mappings/default_values on the view path; do not ask agents to write raw que_relation unless maintaining a legacy config. field_mappings.source_field accepts source schema fields and supported system fields: 数据ID/row_record_id/apply_id/_id means current record id (-17), 编号/record_number means visible record number (0). To fill a target relation with the current record, map {'source_field': '数据ID', 'target_field': '目标引用字段'}; default_values is only for static constants. View button bindings merge by default; standalone view_configs are only for explicit maintenance. Builder view_key arguments are raw keys from app_get.views[].view_key and must not be prefixed with custom:. "
50
50
  "For BI reports, keep report-body development separate from Qingflow in-app display: use app_charts_apply to create, update, remove, or reorder app-source QingBI chart bodies/configs with dataSourceType=qingflow; chart dimension/metric/filter/query fields must come from app_get_fields.chart_fields, not record schema or form-only fields; dataset BI reports are not created or edited by app_charts_apply yet and should be created in QingBI first, then attached with app_associated_resources_apply using report_source=dataset. "
@@ -180,6 +180,41 @@ def build_builder_server() -> FastMCP:
180
180
  def builder_tool_contract(tool_name: str = "") -> dict:
181
181
  return ai_builder.builder_tool_contract(tool_name=tool_name)
182
182
 
183
+ @server.tool()
184
+ def app_form_schema(
185
+ schema_version: str | None = None,
186
+ field_type: str | None = None,
187
+ ) -> dict:
188
+ return ai_builder.app_form_schema(schema_version=schema_version, field_type=field_type)
189
+
190
+ @server.tool()
191
+ def app_form_get(
192
+ profile: str = DEFAULT_PROFILE,
193
+ app_key: str = "",
194
+ schema_version: str | None = None,
195
+ being_draft: bool = False,
196
+ ) -> dict:
197
+ return ai_builder.app_form_get(
198
+ profile=profile,
199
+ app_key=app_key,
200
+ schema_version=schema_version,
201
+ being_draft=being_draft,
202
+ )
203
+
204
+ @server.tool()
205
+ def app_form_apply(
206
+ profile: str = DEFAULT_PROFILE,
207
+ spec: dict | None = None,
208
+ ) -> dict:
209
+ return ai_builder.app_form_apply(profile=profile, spec=spec or {})
210
+
211
+ @server.tool(description=ai_builder._high_risk_tool_description(operation="delete", target="app configuration"))
212
+ def app_delete(
213
+ profile: str = DEFAULT_PROFILE,
214
+ app_key: str = "",
215
+ ) -> dict:
216
+ return ai_builder.app_delete(profile=profile, app_key=app_key)
217
+
183
218
  @server.tool()
184
219
  def workspace_icon_catalog_get(profile: str = DEFAULT_PROFILE) -> dict:
185
220
  return ai_builder.workspace_icon_catalog_get(profile=profile)
@@ -414,89 +449,6 @@ def build_builder_server() -> FastMCP:
414
449
  def chart_get(profile: str = DEFAULT_PROFILE, chart_id: str = "") -> dict:
415
450
  return ai_builder.chart_get(profile=profile, chart_id=chart_id)
416
451
 
417
- @server.tool()
418
- def app_schema_apply(
419
- profile: str = DEFAULT_PROFILE,
420
- app_key: str = "",
421
- package_id: int | None = None,
422
- app_name: str = "",
423
- app_title: str = "",
424
- icon: str = "",
425
- color: str = "",
426
- visibility: dict | None = None,
427
- publish: bool = True,
428
- form: list[dict] | None = None,
429
- add_fields: list[dict] | None = None,
430
- update_fields: list[dict] | None = None,
431
- remove_fields: list[dict] | None = None,
432
- apps: list[dict] | None = None,
433
- ) -> dict:
434
- if apps:
435
- if app_key or app_name or app_title or form or add_fields or update_fields or remove_fields:
436
- return _config_failure(
437
- "app_schema_apply multi-app mode accepts package_id plus apps only.",
438
- fix_hint="Use apps[].form for batch mode, or use the single-app arguments without apps.",
439
- )
440
- if package_id is None:
441
- return _config_failure(
442
- "app_schema_apply multi-app mode requires package_id.",
443
- fix_hint="Pass `package_id` and `apps[].app_name` for new apps, or `apps[].app_key` for existing apps.",
444
- )
445
- return ai_builder.app_schema_apply(
446
- profile=profile,
447
- package_id=package_id,
448
- visibility=visibility,
449
- publish=publish,
450
- form=None,
451
- add_fields=[],
452
- update_fields=[],
453
- remove_fields=[],
454
- apps=apps,
455
- )
456
- has_app_key = bool((app_key or "").strip())
457
- has_app_name = bool((app_name or "").strip())
458
- has_app_title = bool((app_title or "").strip())
459
- has_package_id = package_id is not None
460
- create_by_shape = has_package_id and (has_app_name or has_app_title)
461
- if has_app_key:
462
- if has_package_id:
463
- return _config_failure(
464
- "app_schema_apply edit mode accepts app_key and optional app_name rename only.",
465
- fix_hint="For existing apps, use `app_key` and optionally `app_name`. For create mode, use `package_id + app_name`.",
466
- )
467
- elif not create_by_shape:
468
- return _config_failure(
469
- "app_schema_apply create mode requires package_id and app_name.",
470
- fix_hint="Use `app_key` for existing apps, or pass `package_id + app_name` to create a new app.",
471
- )
472
- return ai_builder.app_schema_apply(
473
- profile=profile,
474
- app_key=app_key,
475
- package_id=package_id,
476
- app_name=app_name,
477
- app_title=app_title,
478
- icon=icon,
479
- color=color,
480
- visibility=visibility,
481
- publish=publish,
482
- form=form or [],
483
- add_fields=add_fields or [],
484
- update_fields=update_fields or [],
485
- remove_fields=remove_fields or [],
486
- apps=None,
487
- )
488
-
489
- @server.tool()
490
- def app_layout_apply(
491
- profile: str = DEFAULT_PROFILE,
492
- app_key: str = "",
493
- mode: str = "merge",
494
- publish: bool = True,
495
- sections: list[dict] | None = None,
496
- apps: list[dict] | None = None,
497
- ) -> dict:
498
- return ai_builder.app_layout_apply(profile=profile, app_key=app_key, mode=mode, publish=publish, sections=sections or [], apps=apps)
499
-
500
452
  @server.tool()
501
453
  def app_flow_get(
502
454
  profile: str = DEFAULT_PROFILE,
@@ -24,6 +24,7 @@ from .server_app_user import build_user_server
24
24
 
25
25
 
26
26
  BUILDER_TOOL_PREFIX = "builder_"
27
+ MAX_OAUTH_PROXY_BODY_BYTES = 64 * 1024
27
28
 
28
29
 
29
30
  ASGIApp = Callable[
@@ -88,6 +89,15 @@ class CloudMcpAuthApp:
88
89
  backend_metadata_path,
89
90
  )
90
91
  return
92
+ backend_oauth_path = self._oauth_proxy.config.backend_oauth_endpoint_path(path)
93
+ if backend_oauth_path is not None:
94
+ await self._proxy_oauth_endpoint(
95
+ scope,
96
+ receive,
97
+ send,
98
+ backend_oauth_path,
99
+ )
100
+ return
91
101
 
92
102
  auth_value, explicit_credential, call_platform = self._extract_auth_value(scope)
93
103
  if auth_value is None:
@@ -196,7 +206,8 @@ class CloudMcpAuthApp:
196
206
  ) -> None:
197
207
  assert self._oauth_proxy is not None
198
208
  challenge = (
199
- f'Bearer error="{_escape_auth_param(error)}", '
209
+ 'Bearer realm="OAuth", '
210
+ f'error="{_escape_auth_param(error)}", '
200
211
  f'error_description="{_escape_auth_param(description)}", '
201
212
  f'resource_metadata="{self._oauth_proxy.config.resource_metadata_url}"'
202
213
  )
@@ -234,6 +245,44 @@ class CloudMcpAuthApp:
234
245
  return
235
246
  await self._raw_response(send, response)
236
247
 
248
+ async def _proxy_oauth_endpoint(
249
+ self,
250
+ scope: dict[str, Any],
251
+ receive: Callable[[], Awaitable[dict[str, Any]]],
252
+ send: Callable[[dict[str, Any]], Awaitable[None]],
253
+ backend_path: str,
254
+ ) -> None:
255
+ assert self._oauth_proxy is not None
256
+ try:
257
+ body = await _read_request_body(receive, MAX_OAUTH_PROXY_BODY_BYTES)
258
+ except ValueError:
259
+ await self._json_response(
260
+ send,
261
+ 413,
262
+ {
263
+ "error": "invalid_request",
264
+ "error_description": "OAuth request body is too large",
265
+ },
266
+ )
267
+ return
268
+ try:
269
+ response = await anyio.to_thread.run_sync(
270
+ self._oauth_proxy.request_oauth_endpoint,
271
+ str(scope.get("method") or "GET"),
272
+ backend_path,
273
+ bytes(scope.get("query_string") or b""),
274
+ body,
275
+ tuple(scope.get("headers") or ()),
276
+ )
277
+ except QingflowApiError as error:
278
+ await self._json_response(
279
+ send,
280
+ 502,
281
+ {"error": "oauth_service_unavailable", "message": error.message},
282
+ )
283
+ return
284
+ await self._raw_response(send, response)
285
+
237
286
  async def _json_response(
238
287
  self,
239
288
  send: Callable[[dict[str, Any]], Awaitable[None]],
@@ -385,6 +434,22 @@ def _extract_host(scope: dict[str, Any]) -> str:
385
434
  return ""
386
435
 
387
436
 
437
+ async def _read_request_body(
438
+ receive: Callable[[], Awaitable[dict[str, Any]]],
439
+ limit: int,
440
+ ) -> bytes:
441
+ body = bytearray()
442
+ while True:
443
+ message = await receive()
444
+ if message.get("type") != "http.request":
445
+ return bytes(body)
446
+ body.extend(bytes(message.get("body") or b""))
447
+ if len(body) > limit:
448
+ raise ValueError("request body is too large")
449
+ if not message.get("more_body", False):
450
+ return bytes(body)
451
+
452
+
388
453
  def _is_allowed_host(host: str, allowed_hosts: list[str]) -> bool:
389
454
  normalized_host = host.strip().lower().rstrip(".")
390
455
  host_without_port = _strip_port(normalized_host)
@@ -14,6 +14,8 @@ from ..builder_facade.button_style_catalog import (
14
14
  BUTTON_STYLE_PRESETS,
15
15
  BUTTON_TEXT_COLORS,
16
16
  )
17
+ from ..builder_facade.app_form import AppFormReconciler
18
+ from ..builder_facade.app_form_schema import app_form_schema_registry
17
19
  from ..public_surface import public_builder_contract_tool_names
18
20
  from ..config import DEFAULT_PROFILE
19
21
  from ..errors import QingflowApiError, backend_code_int, backend_code_value_int
@@ -130,10 +132,14 @@ def _inline_form_layout_was_handled(payload: JSONObject) -> bool:
130
132
 
131
133
  PUBLIC_STABLE_FLOW_NODE_TYPES = ["start", "approve", "fill", "copy", "webhook", "end"]
132
134
  BUILDER_APPLY_SCHEMA_VERSION = "builder.apply.v1"
133
- BUILDER_APPLY_TOOL_NAMES = {
134
- "package_apply",
135
+ # TODO(deprecation): Remove these names and their imperative adapters after internal AppForm migration completes.
136
+ LEGACY_IMPERATIVE_APP_FORM_TOOL_NAMES = {
135
137
  "app_schema_apply",
136
138
  "app_layout_apply",
139
+ }
140
+ BUILDER_APPLY_TOOL_NAMES = {
141
+ "package_apply",
142
+ *LEGACY_IMPERATIVE_APP_FORM_TOOL_NAMES,
137
143
  "app_flow_apply",
138
144
  "app_views_apply",
139
145
  "app_custom_buttons_apply",
@@ -161,10 +167,12 @@ class AiBuilderTools(ToolBase):
161
167
  def __init__(self, sessions, backend) -> None:
162
168
  """执行内部辅助逻辑。"""
163
169
  super().__init__(sessions, backend)
170
+ apps = AppTools(sessions, backend)
171
+ packages = PackageTools(sessions, backend)
164
172
  self._facade = AiBuilderFacade(
165
- apps=AppTools(sessions, backend),
173
+ apps=apps,
166
174
  buttons=CustomButtonTools(sessions, backend),
167
- packages=PackageTools(sessions, backend),
175
+ packages=packages,
168
176
  views=ViewTools(sessions, backend),
169
177
  workflows=WorkflowTools(sessions, backend),
170
178
  portals=PortalTools(sessions, backend),
@@ -173,6 +181,11 @@ class AiBuilderTools(ToolBase):
173
181
  directory=DirectoryTools(sessions, backend),
174
182
  solutions=SolutionTools(sessions, backend),
175
183
  )
184
+ self._app_form = AppFormReconciler(
185
+ apps=apps,
186
+ packages=packages,
187
+ registry=app_form_schema_registry(),
188
+ )
176
189
 
177
190
  def _apply_app_batch(self, *, tool_name: str, profile: str, apps: list[JSONObject], apply_one) -> JSONObject:
178
191
  started_at = time.perf_counter()
@@ -367,6 +380,41 @@ class AiBuilderTools(ToolBase):
367
380
  def builder_tool_contract(tool_name: str = "") -> JSONObject:
368
381
  return self.builder_tool_contract(tool_name=tool_name)
369
382
 
383
+ @mcp.tool()
384
+ def app_form_schema(
385
+ schema_version: str | None = None,
386
+ field_type: str | None = None,
387
+ ) -> JSONObject:
388
+ return self.app_form_schema(schema_version=schema_version, field_type=field_type)
389
+
390
+ @mcp.tool()
391
+ def app_form_get(
392
+ profile: str = DEFAULT_PROFILE,
393
+ app_key: str = "",
394
+ schema_version: str | None = None,
395
+ being_draft: bool = False,
396
+ ) -> JSONObject:
397
+ return self.app_form_get(
398
+ profile=profile,
399
+ app_key=app_key,
400
+ schema_version=schema_version,
401
+ being_draft=being_draft,
402
+ )
403
+
404
+ @mcp.tool()
405
+ def app_form_apply(
406
+ profile: str = DEFAULT_PROFILE,
407
+ spec: JSONObject | None = None,
408
+ ) -> JSONObject:
409
+ return self.app_form_apply(profile=profile, spec=spec or {})
410
+
411
+ @mcp.tool(description=self._high_risk_tool_description(operation="delete", target="app configuration"))
412
+ def app_delete(
413
+ profile: str = DEFAULT_PROFILE,
414
+ app_key: str = "",
415
+ ) -> JSONObject:
416
+ return self.app_delete(profile=profile, app_key=app_key)
417
+
370
418
  @mcp.tool()
371
419
  def workspace_icon_catalog_get(profile: str = DEFAULT_PROFILE) -> JSONObject:
372
420
  return self.workspace_icon_catalog_get(profile=profile)
@@ -612,98 +660,6 @@ class AiBuilderTools(ToolBase):
612
660
  ) -> JSONObject:
613
661
  return self.chart_get(profile=profile, chart_id=chart_id)
614
662
 
615
- @mcp.tool()
616
- def app_schema_apply(
617
- profile: str = DEFAULT_PROFILE,
618
- app_key: str = "",
619
- package_id: int | None = None,
620
- app_name: str = "",
621
- app_title: str = "",
622
- icon: str | JSONObject = "",
623
- color: str = "",
624
- icon_name: str | None = None,
625
- icon_color: str | None = None,
626
- icon_config: JSONObject | None = None,
627
- visibility: JSONObject | None = None,
628
- publish: bool = True,
629
- form: list[JSONObject] | None = None,
630
- add_fields: list[JSONObject] | None = None,
631
- update_fields: list[JSONObject] | None = None,
632
- remove_fields: list[JSONObject] | None = None,
633
- apps: list[JSONObject] | None = None,
634
- ) -> JSONObject:
635
- if apps is not None:
636
- if app_key or app_name or app_title or form or add_fields or update_fields or remove_fields:
637
- return _config_failure(
638
- tool_name="app_schema_apply",
639
- message="app_schema_apply multi-app mode accepts package_id plus apps only.",
640
- fix_hint="Put per-app form in apps[].form when using batch mode.",
641
- )
642
- if package_id is None:
643
- return _config_failure(
644
- tool_name="app_schema_apply",
645
- message="app_schema_apply multi-app mode requires package_id.",
646
- fix_hint="Pass package_id and apps[].app_name for new apps, or apps[].app_key for existing apps.",
647
- )
648
- return self.app_schema_apply(
649
- profile=profile,
650
- package_id=package_id,
651
- visibility=visibility,
652
- publish=publish,
653
- apps=apps,
654
- form=None,
655
- add_fields=[],
656
- update_fields=[],
657
- remove_fields=[],
658
- )
659
- has_app_key = bool((app_key or "").strip())
660
- has_app_name = bool((app_name or "").strip())
661
- has_app_title = bool((app_title or "").strip())
662
- has_package_id = package_id is not None
663
- if has_app_key:
664
- if has_package_id:
665
- return _config_failure(
666
- tool_name="app_schema_apply",
667
- message="app_schema_apply edit mode accepts app_key and optional app_name rename only.",
668
- fix_hint="For existing apps, use `app_key` and optionally `app_name`. For create mode, use `package_id + app_name`.",
669
- )
670
- elif not (has_package_id and (has_app_name or has_app_title)):
671
- return _config_failure(
672
- tool_name="app_schema_apply",
673
- message="app_schema_apply create mode requires package_id and app_name.",
674
- fix_hint="Use `app_key` for existing apps, or pass `package_id + app_name` to create a new app.",
675
- )
676
- return self.app_schema_apply(
677
- profile=profile,
678
- app_key=app_key,
679
- package_id=package_id,
680
- app_name=app_name,
681
- app_title=app_title,
682
- icon=icon,
683
- color=color,
684
- icon_name=icon_name,
685
- icon_color=icon_color,
686
- icon_config=icon_config,
687
- visibility=visibility,
688
- publish=publish,
689
- form=form or [],
690
- add_fields=add_fields or [],
691
- update_fields=update_fields or [],
692
- remove_fields=remove_fields or [],
693
- apps=None,
694
- )
695
-
696
- @mcp.tool()
697
- def app_layout_apply(
698
- profile: str = DEFAULT_PROFILE,
699
- app_key: str = "",
700
- mode: str = "merge",
701
- publish: bool = True,
702
- sections: list[JSONObject] | None = None,
703
- apps: list[JSONObject] | None = None,
704
- ) -> JSONObject:
705
- return self.app_layout_apply(profile=profile, app_key=app_key, mode=mode, publish=publish, sections=sections or [], apps=apps)
706
-
707
663
  @mcp.tool()
708
664
  def app_flow_get(
709
665
  profile: str = DEFAULT_PROFILE,
@@ -857,6 +813,39 @@ class AiBuilderTools(ToolBase):
857
813
  expected_package_id=expected_package_id,
858
814
  )
859
815
 
816
+ def app_form_schema(
817
+ self,
818
+ *,
819
+ schema_version: str | None = None,
820
+ field_type: str | None = None,
821
+ ) -> JSONObject:
822
+ """Return the versioned AppForm summary or one field-type schema."""
823
+ return self._app_form.schema(schema_version=schema_version, field_type=field_type)
824
+
825
+ def app_form_get(
826
+ self,
827
+ *,
828
+ profile: str,
829
+ app_key: str,
830
+ schema_version: str | None = None,
831
+ being_draft: bool = False,
832
+ ) -> JSONObject:
833
+ """Read a canonical draft or published AppForm resource."""
834
+ return self._app_form.get(
835
+ profile=profile,
836
+ app_key=app_key,
837
+ schema_version=schema_version,
838
+ being_draft=being_draft,
839
+ )
840
+
841
+ def app_form_apply(self, *, profile: str, spec: JSONObject) -> JSONObject:
842
+ """Reconcile one complete declarative AppForm target."""
843
+ return self._app_form.apply(profile=profile, spec=spec)
844
+
845
+ def app_delete(self, *, profile: str, app_key: str) -> JSONObject:
846
+ """Delete an application explicitly."""
847
+ return self._app_form.delete(profile=profile, app_key=app_key)
848
+
860
849
  def package_list(self, *, profile: str, trial_status: str = "all", query: str = "") -> JSONObject:
861
850
  """执行分组与包相关逻辑。"""
862
851
  normalized_args = {"trial_status": trial_status, "query": query}
@@ -2092,7 +2081,7 @@ class AiBuilderTools(ToolBase):
2092
2081
  remove_fields: list[JSONObject],
2093
2082
  apps: list[JSONObject] | None = None,
2094
2083
  ) -> JSONObject:
2095
- """执行应用相关逻辑。"""
2084
+ """Legacy imperative schema adapter retained only for internal callers pending deletion."""
2096
2085
  icon, color = _normalize_builder_icon_args(
2097
2086
  icon=icon,
2098
2087
  color=color,
@@ -3435,7 +3424,7 @@ class AiBuilderTools(ToolBase):
3435
3424
  sections: list[JSONObject],
3436
3425
  apps: list[JSONObject] | None = None,
3437
3426
  ) -> JSONObject:
3438
- """执行应用相关逻辑。"""
3427
+ """Legacy imperative layout adapter retained only for internal callers pending deletion."""
3439
3428
  if apps is not None:
3440
3429
  return self._apply_app_batch(
3441
3430
  tool_name="app_layout_apply",
@@ -7282,6 +7271,8 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
7282
7271
  "remove_fields": [],
7283
7272
  },
7284
7273
  },
7274
+ # TODO(deprecation): Retained only for internal imperative adapter validation. This contract
7275
+ # is deliberately excluded from builder_tool_contract and must be deleted with the adapter.
7285
7276
  "app_schema_apply": {
7286
7277
  "allowed_keys": [
7287
7278
  "app_key",
@@ -7638,6 +7629,8 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
7638
7629
  },
7639
7630
  "preset_example": {"profile": "default", "app_key": "APP_KEY", "mode": "merge", "preset": "balanced", "sections": []},
7640
7631
  },
7632
+ # TODO(deprecation): Retained only for internal imperative adapter validation. This contract
7633
+ # is deliberately excluded from builder_tool_contract and must be deleted with the adapter.
7641
7634
  "app_layout_apply": {
7642
7635
  "allowed_keys": ["app_key", "mode", "publish", "sections"],
7643
7636
  "aliases": {"overwrite": "replace", "sectionId": "section_id"},
@@ -8172,7 +8165,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
8172
8165
  "allowed_values": {},
8173
8166
  "execution_notes": [
8174
8167
  "returns compact current field configuration for one app",
8175
- "use this before app_schema_apply when you need exact field definitions",
8168
+ "use app_form_get through the qingflow-app-form Skill for editable form definitions",
8176
8169
  "also returns chart_fields from QingBI datasource fields; app_charts_apply field selectors should use chart_fields because record/schema-visible fields and QingBI fields are not the same schema",
8177
8170
  "chart_fields[].field_id supports field_<queId> selectors, while chart_fields[].bi_field_id is the raw QingBI fieldId accepted by report configs",
8178
8171
  "chart_fields[].chart_apply_examples contains copyable semantic app_charts_apply snippets such as count_by_field, filtered_count, and numeric sum_metric",
@@ -8189,7 +8182,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
8189
8182
  "allowed_values": {},
8190
8183
  "execution_notes": [
8191
8184
  "returns compact current layout configuration for one app",
8192
- "use this before app_layout_apply when you need paragraph and row structure",
8185
+ "use app_form_get through the qingflow-app-form Skill for editable form layout",
8193
8186
  ],
8194
8187
  "minimal_example": {
8195
8188
  "profile": "default",