Skip to content

[api] Expose HwpCtrl / 312 Action registry via WASM (run_action or flattened methods) #272

@hyoseop1231

Description

@hyoseop1231

Summary

@rhwp/core 0.7.3 은 HwpCtrl class 와 312-entry Action registry 를 내부적으로 갖고 있으나, WASM binding 에서는 직접 노출되지 않아 MCP/CLI consumer 가 접근할 수 없습니다.

  • rhwp-mcp 의 rhwp_run_action tool 은 현재 "not bridged" 메시지로 무응답
  • 312 Action 경로가 잠겨 있어 "Hancom Office 수준의 universal 편집 의미론" 을 구현할 수 없음

Environment

  • @rhwp/core 0.7.3
  • Node.js v25.6.0, macOS arm64

Context

Hancom Office 의 HwpCtrl 은 312 개 이상의 Action 을 통해 서식·편집·자동화를 수행합니다 (MovePgDn, Insert, FieldCreate, ApplyCellStyle 등). rhwp 가 이 Action 들을 Rust-side 에서 재현하고 있지만 WASM 경계에서 flatten 된 entry 로 노출되지 않아, 다운스트림 (MCP server, CLI, Swift bridge) 은 각 Action 에 대해 개별 top-level 함수를 찾아 호출해야 하고, 미노출된 Action 은 접근 불가.

현재 rhwp-mcp 가 랩한 high-level 함수들 (getStyleAt, applyParaFormat, insertControl, createTable 등) 은 WASM 에 직접 있지만, 전체 312 Action 중 일부에 불과합니다.

Expected

다음 중 하나의 형태:

Option A — run_action(actionId, paramsJson) WASM 함수

doc.run_action(action_id: &str, params_json: &str) → JSON
  { ok: bool, result: any, warnings?: [] }

312 Action registry 의 key (예: "HwpMoveTopOfFile", "InsertFieldTemplate", "TableCellBlockSelect") 를 action_id 로 받아 내부에서 dispatch. params 는 각 Action 의 signature 에 맞춰 JSON.

Option B — Action 별 top-level 함수 flatten

주요 Action 들 (예: 편집 100 개, 서식 80 개, 표 50 개) 을 WASM HwpDocument prototype 의 top-level method 로 각각 노출. 타입 안정성은 더 높으나 API surface 가 커짐.

Impact

해소 시:

  • rhwp_run_action 이 실제 기능을 가짐
  • LLM agent 가 "한컴 Action 수준" 편집을 자연어로 기술 → MCP 가 dispatch 가능
  • Swift / CLI consumer 도 312 Action 모두 접근 가능 → 다운스트림 래퍼 코드 대폭 축소

Questions

  1. HwpCtrl 의 private state (cursor, selection 등) 를 공개하는 범위는 어디까지로 설계하실 계획인지?
  2. Action signature (params schema) 는 rhwp 리포 어딘가에 정리된 문서가 있는지?
  3. 현재 사용자 입장에서 "Action 접근 가능한 대안 경로" (HwpCtrl 없이) 가 있는지?

English summary

rhwp 0.7.3 does not expose HwpCtrl or its 312-entry Action registry via WASM. Downstream consumers (MCP, CLI, Swift bridge) cannot invoke Actions generically — only the subset of methods already on HwpDocument.prototype are reachable. Please consider exposing either run_action(actionId, paramsJson) or flattening Actions as top-level methods.

References

  • 다운스트림 스텁 (비공개): rhwp-mcp/src/tools/action.ts runActionTool handler — "not bridged" 메시지 반환

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions