@iniesta8888/agent-live 0.3.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 (182) hide show
  1. package/CODE_OF_CONDUCT.md +7 -0
  2. package/CONTRIBUTING.md +56 -0
  3. package/LICENSE +21 -0
  4. package/README.md +92 -0
  5. package/SECURITY.md +13 -0
  6. package/dist/adapter-sdk/index.d.ts +45 -0
  7. package/dist/adapter-sdk/index.d.ts.map +1 -0
  8. package/dist/adapter-sdk/index.js +106 -0
  9. package/dist/adapter-sdk/index.js.map +1 -0
  10. package/dist/content/compiler.d.ts +31 -0
  11. package/dist/content/compiler.d.ts.map +1 -0
  12. package/dist/content/compiler.js +218 -0
  13. package/dist/content/compiler.js.map +1 -0
  14. package/dist/content/graph-validator.d.ts +56 -0
  15. package/dist/content/graph-validator.d.ts.map +1 -0
  16. package/dist/content/graph-validator.js +226 -0
  17. package/dist/content/graph-validator.js.map +1 -0
  18. package/dist/content/library.d.ts +4 -0
  19. package/dist/content/library.d.ts.map +1 -0
  20. package/dist/content/library.js +45 -0
  21. package/dist/content/library.js.map +1 -0
  22. package/dist/content/registry.d.ts +34 -0
  23. package/dist/content/registry.d.ts.map +1 -0
  24. package/dist/content/registry.js +130 -0
  25. package/dist/content/registry.js.map +1 -0
  26. package/dist/content/runtime-content.d.ts +63 -0
  27. package/dist/content/runtime-content.d.ts.map +1 -0
  28. package/dist/content/runtime-content.js +78 -0
  29. package/dist/content/runtime-content.js.map +1 -0
  30. package/dist/content/schema.d.ts +142 -0
  31. package/dist/content/schema.d.ts.map +1 -0
  32. package/dist/content/schema.js +280 -0
  33. package/dist/content/schema.js.map +1 -0
  34. package/dist/content/validator.d.ts +35 -0
  35. package/dist/content/validator.d.ts.map +1 -0
  36. package/dist/content/validator.js +205 -0
  37. package/dist/content/validator.js.map +1 -0
  38. package/dist/core/agents.d.ts +56 -0
  39. package/dist/core/agents.d.ts.map +1 -0
  40. package/dist/core/agents.js +148 -0
  41. package/dist/core/agents.js.map +1 -0
  42. package/dist/core/limits.d.ts +15 -0
  43. package/dist/core/limits.d.ts.map +1 -0
  44. package/dist/core/limits.js +16 -0
  45. package/dist/core/limits.js.map +1 -0
  46. package/dist/core/mapping.d.ts +17 -0
  47. package/dist/core/mapping.d.ts.map +1 -0
  48. package/dist/core/mapping.js +94 -0
  49. package/dist/core/mapping.js.map +1 -0
  50. package/dist/core/protocol.d.ts +105 -0
  51. package/dist/core/protocol.d.ts.map +1 -0
  52. package/dist/core/protocol.js +6 -0
  53. package/dist/core/protocol.js.map +1 -0
  54. package/dist/core/state.d.ts +49 -0
  55. package/dist/core/state.d.ts.map +1 -0
  56. package/dist/core/state.js +216 -0
  57. package/dist/core/state.js.map +1 -0
  58. package/dist/creator/commands.d.ts +19 -0
  59. package/dist/creator/commands.d.ts.map +1 -0
  60. package/dist/creator/commands.js +44 -0
  61. package/dist/creator/commands.js.map +1 -0
  62. package/dist/creator/mode.d.ts +10 -0
  63. package/dist/creator/mode.d.ts.map +1 -0
  64. package/dist/creator/mode.js +23 -0
  65. package/dist/creator/mode.js.map +1 -0
  66. package/dist/creator/service.d.ts +199 -0
  67. package/dist/creator/service.d.ts.map +1 -0
  68. package/dist/creator/service.js +159 -0
  69. package/dist/creator/service.js.map +1 -0
  70. package/dist/index.d.ts +14 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +10 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/runtime/agent-live-runtime.d.ts +17 -0
  75. package/dist/runtime/agent-live-runtime.d.ts.map +1 -0
  76. package/dist/runtime/agent-live-runtime.js +50 -0
  77. package/dist/runtime/agent-live-runtime.js.map +1 -0
  78. package/dist/runtime/content-service.d.ts +75 -0
  79. package/dist/runtime/content-service.d.ts.map +1 -0
  80. package/dist/runtime/content-service.js +60 -0
  81. package/dist/runtime/content-service.js.map +1 -0
  82. package/dist/runtime/resource-guard.d.ts +17 -0
  83. package/dist/runtime/resource-guard.d.ts.map +1 -0
  84. package/dist/runtime/resource-guard.js +54 -0
  85. package/dist/runtime/resource-guard.js.map +1 -0
  86. package/dist/runtime/server.d.ts +39 -0
  87. package/dist/runtime/server.d.ts.map +1 -0
  88. package/dist/runtime/server.js +286 -0
  89. package/dist/runtime/server.js.map +1 -0
  90. package/dist/web/app.d.ts +1 -0
  91. package/dist/web/app.js +1317 -0
  92. package/dist/web/index.html +45 -0
  93. package/dist/web/office.js +350 -0
  94. package/dist/web/sprites.js +185 -0
  95. package/dist/web/style.css +288 -0
  96. package/dist/web/v2/bootstrap.js +276 -0
  97. package/dist/web/v2/content/README.md +17 -0
  98. package/dist/web/v2/content/agent-skins/studio-team.json +33 -0
  99. package/dist/web/v2/content/agent-skins/tiny-developers.json +33 -0
  100. package/dist/web/v2/content/atmospheres/default.json +13 -0
  101. package/dist/web/v2/content/atmospheres/rainy-night.json +37 -0
  102. package/dist/web/v2/content/catalog.json +14 -0
  103. package/dist/web/v2/content/component-library/activity-implementations.json +873 -0
  104. package/dist/web/v2/content/component-library/activity-recipes.json +25 -0
  105. package/dist/web/v2/content/component-library/agent-profile-templates.json +18 -0
  106. package/dist/web/v2/content/component-library/catalog.json +38 -0
  107. package/dist/web/v2/content/component-library/npc-templates.json +42 -0
  108. package/dist/web/v2/content/component-library/props.json +41 -0
  109. package/dist/web/v2/content/environments/local-office.json +31 -0
  110. package/dist/web/v2/content/environments/rainy-night.json +28 -0
  111. package/dist/web/v2/content/environments/static-office.json +27 -0
  112. package/dist/web/v2/content/layouts/boardroom-office.json +122 -0
  113. package/dist/web/v2/content/layouts/demo-office.json +88 -0
  114. package/dist/web/v2/content/layouts/lively-office.json +96 -0
  115. package/dist/web/v2/content/layouts/old-school-office.json +154 -0
  116. package/dist/web/v2/content/layouts/tech-open-office.json +132 -0
  117. package/dist/web/v2/content/life-activities/boardroom-routines.json +67 -0
  118. package/dist/web/v2/content/life-activities/none.json +10 -0
  119. package/dist/web/v2/content/life-activities/office-basics.json +39 -0
  120. package/dist/web/v2/content/life-activities/old-school-routines.json +74 -0
  121. package/dist/web/v2/content/life-activities/tech-office-routines.json +148 -0
  122. package/dist/web/v2/content/npcs/boardroom-staff.json +54 -0
  123. package/dist/web/v2/content/npcs/none.json +10 -0
  124. package/dist/web/v2/content/npcs/office-staff.json +25 -0
  125. package/dist/web/v2/content/npcs/old-school-staff.json +39 -0
  126. package/dist/web/v2/content/npcs/tech-office-staff.json +40 -0
  127. package/dist/web/v2/content/official-offices/boardroom-office.json +25 -0
  128. package/dist/web/v2/content/official-offices/old-school-office.json +25 -0
  129. package/dist/web/v2/content/official-offices/tech-open-office.json +25 -0
  130. package/dist/web/v2/content/presets/boardroom-office.json +21 -0
  131. package/dist/web/v2/content/presets/cozy-studio.json +19 -0
  132. package/dist/web/v2/content/presets/demo-office.json +19 -0
  133. package/dist/web/v2/content/presets/lively-office.json +19 -0
  134. package/dist/web/v2/content/presets/night-shift.json +19 -0
  135. package/dist/web/v2/content/presets/old-school-office.json +20 -0
  136. package/dist/web/v2/content/presets/refined-demo.json +20 -0
  137. package/dist/web/v2/content/presets/tech-open-office.json +21 -0
  138. package/dist/web/v2/content/props/default-office.json +23 -0
  139. package/dist/web/v2/content/props/extended-office.json +39 -0
  140. package/dist/web/v2/content/props/tech-office.json +28 -0
  141. package/dist/web/v2/content/styles/pixel-classic.json +160 -0
  142. package/dist/web/v2/content/styles/warm-studio.json +150 -0
  143. package/dist/web/v2/environment-runtime.d.ts +1 -0
  144. package/dist/web/v2/environment-runtime.js +138 -0
  145. package/dist/web/v2/graph-validator.d.ts +55 -0
  146. package/dist/web/v2/graph-validator.js +225 -0
  147. package/dist/web/v2/i18n.js +54 -0
  148. package/dist/web/v2/locales/en.json +209 -0
  149. package/dist/web/v2/locales/zh-CN.json +52 -0
  150. package/dist/web/v2/office-engine.d.ts +1 -0
  151. package/dist/web/v2/office-engine.js +145 -0
  152. package/dist/web/v2/office-renderer.d.ts +1 -0
  153. package/dist/web/v2/office-renderer.js +843 -0
  154. package/dist/web/v2/parity.html +10 -0
  155. package/dist/web/v2/parity.js +82 -0
  156. package/dist/web/v2/sprite-renderer.d.ts +1 -0
  157. package/dist/web/v2/sprite-renderer.js +242 -0
  158. package/dist/web/v2/static-content.js +48 -0
  159. package/dist/web/v2/style.css +140 -0
  160. package/dist/web/v2.html +68 -0
  161. package/docs/ADAPTER-DEVELOPMENT.md +328 -0
  162. package/docs/ADAPTER-SDK.md +109 -0
  163. package/docs/ARCHITECTURE.md +223 -0
  164. package/docs/COMPONENT-LIBRARY.md +212 -0
  165. package/docs/CUSTOMIZATION.md +163 -0
  166. package/docs/DEVELOPER.md +186 -0
  167. package/docs/DSH-ADAPTER-DESIGN.md +173 -0
  168. package/docs/OFFICE-THEMES.md +516 -0
  169. package/docs/PRESET-CONFIG.md +460 -0
  170. package/docs/RELEASE-CHECK.md +23 -0
  171. package/docs/TECHNICAL.md +515 -0
  172. package/docs/USING-CODEX.md +24 -0
  173. package/docs/USING-DSH.md +44 -0
  174. package/docs/USING-PI.md +50 -0
  175. package/docs/VISION.md +146 -0
  176. package/examples/adapter/local-office.mjs +52 -0
  177. package/package.json +89 -0
  178. package/skills/agent-live-adapter-builder/SKILL.md +30 -0
  179. package/skills/agent-live-adapter-builder/agents/openai.yaml +4 -0
  180. package/skills/agent-live-adapter-builder/references/investigation.md +9 -0
  181. package/skills/agent-live-adapter-builder/references/review.md +7 -0
  182. package/skills/agent-live-adapter-builder/scripts/create-adapter.mjs +26 -0
