openyida 2026.9.23-beta.1 → 2026.9.23-beta.2

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 (237) hide show
  1. package/README.md +31 -15
  2. package/bin/yida.js +33 -21
  3. package/lib/agent/PROTOCOL.md +165 -0
  4. package/lib/agent/ask-human.js +151 -0
  5. package/lib/agent/cmd.js +403 -0
  6. package/lib/agent/command-receipt.js +84 -0
  7. package/lib/agent/connection-store.js +148 -0
  8. package/lib/agent/diagnostic-log.js +133 -0
  9. package/lib/agent/frozen-bundle.js +286 -0
  10. package/lib/agent/managed-command-map.js +117 -0
  11. package/lib/agent/managed-context.js +40 -0
  12. package/lib/agent/managed-run.js +96 -0
  13. package/lib/agent/mutation-receipt.js +82 -0
  14. package/lib/agent/private-directory.js +63 -0
  15. package/lib/agent/provider-preflight.js +236 -0
  16. package/lib/agent/providers.js +4 -0
  17. package/lib/agent/runtime-catalog.json +42 -0
  18. package/lib/agent/runtime-manifest.js +96 -0
  19. package/lib/agent/runtime-package.js +155 -0
  20. package/lib/agent/stdio.js +265 -0
  21. package/lib/app/app-list.js +0 -1
  22. package/lib/app/canvas-theme-guard.js +8 -78
  23. package/lib/app/check-prd-completeness.js +15 -4
  24. package/lib/app/create-form/args.js +12 -37
  25. package/lib/app/create-form/batch.js +35 -41
  26. package/lib/app/create-form.js +57 -94
  27. package/lib/app/custom-theme.js +13 -3
  28. package/lib/app/form-field-validator.js +36 -0
  29. package/lib/app/get-schema.js +6 -1
  30. package/lib/app/publish.js +3 -67
  31. package/lib/app/services/form-compiler.js +2 -0
  32. package/lib/app/theme-from-design.js +14 -40
  33. package/lib/app/update-app.js +26 -64
  34. package/lib/app/update-form-config.js +19 -9
  35. package/lib/auth/profile-lock.js +89 -0
  36. package/lib/auth/token-auth.js +75 -42
  37. package/lib/auth/token-store.js +26 -2
  38. package/lib/core/command-manifest.js +43 -92
  39. package/lib/core/locales/en.js +53 -42
  40. package/lib/core/locales/zh.js +53 -42
  41. package/lib/core/sample.js +14 -36
  42. package/lib/core/update.js +3 -1
  43. package/lib/core/utils.js +29 -0
  44. package/lib/design/document.js +0 -1
  45. package/lib/design-plan/design-plan.js +2 -44
  46. package/lib/design-plan/entry-navigation.js +2 -10
  47. package/lib/design-plan/init.js +9 -16
  48. package/lib/design-plan/materialize.js +58 -88
  49. package/lib/design-plan/normalize.js +14 -13
  50. package/lib/design-plan/parallel.js +13 -62
  51. package/lib/design-plan/patch.js +7 -21
  52. package/lib/design-plan/preview.js +1 -4
  53. package/lib/design-plan/themes.js +1 -16
  54. package/lib/design-plan/validate.js +3 -18
  55. package/lib/design-plan/visual-policy.js +4 -29
  56. package/lib/page-config/save-share-config.js +16 -5
  57. package/lib/samples/openyida-scaffold/canvas-form-drawer.canvas.jsx +3 -3
  58. package/lib/samples/openyida-scaffold/canvas-nav/mixed.jsx +4 -6
  59. package/lib/samples/openyida-scaffold/canvas-nav/shared.jsx +5 -5
  60. package/lib/samples/openyida-scaffold/canvas-nav/side.jsx +2 -1
  61. package/lib/samples/openyida-scaffold/canvas-nav/sidebar.jsx +1 -1
  62. package/lib/samples/openyida-scaffold/canvas-nav/top.jsx +4 -5
  63. package/package.json +10 -1
  64. package/yida-skills/SKILL.md +26 -2
  65. package/yida-skills/references/local-agent-diagnostics.md +154 -0
  66. package/yida-skills/references/local-agent-preflight.md +56 -0
  67. package/yida-skills/references/official-example-schema-patterns.md +1 -1
  68. package/yida-skills/references/yida-api.md +0 -4
  69. package/yida-skills/skills/yida-app/SKILL.md +4 -15
  70. package/yida-skills/skills/yida-app/references/entry-navigation.md +9 -11
  71. package/yida-skills/skills/yida-app/workflow/plan/step-4-deliver.md +1 -1
  72. package/yida-skills/skills/yida-app/workflow/plan/workflow.md +4 -11
  73. package/yida-skills/skills/yida-app/workflow/step-2-design.md +3 -3
  74. package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +2 -2
  75. package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +3 -3
  76. package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +2 -23
  77. package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +2 -3
  78. package/yida-skills/skills/yida-canvas-custom-page/references/canvas-style-implementation-guide.md +1 -1
  79. package/yida-skills/skills/yida-canvas-custom-page/references/canvas-theme-provider.md +1 -1
  80. package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +1 -140
  81. package/yida-skills/skills/yida-canvas-custom-page/references/navigation-and-entry-guide.md +1 -1
  82. package/yida-skills/skills/yida-canvas-custom-page/scripts/canvas-theme-provider.template.jsx +1 -1
  83. package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +0 -7
  84. package/yida-skills/skills/yida-create-form-page/SKILL.md +43 -34
  85. package/yida-skills/skills/yida-create-form-page/references/advanced-form-modes.md +5 -5
  86. package/yida-skills/skills/yida-create-form-page/references/association-form-field.md +4 -4
  87. package/yida-skills/skills/yida-create-form-page/references/batch-forms.md +2 -2
  88. package/yida-skills/skills/yida-create-form-page/references/field-definition-guide.md +16 -4
  89. package/yida-skills/skills/yida-create-form-page/references/form-field-properties.md +37 -14
  90. package/yida-skills/skills/yida-design/SKILL.md +5 -7
  91. package/yida-skills/skills/yida-design/references/application-theme-consistency.md +7 -48
  92. package/yida-skills/skills/yida-design/references/ask-human-interaction-contract.md +1 -1
  93. package/yida-skills/skills/yida-design/references/navigation-decision.md +4 -6
  94. package/yida-skills/skills/yida-design/references/theme/app-custom-theme-template.css +1 -110
  95. package/yida-skills/skills/yida-design/references/theme-selection.md +11 -12
  96. package/yida-skills/skills/yida-design/references/visual-decision-engine.md +1 -1
  97. package/yida-skills/skills/yida-design/scripts/validate_design_themes.py +6 -49
  98. package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/SKILL.md +3 -13
  99. package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/references/build-plan-compact-schema.md +2 -6
  100. package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/references/build-plan-schema.md +3 -5
  101. package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/references/visual-design.md +1 -3
  102. package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/references/visual-theme-selection.md +23 -22
  103. package/yida-skills/skills/yida-design/sub_skill/yida-design-plan/scripts/render_build_plan.py +0 -2
  104. package/yida-skills/skills/yida-design/templates/design-themes/README.md +10 -15
  105. package/yida-skills/skills/yida-design/templates/design-themes/basic-tokens.json +1 -2
  106. package/yida-skills/skills/yida-design/templates/design-themes/{dark-inset-hairline/design.md → dark-inset-hairline.md} +58 -107
  107. package/yida-skills/skills/yida-design/templates/design-themes/{dark-rail-fine-lines/design.md → dark-rail-fine-lines.md} +50 -106
  108. package/yida-skills/skills/yida-design/templates/design-themes/{dark-rail-signal-panels/design.md → dark-rail-signal-panels.md} +12 -66
  109. package/yida-skills/skills/yida-design/templates/design-themes/{graphite-bevel-grid/design.md → graphite-bevel-grid.md} +10 -64
  110. package/yida-skills/skills/yida-design/templates/design-themes/{hairline-shared-bands/design.md → hairline-shared-bands.md} +12 -66
  111. package/yida-skills/skills/yida-design/templates/design-themes/{hairline-soft-blocks/design.md → hairline-soft-blocks.md} +9 -61
  112. package/yida-skills/skills/yida-design/templates/design-themes/index.json +31 -399
  113. package/yida-skills/skills/yida-design/templates/design-themes/{ink-glow-soft-panels/design.md → ink-glow-soft-panels.md} +8 -62
  114. package/yida-skills/skills/yida-design/templates/design-themes/{inset-frame-pixel-rhythm/design.md → inset-frame-pixel-rhythm.md} +9 -63
  115. package/yida-skills/skills/yida-design/templates/design-themes/{outlined-texture-duotone/design.md → outlined-texture-duotone.md} +12 -66
  116. package/yida-skills/skills/yida-design/templates/design-themes/{soft-inset-surfaces/design.md → soft-inset-surfaces.md} +11 -63
  117. package/yida-skills/skills/yida-design/templates/design-themes/{soft-outline-rhythm/design.md → soft-outline-rhythm.md} +26 -64
  118. package/yida-skills/skills/yida-design/templates/design-themes/{soft-rail-bold-band/design.md → soft-rail-bold-band.md} +49 -103
  119. package/yida-skills/skills/yida-design/templates/design-themes/{soft-spectral-panels/design.md → soft-spectral-panels.md} +13 -67
  120. package/yida-skills/skills/yida-design/templates/design-themes/{warm-canvas-contrast-panels/design.md → warm-canvas-contrast-panels.md} +10 -64
  121. package/yida-skills/skills/yida-design/templates/design-themes/{warm-rail-muted-panels/design.md → warm-rail-muted-panels.md} +50 -102
  122. package/yida-skills/skills/yida-design/workflow/output-design.md +6 -9
  123. package/yida-skills/skills/yida-design/workflow/step-2-theme-system.md +4 -12
  124. package/yida-skills/skills/yida-design/workflow/step-6-handoff.md +1 -1
  125. package/yida-skills/skills/yida-document-markdown/SKILL.md +6 -0
  126. package/yida-skills/skills/yida-form-permission/SKILL.md +0 -6
  127. package/yida-skills/skills/yida-nav-shell/SKILL.md +1 -1
  128. package/yida-skills/skills/yida-nav-shell/references/nav-shell-patterns.md +0 -6
  129. package/yida-skills/skills/yida-page-config/SKILL.md +0 -9
  130. package/yida-skills/skills/yida-prd/SKILL.md +0 -1
  131. package/yida-skills/skills/yida-prd/workflow/output-prd.md +2 -2
  132. package/yida-skills/skills/yida-prd/workflow/step-2-information-architecture.md +1 -1
  133. package/yida-skills/skills/yida-publish-page/SKILL.md +0 -1
  134. package/yida-skills/skills/yida-requirement-analysis/references/experience-groups.md +9 -45
  135. package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +5 -5
  136. package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +4 -17
  137. package/yida-skills/skills/yida-tingji/SKILL.md +4 -0
  138. package/yida-skills/skills-index.json +2 -2
  139. package/lib/app/app-entry.js +0 -118
  140. package/lib/app/application-style.js +0 -69
  141. package/lib/app/fix-theme.js +0 -82
  142. package/lib/auth/oauth-device.js +0 -278
  143. package/lib/design-plan/confirmation.js +0 -13
  144. package/lib/design-plan/rebase.js +0 -69
  145. package/yida-skills/skills/yida-canvas-custom-page/references/waf-safe-authoring.md +0 -45
  146. package/yida-skills/skills/yida-design/references/application-style-library.md +0 -93
  147. package/yida-skills/skills/yida-design/references/native-form-styles.md +0 -208
  148. package/yida-skills/skills/yida-design/references/theme/application-style-recipes.css +0 -58
  149. package/yida-skills/skills/yida-design/templates/application-styles.json +0 -398
  150. package/yida-skills/skills/yida-design/templates/design-themes/app-amber/app_theme.css +0 -748
  151. package/yida-skills/skills/yida-design/templates/design-themes/app-amber/design.md +0 -274
  152. package/yida-skills/skills/yida-design/templates/design-themes/app-amber/form-layout.json +0 -15
  153. package/yida-skills/skills/yida-design/templates/design-themes/app-editorial/app_theme.css +0 -748
  154. package/yida-skills/skills/yida-design/templates/design-themes/app-editorial/design.md +0 -274
  155. package/yida-skills/skills/yida-design/templates/design-themes/app-editorial/form-layout.json +0 -14
  156. package/yida-skills/skills/yida-design/templates/design-themes/app-executive/app_theme.css +0 -748
  157. package/yida-skills/skills/yida-design/templates/design-themes/app-executive/design.md +0 -274
  158. package/yida-skills/skills/yida-design/templates/design-themes/app-executive/form-layout.json +0 -13
  159. package/yida-skills/skills/yida-design/templates/design-themes/app-finance/app_theme.css +0 -748
  160. package/yida-skills/skills/yida-design/templates/design-themes/app-finance/design.md +0 -274
  161. package/yida-skills/skills/yida-design/templates/design-themes/app-finance/form-layout.json +0 -14
  162. package/yida-skills/skills/yida-design/templates/design-themes/app-glass/app_theme.css +0 -748
  163. package/yida-skills/skills/yida-design/templates/design-themes/app-glass/design.md +0 -274
  164. package/yida-skills/skills/yida-design/templates/design-themes/app-glass/form-layout.json +0 -14
  165. package/yida-skills/skills/yida-design/templates/design-themes/app-graphite/app_theme.css +0 -748
  166. package/yida-skills/skills/yida-design/templates/design-themes/app-graphite/design.md +0 -274
  167. package/yida-skills/skills/yida-design/templates/design-themes/app-graphite/form-layout.json +0 -14
  168. package/yida-skills/skills/yida-design/templates/design-themes/app-line/app_theme.css +0 -748
  169. package/yida-skills/skills/yida-design/templates/design-themes/app-line/design.md +0 -274
  170. package/yida-skills/skills/yida-design/templates/design-themes/app-line/form-layout.json +0 -13
  171. package/yida-skills/skills/yida-design/templates/design-themes/app-neon/app_theme.css +0 -748
  172. package/yida-skills/skills/yida-design/templates/design-themes/app-neon/design.md +0 -274
  173. package/yida-skills/skills/yida-design/templates/design-themes/app-neon/form-layout.json +0 -14
  174. package/yida-skills/skills/yida-design/templates/design-themes/app-nordic/app_theme.css +0 -754
  175. package/yida-skills/skills/yida-design/templates/design-themes/app-nordic/design.md +0 -279
  176. package/yida-skills/skills/yida-design/templates/design-themes/app-nordic/form-layout.json +0 -13
  177. package/yida-skills/skills/yida-design/templates/design-themes/app-paper/app_theme.css +0 -748
  178. package/yida-skills/skills/yida-design/templates/design-themes/app-paper/design.md +0 -274
  179. package/yida-skills/skills/yida-design/templates/design-themes/app-paper/form-layout.json +0 -13
  180. package/yida-skills/skills/yida-design/templates/design-themes/app-platinum/app_theme.css +0 -748
  181. package/yida-skills/skills/yida-design/templates/design-themes/app-platinum/design.md +0 -274
  182. package/yida-skills/skills/yida-design/templates/design-themes/app-platinum/form-layout.json +0 -14
  183. package/yida-skills/skills/yida-design/templates/design-themes/app-plum/app_theme.css +0 -748
  184. package/yida-skills/skills/yida-design/templates/design-themes/app-plum/design.md +0 -274
  185. package/yida-skills/skills/yida-design/templates/design-themes/app-plum/form-layout.json +0 -14
  186. package/yida-skills/skills/yida-design/templates/design-themes/app-pop/app_theme.css +0 -758
  187. package/yida-skills/skills/yida-design/templates/design-themes/app-pop/design.md +0 -281
  188. package/yida-skills/skills/yida-design/templates/design-themes/app-pop/form-layout.json +0 -14
  189. package/yida-skills/skills/yida-design/templates/design-themes/app-sage/app_theme.css +0 -748
  190. package/yida-skills/skills/yida-design/templates/design-themes/app-sage/design.md +0 -274
  191. package/yida-skills/skills/yida-design/templates/design-themes/app-sage/form-layout.json +0 -14
  192. package/yida-skills/skills/yida-design/templates/design-themes/app-teal/app_theme.css +0 -748
  193. package/yida-skills/skills/yida-design/templates/design-themes/app-teal/design.md +0 -274
  194. package/yida-skills/skills/yida-design/templates/design-themes/app-teal/form-layout.json +0 -14
  195. package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/app_theme.css +0 -754
  196. package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/design.md +0 -279
  197. package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/form-layout.json +0 -14
  198. package/yida-skills/skills/yida-design/templates/design-themes/app-ticket/app_theme.css +0 -752
  199. package/yida-skills/skills/yida-design/templates/design-themes/app-ticket/design.md +0 -278
  200. package/yida-skills/skills/yida-design/templates/design-themes/app-ticket/form-layout.json +0 -13
  201. package/yida-skills/skills/yida-design/templates/design-themes/app-wire/app_theme.css +0 -748
  202. package/yida-skills/skills/yida-design/templates/design-themes/app-wire/design.md +0 -274
  203. package/yida-skills/skills/yida-design/templates/design-themes/app-wire/form-layout.json +0 -14
  204. package/yida-skills/skills/yida-design/templates/design-themes/dark-inset-hairline/app_theme.css +0 -690
  205. package/yida-skills/skills/yida-design/templates/design-themes/dark-inset-hairline/form-layout.json +0 -13
  206. package/yida-skills/skills/yida-design/templates/design-themes/dark-rail-fine-lines/app_theme.css +0 -691
  207. package/yida-skills/skills/yida-design/templates/design-themes/dark-rail-fine-lines/form-layout.json +0 -13
  208. package/yida-skills/skills/yida-design/templates/design-themes/dark-rail-signal-panels/app_theme.css +0 -696
  209. package/yida-skills/skills/yida-design/templates/design-themes/dark-rail-signal-panels/form-layout.json +0 -13
  210. package/yida-skills/skills/yida-design/templates/design-themes/free-creative/app_theme.css +0 -689
  211. package/yida-skills/skills/yida-design/templates/design-themes/free-creative/design.md +0 -238
  212. package/yida-skills/skills/yida-design/templates/design-themes/free-creative/form-layout.json +0 -13
  213. package/yida-skills/skills/yida-design/templates/design-themes/graphite-bevel-grid/app_theme.css +0 -692
  214. package/yida-skills/skills/yida-design/templates/design-themes/graphite-bevel-grid/form-layout.json +0 -13
  215. package/yida-skills/skills/yida-design/templates/design-themes/hairline-shared-bands/app_theme.css +0 -691
  216. package/yida-skills/skills/yida-design/templates/design-themes/hairline-shared-bands/form-layout.json +0 -13
  217. package/yida-skills/skills/yida-design/templates/design-themes/hairline-soft-blocks/app_theme.css +0 -691
  218. package/yida-skills/skills/yida-design/templates/design-themes/hairline-soft-blocks/form-layout.json +0 -13
  219. package/yida-skills/skills/yida-design/templates/design-themes/ink-glow-soft-panels/app_theme.css +0 -701
  220. package/yida-skills/skills/yida-design/templates/design-themes/ink-glow-soft-panels/form-layout.json +0 -13
  221. package/yida-skills/skills/yida-design/templates/design-themes/inset-frame-pixel-rhythm/app_theme.css +0 -691
  222. package/yida-skills/skills/yida-design/templates/design-themes/inset-frame-pixel-rhythm/form-layout.json +0 -13
  223. package/yida-skills/skills/yida-design/templates/design-themes/outlined-texture-duotone/app_theme.css +0 -698
  224. package/yida-skills/skills/yida-design/templates/design-themes/outlined-texture-duotone/form-layout.json +0 -13
  225. package/yida-skills/skills/yida-design/templates/design-themes/soft-inset-surfaces/app_theme.css +0 -691
  226. package/yida-skills/skills/yida-design/templates/design-themes/soft-inset-surfaces/form-layout.json +0 -13
  227. package/yida-skills/skills/yida-design/templates/design-themes/soft-outline-rhythm/app_theme.css +0 -690
  228. package/yida-skills/skills/yida-design/templates/design-themes/soft-outline-rhythm/form-layout.json +0 -13
  229. package/yida-skills/skills/yida-design/templates/design-themes/soft-rail-bold-band/app_theme.css +0 -698
  230. package/yida-skills/skills/yida-design/templates/design-themes/soft-rail-bold-band/form-layout.json +0 -13
  231. package/yida-skills/skills/yida-design/templates/design-themes/soft-spectral-panels/app_theme.css +0 -692
  232. package/yida-skills/skills/yida-design/templates/design-themes/soft-spectral-panels/form-layout.json +0 -13
  233. package/yida-skills/skills/yida-design/templates/design-themes/warm-canvas-contrast-panels/app_theme.css +0 -711
  234. package/yida-skills/skills/yida-design/templates/design-themes/warm-canvas-contrast-panels/form-layout.json +0 -13
  235. package/yida-skills/skills/yida-design/templates/design-themes/warm-rail-muted-panels/app_theme.css +0 -692
  236. package/yida-skills/skills/yida-design/templates/design-themes/warm-rail-muted-panels/form-layout.json +0 -13
  237. package/yida-skills/skills/yida-design/templates/navigation-styles.json +0 -769
