@underdogai/mesh-event-schemas 0.1.0

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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/dist/apppacks.d.ts +15652 -0
  4. package/dist/apppacks.d.ts.map +1 -0
  5. package/dist/apppacks.js +71 -0
  6. package/dist/apppacks.js.map +1 -0
  7. package/dist/blocks.d.ts +2320 -0
  8. package/dist/blocks.d.ts.map +1 -0
  9. package/dist/blocks.js +472 -0
  10. package/dist/blocks.js.map +1 -0
  11. package/dist/capabilities.d.ts +35 -0
  12. package/dist/capabilities.d.ts.map +1 -0
  13. package/dist/capabilities.js +37 -0
  14. package/dist/capabilities.js.map +1 -0
  15. package/dist/events.d.ts +4557 -0
  16. package/dist/events.d.ts.map +1 -0
  17. package/dist/events.js +571 -0
  18. package/dist/events.js.map +1 -0
  19. package/dist/index.d.ts +16 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +16 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/namespace.d.ts +56 -0
  24. package/dist/namespace.d.ts.map +1 -0
  25. package/dist/namespace.js +60 -0
  26. package/dist/namespace.js.map +1 -0
  27. package/dist/plugins.d.ts +131 -0
  28. package/dist/plugins.d.ts.map +1 -0
  29. package/dist/plugins.js +66 -0
  30. package/dist/plugins.js.map +1 -0
  31. package/dist/registry.d.ts +67 -0
  32. package/dist/registry.d.ts.map +1 -0
  33. package/dist/registry.js +212 -0
  34. package/dist/registry.js.map +1 -0
  35. package/dist/surfaces.d.ts +54323 -0
  36. package/dist/surfaces.d.ts.map +1 -0
  37. package/dist/surfaces.js +523 -0
  38. package/dist/surfaces.js.map +1 -0
  39. package/dist/templates.d.ts +390 -0
  40. package/dist/templates.d.ts.map +1 -0
  41. package/dist/templates.js +493 -0
  42. package/dist/templates.js.map +1 -0
  43. package/package.json +50 -0
  44. package/src/apppacks.ts +90 -0
  45. package/src/blocks.ts +544 -0
  46. package/src/capabilities.ts +58 -0
  47. package/src/events.ts +758 -0
  48. package/src/index.ts +15 -0
  49. package/src/namespace.ts +64 -0
  50. package/src/plugins.ts +118 -0
  51. package/src/registry.ts +261 -0
  52. package/src/surfaces.ts +610 -0
  53. package/src/templates.ts +736 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Underdog
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @underdogai/mesh-event-schemas
2
+
3
+ [`@underdogai/mesh-app-sdk`](https://www.npmjs.com/package/@underdogai/mesh-app-sdk) 가 주고받는 **Matrix 이벤트와 UI 데이터의 스키마**(zod). 카드·서피스가 와이어에서 어떤 모양이어야 하는지를 정의하는 단일 진실 공급원이다.
4
+
5
+ ```bash
6
+ npm i @underdogai/mesh-event-schemas
7
+ ```
8
+
9
+ 보통은 직접 설치하지 않는다 — `@underdogai/mesh-app-sdk` 를 설치하면 함께 딸려온다. 이벤트 타입 상수나 스키마를 직접 다룰 때만 명시적으로 import 한다.
10
+
11
+ ## 구성
12
+
13
+ | 파일 | 내용 |
14
+ |---|---|
15
+ | `namespace.ts` | `NS=org.corp`, `EventType.*` 상수, `UI_CONTENT_KEY` |
16
+ | `blocks.ts` | UI Blocks 데이터 스키마 (text/heading/fields/input/select/button/actions …) — 닫힌 집합이라 앱이 새 블록을 만들 수 없다(안전 속성) |
17
+ | `events.ts` | 이벤트 content 스키마 + 빌더 (`buildUiMessageContent`, `buildUiActionContent`, `extractUiCard` …) |
18
+ | `surfaces.ts` | 방에 머무는 화면 — 패널·헤더·컴포저·커맨드 팔레트·도크·모달 스펙 |
19
+ | `registry.ts` | 스키마 레지스트리 — `validateEvent(type, content)`, `canPublish(type, publisher)` |
20
+
21
+ ## 핵심 이벤트 타입
22
+
23
+ | 타입 | 종류 | 방향 |
24
+ |---|---|---|
25
+ | `m.room.message` + `org.corp.ui` 키 | message | 앱 → 사용자 (타임라인 카드) |
26
+ | `org.corp.ui.action` | message | 사용자·앱 → 앱 (버튼·폼 제출·앱 간 호출) |
27
+ | `org.corp.app.surface` | state | 앱 → 방 (패널·컴포저·⌘K 등 머무는 화면) |
28
+ | `org.corp.workflow.state` | state | 엔티티 진행 상태 |
29
+ | `org.corp.agent.capability` | state | 에이전트 역량 |
30
+
31
+ ## 사용 예
32
+
33
+ ```ts
34
+ import { EventType, buildUiMessageContent, validateEvent } from "@underdogai/mesh-event-schemas";
35
+
36
+ const content = buildUiMessageContent({
37
+ card_id: "approve-inv-1023",
38
+ title: "Approval needed",
39
+ fallback: "Invoice INV-1023 needs approval", // 미지원 클라이언트가 보는 평문 — 필수
40
+ blocks: [
41
+ { type: "fields", items: [{ label: "Invoice", value: "INV-1023" }, { label: "Amount", value: "$1,200" }] },
42
+ { type: "actions", elements: [
43
+ { type: "button", action_id: "finance.approve", text: "Approve", style: "primary" },
44
+ { type: "button", action_id: "finance.reject", text: "Reject", style: "danger" },
45
+ ]},
46
+ ],
47
+ });
48
+ // → client.sendEvent(roomId, "m.room.message", content)
49
+
50
+ const v = validateEvent(EventType.UiAction, incoming);
51
+ if (v.ok) { /* v.data 사용 */ }
52
+ ```
53
+
54
+ 보낼 때는 엄격하게 검증하고, 받을 때는 관대하다 — 모르는 블록은 버리고 나머지를 그린다(버전이 다른 클라이언트끼리도 카드가 통째로 깨지지 않는다).
55
+
56
+ ## 문서
57
+
58
+ **https://chatops.theunderdog.ai/sdk-guide**
59
+
60
+ ## 라이선스
61
+
62
+ MIT