package/docs/VISION.md ADDED
@@ -0,0 +1,146 @@
1
+ # Live Agent Show 产品愿景
2
+
3
+ > 状态:已收敛方向 · 最后校准 2026-09-13
4
+
5
+ 相关设计:[Office 可配置内容模型](./OFFICE-THEMES.md) · [基础组件库](./COMPONENT-LIBRARY.md) · [系统架构](./ARCHITECTURE.md)
6
+
7
+ ## 1. 产品定义
8
+
9
+ **Live Agent Show 把 AI Agent 的真实工作,实时呈现在一间有生命的办公室里。**
10
+
11
+ 这里的 Show 不是舞台剧,也不是让用户创造任意世界;它表示“工作正在现场发生,并且看得见”。办公室是固定的产品世界观,读取文件、执行命令、编辑代码、任务委派、等待和完成,都有稳定的办公叙事。
12
+
13
+ 当前只做 Demo 规格的单层办公室。普通用户选择完整 Office;Creator 可以在当前 Office 已声明的能力内调整美术风格、Agent 外观、NPC、物件、办公室生活、环境视觉、公共运行环境和文字区,但不能单独更换 Layout,也不能改变真实工作语义和基础运行规则。新的房间结构由内容开发者通过源码新增为完整 Preset。
14
+
15
+ 一句话可以表达为:
16
+
17
+ > Watch your AI agents work—live in their office.
18
+
19
+ ## 2. 产品层级
20
+
21
+ | 层级 | 定义 | 当前对应 |
22
+ | --- | --- | --- |
23
+ | Agent Live | 产品品牌 | 整个产品 |
24
+ | Adapter | 从不同宿主读取其开放的 Agent 事实 | 已有 Pi、Codex、DSH;未来可继续接入 Cursor 等宿主 |
25
+ | OfficeEvent | 与宿主无关的真实工作事件 | Pi、Codex、DSH 官方事实的转换结果 |
26
+ | Office Engine | 将事件转成办公室位置、动作和状态 | 当前 `OfficeState`、映射与前端状态机 |
27
+ | Office Runtime | 单层办公室的渲染、移动、寻路、气泡和状态规则 | 当前 Demo 前端状态机 |
28
+ | Component Library | 八类基础组件的唯一全集与 Capability Catalog | 当前三个正式 Office 与 Custom Office 的共同内容来源 |
29
+ | Office Spec | 一间办公室最终引用和实例化的组件集合 | Official Preset 与 Custom Office 的共同合同 |
30
+ | Official Preset | 为普通用户准备的只读 Office Spec | 当前三个正式办公室 |
31
+ | Custom Office | Creator 基于完整 Preset 修改、校验并保存在本地的 Office Spec | 已实现;Pi/DSH 支持会话级 custom/exit,Codex 使用当轮显式自定义 |
32
+ | Episode | 一次可实时观看或回放的任务 | 一次 session / task |
33
+
34
+ 无论接入哪个宿主,核心体验都保持一致:Agent 在办公室中工作。不同宿主只会因为开放能力不同而出现信息精度差异,不会变成不同产品。
35
+
36
+ ## 3. 真实工作与开放的办公表现
37
+
38
+ 产品固定 Agent 真实工作的语义,但不把每种工作写死到一件家具:
39
+
40
+ | 真实行为 | 固定语义 | 可选办公表现 |
41
+ | --- | --- | --- |
42
+ | 读取、搜索、分析 | `research` | 个人电脑、资料室、书架或档案柜 |
43
+ | 写入、编辑 | `create` | 个人工位、设计台或共享工作桌 |
44
+ | 命令、测试、运行 | `compute` | 个人电脑、服务器、机房或测试实验室 |
45
+ | 计划、任务拆解 | `plan` | 白板、项目室或会议屏幕 |
46
+ | 网络、提问、外部服务 | `communicate` | 电话间、前台、会议室或个人电脑 |
47
+ | 委派、交接、评审 | `collaborate` | 会议桌、站会区或休息区 |
48
+
49
+ Office 给设施标注能力,Office Engine 再为工作语义选择合适地点。因此办公室可以自由增加房间和设施;没有专用设施时,工作回退到个人工位。不能改变的是宿主事件的事实含义,而不是某张地图上的固定坐标。
50
+
51
+ ## 4. 可组合的 Office 内容
52
+
53
+ 当前固定为 Demo 的单层同屏办公室,不再定义 Company Scale。可替换内容拆成八个插槽:
54
+
55
+ - **Style**:像素、手绘等整体美术语言,覆盖角色、家具、气泡、侧栏、颜色和特效。
56
+ - **Layout**:同一单层办公室内的墙体、区域、家具坐标、功能锚点、座位和路径。
57
+ - **Agent Skin**:真实 Agent 的角色造型、职位、制服与身份外观。
58
+ - **NPC**:保安、清洁工、前台、访客、普通同事和宠物等办公室角色。
59
+ - **Props**:工位、服务器、白板、饮水机、沙发、游戏机、绿植等功能或装饰物件。
60
+ - **Life Activities**:喝水、休息、聊天、划水、娱乐,以及 NPC 的巡逻、打扫和接待等模拟日常。
61
+ - **Atmosphere**:白天、雨夜等状态的色板、窗外、粒子和声音表现。
62
+ - **Environment**:本地或固定时间、外部天气输入、自动照明和 NPC 班次。
63
+
64
+ Component Library 是上述内容的唯一全集。Office Spec 从中组装一间办公室;Official Preset 是给普通用户一键选择的只读 Office Spec,Custom Office 则由 Creator 基于某个 Official Preset 修改得到(第一笔改动即生成内容完整继承的副本)。两者使用同一个 Compiler 和 Validator。内容模块不改变:
65
+
66
+ - Agent 的真实状态与事件事实。
67
+ - Work Event 的真实事实和工作语义。
68
+ - 委派、等待、失败和完成代表的含义。
69
+
70
+ 其中 Work Event 来自宿主,拥有最高优先级;Life Event 由本地办公室模拟生成,只在空闲时运行,可以随时被真实工作打断,也不能进入真实工作统计。
71
+
72
+ 无论使用哪个 Preset,都保持单个场所、单层俯视、全办公室同屏,不增加园区、多楼层或视角下钻。
73
+
74
+ 完整边界与组合关系见 [Office 可配置内容模型](./OFFICE-THEMES.md)。
75
+
76
+ ## 5. 核心价值
77
+
78
+ 视觉风格负责吸引和陪伴,真实工作信息负责留存。产品应帮助用户快速回答:
79
+
80
+ - 现在谁在做什么?
81
+ - 哪一路正在等待、失败或需要我介入?
82
+ - 多个 Agent 是否真的在并行?
83
+ - 任务进行到哪里,刚才发生了什么?
84
+ - 这次任务是否值得回放或分享?
85
+
86
+ 主画面服务于“瞥一眼”,完整日志、Diff、用量和时间轴放在侧栏或回放中。不能为了画面好看制造没有真实发生的工作、协作或结论。
87
+
88
+ ## 6. 建议路线图
89
+
90
+ ### 阶段一:把当前办公室做扎实(已完成基础版本)
91
+
92
+ - 完善 Pi 事件覆盖、多人委派、错误和等待状态。
93
+ - 将当前 Demo 明确为唯一的空间规格,不建设 Company Scale。
94
+ - 已将 Demo 拆为 Preset 与八类内容,并由 V2 原生 renderer 和 Environment Runtime 驱动。
95
+ - 将现有 `OfficeAction` 从具体家具逐步提升为 `research / create / compute / plan / communicate / collaborate` 等工作语义。
96
+ - 将项目整理成用户可一键安装的 Pi Package,并提供宿主内启动入口。
97
+
98
+ ### 阶段二:先验证办公室生活的完整链路(已完成)
99
+
100
+ - 加入一个饮水机 Prop、一个保洁 NPC,以及接水和巡检两类 Life Activities。
101
+ - 保证 Life Activity 只在空闲时触发,并能被新的 Work Event 立即打断。
102
+ - 保证 NPC 与模拟活动不会进入 Agent、工具、token 或任务统计。
103
+ - 用这条纵向切片验证内容模块不是只有配置文件,而是能共同驱动画面与行为。
104
+
105
+ ### 阶段三:用第二套 Style 验证美术切换(已完成)
106
+
107
+ - 制作一套视觉差异明显、但布局和行为相同的 Style。
108
+ - 支持运行时选择 Style、预览和热切换。
109
+ - 验证更换资源和视觉配置不影响事件语义与状态机。
110
+ - 增加 Style 格式校验和资源缺失时的默认回退。
111
+
112
+ ### 阶段四:增加布局与角色内容(已完成基础版本)
113
+
114
+ - 已增加 `old-school-office` 与 `boardroom-office` 两个单层 Layout,用设施能力标签承载相同 Work Semantics。
115
+ - 已增加前台、后勤、秘书和会务 NPC,以及文件流转、会议支持与茶水服务;保安、办公室猫和更多生活行为继续作为可选内容。
116
+ - 已用 Office Preset 将八类内容组合成顶部一键选项,并把时间、天气、照明和 NPC 班次收敛进共享 Environment。
117
+
118
+ ### 阶段五:回放与更多宿主(当前已有基础版本)
119
+
120
+ - 保存标准 Show Event,支持时间轴、暂停、倍速和关键节点。
121
+ - 当前已提供 Pi、Codex、DSH 三种官方 Adapter;未来宿主仍按其公开能力接入。
122
+ - 在宿主能力不足时明确降级,而不是猜测或伪造状态。
123
+ - 提供独立 Viewer / WebView,统一查看实时任务和历史 Episode。
124
+
125
+ ### 阶段六:有限开放内容创作(基础版本已完成)
126
+
127
+ - 用户先选择经过验证的完整 Office,再通过受限 Creator 修改已实现内容;校验通过后直接保存并选择。
128
+ - 导入、导出、版本检查和分享尚未实现,需要真实需求后再决定。
129
+ - 只有真实需求出现后,再考虑可视化编辑器和内容市场。
130
+
131
+ ## 7. 当前明确不做
132
+
133
+ - 不做任意世界生成器。
134
+ - 不让用户改写真实工作语义,但允许 Office 自由提供不同设施来承载它们。
135
+ - 不做故事规则编辑器、地图逻辑编辑器或脚本插件系统。
136
+ - 不把产品做成只有一个桌宠的小悬浮窗。
137
+ - 不为了展示原始推理而突破宿主能力和隐私边界。
138
+ - 不先建设庞大的创作者平台或主题市场。
139
+
140
+ ## 8. 当前最重要的判断
141
+
142
+ Live Agent Show 的边界可以概括为:
143
+
144
+ > **一个开放而可信的办公世界:真实 Agent 工作驱动主线,独立 Office Life 让它在空闲时也持续生活。**
145
+
146
+ 当前 Demo 的配置拆分、V2 原生渲染、Office Life、三套正式 Office、公共 Environment、基础 Creator 和 Pi/Codex/DSH Adapter 已经进入主线。下一阶段聚焦真实宿主接入质量、三个 Adapter 的可维护性、开发者体验和发布流程,不扩张办公室世界边界。
@@ -0,0 +1,52 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { pathToFileURL } from "node:url";
3
+ import {
4
+ AgentLiveRuntime, OfficeContentService, CreatorService, CreatorCommandRouter,
5
+ defineAdapter, connectAdapter, createOfficeEventPublisher,
6
+ } from "@iniesta8888/agent-live";
7
+
8
+ // Public exports only. Replace this host subscription with your host's
9
+ // documented event-to-OfficeDelta mapping.
10
+ const adapter = defineAdapter({
11
+ id: "example",
12
+ name: "Example",
13
+ connect({ host, office }) { return host.subscribe((event) => office.publish(event)); },
14
+ });
15
+
16
+ export async function startExample({ host, cwd = process.cwd(), dataRoot, port = 0 }) {
17
+ const runtime = new AgentLiveRuntime(cwd, { dataRoot });
18
+ let connection;
19
+ let closePromise;
20
+ const close = () => closePromise ??= (async () => {
21
+ const results = await Promise.allSettled([connection?.close(), runtime.close()]);
22
+ const failures = results.filter((result) => result.status === "rejected");
23
+ if (failures.length) throw new AggregateError(failures.map((result) => result.reason), "Example cleanup failed");
24
+ })();
25
+ try {
26
+ const content = await OfficeContentService.create({ dataRoot });
27
+ const creator = new CreatorService(content.registry, content.library);
28
+ const commands = new CreatorCommandRouter(creator);
29
+ connection = await connectAdapter(adapter, { host, office: createOfficeEventPublisher(runtime.state) });
30
+ const token = randomBytes(24).toString("hex");
31
+ const server = await runtime.start({ port, content, creator: commands, creatorToken: token });
32
+ return { url: `${server.url}/v2.html?token=${token}`, close, creator, commands };
33
+ } catch (error) {
34
+ await close();
35
+ throw error;
36
+ }
37
+ }
38
+
39
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
40
+ const host = {
41
+ subscribe(publish) {
42
+ publish({ type: "agent_join", agent: { id: "main", name: "Example", role: "Agent", state: "idle", tokens: 0, cost: 0, toolCalls: 0, joinedAt: Date.now() } });
43
+ return () => {};
44
+ },
45
+ };
46
+ const office = await startExample({ host });
47
+ console.log(office.url);
48
+ console.log("Press Ctrl+C to close this example. Host adapters choose their own normal exit policy.");
49
+ const stop = () => void office.close().catch(console.error);
50
+ process.once("SIGINT", stop);
51
+ process.once("SIGTERM", stop);
52
+ }
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "@iniesta8888/agent-live",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "description": "Give coding agents a live pixel office",
6
+ "keywords": ["coding-agent", "agent-adapter", "codex-plugin", "pi-extension", "agent-visualization", "pixel-office"],
7
+ "author": "ssssnail",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ssssnail/agent-live.git"
12
+ },
13
+ "homepage": "https://github.com/ssssnail/agent-live#readme",
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "bugs": {
17
+ "url": "https://github.com/ssssnail/agent-live/issues"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ },
24
+ "./adapter-sdk": {
25
+ "types": "./dist/adapter-sdk/index.d.ts",
26
+ "import": "./dist/adapter-sdk/index.js"
27
+ }
28
+ },
29
+ "files": ["dist/adapter-sdk", "dist/content", "dist/core", "dist/creator", "dist/runtime", "dist/web", "dist/index.js", "dist/index.js.map", "dist/index.d.ts", "dist/index.d.ts.map", "skills", "docs", "examples", "README.md", "CONTRIBUTING.md", "SECURITY.md", "CODE_OF_CONDUCT.md", "LICENSE"],
30
+ "engines": {
31
+ "node": ">=22"
32
+ },
33
+ "scripts": {
34
+ "test": "npm run check",
35
+ "build": "npm run build:validator && node scripts/build.mjs",
36
+ "typecheck": "tsc -p tsconfig.check.json",
37
+ "preview": "node plugins/agent-live/scripts/preview.ts",
38
+ "validate:components": "node plugins/agent-live/scripts/validate-component-library.ts",
39
+ "validate:activity-implementations": "node plugins/agent-live/scripts/validate-activity-implementations.ts",
40
+ "validate:architecture": "node plugins/agent-live/scripts/validate-architecture.ts",
41
+ "validate:adapter-sdk": "node plugins/agent-live/scripts/validate-adapter-sdk.ts",
42
+ "validate:sdk-example": "node scripts/validate-sdk-example.mjs",
43
+ "validate:layouts": "node plugins/agent-live/scripts/validate-layouts.ts && node plugins/agent-live/scripts/validate-office-engine.ts",
44
+ "validate:office-schema": "node plugins/agent-live/scripts/validate-office-schema.ts",
45
+ "validate:office-compiler": "node plugins/agent-live/scripts/validate-office-compiler.ts",
46
+ "validate:official-offices": "node plugins/agent-live/scripts/validate-official-offices.ts",
47
+ "validate:office-registry": "node plugins/agent-live/scripts/validate-office-registry.ts",
48
+ "validate:creator-service": "node plugins/agent-live/scripts/validate-creator-service.ts",
49
+ "validate:creator-mode": "node plugins/agent-live/scripts/validate-creator-mode.ts",
50
+ "validate:creator-commands": "node plugins/agent-live/scripts/validate-creator-commands.ts",
51
+ "validate:runtime-content": "node plugins/agent-live/scripts/validate-runtime-content.ts",
52
+ "validate:resource-guard": "node plugins/agent-live/scripts/validate-resource-guard.ts",
53
+ "validate:custom-office-runtime": "node plugins/agent-live/scripts/validate-custom-office-runtime.ts",
54
+ "validate:content": "node plugins/agent-live/scripts/validate-content.ts",
55
+ "validate:environment": "node plugins/agent-live/scripts/validate-environment.ts",
56
+ "validate:history": "node plugins/agent-live/scripts/validate-history.ts",
57
+ "validate:locales": "node plugins/agent-live/scripts/validate-locales.ts",
58
+ "validate:agents": "node plugins/agent-live/scripts/validate-agent-registry.ts",
59
+ "validate:codex-adapter": "node plugins/agent-live/scripts/validate-codex-adapter.ts",
60
+ "validate:dsh-adapter": "node plugins/agent-live/scripts/validate-dsh-adapter.ts",
61
+ "validate:office-engine": "node plugins/agent-live/scripts/validate-office-engine.ts",
62
+ "validate:render": "node plugins/agent-live/scripts/validate-render.mjs",
63
+ "validate:pi-creator": "node plugins/agent-live/scripts/validate-pi-creator.ts",
64
+ "validate:pi-lifecycle": "node plugins/agent-live/scripts/validate-pi-lifecycle.ts",
65
+ "validate:runtime-lifecycle": "node plugins/agent-live/scripts/validate-runtime-lifecycle.ts",
66
+ "validate:codex-turn-race": "node plugins/agent-live/scripts/validate-codex-turn-race.ts",
67
+ "validate:server-url": "node plugins/agent-live/scripts/validate-server-url.ts",
68
+ "validate:codex-client": "node plugins/agent-live/scripts/validate-codex-client.ts",
69
+ "validate:codex-session": "node plugins/agent-live/scripts/validate-codex-session.ts",
70
+ "validate:package": "node plugins/agent-live/scripts/validate-package.ts",
71
+ "codex": "node plugins/agent-live/scripts/codex-client.ts",
72
+ "test:integration:codex": "npm run validate:codex-client && npm run validate:codex-session",
73
+ "check": "npm run typecheck && npm run validate:architecture && npm run validate:web-validator && npm run validate:resource-guard && npm run validate:components && npm run validate:activity-implementations && npm run validate:layouts && npm run validate:office-schema && npm run validate:office-compiler && npm run validate:official-offices && npm run validate:office-registry && npm run validate:creator-service && npm run validate:creator-mode && npm run validate:creator-commands && npm run validate:runtime-content && npm run validate:custom-office-runtime && npm run validate:content && npm run validate:environment && npm run validate:history && npm run validate:locales && npm run validate:agents && npm run validate:codex-adapter && npm run validate:dsh-adapter && npm run validate:render && npm run validate:pi-creator && npm run validate:pi-lifecycle && npm run validate:runtime-lifecycle && npm run validate:codex-turn-race && npm run validate:server-url && node --check plugins/agent-live/src/core/protocol.ts && node --check plugins/agent-live/src/core/limits.ts && node --check plugins/agent-live/src/core/agents.ts && node --check plugins/agent-live/src/core/state.ts && node --check plugins/agent-live/src/core/mapping.ts && node --check plugins/agent-live/src/runtime/content-service.ts && node --check plugins/agent-live/src/runtime/server.ts && node --check plugins/agent-live/src/runtime/agent-live-runtime.ts && node --check plugins/agent-live/src/runtime/resource-guard.ts && node --input-type=module -e \"await import('./plugins/agent-live/src/runtime/agent-live-runtime.ts')\" && node --check packages/pi/src/adapter.ts && node --check plugins/agent-live/src/adapters/codex/app-server-client.ts && node --check plugins/agent-live/src/adapters/codex/adapter.ts && node --check plugins/agent-live/src/adapters/codex/launcher.ts && node --check plugins/agent-live/dsh/src/adapter.ts && node --check plugins/agent-live/scripts/codex-client.ts && node --check plugins/agent-live/scripts/creator-command.ts && node --check plugins/agent-live/web/app.js && node --check plugins/agent-live/web/v2/bootstrap.js && node --check plugins/agent-live/web/v2/static-content.js && node --check plugins/agent-live/web/v2/codex-controls.js && node --check plugins/agent-live/web/v2/i18n.js && node --check plugins/agent-live/web/v2/environment-runtime.js && node --check plugins/agent-live/web/v2/office-renderer.js && node --check plugins/agent-live/web/v2/sprite-renderer.js",
74
+ "check:dsh": "npm ci --ignore-scripts --prefix plugins/agent-live/dsh && npm run check --prefix plugins/agent-live/dsh",
75
+ "check:ci": "npm run check && npm run validate:adapter-sdk && npm run build && npm run validate:sdk-example && npm run check:dsh && npm run validate:generated && npm run validate:package && npm run validate:distributions && npm pack --dry-run --ignore-scripts",
76
+ "prepare": "npm run build",
77
+ "prepack": "npm run check && npm run build",
78
+ "build:validator": "node scripts/web-validator.mjs",
79
+ "validate:web-validator": "node scripts/web-validator.mjs --check",
80
+ "validate:generated": "node scripts/validate-generated.mjs",
81
+ "validate:distributions": "node scripts/validate-distributions.mjs"
82
+ },
83
+ "devDependencies": {
84
+ "@earendil-works/pi-coding-agent": "0.85.1",
85
+ "@types/node": "22.20.2",
86
+ "esbuild": "^0.25.0",
87
+ "typescript": "5.9.3"
88
+ }
89
+ }
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: agent-live-adapter-builder
3
+ description: Investigate a coding agent's official extension APIs and build or review an independent Agent Live adapter with evidence, event mapping, scaffolding, and contract tests. Use when adding Agent Live support to a new coding-agent host; do not use for editing Offices or presets.
4
+ ---
5
+
6
+ # Agent Live Adapter Builder
7
+
8
+ Build adapters against the public `@iniesta8888/agent-live` package. Never import repository-internal files.
9
+
10
+ ## Required gates
11
+
12
+ 1. Locate official host documentation, SDK types, or public source. Record exact links, versions, event names, fields, and lifecycle behavior in `HOST-CAPABILITIES.md`.
13
+ 2. If the evidence cannot establish a supported extension or event surface, stop with an analysis. Do not probe private storage, infer events from UI text, or generate a pretend adapter.
14
+ 3. Map each authoritative host event to one `OfficeDelta` in `EVENT-MAPPING.md`. Mark missing capabilities unsupported; do not manufacture work facts for visual completeness.
15
+ 4. Run `scripts/create-adapter.mjs` only after the evidence and mapping are clear. Then replace every generated TODO with host-specific code.
16
+ 5. Test normal completion, failure, interruption/disconnect, stable IDs, duplicate delivery, missing optional fields, cleanup, and officially supported subagents or controls.
17
+
18
+ Read [references/investigation.md](references/investigation.md) while investigating. Read [references/review.md](references/review.md) before declaring the adapter complete or preparing an upstream contribution.
19
+
20
+ ## Scaffold
21
+
22
+ ~~~bash
23
+ node <SKILL_ROOT>/scripts/create-adapter.mjs --id <host-id> --name "<Host Name>" --output <directory>
24
+ ~~~
25
+
26
+ The script refuses to overwrite a non-empty directory. The adapter remains an independent package unless the user explicitly asks to integrate it into the Agent Live repository.
27
+
28
+ ## Completion report
29
+
30
+ Report verified capabilities, unsupported capabilities, tests run, real-host validation still required, and every assumption. Never describe a simulated test as real-host validation.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Agent Live Adapter Builder"
3
+ short_description: "Build a verified Agent Live adapter"
4
+ default_prompt: "Build an Agent Live adapter from official host documentation and SDK evidence."
@@ -0,0 +1,9 @@
1
+ # Host investigation
2
+
3
+ Prefer the host's official terminology. For every claimed capability, capture a source and the exact public symbol, endpoint, callback, notification, command, or view slot.
4
+
5
+ Investigate independently: realtime observation; task submission and interruption; approval response; model read or selection; stable session, agent, parent-agent, turn and tool-call identities; history APIs; command, tool, context and view registration; startup, shutdown, reconnect and duplicate delivery.
6
+
7
+ An API that controls a task does not automatically expose all internal events. A history API is not realtime observation. A hook supplies only the fields present at that hook. Unknown means unsupported until evidence is found.
8
+
9
+ Create an event table with: official event, source, delivery form, available fields, stable IDs, ordering/duplication notes, mapped `OfficeDelta`, and degradation.
@@ -0,0 +1,7 @@
1
+ # Adapter review
2
+
3
+ Confirm that the package imports only `@iniesta8888/agent-live` public exports, contains no copied renderer or Creator implementation, and changes no other adapter. Capabilities must be inferred from implemented controls and view mounting rather than manually asserted.
4
+
5
+ Check that one authoritative host source produces each fact, streaming cursors do not repeat completed text, tool start/end share an ID, subagents never replace the main agent, and uncertain outcomes remain uncertain. Cleanup must be idempotent and release only adapter-owned resources. Agent Live owns and cleans its own runtime resources; the adapter must not stop the host.
6
+
7
+ For an official contribution, require automated contract tests, a real-host test record, supported host versions, permissions/data disclosure, dependency licenses, and evidence for every public API claim.
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import { mkdir, readdir, writeFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+
5
+ const args = process.argv.slice(2);
6
+ const value = (flag) => { const index = args.indexOf(flag); return index >= 0 ? args[index + 1] : undefined; };
7
+ const id = value("--id");
8
+ const name = value("--name");
9
+ const output = value("--output");
10
+ if (!id || !/^[a-z0-9][a-z0-9-]*$/.test(id) || !name || !output) throw new Error("Usage: create-adapter.mjs --id <lowercase-id> --name <name> --output <directory>");
11
+ const root = path.resolve(output);
12
+ await mkdir(root, { recursive: true });
13
+ if ((await readdir(root)).length) throw new Error(`Refusing to overwrite non-empty directory: ${root}`);
14
+ await mkdir(path.join(root, "src"));
15
+ await mkdir(path.join(root, "test"));
16
+ const className = id.replace(/(^|-)([a-z])/g, (_match, _dash, letter) => letter.toUpperCase());
17
+ const files = {
18
+ "package.json": JSON.stringify({ name: `agent-live-adapter-${id}`, version: "0.1.0", private: true, type: "module", scripts: { test: "node --test" }, dependencies: { "@iniesta8888/agent-live": "^0.3.0" } }, null, 2) + "\n",
19
+ "src/index.ts": `import { defineAdapter, type OfficeDelta } from "@iniesta8888/agent-live";\n\nexport interface ${className}Host {\n\tsubscribe(listener: (event: unknown) => void): () => void;\n}\n\nfunction mapHostEvent(_event: unknown): OfficeDelta | undefined {\n\t// TODO: implement only mappings supported by official host evidence.\n\treturn undefined;\n}\n\nexport default defineAdapter<${className}Host>({\n\tid: "${id}",\n\tname: ${JSON.stringify(name)},\n\tconnect({ host, office }) {\n\t\treturn host.subscribe((event) => {\n\t\t\tconst mapped = mapHostEvent(event);\n\t\t\tif (mapped) office.publish(mapped);\n\t\t});\n\t},\n});\n`,
20
+ "test/adapter.test.ts": `import test from "node:test";\nimport assert from "node:assert/strict";\nimport adapter from "../src/index.ts";\n\ntest("adapter identity", () => {\n\tassert.equal(adapter.id, "${id}");\n});\n`,
21
+ "HOST-CAPABILITIES.md": `# ${name} capabilities\n\nTODO: Record official sources, versions, supported and unsupported capabilities before implementation.\n`,
22
+ "EVENT-MAPPING.md": `# ${name} event mapping\n\n| Official event | Source | Fields and IDs | Delivery | OfficeDelta | Degradation |\n| --- | --- | --- | --- | --- | --- |\n| TODO | TODO | TODO | TODO | TODO | TODO |\n`,
23
+ "README.md": `# Agent Live adapter for ${name}\n\nDevelop against the public Agent Live Adapter SDK manual. Do not import Agent Live repository internals.\n`,
24
+ };
25
+ for (const [relative, content] of Object.entries(files)) await writeFile(path.join(root, relative), content, "utf8");
26
+ console.log(root);