package/README.md CHANGED
@@ -74,13 +74,6 @@ openyida login
74
74
 
75
75
  OpenYida login defaults to OAuth token mode. It opens the DingTalk OAuth authorization page, receives the local loopback callback, exchanges `code` / `authCode` with the Yida server, and stores `access_token` / `refresh_token` in the user auth store when available. If the user auth store is not writable, OpenYida explicitly falls back to the current project cache and reports that narrower persistence scope.
76
76
 
77
- In a sandbox, headless shell, or CI dashboard where the loopback callback cannot complete, use the device authorization flow. Open the displayed verification URL on any device and enter the user code. `--env-hint` optionally pins the intended environment profile at authorization time:
78
-
79
- ```bash
80
- openyida login --device
81
- openyida login --device --env-hint pre
82
- ```
83
-
84
77
  When the user names a target Yida entry URL, pass it to the login command so OpenYida can select the matching environment and auth profile. For example:
85
78
 
86
79
  ```bash
@@ -125,7 +118,6 @@ The agent can then call OpenYida commands to create the application, generate so
125
118
  | [Codex](https://openai.com/codex/) | Full support |
126
119
  | [Claude Code](https://claude.ai/code) | Full support |
127
120
  | [MuleRun](https://mulerun.com) | Full support |
128
- | [OpenCode](https://opencode.ai) | Full support |
129
121
  | [Cursor](https://cursor.com/) | Full support |
130
122
  | [Visual Studio Code](https://code.visualstudio.com/) | Full support |
131
123
  | QwenWork(千问办公) | Full support |
@@ -190,7 +182,7 @@ openyida get-schema APP_XXX FORM_XXX --compact --resolve-fields "Customer Name,S
190
182
  openyida get-schema APP_XXX --all --output-dir .cache/schemas
191
183
  ```
