@agentic-canvas/core 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ Agentic Creative Canvas (ACC)
2
+ Copyright 2026 ACC contributors.
3
+
4
+ ACC-authored code is licensed under the Apache License, Version 2.0.
5
+ Third-party code, fonts and other assets retain their original licenses.
6
+ The ACC license does not replace or remove those third-party terms.
7
+
8
+ The grida-adapter package includes third-party source provenance, license
9
+ texts and modification records under dist/third-party/, plus font and
10
+ WASM license texts alongside dist/native-ui-public/ assets.
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # @agentic-canvas/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 公共类型、查询/命令/事件契约与后端协议。
4
+
5
+ 不依赖 React 或 Grida,不创建另一套可写 Canvas Document。公共对象视图与快照是权威状态的投影。
6
+
7
+ ## 当前公共契约
8
+
9
+ `src/index.ts` 导出对象视图、快照、对象 / 层级 / 场景几何查询、命令、事务结果、事件和 CanvasSDK 接口,以及纯校验与过滤函数。实现中没有 Document、Store、历史栈或独立可写几何,不依赖 React、Grida、Demo 或模型服务。
10
+
11
+ - `validateObject(unknown)` 检查结构、有限几何数值、正尺寸与 JSON 可保存的扩展属性。未知非空对象类型允许保存;实际编辑能力由后端判断。
12
+ - `validateExecuteRequest(unknown)` 检查事务结构;对象存在性、原子提交、revision、幂等与历史由适配器验证和执行。
13
+ - `validateQueryObjectsInput(unknown)` / `validateQueryHierarchyInput(unknown)` / `validateQueryGeometryInput(unknown)` 检查严格 JSON 查询参数。
14
+ - `filterObjects(objects, input?, hierarchy?)` 在源顺序上按 AND 组合条件,所有标签均须匹配;关系条件要求传入从权威文档派生的 hierarchy map,缺少上下文明确 UNSUPPORTED。返回新数组,对象引用不变。
15
+ - `CanvasQueryError extends TypeError` 区分 `VALIDATION_ERROR` / `UNSUPPORTED`,可带冻结复制的 `objectIds`;错误本身不带成功观察的 documentId / revision。该类型用于只读查询,不代替命令结果或表示未知写入结果。
16
+
17
+ `CanvasTransform` 是以像素为单位的 authored frame 投影,缺失后端字段可能使用默认值;旋转单位是度,具体原生 pivot 由后端 geometry 规则决定。它不求值嵌套 / 自动布局,不无条件等于世界几何。纯 `filterObjects` 只计算所给平面外框按中心旋转后的 AABB,相交接触边缘算命中;真正 world bounds 的支持性必须由后端在应用空间条件前核对,core 不持有原生布局求值器。
18
+
19
+ 当前 Grida backend 先执行非空间条件,再复用独立 evaluator 检查 bounds 候选:支持选定 scene 内的已知 absolute 链、container / tray 与 raw / fallback group;任一候选 unresolved 整次 CanvasQueryError UNSUPPORTED / candidate objectIds,不返回部分成功。string sceneId 选择其 scene 空间,否则默认 entry;空 group null 不命中。纯 core 不含原生求值器,精确 gate 见 ADR 0012。
20
+
21
+ `props` 必须由普通对象、数组及 JSON 标量组成;拒绝循环引用、稀疏数组、访问器、非有限数及会在 JSON 保存时丢失的数据。没有自动分配 ID 的工厂函数,宿主负责显式提供稳定身份。
22
+
23
+ ## 只读空间层级
24
+
25
+ `CanvasSDK.queryHierarchy?(input?)` 是可选后端能力,两个 Grida backend 已实现。输入 nodeId 与 self / children / descendants / ancestors;空输入读取全部原生节点。结果包含 documentId / revision / entrySceneId / 原 refs 顺序 sceneIds / nodes / missingIds;节点含 kind / parentId / 完整 childIds / sceneId / siblingIndex,不复制几何或 props。Grida 返回的节点和数组冻结、与 Document 分离,关系仍由唯一 Document 派生。
26
+
27
+ `QueryObjectsInput` 增加 parentId / ancestorId / sceneId,与其他条件按 AND 组合;使用关系过滤时结果含 missingHierarchyIds。缺失 ID 返回空对象与诊断,已有非 scene 用作 sceneId 则验证失败。CanvasObject / patch 没有 parentId / childIds 写字段;来源引用不改变空间父子。
28
+
29
+ ## 独立只读几何
30
+
31
+ `queryGeometry?({ ids?, sceneId? })` 在两个 Grida backend 已实现。`Affine2D` 是列向量约定的 readonly 2×3;结果包含 documentId / revision / scene space / entries / missingIds。resolved 项的 source 为 authored-absolute(作者绝对坐标)或 native-layout(宿主原生布局引擎对同一 Document 的实测,只读),含 frame / group-union、localToWorld 和 AABB;unresolved 项含 reason 与非空、去重的代表性 blockingIds,不保证穷尽坏后代。空 group AABB=null,finite singular 允许前向零轴 AABB,不承诺逆矩阵 / hit / PNG。
32
+
33
+ 省略 IDs 读取选定 scene 的非 scene 节点,ids=[] 返回空;请求 IDs 去重、entries 保持稳定文档次序,missing 保持请求去重次序。显式 scene selector 非法抛 VALIDATION_ERROR;显式 scene 节点 unsupported-node,其他 scene / orphan outside-scene。Grida 返回整体及嵌套 DTO 冻结,与 Document 分离,不写回 CanvasObject / patch。source 不等于 native-layout,frame / union 不含 clipping / stroke / shadow extent。
34
+
35
+ 更新命令中,transform 按字段合并,tags 整体替换,assetRef 整体替换且 null 移除引用;props 浅合并,空对象不清空。只写 authored 字段,不能复制 computed matrix / AABB 代替原输入。
36
+
37
+ ## 显式结构命令
38
+
39
+ `CanvasHierarchyCommand` 将 group.create / group.ungroup / object.reparent / object.reorder 并入 CanvasCommand;不向 CanvasObject / patch 增加 parent / children 写字段。core 仅校验严格参数和类型,不持有原生树、planner 或 world 状态。reparent 必须 preserveWorld:true;index 为移除来源后的安全整数,group / block 顺序和能力由后端执行前验证。专用 native 结构角色不把 group 的旧 scalar CRUD 自动设为可用。
40
+
41
+ 当前 Grida 首切片包含共享事务 / flags / 结构事件和真实网络专项;结构冻结快照60文件 / 576项、类型检查、构建 / 产物 smoke与限定 mock 浏览器任务通过,见 [ADR 0013](../../docs/decisions/0013-hierarchy-editing.md)、[指南](../../docs/examples/hierarchy-editing.md)和 [报告](../../docs/poc/hierarchy-editing-report.md)。非连续分组可改变遮挡,relative reorder 可 reflow;完整自动布局 / native computed、任意 affine / 跨 scene、专业嵌套 UI 与 F01 / F03 / F07 / M0 / M1 仍开放。
42
+
43
+ 纯函数测试不代替后端、网络或浏览器验收。几何阶段证据 / 最终计数见 [报告](../../docs/poc/world-geometry-report.md),契约与用法见 [ADR 0012](../../docs/decisions/0012-world-geometry.md) / [指南](../../docs/examples/world-geometry.md)。模块边界见 [项目结构](../../docs/project-structure.md),需求见 [当前 PRD](../../docs/product/requirements.md)。
44
+
45
+ ## 实验视图与人工手势协议
46
+
47
+ `CanvasSurfaceBinding`、`CanvasSurfaceRenderer`、`SurfaceGesture(Request)` 及视口 / 状态 / 框选候选类型已按 [ADR 0030](../../docs/decisions/0030-retire-self-built-interactions.md) 从 core 移除:它们只服务已退役的自研画布组件。画布 UI 改用 `@agentic-canvas/grida-adapter/native-ui`,人工编辑经原生控制器提交公开命令;受控的原生人工事务类型 `NativeGesture` 现在由 grida-adapter 的 experimental 入口定义。场景坐标的公开平移 `CanvasSceneCommand.object.translate` 见 [ADR 0015](../../docs/decisions/0015-public-scene-translation.md),七工具不变。以下各节中关于 Surface 手势的段落是阶段记录。
48
+
49
+ ## 显式安全子树删除
50
+
51
+ `CanvasSubtreeDeleteCommand` 增加严格的 `{ type: "object.deleteSubtree", objectIds: string[] }`,并入CanvasCommand;core只校验非空唯一根等JSON结构,不存树或闭包。后端按当前草稿完整逐节点检查后原子删除,允许明确跨scene / orphan根,保留空祖先 / 资源表 / 幸存引用,不依赖world bounds或transform能力。旧object.delete与native / keyboard范围不由此扩大。
52
+
53
+ ADR0016冻结75文件 / 926项、类型检查、构建 / dist及限定MOCK浏览器通过,见 [决策](../../docs/decisions/0016-explicit-subtree-deletion.md)、[指南](../../docs/examples/subtree-deletion.md)与 [报告](../../docs/poc/subtree-delete-report.md)。后续 [ADR0017](../../docs/decisions/0017-opt-in-surface-subtree-deletion.md)可选Surface交互独立实施验收,不计入该历史快照。
54
+
55
+ ## 可选Surface子树手势
56
+
57
+ 原 `SurfaceGesture.deleteSubtree` 随 core 的 surface 协议一并移除(ADR 0030);子树删除的公开命令见上一节。阶段记录见 [ADR0017](../../docs/decisions/0017-opt-in-surface-subtree-deletion.md)。
58
+
59
+ ## 固定局部角的叶节点缩放手势
60
+
61
+ 原 `SurfaceGesture.resizeAnchored` 随 core 的 surface 协议一并移除(ADR 0030);固定角尺寸使用下一节的公开 `object.resize` 命令。阶段记录见 [ADR0018](../../docs/decisions/0018-anchored-leaf-resize.md)。
62
+
63
+ ## 公开固定角尺寸命令
64
+
65
+ `CanvasResizeCommand`并入`CanvasCommand`:`{type:"object.resize",objectId,width,height,anchor:"top-left"}`。目标是node-local正有限绝对宽高,固定local(0,0),不是world AABB或旧authored frame patch;public不施加pointer最小10。core只定义 / 校验JSON,backend按strict planner证明完整候选,不新增可写文档。七工具、execute十分支。
66
+
67
+ 两backend public与human共享事务 / revision / 幂等 / 实际diff / History;mixed noop及先改后还原的目标可能不在affectedIds中,确认不能强求请求ID覆盖。冻结83文件 / 1254项、构建 / dist及77个MOCK状态通过,见 [ADR0019](../../docs/decisions/0019-public-anchored-resize.md)、[指南](../../docs/examples/public-anchored-resize.md)与 [报告](../../docs/poc/public-anchored-resize-report.md)。1075人工阶段不倒写,容器 / 任意affine / 完整输入和性能仍开放。
68
+
69
+ ## 显式会话框选的中性边界
70
+
71
+ `CanvasSurfaceBinding.getMarqueeCandidates()` 与 `SurfaceMarqueeCandidates` 已移除(ADR 0030);框选由原生 UI 完成,选择只是会话状态,不产生 revision、事件或历史。阶段记录见 [ADR0020](../../docs/decisions/0020-opt-in-marquee-selection.md)。
72
+
73
+ ## 对象外框吸附后续切片
74
+
75
+ [ADR0021对象外框吸附](../../docs/decisions/0021-opt-in-object-snapping.md)在React使用既有中性候选和translate,不增加core DTO、命令、Runtime工具或可写状态。89文件 / 1422项与65个MOCK状态的独立范围见 [报告](../../docs/poc/object-snapping-report.md);阈值 / UI与数值proof不改变SDK的权限、事务或History。旧1328 / 54固定,完整F07仍开放。
76
+
77
+ ## 原生容器尺寸独立版本(限定通过)
78
+
79
+ [ADR0022](../../docs/decisions/0022-anchored-container-resize.md)复用既有CanvasResizeCommand / resizeAnchored,core DTO、七工具 / 十命令均不增加;native role和完整子树尺寸proof归adapter。独立版本93文件 / 1528项、生产及71个MOCK状态限定通过,见 [报告](../../docs/poc/anchored-container-resize-report.md)。用户选择保留原页,不执行canonical同步;完整F07 / M0 / M1仍开放。