192
184
 
193
- Native forms use a component tree: business fields capture data, tabs switch content, action groups trigger business actions, images establish visual focus, status areas provide feedback, and `Divider` plus `ColumnContainer` organize hierarchy and columns. `create-form` field definitions create 19 business field types plus `Divider` and `ColumnContainer` (mapped to `ColumnsLayout` + `Column`), while updates retain other existing components.
185
+ Form definitions support 19 business field types plus verified presentation/layout components. Prefer `Divider` for section titles and `ColumnContainer` (mapped to `ColumnsLayout` + `Column`) for multi-column layout; use `GroupContainer` / `PageSection` only when an actual grouping container is needed.
194
186
 
195
187
  ### Custom Page Development
196
188
 
@@ -390,7 +382,7 @@ Run `openyida --help` or `openyida <command> --help` for detailed usage.
390
382
 
391
383
  | Command | Description |
392
384
  |---------|-------------|
393
- | `openyida login [target-url] [--env <name>\|--intl\|--overseas\|--global\|--yidaapps\|--alibaba] [--client-id <clientId>] [--endpoint <url>] [--no-browser] [--device] [--env-hint <name>]` | Login with OAuth token mode |
385
+ | `openyida login [target-url] [--env <name>\|--intl\|--overseas\|--global\|--yidaapps\|--alibaba] [--client-id <clientId>] [--endpoint <url>] [--no-browser]` | Login with OAuth token mode |
394
386
  | `openyida logout` | Logout / unbind current project auth |
395
387
  | `openyida auth <status\|login\|refresh\|logout\|profiles\|profile switch>` | Token login state and profile management |
396
388
  | `openyida org <list\|switch> [--json] [--corp-id <corpId>]` | Organization management (list / switch existing profiles first) |
@@ -400,15 +392,13 @@ Run `openyida --help` or `openyida <command> --help` for detailed usage.
400
392
 
401
393
  | Command | Description |
402
394
  |---------|-------------|
403
- | `openyida app-entry get <appType> [--json]` | Read frontend and management runtime entries |
404
- | `openyida app-entry set <appType> [--frontend <url>] [--management <url>] [--clear-frontend] [--clear-management] [--json]` | Register application entries with partial update and readback |
405
395
  | `openyida app-list [--type managed\|created] [--page N] [--size N]` | Page through apps I manage or created |
406
396
  | `openyida corp-efficiency [overview\|details\|detail\|groups\|notify] [options] [--open\|--no-open]` | Query enterprise efficiency overview and detail reports |
407
397
  | `openyida create-app "<name>"\|--name <name> [options] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a Yida app |
408
398
  | `openyida design-plan catalog [--json]` | List available planning themes and page patterns |
409
399
  | `openyida design-plan init <requirement-brief.json> [--theme-id <id>] [--output-dir <dir>] [--json]` | Initialize a plan draft from confirmed requirements |
410
400
  | `openyida design-plan preview <build-plan.json> --part-file <module.json> [--json]` | Update plan drafts by module |
411
- | `openyida design-plan materialize <build-plan.json> [--from-preview \| --business-file <json> --visual-file <json>] [--output-dir <dir>] [--rebase-parts] [--check] [--json]` | Generate or update plan documents and theme with consistency checks |
401
+ | `openyida design-plan materialize <build-plan.json> [--from-preview \| --business-file <json> --visual-file <json>] [--output-dir <dir>] [--check] [--json]` | Generate or update plan documents and theme with consistency checks |
412
402
  | `openyida design-plan patch <build-plan.json> --set <path=value> [--set <path=value> ...] [--materialize] [--output-dir <dir>] [--json]` | Patch plan fields and optionally sync documents and theme |
413
403
  | `openyida update-app <appType> [--name "..."] [--desc "..."] [--icon <name>] [--icon-color <color>] [--colour <key>] [--theme-color <color>] [--theme-file <css>] [--nav-theme light\|dark\|white\|gray] [--logo-source appIcon\|customImage] [--layout side\|top\|l_shape] [--hide-app-nav\|--show-app-nav]` | Update app info |
414
404
  | `openyida app-online <appType> [--to-ding-app-center] [--show-app-center]` | Enable a Yida app |
@@ -424,7 +414,7 @@ Run `openyida --help` or `openyida <command> --help` for detailed usage.
424
414
  | Command | Description |
425
415
  |---------|-------------|
426
416
  | `openyida create-form batch <appType> <plan.json> [--concurrency 1..4] [--check] [--json]` | Create forms concurrently by dependency |
427
- | `openyida create-form create <appType> "<formTitle>" <fieldsJsonFile> [--layout single\|double\|card\|section] [--theme default\|compact\|comfortable] [--label-align top\|left\|right] [--icon auto\|<iconName>] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a form page |
417
+ | `openyida create-form create <appType> "<formTitle>" <fieldsJsonFile> [--icon auto\|<iconName>] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a form page |
428
418
  | `openyida create-form icons [--json]` | List available form navigation icons |
429
419
  | `openyida create-form validate-fields <fieldsJsonOrFile> [--json]` | Validate form field JSON locally |
430
420
  | `openyida create-form update <appType> <formUuid> (<changesJsonOrFile> \| --data-file <changesJsonOrFile>) [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Update a form page |
@@ -529,10 +519,11 @@ Run `openyida --help` or `openyida <command> --help` for detailed usage.
529
519
  |---------|-------------|
530
520
  | `openyida commands [--json]` | Output machine-readable command manifest |
531
521
  | `openyida agent-capabilities [--json] [--summary-json\|--compact]` | Output one-shot agent capability snapshot |
522
+ | `openyida agent <doctor\|diagnose\|status\|connect\|run\|disconnect\|logout> [options]` | Connect a local Agent (Go runtime, development preview) |
532
523
  | `openyida a2a <serve\|agent-card> [options]` | Start local read-only A2A adapter or print Agent Card |
533
524
  | `openyida bridge start [--token <pair-token>] [--port 6736] [--origin https://demo.aliwork.com] [--open\|--no-open]` | Start OpenYida local web bridge service |
534
525
  | `openyida copy [--force]` | Copy project working directory |
535
- | `openyida sample [--list] [<skill> <name>] [--output <file-or-directory>] [--var KEY=VALUE ...] [--design-file <design.md>] [--style-id <themeId\|free-creative>]` | Output code samples/templates |
526
+ | `openyida sample [--list] [<skill> <name>] [--output <file>] [--var KEY=VALUE ...] [--design-file <design.md>]` | Output code samples/templates |
536
527
  | `openyida doctor [--fix]` | Environment diagnostics & auto-fix |
537
528
  | `openyida db-seq-fix [--fix]` | Detect and repair PostgreSQL sequence drift |
538
529
  | `openyida formula evaluate <formula\|file> [--schema file]` | Static-check Yida formula syntax and field refs |
@@ -597,6 +588,31 @@ Form field definitions can include `alias` or `componentAlias` to populate Yida
597
588
 
598
589
  `openyida integration create` supports form events (`insert`, `update`, `delete`, `comment`) and approval events (`processFinish`, `activityTask`; aliases: `approval`, `approvalNode`). Approval events require `--approval-actions agree,disagree,terminated`; `activityTask` also requires `--approval-node-ids <nodeId,...>`. Passing `--process-code` selects a full graph replacement and now requires explicit `--replace`; it is not a safe update. `integration update` currently performs capability detection only: because full platform `processJson` + `viewJson` readback is unproven, it writes a redacted local probe artifact and returns `PLATFORM_PROBE_REQUIRED` before authentication, spec reading, or remote writes. It does not edit a flow.
599
590
 
591
+ ### Local Agent development preview
592
+
593
+ `openyida agent` is a thin Node launcher for a separately supplied Go runtime. Node does not connect to the agent service or manage provider sessions. Platform runtime packages are **not published** in this preview; no Go executable is discovered on `PATH` and no provider is installed or invoked by Node.
594
+
595
+ The Local Agent Beta production allowlist contains macOS and Windows only. Linux remains supported by the ordinary OpenYida CLI and by the explicit development-runtime workflow below, but Linux Local Agent packages are not published and production `connect`/`run` are rejected until native acceptance is complete.
596
+
597
+ ```bash
598
+ openyida agent doctor --json
599
+ openyida agent doctor --development-runtime --runtime-path /absolute/path/openyida-runtime --runtime-manifest /absolute/path/runtime-manifest.json
600
+ openyida agent connect --development-runtime --runtime-path /absolute/path/openyida-runtime --runtime-manifest /absolute/path/runtime-manifest.json --endpoint https://agent.example.test --endpoint-id configured-platform-id
601
+ openyida agent run --development-runtime --runtime-path /absolute/path/openyida-runtime --runtime-manifest /absolute/path/runtime-manifest.json --endpoint https://agent.example.test --endpoint-id configured-platform-id --provider qoder --provider-path /absolute/path/qodercli
602
+ ```
603
+
604
+ Development manifest v1 specifies runtime version, protocol `1`, Node-style OS/architecture names, and `binary: {file, sha256}`; it requires the explicit `--development-runtime` flag. This is an integrity check, **not a publisher signature**. The production loader requires a strictly validated v2 manifest, exact approved platform-package version/digest, and an Ed25519 signature over the original manifest bytes using trust roots bundled in the Node host. The release catalog is currently empty: no production signing key or package is implied to exist. See the [launcher contract](lib/agent/PROTOCOL.md).
605
+
606
+ `connect` supports two equivalent enrollment entries. CLI-first opens the Yida browser approval page and returns through a state/PKCE-protected loopback callback. Web-first copies one five-minute command containing `--enroll`; the token is single-use and carries no business authority. Neither path reads or uploads an ordinary OpenYida login profile.
607
+
608
+ One installation may connect to multiple organizations. Node keeps only a shared Installation ID at the installation root; each organization authorization gets an isolated private Connection state directory, device credentials, journals, control socket, and frozen bundle. `agent connect` keeps the new Connection online in the foreground, while `agent run`, `status`, `disconnect`, and `logout` enumerate every valid Connection. Each Connection registers all locally discovered Qoder and Codex Runtimes, and the web UI selects computer, CLI, and model.
609
+
610
+ For each attempt, Go injects `OPENYIDA_MANAGED_RUN=1`, the cloud user/corp/app/run/attempt context, and a fixed-value Tianshu task grant with an initial 60-minute lease. The CLI uses that grant instead of local auth and sends scope-correlation headers. While the authenticated device connection and server-side Run remain active, yida-agent can renew the same bearer server-to-server; the CLI cannot renew it and never receives a task refresh token. Tianshu independently checks the grant against the requested app and rejects application creation, identity/environment changes, arbitrary batches, and cross-application requests. `formUuid` remains optional per-turn page-focus context, so one app-bound session can work across pages in that application. Without `OPENYIDA_MANAGED_RUN`, existing login, token refresh, and command behavior are unchanged.
611
+
612
+ Before `connect` or `run`, Node now freezes the verified runtime bytes, CLI, full production dependency closure, and packaged Skills into a private content-addressed bundle. Source changes during copying fail closed. Existing bundles are verified, never silently repaired or garbage-collected by Node, and survive replacement/removal of the original npm directory. Go owns active/session references and version activation; the external Node executable and provider installations are not copied or managed by npm. A separate parent-watch pipe and a 15-second stop grace prevent normal config EOF from being mistaken for parent death; an unconfirmed forced stop remains unknown.
613
+
614
+ This is not an OS sandbox or an authorization boundary against arbitrary shell code. Production signing/release infrastructure, full Go/provider recovery and upgrade acceptance, and OS/architecture-specific provider E2E are not claimed by these fake-process tests. Auto-update is disabled for `agent` and managed invocations; ordinary CLI commands neither spawn nor download the runtime.
615
+
600
616
  ## Agent Skills
601
617
 
602
618
  The `yida-skills/` directory is the source skill library used by OpenYida during development and distributed with the npm package.
package/bin/yida.js CHANGED
@@ -24,6 +24,8 @@ const { COMMAND_GROUPS, buildCommandManifest, findCommandSuggestion } = require(
24
24
  const command = process.argv[2];
25
25
  const args = process.argv.slice(3);
26
26
  const rawArgs = process.argv.slice(3);
27
+ const { beginCommandReceipt } = require('../lib/agent/command-receipt');
28
+ let commandReceipt;
27
29
 
28
30
  function shouldUseEnvManagement(argsList) {
29
31
  const subCommand = argsList[0];
@@ -279,7 +281,6 @@ function getFirstPositionalArg(cliArgs, startIndex = 0) {
279
281
  '--login-url',
280
282
  '--profile',
281
283
  '--user-id',
282
- '--env-hint',
283
284
  ]);
284
285
  for (let index = startIndex; index < cliArgs.length; index++) {
285
286
  const arg = cliArgs[index];
@@ -387,7 +388,6 @@ function applyLoginEnvironmentFlags(cliArgs, options = {}) {
387
388
  '--client-id',
388
389
  '--profile',
389
390
  '--user-id',
390
- '--env-hint',
391
391
  ]);
392
392
  const targetUrlFlags = new Set([
393
393
  '--endpoint',
@@ -539,23 +539,13 @@ function printLoginHelp() {
539
539
  }
540
540
 
541
541
  function buildTokenLoginOptions(loginArgs) {
542
- const device = loginArgs.includes('--device');
543
542
  return {
544
543
  clientId: getArgValue(loginArgs, '--client-id'),
545
544
  corpId: getArgValue(loginArgs, '--corp-id'),
546
545
  userId: getArgValue(loginArgs, '--user-id'),
547
546
  authProfile: getArgValue(loginArgs, '--profile'),
548
547
  quiet: process.env.YIDA_QUIET === '1' || loginArgs.includes('--quiet'),
549
- noBrowser: device || loginArgs.includes('--no-browser'),
550
- device,
551
- envHint: getArgValue(loginArgs, '--env-hint'),
552
- // Machine-readable progress events for agent runtimes (sandbox browsers,
553
- // CI dashboards). Emits one JSON line per state transition.
554
- onDeviceState: (state) => {
555
- if (device) {
556
- process.stdout.write(JSON.stringify({ type: 'device_login_state', ...state }) + '\n');
557
- }
558
- },
548
+ noBrowser: loginArgs.includes('--no-browser'),
559
549
  };
560
550
  }
561
551
 
@@ -583,6 +573,26 @@ function assertNoUnsupportedLegacyLoginFlags(...argLists) {
583
573
  }
584
574
 
585
575
  async function main() {
576
+ const { assertManagedInvocation, resolveManagedHelp } = require('../lib/agent/managed-run');
577
+ const { readManagedContext } = require('../lib/agent/managed-context');
578
+ if (readManagedContext() && [command, ...rawArgs].some(arg => arg === '--help' || arg === '-h')) {
579
+ assertManagedInvocation(command, rawArgs);
580
+ const entries = resolveManagedHelp(command, rawArgs, { t, version: currentVersion });
581
+ // Managed help is static and local: no Receipt, auth, update, first-run
582
+ // guide or business command module may run on this path.
583
+ commandReceipt = { finish() {} };
584
+ if (rawArgs.includes('--json')) {
585
+ console.log(JSON.stringify({ name: 'openyida', version: currentVersion, commands: entries }, null, 2));
586
+ } else {
587
+ printCommandUsage(...entries.flatMap(entry => [entry.usage, entry.description, ...(entry.examples || [])]));
588
+ }
589
+ return;
590
+ }
591
+ commandReceipt = beginCommandReceipt({ command, args: rawArgs });
592
+ process.once('exit', code => {
593
+ try {commandReceipt.finish(code);} catch {process.exitCode = 1;}
594
+ });
595
+ assertManagedInvocation(command, rawArgs);
586
596
  applyQuietFlag();
587
597
  applyGlobalEnvironmentFlags();
588
598
 
@@ -631,6 +641,12 @@ async function main() {
631
641
  break;
632
642
  }
633
643
 
644
+ case 'agent': {
645
+ const { run } = require('../lib/agent/cmd');
646
+ await run(args);
647
+ break;
648
+ }
649
+
634
650
  case 'mcp': {
635
651
  const { runStdioServer } = require('../lib/mcp/server');
636
652
  runStdioServer();
@@ -745,12 +761,6 @@ async function main() {
745
761
  break;
746
762
  }
747
763
 
748
- case 'app-entry': {
749
- const { run } = require('../lib/app/app-entry');
750
- await run(args);
751
- break;
752
- }
753
-
754
764
  case 'app-list': {
755
765
  const { run } = require('../lib/app/app-list');
756
766
  await run(args);
@@ -906,8 +916,8 @@ async function main() {
906
916
  if (args.length < 4) {
907
917
  throwCliUsage(t('cli.form_config_usage'), t('cli.form_config_example'));
908
918
  }
909
- process.argv = [process.argv[0], process.argv[1], ...args];
910
- require('../lib/app/update-form-config');
919
+ const { run: runUpdateFormConfig } = require('../lib/app/update-form-config');
920
+ await runUpdateFormConfig(args);
911
921
  break;
912
922
  }
913
923
 
@@ -1293,7 +1303,9 @@ async function main() {
1293
1303
  }
1294
1304
 
1295
1305
  main()
1306
+ .then(() => { commandReceipt.finish(process.exitCode || 0); })
1296
1307
  .catch((err) => {
1308
+ try {commandReceipt?.finish(err && err.exitCode ? err.exitCode : 1);} catch { /* Intent remains recoverable. */ }
1297
1309
  if (shouldUseStructuredErrorOutput(err, args)) {
1298
1310
  console.error(JSON.stringify(toErrorPayload(err), null, 2));
1299
1311
  } else if (isCliError(err)) {
@@ -0,0 +1,165 @@
1
+ # Local runtime launcher contract (development implementation)
2
+
3
+ This Node package contains no Go source or build/download fallback. The runtime
4
+ catalog is intentionally empty until release ownership, signing keys, platform
5
+ support and real package publication are approved. Internal test injection is not
6
+ a CLI trust-root option. Ordinary commands do not resolve or spawn this runtime.
7
+
8
+ ## Production metadata and development mode
9
+
10
+ `runtime-manifest.js` is the strict v2 codec: no extra/duplicate JSON keys, malformed
11
+ UTF-8, unknown OS/CPU aliases, invalid protocol/state ranges, unsafe binary paths,
12
+ oversized metadata/binaries or invalid digests. The binary path is exactly
13
+ `bin/openyida-agent-runtime` (Windows: `.exe`). `sourceRevision` is a 40- or
14
+ 64-character lowercase source commit digest, not a public artifact tag.
15
+
16
+ Detached Ed25519 signature: original UTF-8 `runtime-manifest.json` bytes, with no
17
+ re-serialization; `.sig` is canonical base64 for 64 signature bytes, optionally
18
+ one final LF. Trust roots live in the main package's `runtime-catalog.json`:
19
+ `keys[keyId] = {publicKey: <SPKI PEM>, revoked?: boolean}`. Unknown/revoked keys
20
+ fail closed; no TOFU, downloaded trust key, arbitrary URL or PATH fallback exists.
21
+
22
+ Each approved release entry is `{platform, arch, packageName, packageVersion,
23
+ runtimeVersion, manifestSha256}`. The main package must declare that exact
24
+ `optionalDependencies` version. Candidate naming is
25
+ `@openyida/local-agent-runtime-${process.platform}-${process.arch}`; this is not a
26
+ claim those names are registered or published. Platform metadata must match its
27
+ exact name/version and single-element `os`/`cpu`, and have no lifecycle scripts.
28
+ Main-package-relative Node resolution supports hoisting; platform packages must
29
+ make `package.json` resolvable. Missing optional packages block Local Agent only.
30
+ The current Beta production allowlist is macOS (`darwin`) and Windows (`win32`).
31
+ Linux remains a source/development target but must not appear in the production
32
+ catalog or optional dependencies until native acceptance is complete. Ordinary
33
+ non-Agent OpenYida CLI commands remain available on Linux.
34
+
35
+ Unsigned v1 requires CLI `--development-runtime` plus explicit absolute
36
+ `--runtime-path` and `--runtime-manifest`. Environment variables cannot enable it.
37
+ Node sends `developmentRuntime: true` only for that flag. v1 is not accepted as a
38
+ production compatibility fallback. Development binaries are normalized to the
39
+ bundle executable filename; their original manifest is preserved as evidence.
40
+
41
+ ## Launch DTO (protocolVersion remains 1)
42
+
43
+ Go argv is `[command, "--stdio-config"]`; stdin is one JSON object plus LF, at
44
+ most 64 KiB. Business access/refresh tokens and ordinary OpenYida profile
45
+ identifiers are never included. The launch contains the control endpoint,
46
+ endpointId, providers and stateDir; web-first connect may additionally contain
47
+ one short-lived Enrollment token. `node.version` remains the OpenYida package
48
+ version, not the Node version.
49
+
50
+ CLI-first connect lets Go create a state/PKCE/device-key-bound Enrollment and open
51
+ the configured browser authorization page. Web-first connect receives the same
52
+ device result by claiming the single-use `--enroll` token. Both modes persist only
53
+ device connection credentials. For every accepted attempt, Python requests a
54
+ fixed-value Tianshu task grant with an initial 60-minute lease and Go injects it
55
+ only into that attempt's managed environment; Node never falls back to a normal
56
+ local profile. The authenticated Runtime heartbeat lets Python renew the lease
57
+ server-to-server while the authoritative Run remains active. Node has no task
58
+ RefreshToken and cannot renew the bearer itself. The grant is bound to the
59
+ application, not one form/page. An optional `formUuid` remains per-turn focus
60
+ context and may change between turns inside the same `appType`.
61
+
62
+ The device bearer is not sufficient by itself. Python sends a fresh nonce before
63
+ accepting the Runtime hello, and Go signs the device/endpoint/nonce binding with
64
+ the Ed25519 key created at Enrollment. Refresh requests similarly sign the
65
+ device/action/refresh-token digest/endpoint binding. A copied access or refresh
66
+ bearer therefore cannot connect or rotate without the enrolled private key.
67
+
68
+ For both `connect` and `run`, added fields are:
69
+
70
+ ```json
71
+ {
72
+ "parentWatchFD": 3,
73
+ "node": {
74
+ "executable": "/external/node",
75
+ "nodeVersion": "v22.22.3",
76
+ "sha256": "NODE_BINARY_SHA256",
77
+ "version": "2026.9.7",
78
+ "packageRoot": "/private/bundles/BUNDLE_SHA256/openyida",
79
+ "cliEntry": "/private/bundles/BUNDLE_SHA256/openyida/bin/yida.js"
80
+ },
81
+ "bundle": {
82
+ "schemaVersion": 1,
83
+ "id": "BUNDLE_SHA256",
84
+ "root": "/private/bundles/BUNDLE_SHA256",
85
+ "manifestPath": "/private/bundles/BUNDLE_SHA256/bundle-manifest.json",
86
+ "manifestSha256": "BUNDLE_SHA256",
87
+ "runtimeVersion": "0.1.0-dev",
88
+ "skillsDir": "/private/bundles/BUNDLE_SHA256/openyida/yida-skills"
89
+ }
90
+ }
91
+ ```
92
+
93
+ The launcher uses four stdio pipes and keeps fd 3 open independently from normal
94
+ configuration stdin EOF. Parent death/pipe EOF asks Go to stop admission and
95
+ cancel/drain, never to report successful completion. Node forwards SIGINT/TERM;
96
+ failure grants 15 seconds before forcing the Go wrapper down. Such timeout returns
97
+ `AGENT_RUNTIME_STOP_UNCONFIRMED` with `executionState: unknown`, not proof that
98
+ provider processes or in-flight business effects stopped.
99
+
100
+ ## Bundle bytes, ownership and lifetime
101
+
102
+ `bundle-manifest.json` is `JSON.stringify(object) + "\n"`, encoded as UTF-8.
103
+ Its exact SHA-256 is the bundle ID; it is a local content manifest, not a publisher
104
+ signature. Fields (in emitted order) are:
105
+
106
+ ```text
107
+ schemaVersion: 1
108
+ product: "openyida-local-agent-bundle"
109
+ openyidaVersion, runtimeVersion
110
+ launcherProtocol: 1
111
+ wireProtocol: 1
112
+ node: {version: <process.version>, sha256: <external Node binary hash>}
113
+ runtime: {executable: "runtime/bin/openyida-agent-runtime[.exe]",
114
+ manifest: "runtime/runtime-manifest.json",
115
+ signature: "runtime/runtime-manifest.sig" | null,
116
+ development: boolean}
117
+ cliEntry: "openyida/bin/yida.js"
118
+ skillsDir: "openyida/yida-skills"
119
+ files: [{path: <relative POSIX>, size: <integer>, sha256: <lowercase hex>,
120
+ mode: 292 | 365}]
121
+ ```
122
+
123
+ Files sort by path using UTF-8 byte order (not JavaScript UTF-16 comparison).
124
+ Mode 292 is octal 0444; 365 is 0555.
125
+ The manifest is not its own files entry. Unknown files and symlinks are rejected.
126
+ Go verifies the same raw manifest digest, file list/hash/size/mode, launch paths,
127
+ runtime version and external Node identity before accepting work and before
128
+ subsequent helper/new-turn use. Production publication trust is established by
129
+ Node's v2 signature and approved digest, not by pretending the local bundle hash
130
+ is a release signature.
131
+
132
+ Node copies only packaged CLI assets and the recursively resolved production
133
+ dependency/peer/available optional closure, preserving nested dependency
134
+ resolution and cycles. It omits root platform packages (verified runtime bytes
135
+ are copied separately), user projects, credentials, checkout metadata and
136
+ devDependencies. Source content/tree membership is checked again before publish;
137
+ missing dependencies or concurrent replacement fail closed. No install hook runs.
138
+
139
+ Unique private staging directories plus atomic compare-and-publish handle
140
+ concurrent materializers without a second execution lease. Contents are read-only;
141
+ on macOS the staging root must remain writable until rename, then becomes 0500.
142
+ Cache is 0700 on Unix. Same-user/root compromise is outside this protection;
143
+ Windows ACL/OS release acceptance remains unverified. Interrupted staging is not
144
+ an executable published bundle. Node does not repair a modified winner or GC
145
+ existing bundles, unknown journals or user files.
146
+
147
+ Go exclusively owns durable refs under
148
+ `stateDir/bundle-references/<bundleId>/...` for connection, session and attempt
149
+ lifetimes. Session identity no longer pins BundleID.
150
+ Node has no ref writer, owner lease, GC or automatic migration. Global npm upgrade
151
+ can produce a new bundle. After the connection drains and is restarted, a compatible
152
+ bundle may continue the same native session; an active attempt never switches. External Node and
153
+ provider binaries are not redistributed/frozen by this package; loss or an
154
+ incompatible change blocks new work rather than silently starting fresh.
155
+
156
+ For allowlisted Yida write commands only, Node writes one bounded Mutation Receipt
157
+ after an explicit success result in OPENYIDA_AGENT_RECEIPTS_DIR. Read-only, failed
158
+ and interrupted commands write nothing.
159
+ Go forwards a successful openyida_mutation through the authenticated Run stream;
160
+ Python adds requiresHostRefresh. No Go command gateway is involved.
161
+ Windows parent lifetime uses parentPID and an OS process handle, not parentWatchFD.
162
+
163
+ All current automated tests use generated signing keys and fake processes.
164
+ No real provider, user account, Yida write, public upload or npm publication is
165
+ part of this implementation checkpoint.
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ const crypto = require('crypto');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { CliError } = require('../core/cli-error');
7
+ const { readManagedContext } = require('./managed-context');
8
+
9
+ const SCHEMA = 'openyida.ask-human.v1';
10
+ const MAX_FILE_BYTES = 32 * 1024;
11
+ const USAGE = '用法:openyida agent ask-human --request-key <稳定业务键> --questions-file <相对路径> --json';
12
+
13
+ function fail(code, message) { throw new CliError(message, { code, details: { retryable: false } }); }
14
+ function text(value, max) { return typeof value === 'string' && value === value.trim() && value.length > 0 && Buffer.byteLength(value) <= max; }
15
+
16
+ function parseArgs(argv) {
17
+ if (argv.length === 1 && ['--help', '-h'].includes(argv[0])) { return { help: true }; }
18
+ const result = { json: false };
19
+ for (let i = 0; i < argv.length; i++) {
20
+ const name = argv[i];
21
+ if (name === '--json' && !result.json) { result.json = true; continue; }
22
+ const key = name === '--request-key' ? 'requestKey' : name === '--questions-file' ? 'questionsFile' : null;
23
+ if (!key || result[key] !== undefined || !argv[i + 1] || argv[i + 1].startsWith('--')) {
24
+ fail('AGENT_ASK_HUMAN_INVALID', USAGE);
25
+ }
26
+ result[key] = argv[++i];
27
+ }
28
+ if (!text(result.requestKey, 128) || !/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(result.requestKey) ||
29
+ !text(result.questionsFile, 512) || path.isAbsolute(result.questionsFile)) {
30
+ fail('AGENT_ASK_HUMAN_INVALID', 'Ask Human 参数无效。');
31
+ }
32
+ return result;
33
+ }
34
+
35
+ function readQuestions(relativePath, cwd) {
36
+ let root;
37
+ let candidate;
38
+ let realCandidate;
39
+ let stat;
40
+ try {
41
+ root = fs.realpathSync(cwd);
42
+ candidate = path.resolve(root, relativePath);
43
+ stat = fs.lstatSync(candidate);
44
+ realCandidate = fs.realpathSync(candidate);
45
+ } catch { fail('AGENT_ASK_HUMAN_INVALID', '问题文件不可读取。'); }
46
+ if (candidate === root || !candidate.startsWith(root + path.sep) || realCandidate === root || !realCandidate.startsWith(root + path.sep)) {
47
+ fail('AGENT_ASK_HUMAN_INVALID', '问题文件必须位于当前工作目录。');
48
+ }
49
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_FILE_BYTES) { fail('AGENT_ASK_HUMAN_INVALID', '问题文件必须是 32 KiB 以内的普通文件。'); }
50
+ let document;
51
+ try { document = JSON.parse(fs.readFileSync(candidate, 'utf8')); } catch { fail('AGENT_ASK_HUMAN_INVALID', '问题文件不是有效 JSON。'); }
52
+ if (!document || typeof document !== 'object' || Array.isArray(document) || !text(document.title, 256) ||
53
+ !Array.isArray(document.questions) || document.questions.length < 1 || document.questions.length > 3) {
54
+ fail('AGENT_ASK_HUMAN_INVALID', 'Ask Human 问题结构无效。');
55
+ }
56
+ const ids = new Set();
57
+ for (const question of document.questions) {
58
+ const allowed = new Set(['id', 'header', 'question', 'type', 'required', 'options']);
59
+ if (!question || typeof question !== 'object' || Array.isArray(question) || Object.keys(question).some(key => !allowed.has(key)) ||
60
+ !text(question.id, 128) || ids.has(question.id) || !text(question.header, 128) || !text(question.question, 2048) ||
61
+ !['text', 'single_select', 'multi_select'].includes(question.type) ||
62
+ (question.required !== undefined && typeof question.required !== 'boolean')) {
63
+ fail('AGENT_ASK_HUMAN_INVALID', 'Ask Human 问题结构无效。');
64
+ }
65
+ ids.add(question.id);
66
+ const options = question.options === undefined ? [] : question.options;
67
+ if (!Array.isArray(options)) { fail('AGENT_ASK_HUMAN_INVALID', 'Ask Human 选项结构无效。'); }
68
+ if ((question.type === 'text' && options.length) || (question.type !== 'text' && (!Array.isArray(options) || options.length < 1 || options.length > 12)) ||
69
+ options.some(option => !option || typeof option !== 'object' || Array.isArray(option) || Object.keys(option).some(key => !['label', 'description'].includes(key)) || !text(option.label, 512) ||
70
+ (option.description !== undefined && (typeof option.description !== 'string' || Buffer.byteLength(option.description) > 1024)))) {
71
+ fail('AGENT_ASK_HUMAN_INVALID', 'Ask Human 选项结构无效。');
72
+ }
73
+ if (new Set(options.map(option => option.label)).size !== options.length) { fail('AGENT_ASK_HUMAN_INVALID', 'Ask Human 选项不能重复。'); }
74
+ }
75
+ return { title: document.title, questions: document.questions.map(question => ({ ...question, required: question.required !== false })) };
76
+ }
77
+
78
+ function ensureReceiptDir(env) {
79
+ const value = env.OPENYIDA_AGENT_INTERACTIONS_DIR;
80
+ if (!value || !path.isAbsolute(value)) { fail('AGENT_ASK_HUMAN_UNAVAILABLE', '当前任务未启用 Ask Human。'); }
81
+ fs.mkdirSync(value, { recursive: true, mode: 0o700 });
82
+ const stat = fs.lstatSync(value);
83
+ if (!stat.isDirectory() || stat.isSymbolicLink()) { fail('AGENT_ASK_HUMAN_UNAVAILABLE', 'Ask Human 私有目录不可用。'); }
84
+ if (fs.readdirSync(value).filter(name => name.endsWith('.json')).length >= 64) { fail('AGENT_ASK_HUMAN_LIMIT', '本轮 Ask Human 请求过多。'); }
85
+ return value;
86
+ }
87
+
88
+ function retryWindowsFileOperation(operation) {
89
+ const delays = [20, 40, 80, 160, 320];
90
+ for (let attempt = 0; ; attempt++) {
91
+ try { return operation(); } catch (error) {
92
+ if (process.platform !== 'win32' || attempt === delays.length || !['EBUSY', 'EPERM', 'EACCES'].includes(error.code)) { throw error; }
93
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, delays[attempt]);
94
+ }
95
+ }
96
+ }
97
+
98
+ function writeReceipt(directory, requestId, receipt) {
99
+ const temporary = path.join(directory, `.${requestId}.tmp`);
100
+ const target = path.join(directory, `${requestId}.json`);
101
+ let fd;
102
+ try {
103
+ fd = fs.openSync(temporary, 'wx', 0o600);
104
+ fs.writeFileSync(fd, JSON.stringify(receipt));
105
+ fs.fsyncSync(fd);
106
+ fs.closeSync(fd);
107
+ fd = undefined;
108
+ retryWindowsFileOperation(() => fs.renameSync(temporary, target));
109
+ if (process.platform !== 'win32') {
110
+ const parent = fs.openSync(directory, 'r');
111
+ try { fs.fsyncSync(parent); } finally { fs.closeSync(parent); }
112
+ }
113
+ } catch (error) {
114
+ if (fd !== undefined) { try { fs.closeSync(fd); } catch {} }
115
+ if (fs.existsSync(temporary)) { try { retryWindowsFileOperation(() => fs.unlinkSync(temporary)); } catch {} }
116
+ throw error;
117
+ }
118
+ }
119
+
120
+ function run(argv = [], options = {}) {
121
+ const env = options.env || process.env;
122
+ const context = readManagedContext(env);
123
+ if (!context) { fail('AGENT_ASK_HUMAN_MANAGED_ONLY', 'Ask Human 仅可在宜搭云端发起的本地 Agent 任务中使用。'); }
124
+ const args = parseArgs(argv);
125
+ if (args.help) {
126
+ (options.stdout || process.stdout).write(`${USAGE}\n问题文件格式:{ "title": "...", "questions": [{ "id": "...", "header": "...", "question": "...", "type": "text|single_select|multi_select", "options": [{ "label": "...", "description": "..." }] }] }\n`);
127
+ return { ok: true, help: true };
128
+ }
129
+ const document = readQuestions(args.questionsFile, options.cwd || process.cwd());
130
+ const digest = crypto.createHash('sha256').update(JSON.stringify(document)).digest('hex');
131
+ const directory = ensureReceiptDir(env);
132
+ for (const name of fs.readdirSync(directory).filter(item => item.endsWith('.json'))) {
133
+ let prior;
134
+ try { prior = JSON.parse(fs.readFileSync(path.join(directory, name), 'utf8')); } catch { continue; }
135
+ if (prior.requestKey === args.requestKey) {
136
+ if (prior.contentDigest !== digest) { fail('AGENT_ASK_HUMAN_CONFLICT', '同一 request-key 不能提交不同问题。'); }
137
+ const output = { ok: true, requestId: prior.requestId, status: 'queued' };
138
+ (options.stdout || process.stdout).write(JSON.stringify(output) + '\n');
139
+ return output;
140
+ }
141
+ }
142
+ const requestId = crypto.randomUUID();
143
+ const receipt = { schemaVersion: SCHEMA, requestId, requestKey: args.requestKey, contentDigest: digest,
144
+ runId: context.runId, attemptId: context.attemptId, createdAt: new Date().toISOString(), ...document };
145
+ writeReceipt(directory, requestId, receipt);
146
+ const output = { ok: true, requestId, status: 'queued' };
147
+ (options.stdout || process.stdout).write(JSON.stringify(output) + '\n');
148
+ return output;
149
+ }
150
+
151
+ module.exports = { run, SCHEMA };