@atom-workflow-agent/atom-sdk 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 (44) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +44 -0
  3. package/README.zh-CN.md +44 -0
  4. package/dist/atoms/agent-runtime.d.ts +17 -0
  5. package/dist/atoms/agent-runtime.d.ts.map +1 -0
  6. package/dist/atoms/agent-runtime.js +2 -0
  7. package/dist/atoms/agent-runtime.js.map +1 -0
  8. package/dist/atoms/atom-definition.d.ts +44 -0
  9. package/dist/atoms/atom-definition.d.ts.map +1 -0
  10. package/dist/atoms/atom-definition.js +171 -0
  11. package/dist/atoms/atom-definition.js.map +1 -0
  12. package/dist/atoms/atom-execution-error.d.ts +21 -0
  13. package/dist/atoms/atom-execution-error.d.ts.map +1 -0
  14. package/dist/atoms/atom-execution-error.js +27 -0
  15. package/dist/atoms/atom-execution-error.js.map +1 -0
  16. package/dist/atoms/atom-package.d.ts +18 -0
  17. package/dist/atoms/atom-package.d.ts.map +1 -0
  18. package/dist/atoms/atom-package.js +22 -0
  19. package/dist/atoms/atom-package.js.map +1 -0
  20. package/dist/atoms/context.d.ts +115 -0
  21. package/dist/atoms/context.d.ts.map +1 -0
  22. package/dist/atoms/context.js +55 -0
  23. package/dist/atoms/context.js.map +1 -0
  24. package/dist/atoms/schema.d.ts +6 -0
  25. package/dist/atoms/schema.d.ts.map +1 -0
  26. package/dist/atoms/schema.js +14 -0
  27. package/dist/atoms/schema.js.map +1 -0
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +6 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/testing/fake-atoms.d.ts +9 -0
  33. package/dist/testing/fake-atoms.d.ts.map +1 -0
  34. package/dist/testing/fake-atoms.js +50 -0
  35. package/dist/testing/fake-atoms.js.map +1 -0
  36. package/dist/testing/index.d.ts +3 -0
  37. package/dist/testing/index.d.ts.map +1 -0
  38. package/dist/testing/index.js +3 -0
  39. package/dist/testing/index.js.map +1 -0
  40. package/dist/testing/schema-descriptions.d.ts +4 -0
  41. package/dist/testing/schema-descriptions.d.ts.map +1 -0
  42. package/dist/testing/schema-descriptions.js +37 -0
  43. package/dist/testing/schema-descriptions.js.map +1 -0
  44. package/package.json +53 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @atom-workflow-agent/atom-sdk
2
+
3
+ [English](README.md) | [简体中文](README.zh-CN.md)
4
+
5
+ The public TypeScript authoring API for lifecycle-based Atoms and Atom Packages.
6
+
7
+ ```bash
8
+ npm install @atom-workflow-agent/atom-sdk zod
9
+ ```
10
+
11
+ ## Responsibilities
12
+
13
+ - Defines Atoms from Zod or JSON Schema input/output contracts.
14
+ - Provides execution context, artifacts, suspension helpers, and AtomExecutionError.
15
+ - Derives stable user, planner, and runtime projections from one authoring definition.
16
+
17
+ ## Boundaries
18
+
19
+ - Does not discover packages, schedule workflows, inject model clients, or wrap browser/filesystem access.
20
+ - Model-backed Atoms import `@atom-workflow-agent/acp-sdk` or another model SDK as an ordinary dependency.
21
+ - Worker isolation is not a permission sandbox.
22
+
23
+ ## Main entry points
24
+
25
+ | Entry point | Purpose |
26
+ | --- | --- |
27
+ | `defineAtom` | derives Manifest, catalog, and runtime contracts from one authoring definition |
28
+ | `defineAtomPackage` | groups one or more independent Atoms into a discoverable package |
29
+ | `createAtomLifecycleHelpers` | creates `continue`, Signal, and HostTask transitions for a unit-test context |
30
+ | `AtomExecutionError` | represents expected technical failures with a stable code, retry flag, and JSON details |
31
+ | `@atom-workflow-agent/atom-sdk/testing` | test-only helpers such as `createFakeAtom` and `findUndescribedSchemaFields` |
32
+
33
+ Atoms may use Zod or JSON Schema directly. Every named field should carry business meaning in its description. Runtime validates input and terminal output; lifecycle transitions are converted into the durable suspension protocol.
34
+
35
+ See [Authoring Atoms](../../docs/atom-authoring.md) for a minimal implementation, package registration, independent CLI debugging, and tests. See the [example packages](../../examples/atoms/README.md) for browser, model, Signal, and batch-processing cases.
36
+
37
+ ## Development
38
+
39
+ ```bash
40
+ pnpm --filter @atom-workflow-agent/atom-sdk typecheck
41
+ pnpm --filter @atom-workflow-agent/atom-sdk test
42
+ ```
43
+
44
+ See the project [documentation](../../docs/README.md) for shared concepts and complete flows.
@@ -0,0 +1,44 @@
1
+ # @atom-workflow-agent/atom-sdk
2
+
3
+ [English](README.md) | [简体中文](README.zh-CN.md)
4
+
5
+ 面向生命周期 Atom 与 Atom Package 的公开 TypeScript Authoring API。
6
+
7
+ ```bash
8
+ npm install @atom-workflow-agent/atom-sdk zod
9
+ ```
10
+
11
+ ## 职责
12
+
13
+ - 使用 Zod 或 JSON Schema 输入输出契约定义 Atom。
14
+ - 提供执行 Context、Artifact、暂停 helper 与 AtomExecutionError。
15
+ - 从一个 Authoring Definition 派生稳定的用户、Planner 和 Runtime 投影。
16
+
17
+ ## 边界
18
+
19
+ - 不发现 Package、不调度 Workflow,也不注入模型 Client、浏览器或文件系统 wrapper。
20
+ - 需要模型的 Atom 将 `@atom-workflow-agent/acp-sdk` 或其他模型 SDK 作为普通依赖导入。
21
+ - Worker 隔离不是权限沙箱。
22
+
23
+ ## 主要入口
24
+
25
+ | 入口 | 用途 |
26
+ | --- | --- |
27
+ | `defineAtom` | 从一个 Authoring Definition 派生 Manifest、Catalog 与 Runtime 契约 |
28
+ | `defineAtomPackage` | 将一个或多个独立 Atom 组成可发现 Package |
29
+ | `createAtomLifecycleHelpers` | 在单元测试 Context 中构造 `continue`、Signal 和 HostTask transition |
30
+ | `AtomExecutionError` | 表达带稳定错误码、重试属性和 JSON details 的预期技术失败 |
31
+ | `@atom-workflow-agent/atom-sdk/testing` | `createFakeAtom`、`findUndescribedSchemaFields` 等测试专用工具 |
32
+
33
+ Atom 可以直接使用 Zod 或 JSON Schema。每个命名字段都应提供业务描述;Runtime 会校验输入和最终输出,生命周期 transition 则由 Runtime 转换为持久化暂停协议。
34
+
35
+ 最小实现、Package 注册、独立 CLI 调试和测试方式见 [Atom 开发指南](../../docs/atom-authoring.zh-CN.md)。真实浏览器、模型、Signal 和批量处理案例见 [示例 Package](../../examples/atoms/README.zh-CN.md)。
36
+
37
+ ## 开发
38
+
39
+ ```bash
40
+ pnpm --filter @atom-workflow-agent/atom-sdk typecheck
41
+ pnpm --filter @atom-workflow-agent/atom-sdk test
42
+ ```
43
+
44
+ 通用概念与完整流程见项目[中文文档](../../docs/README.zh-CN.md)。
@@ -0,0 +1,17 @@
1
+ import type { AgentAtomCompletion, AgentAtomTask } from "@atom-workflow-agent/contracts";
2
+ export type { AgentAtomCompletion, AgentAtomTask } from "@atom-workflow-agent/contracts";
3
+ export interface AtomAcpTarget {
4
+ readonly providerId: string;
5
+ readonly model?: string;
6
+ readonly cwd: string;
7
+ }
8
+ export interface AtomAcpRunOptions {
9
+ /** Optional per-call target. Runtime policy still validates the provider/model/cwd. */
10
+ readonly target?: Partial<AtomAcpTarget> & Pick<AtomAcpTarget, "providerId">;
11
+ }
12
+ /** Runtime-owned ACP capability available to every Atom. */
13
+ export interface AtomAcpService {
14
+ readonly defaultTarget?: AtomAcpTarget;
15
+ run(task: AgentAtomTask, options?: AtomAcpRunOptions): Promise<AgentAtomCompletion>;
16
+ }
17
+ //# sourceMappingURL=agent-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runtime.d.ts","sourceRoot":"","sources":["../../src/atoms/agent-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEzF,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEzF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,uFAAuF;IACvF,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;CAC9E;AAED,4DAA4D;AAC5D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runtime.js","sourceRoot":"","sources":["../../src/atoms/agent-runtime.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ import { type AtomCachePolicy, type AtomCapability, type AtomManifest, type AtomRetryPolicy, type PlannerAtomDescriptor, type JsonValue, type PlannerCatalogIndexAtomDescriptor } from "@atom-workflow-agent/contracts";
2
+ import type { AtomExecutionContext, AtomInstanceContext, AtomResumeInput, AtomTransition } from "./context.js";
3
+ import { type AtomSchema } from "./schema.js";
4
+ export type MaybePromise<T> = T | Promise<T>;
5
+ export type { AtomSchema } from "./schema.js";
6
+ export interface AtomReliabilityOptions {
7
+ readonly idempotent?: boolean;
8
+ readonly timeoutMs?: number;
9
+ readonly retry?: Partial<AtomRetryPolicy>;
10
+ readonly cache?: Partial<AtomCachePolicy>;
11
+ }
12
+ export interface AtomAuthoringDefinition<TInput, TOutput> {
13
+ readonly id: string;
14
+ /** Omit to inherit the containing Atom Package version. */
15
+ readonly version?: string;
16
+ readonly title?: string;
17
+ readonly description: string;
18
+ readonly status?: "experimental" | "stable" | "deprecated";
19
+ readonly input: AtomSchema<TInput>;
20
+ readonly output: AtomSchema<TOutput>;
21
+ readonly reliability?: AtomReliabilityOptions;
22
+ initialize?(context: AtomInstanceContext): MaybePromise<void>;
23
+ execute(input: TInput, context: AtomExecutionContext): MaybePromise<TOutput | AtomTransition>;
24
+ resume?(input: TInput, resumeInput: AtomResumeInput, context: AtomExecutionContext): MaybePromise<TOutput | AtomTransition>;
25
+ dispose?(context: AtomInstanceContext): MaybePromise<void>;
26
+ }
27
+ /** Runtime-only normalized Atom contract generated by defineAtom(). */
28
+ export interface RuntimeAtomDefinition<TInput = unknown, TOutput = JsonValue> {
29
+ readonly manifest: AtomManifest;
30
+ readonly capability: AtomCapability;
31
+ readonly catalogIndexDescriptor: PlannerCatalogIndexAtomDescriptor;
32
+ readonly plannerDescriptor: PlannerAtomDescriptor;
33
+ readonly inheritsPackageVersion: boolean;
34
+ initialize?(context: AtomInstanceContext): MaybePromise<void>;
35
+ execute(input: TInput, context: AtomExecutionContext): MaybePromise<TOutput | AtomTransition>;
36
+ resume?(input: TInput, resumeInput: AtomResumeInput, context: AtomExecutionContext): MaybePromise<TOutput | AtomTransition>;
37
+ dispose?(context: AtomInstanceContext): MaybePromise<void>;
38
+ }
39
+ export type AtomDefinition<TInput = unknown, TOutput = JsonValue> = RuntimeAtomDefinition<TInput, TOutput>;
40
+ /** The only public Atom authoring entry point. */
41
+ export declare function defineAtom<TInput, TOutput>(authoring: AtomAuthoringDefinition<TInput, TOutput>): RuntimeAtomDefinition<TInput, TOutput>;
42
+ /** @internal Rebinds only definitions that omitted an Atom-level version. */
43
+ export declare function bindAtomPackageVersion<TInput, TOutput>(definition: RuntimeAtomDefinition<TInput, TOutput>, packageVersion: string): RuntimeAtomDefinition<TInput, TOutput>;
44
+ //# sourceMappingURL=atom-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom-definition.d.ts","sourceRoot":"","sources":["../../src/atoms/atom-definition.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,YAA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kDAAkD;AAClD,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAEvI;AAED,6EAA6E;AAC7E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,EACpD,UAAU,EAAE,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,EAClD,cAAc,EAAE,MAAM,GACrB,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAKxC"}
@@ -0,0 +1,171 @@
1
+ import { createHash } from "node:crypto";
2
+ import { AtomCapabilitySchema, AtomManifestSchema, PlannerAtomDescriptorSchema, PlannerCatalogIndexAtomDescriptorSchema, atomKey, } from "@atom-workflow-agent/contracts";
3
+ import { atomSchemaToJsonSchema, parseAtomSchema } from "./schema.js";
4
+ const DEFAULT_RETRY = Object.freeze({
5
+ maxAttempts: 1,
6
+ strategy: "fixed",
7
+ baseDelayMs: 0,
8
+ maxDelayMs: 0,
9
+ jitter: false,
10
+ });
11
+ const DEFAULT_CACHE = Object.freeze({ enabled: false });
12
+ function canonicalize(value) {
13
+ if (Array.isArray(value))
14
+ return value.map(canonicalize);
15
+ if (value !== null && typeof value === "object") {
16
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, canonicalize(nested)]));
17
+ }
18
+ return value;
19
+ }
20
+ function projectionHash(value) {
21
+ return `sha256:${createHash("sha256").update(JSON.stringify(canonicalize(value))).digest("hex")}`;
22
+ }
23
+ const CATALOG_FIELD_TYPES = [
24
+ "null", "boolean", "object", "array", "number", "integer", "string",
25
+ ];
26
+ const CATALOG_FIELD_TYPE_SET = new Set(CATALOG_FIELD_TYPES);
27
+ function jsonValueType(value) {
28
+ if (value === null)
29
+ return "null";
30
+ if (Array.isArray(value))
31
+ return "array";
32
+ if (typeof value === "boolean")
33
+ return "boolean";
34
+ if (typeof value === "number")
35
+ return Number.isInteger(value) ? "integer" : "number";
36
+ if (typeof value === "string")
37
+ return "string";
38
+ if (typeof value === "object")
39
+ return "object";
40
+ return undefined;
41
+ }
42
+ function schemaFieldTypes(schema) {
43
+ if (schema === null || typeof schema !== "object" || Array.isArray(schema))
44
+ return [...CATALOG_FIELD_TYPES];
45
+ const candidate = schema;
46
+ const explicit = (Array.isArray(candidate.type) ? candidate.type : [candidate.type])
47
+ .filter((value) => typeof value === "string" && CATALOG_FIELD_TYPE_SET.has(value));
48
+ const enumTypes = Array.isArray(candidate.enum)
49
+ ? candidate.enum.flatMap((value) => jsonValueType(value) ?? [])
50
+ : [];
51
+ const constType = "const" in candidate ? jsonValueType(candidate.const) : undefined;
52
+ const alternatives = [candidate.oneOf, candidate.anyOf]
53
+ .flatMap((value) => Array.isArray(value) ? value : [])
54
+ .flatMap(schemaFieldTypes);
55
+ const inferred = [
56
+ ...explicit,
57
+ ...enumTypes,
58
+ ...(constType ? [constType] : []),
59
+ ...alternatives,
60
+ ...(candidate.properties && typeof candidate.properties === "object" ? ["object"] : []),
61
+ ...(candidate.items !== undefined ? ["array"] : []),
62
+ ];
63
+ const unique = new Set(inferred);
64
+ return unique.size > 0 ? CATALOG_FIELD_TYPES.filter((type) => unique.has(type)) : [...CATALOG_FIELD_TYPES];
65
+ }
66
+ function schemaFields(schema) {
67
+ const properties = schema.properties;
68
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
69
+ return properties !== null && typeof properties === "object" && !Array.isArray(properties)
70
+ ? Object.entries(properties).sort(([left], [right]) => left.localeCompare(right)).map(([name, fieldSchema]) => ({
71
+ name,
72
+ description: fieldSchema !== null && typeof fieldSchema === "object" && !Array.isArray(fieldSchema)
73
+ && typeof fieldSchema.description === "string" && fieldSchema.description.trim()
74
+ ? fieldSchema.description
75
+ : `字段 ${name}。`,
76
+ required: required.has(name),
77
+ types: schemaFieldTypes(fieldSchema),
78
+ }))
79
+ : [];
80
+ }
81
+ function normalizeRetry(input) {
82
+ return { ...DEFAULT_RETRY, ...input };
83
+ }
84
+ function normalizeCache(input) {
85
+ return { ...DEFAULT_CACHE, ...input };
86
+ }
87
+ function withHash(value) {
88
+ return { ...value, hash: projectionHash(value) };
89
+ }
90
+ function materialize(authoring, version, inheritsPackageVersion) {
91
+ const inputSchema = atomSchemaToJsonSchema(authoring.input);
92
+ const outputSchema = atomSchemaToJsonSchema(authoring.output);
93
+ const manifest = AtomManifestSchema.parse({
94
+ schemaVersion: "2.0",
95
+ id: authoring.id,
96
+ version,
97
+ title: authoring.title ?? authoring.id,
98
+ description: authoring.description,
99
+ status: authoring.status ?? "experimental",
100
+ inputSchema,
101
+ outputSchema,
102
+ idempotent: authoring.reliability?.idempotent ?? false,
103
+ defaults: {
104
+ ...(authoring.reliability?.timeoutMs !== undefined ? { timeoutMs: authoring.reliability.timeoutMs } : {}),
105
+ retry: normalizeRetry(authoring.reliability?.retry),
106
+ cache: normalizeCache(authoring.reliability?.cache),
107
+ },
108
+ });
109
+ const key = atomKey(manifest);
110
+ const capability = AtomCapabilitySchema.parse(withHash({
111
+ schemaVersion: "1.0",
112
+ key,
113
+ id: manifest.id,
114
+ version: manifest.version,
115
+ title: manifest.title,
116
+ description: manifest.description,
117
+ inputSchema,
118
+ outputSchema,
119
+ }));
120
+ const catalogIndexDescriptor = PlannerCatalogIndexAtomDescriptorSchema.parse(withHash({
121
+ schemaVersion: "1.0",
122
+ key,
123
+ title: manifest.title,
124
+ purpose: manifest.description,
125
+ inputFields: schemaFields(inputSchema),
126
+ outputFields: schemaFields(outputSchema),
127
+ }));
128
+ const plannerDescriptor = PlannerAtomDescriptorSchema.parse(withHash({
129
+ schemaVersion: "1.0",
130
+ key,
131
+ title: manifest.title,
132
+ purpose: manifest.description,
133
+ inputSchema,
134
+ outputSchema,
135
+ }));
136
+ const definition = {
137
+ manifest: Object.freeze(manifest),
138
+ capability: Object.freeze(capability),
139
+ catalogIndexDescriptor: Object.freeze(catalogIndexDescriptor),
140
+ plannerDescriptor: Object.freeze(plannerDescriptor),
141
+ inheritsPackageVersion,
142
+ ...(authoring.initialize ? { initialize: authoring.initialize.bind(authoring) } : {}),
143
+ async execute(input, context) {
144
+ const raw = await authoring.execute(parseAtomSchema(authoring.input, input), context);
145
+ return context.isTransition(raw) ? raw : parseAtomSchema(authoring.output, raw);
146
+ },
147
+ ...(authoring.resume ? {
148
+ async resume(input, resumeInput, context) {
149
+ const raw = await authoring.resume(parseAtomSchema(authoring.input, input), resumeInput, context);
150
+ return context.isTransition(raw) ? raw : parseAtomSchema(authoring.output, raw);
151
+ },
152
+ } : {}),
153
+ ...(authoring.dispose ? { dispose: authoring.dispose.bind(authoring) } : {}),
154
+ };
155
+ Object.defineProperty(definition, "__authoring", { value: authoring, enumerable: false });
156
+ return Object.freeze(definition);
157
+ }
158
+ /** The only public Atom authoring entry point. */
159
+ export function defineAtom(authoring) {
160
+ return materialize(authoring, authoring.version ?? "1.0.0", authoring.version === undefined);
161
+ }
162
+ /** @internal Rebinds only definitions that omitted an Atom-level version. */
163
+ export function bindAtomPackageVersion(definition, packageVersion) {
164
+ if (!definition.inheritsPackageVersion || definition.manifest.version === packageVersion)
165
+ return definition;
166
+ const authoring = definition.__authoring;
167
+ if (!authoring)
168
+ throw new TypeError(`Atom cannot inherit package version: ${definition.manifest.id}`);
169
+ return materialize(authoring, packageVersion, true);
170
+ }
171
+ //# sourceMappingURL=atom-definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom-definition.js","sourceRoot":"","sources":["../../src/atoms/atom-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,2BAA2B,EAC3B,uCAAuC,EACvC,OAAO,GAUR,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AA2CvF,MAAM,aAAa,GAAoB,MAAM,CAAC,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,OAAO,KAAK,cAAc;QAAE,OAAO,UAAU,CAAC;IAC5G,MAAM,SAAS,GAAI,UAAoF,CAAC,WAAW,CAAC;IACpH,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,SAAS,CAAC,wCAAwC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IACtG,OAAO,WAAW,CAAC,SAAS,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { JsonValue } from "@atom-workflow-agent/contracts";
2
+ export interface AtomExecutionErrorOptions {
3
+ /** Runtime may create a new Attempt only when the Atom is also idempotent. */
4
+ readonly retryable?: boolean;
5
+ /** Stable, JSON-only diagnostic context persisted with the Attempt. */
6
+ readonly details?: JsonValue;
7
+ readonly cause?: unknown;
8
+ }
9
+ /**
10
+ * Standard technical failure emitted by Atom implementations.
11
+ * Expected business branches belong in DecisionNode output and frozen edges.
12
+ */
13
+ export declare class AtomExecutionError extends Error {
14
+ readonly code: string;
15
+ readonly name = "AtomExecutionError";
16
+ readonly retryable: boolean;
17
+ readonly details?: JsonValue;
18
+ constructor(code: string, message: string, options?: AtomExecutionErrorOptions);
19
+ }
20
+ export declare function isAtomExecutionError(error: unknown): error is AtomExecutionError;
21
+ //# sourceMappingURL=atom-execution-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom-execution-error.d.ts","sourceRoot":"","sources":["../../src/atoms/atom-execution-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAIhE,MAAM,WAAW,yBAAyB;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAMzC,QAAQ,CAAC,IAAI,EAAE,MAAM;IALvB,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;gBAGlB,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,yBAA8B;CAU1C;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF"}
@@ -0,0 +1,27 @@
1
+ const CODE_PATTERN = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
2
+ /**
3
+ * Standard technical failure emitted by Atom implementations.
4
+ * Expected business branches belong in DecisionNode output and frozen edges.
5
+ */
6
+ export class AtomExecutionError extends Error {
7
+ code;
8
+ name = "AtomExecutionError";
9
+ retryable;
10
+ details;
11
+ constructor(code, message, options = {}) {
12
+ if (!CODE_PATTERN.test(code)) {
13
+ throw new TypeError("AtomExecutionError code must be UPPER_SNAKE_CASE");
14
+ }
15
+ if (!message.trim())
16
+ throw new TypeError("AtomExecutionError message is required");
17
+ super(message, options.cause === undefined ? undefined : { cause: options.cause });
18
+ this.code = code;
19
+ this.retryable = options.retryable ?? false;
20
+ if (options.details !== undefined)
21
+ this.details = options.details;
22
+ }
23
+ }
24
+ export function isAtomExecutionError(error) {
25
+ return error instanceof AtomExecutionError;
26
+ }
27
+ //# sourceMappingURL=atom-execution-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom-execution-error.js","sourceRoot":"","sources":["../../src/atoms/atom-execution-error.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAUvD;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAMhC;IALF,IAAI,GAAG,oBAAoB,CAAC;IAC5B,SAAS,CAAU;IACnB,OAAO,CAAa;IAE7B,YACW,IAAY,EACrB,OAAe,EACf,UAAqC,EAAE;QAEvC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;QACnF,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAR1E,SAAI,GAAJ,IAAI,CAAQ;QASrB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC5C,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACpE,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,YAAY,kBAAkB,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type AtomPackageManifest, type JsonValue } from "@atom-workflow-agent/contracts";
2
+ import { type AtomDefinition } from "./atom-definition.js";
3
+ export interface AtomPackageAuthoringDefinition {
4
+ readonly id: string;
5
+ readonly version: string;
6
+ readonly name?: string;
7
+ readonly description?: string;
8
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
9
+ readonly atoms: readonly AtomDefinition<any, any>[];
10
+ }
11
+ /** Generated package contract consumed by discovery and Registry. */
12
+ export interface AtomPackage {
13
+ readonly manifest: AtomPackageManifest;
14
+ readonly atoms: readonly AtomDefinition<any, any>[];
15
+ }
16
+ /** Defines one discoverable package without a duplicate manifest/factory list. */
17
+ export declare function defineAtomPackage(authoring: AtomPackageAuthoringDefinition): AtomPackage;
18
+ //# sourceMappingURL=atom-package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom-package.d.ts","sourceRoot":"","sources":["../../src/atoms/atom-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEnF,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;CACrD;AAED,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;CACrD;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,8BAA8B,GAAG,WAAW,CAgBxF"}
@@ -0,0 +1,22 @@
1
+ import { AtomPackageManifestSchema, atomKey, } from "@atom-workflow-agent/contracts";
2
+ import { bindAtomPackageVersion } from "./atom-definition.js";
3
+ /** Defines one discoverable package without a duplicate manifest/factory list. */
4
+ export function defineAtomPackage(authoring) {
5
+ if (!Array.isArray(authoring.atoms) || authoring.atoms.length === 0) {
6
+ throw new TypeError("Atom package must contain at least one Atom");
7
+ }
8
+ const atoms = authoring.atoms.map((atom) => bindAtomPackageVersion(atom, authoring.version));
9
+ const keys = atoms.map((atom) => atomKey(atom.manifest));
10
+ if (new Set(keys).size !== keys.length)
11
+ throw new TypeError("Atom package cannot contain duplicate Atom keys");
12
+ const manifest = AtomPackageManifestSchema.parse({
13
+ schemaVersion: "2.0",
14
+ id: authoring.id,
15
+ version: authoring.version,
16
+ name: authoring.name ?? authoring.id,
17
+ description: authoring.description ?? `${authoring.id} Atom package`,
18
+ metadata: authoring.metadata ?? {},
19
+ });
20
+ return Object.freeze({ manifest: Object.freeze(manifest), atoms: Object.freeze(atoms) });
21
+ }
22
+ //# sourceMappingURL=atom-package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom-package.js","sourceRoot":"","sources":["../../src/atoms/atom-package.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,OAAO,GAGR,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAuB,MAAM,sBAAsB,CAAC;AAiBnF,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,SAAyC;IACzE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7F,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzD,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,SAAS,CAAC,iDAAiD,CAAC,CAAC;IAC/G,MAAM,QAAQ,GAAG,yBAAyB,CAAC,KAAK,CAAC;QAC/C,aAAa,EAAE,KAAK;QACpB,EAAE,EAAE,SAAS,CAAC,EAAE;QAChB,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE;QACpC,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,GAAG,SAAS,CAAC,EAAE,eAAe;QACpE,QAAQ,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE;KACnC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,115 @@
1
+ import type { AtomArtifactReference, AtomLifecycleResult, JsonValue } from "@atom-workflow-agent/contracts";
2
+ import { type AtomSchema } from "./schema.js";
3
+ export interface AtomLogger {
4
+ debug(message: string, fields?: Readonly<Record<string, JsonValue>>): void;
5
+ info(message: string, fields?: Readonly<Record<string, JsonValue>>): void;
6
+ warn(message: string, fields?: Readonly<Record<string, JsonValue>>): void;
7
+ error(message: string, fields?: Readonly<Record<string, JsonValue>>): void;
8
+ }
9
+ export interface ManagedAtomResource {
10
+ readonly id: string;
11
+ readonly kind: string;
12
+ readonly recoveryLease?: JsonValue;
13
+ dispose(reason: "completed" | "failed" | "cancelled" | "timeout" | "interrupted" | "unknown_outcome" | "shutdown" | "initialization_failed"): void | Promise<void>;
14
+ }
15
+ export interface AtomInstanceResourceManager {
16
+ readonly scope: "instance";
17
+ register(resource: ManagedAtomResource): void;
18
+ disposeAll(reason: "shutdown" | "initialization_failed"): Promise<void>;
19
+ }
20
+ export interface AttemptResourceManager {
21
+ readonly scope: "attempt";
22
+ register(resource: ManagedAtomResource): void;
23
+ disposeAll(reason: "completed" | "failed" | "cancelled" | "timeout" | "interrupted" | "unknown_outcome"): Promise<void>;
24
+ }
25
+ export interface AtomArtifactService {
26
+ put(input: {
27
+ kind: string;
28
+ data?: JsonValue;
29
+ path?: string;
30
+ metadata?: Readonly<Record<string, JsonValue>>;
31
+ }): Promise<AtomArtifactReference>;
32
+ get(id: string): Promise<AtomArtifactReference | undefined>;
33
+ }
34
+ /** Worker-lifecycle hooks are deliberately detached from a Workflow Run or ACP target. */
35
+ export interface AtomInstanceContext {
36
+ cwd: string;
37
+ logger: AtomLogger;
38
+ resources: AtomInstanceResourceManager;
39
+ metadata: Readonly<Record<string, JsonValue>>;
40
+ }
41
+ export type AtomResumeInput = {
42
+ readonly type: "timer";
43
+ readonly checkpoint: JsonValue;
44
+ } | {
45
+ readonly type: "signal";
46
+ readonly value: JsonValue;
47
+ readonly checkpoint: JsonValue;
48
+ } | {
49
+ readonly type: "host";
50
+ readonly value: JsonValue;
51
+ readonly artifacts: readonly AtomArtifactReference[];
52
+ readonly summary: string;
53
+ readonly checkpoint: JsonValue;
54
+ };
55
+ export declare const ATOM_TRANSITION: unique symbol;
56
+ /** Branded in-process suspension value; Runtime converts it to its durable protocol. */
57
+ export interface AtomTransition {
58
+ readonly [ATOM_TRANSITION]: true;
59
+ readonly result: AtomLifecycleResult<JsonValue, JsonValue>;
60
+ }
61
+ export interface AtomContinueInput {
62
+ readonly checkpoint?: JsonValue;
63
+ readonly afterMs?: number;
64
+ }
65
+ export interface AtomSignalWaitInput<TResponse = JsonValue> {
66
+ readonly key: string;
67
+ readonly prompt: string;
68
+ /** Business context the Host may show while collecting the response. */
69
+ readonly context?: JsonValue;
70
+ readonly response: AtomSchema<TResponse>;
71
+ readonly checkpoint?: JsonValue;
72
+ readonly expiresInMs?: number;
73
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
74
+ }
75
+ export interface AtomHostWaitInput<TResponse = JsonValue> {
76
+ readonly instruction: string;
77
+ readonly context?: JsonValue;
78
+ readonly artifacts?: readonly AtomArtifactReference[];
79
+ /** Defaults to the Atom output contract; use for an intermediate Host decision. */
80
+ readonly response?: AtomSchema<TResponse>;
81
+ readonly checkpoint?: JsonValue;
82
+ readonly expiresInMs?: number;
83
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
84
+ }
85
+ export interface AtomLifecycleHelpers {
86
+ continue(input?: AtomContinueInput): AtomTransition;
87
+ waitForSignal<TResponse = JsonValue>(input: AtomSignalWaitInput<TResponse>): AtomTransition;
88
+ waitForHost<TResponse = JsonValue>(input: AtomHostWaitInput<TResponse>): AtomTransition;
89
+ isTransition(value: unknown): value is AtomTransition;
90
+ }
91
+ export interface AtomRuntimeContext {
92
+ readonly runId: string;
93
+ readonly workflowRevisionId: string;
94
+ readonly nodeId: string;
95
+ readonly attemptId: string;
96
+ readonly attempt: number;
97
+ readonly cwd: string;
98
+ }
99
+ /** Runtime-owned context shared by every Atom execute/resume call. */
100
+ export interface AtomExecutionContext extends AtomLifecycleHelpers {
101
+ readonly runtime: AtomRuntimeContext;
102
+ readonly cwd: string;
103
+ readonly signal: AbortSignal;
104
+ readonly artifacts: AtomArtifactService;
105
+ readonly resources: AttemptResourceManager;
106
+ readonly logger: AtomLogger;
107
+ readonly metadata: Readonly<Record<string, JsonValue>>;
108
+ /** Present only for a DecisionNode; branch ids come from the frozen WorkflowIR. */
109
+ readonly decision?: {
110
+ readonly branches: readonly string[];
111
+ };
112
+ }
113
+ export declare function isAtomTransition(value: unknown): value is AtomTransition;
114
+ export declare function createAtomLifecycleHelpers(): AtomLifecycleHelpers;
115
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/atoms/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,SAAS,EACV,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,OAAO,EAAE,M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AQ,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CAC9D;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,wBAAgB,0BAA0B,IAAI,oBAAoB,CA6CjE"}
@@ -0,0 +1,55 @@
1
+ import { atomSchemaToJsonSchema } from "./schema.js";
2
+ export const ATOM_TRANSITION = Symbol("atom-workflow-agent.transition");
3
+ function transition(result) {
4
+ return Object.freeze({ [ATOM_TRANSITION]: true, result });
5
+ }
6
+ export function isAtomTransition(value) {
7
+ return typeof value === "object" && value !== null && value[ATOM_TRANSITION] === true;
8
+ }
9
+ export function createAtomLifecycleHelpers() {
10
+ return Object.freeze({
11
+ continue(input = {}) {
12
+ return transition({
13
+ schemaVersion: "1.0",
14
+ status: "running",
15
+ checkpoint: input.checkpoint ?? null,
16
+ ...(input.afterMs !== undefined ? { nextPollAfterMs: input.afterMs } : {}),
17
+ });
18
+ },
19
+ waitForSignal(input) {
20
+ return transition({
21
+ schemaVersion: "1.0",
22
+ status: "awaiting_signal",
23
+ checkpoint: input.checkpoint ?? null,
24
+ signal: {
25
+ schemaVersion: "1.0",
26
+ key: input.key,
27
+ prompt: input.prompt,
28
+ context: input.context ?? {},
29
+ responseSchema: atomSchemaToJsonSchema(input.response),
30
+ ...(input.expiresInMs !== undefined ? { expiresInMs: input.expiresInMs } : {}),
31
+ ...(input.metadata ? { metadata: input.metadata } : {}),
32
+ },
33
+ });
34
+ },
35
+ waitForHost(input) {
36
+ return transition({
37
+ schemaVersion: "1.0",
38
+ status: "awaiting_host",
39
+ checkpoint: input.checkpoint ?? null,
40
+ task: {
41
+ schemaVersion: "1.0",
42
+ instruction: input.instruction,
43
+ context: input.context ?? {},
44
+ artifacts: [...(input.artifacts ?? [])],
45
+ ...(input.response ? { responseSchema: atomSchemaToJsonSchema(input.response) } : {}),
46
+ requireSameProject: true,
47
+ ...(input.expiresInMs !== undefined ? { expiresInMs: input.expiresInMs } : {}),
48
+ metadata: { ...(input.metadata ?? {}) },
49
+ },
50
+ });
51
+ },
52
+ isTransition: isAtomTransition,
53
+ });
54
+ }
55
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/atoms/context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAmB,MAAM,aAAa,CAAC;AA2DtE,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAgExE,SAAS,UAAU,CAAC,MAAiD;IACnE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,IAAa,EAAE,MAAM,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAiC,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;AACrH,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,QAAQ,CAAC,QAA2B,EAAE;YACpC,OAAO,UAAU,CAAC;gBAChB,aAAa,EAAE,KAAK;gBACpB,MAAM,EAAE,SAAS;gBACjB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;gBACpC,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3E,CAAC,CAAC;QACL,CAAC;QACD,aAAa,CAAwB,KAAqC;YACxE,OAAO,UAAU,CAAC;gBAChB,aAAa,EAAE,KAAK;gBACpB,MAAM,EAAE,iBAAiB;gBACzB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;gBACpC,MAAM,EAAE;oBACN,aAAa,EAAE,KAAK;oBACpB,GAAG,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,EAAE;iBACxC;aACF,CAAC,CAAC;QACL,CAAC;QACD,YAAY,EAAE,gBAAgB;KAC/B,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ import { type JsonSchema } from "@atom-workflow-agent/contracts";
3
+ export type AtomSchema<T> = z.ZodType<T> | JsonSchema;
4
+ export declare function atomSchemaToJsonSchema<T>(schema: AtomSchema<T>): JsonSchema;
5
+ export declare function parseAtomSchema<T>(schema: AtomSchema<T>, value: unknown): T;
6
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/atoms/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEnF,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;AAMtD,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAG3E;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAE3E"}
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { JsonSchemaSchema } from "@atom-workflow-agent/contracts";
3
+ function isZodSchema(schema) {
4
+ return typeof schema.safeParse === "function";
5
+ }
6
+ export function atomSchemaToJsonSchema(schema) {
7
+ if (!isZodSchema(schema))
8
+ return JsonSchemaSchema.parse(schema);
9
+ return JsonSchemaSchema.parse(z.toJSONSchema(schema));
10
+ }
11
+ export function parseAtomSchema(schema, value) {
12
+ return isZodSchema(schema) ? schema.parse(value) : value;
13
+ }
14
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/atoms/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gCAAgC,CAAC;AAInF,SAAS,WAAW,CAAI,MAAqB;IAC3C,OAAO,OAAQ,MAAkC,CAAC,SAAS,KAAK,UAAU,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAI,MAAqB;IAC7D,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChE,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAY,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,eAAe,CAAI,MAAqB,EAAE,KAAc;IACtE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAU,CAAC;AAChE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./atoms/atom-definition.js";
2
+ export * from "./atoms/schema.js";
3
+ export * from "./atoms/context.js";
4
+ export * from "./atoms/atom-execution-error.js";
5
+ export * from "./atoms/atom-package.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./atoms/atom-definition.js";
2
+ export * from "./atoms/schema.js";
3
+ export * from "./atoms/context.js";
4
+ export * from "./atoms/atom-execution-error.js";
5
+ export * from "./atoms/atom-package.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { JsonValue } from "@atom-workflow-agent/contracts";
2
+ import { type AtomDefinition } from "../atoms/atom-definition.js";
3
+ export declare function createFakeAtom<T extends Record<string, JsonValue> = Record<string, JsonValue>>(id?: string): AtomDefinition<T, T>;
4
+ export declare function createFakeHostHandoffAtom(id?: string): AtomDefinition<{
5
+ instruction: string;
6
+ }, {
7
+ summary: string;
8
+ }>;
9
+ //# sourceMappingURL=fake-atoms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-atoms.d.ts","sourceRoot":"","sources":["../../src/testing/fake-atoms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI9E,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC5F,EAAE,SAAiB,GAClB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAYtB;AAED,wBAAgB,yBAAyB,CACvC,EAAE,SAAsB,GACvB,cAAc,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAgC9D"}
@@ -0,0 +1,50 @@
1
+ import { AtomExecutionError } from "../atoms/atom-execution-error.js";
2
+ import { defineAtom } from "../atoms/atom-definition.js";
3
+ const objectSchema = { type: "object", additionalProperties: true };
4
+ export function createFakeAtom(id = "fixture.echo") {
5
+ return defineAtom({
6
+ id,
7
+ version: "1.0.0",
8
+ title: "Fake echo Atom",
9
+ description: "Echoes its input for contract, Registry, Planner, and Runtime tests",
10
+ status: "experimental",
11
+ input: objectSchema,
12
+ output: objectSchema,
13
+ reliability: { idempotent: true, timeoutMs: 1_000 },
14
+ async execute(input) { return input; },
15
+ });
16
+ }
17
+ export function createFakeHostHandoffAtom(id = "fixture.host-task") {
18
+ return defineAtom({
19
+ id,
20
+ version: "1.0.0",
21
+ title: "Fake Host Handoff Atom",
22
+ description: "Pauses for the current Host Model and resumes the same Attempt",
23
+ input: {
24
+ type: "object",
25
+ properties: { instruction: { type: "string" } },
26
+ required: ["instruction"],
27
+ additionalProperties: false,
28
+ },
29
+ output: {
30
+ type: "object",
31
+ properties: { summary: { type: "string" } },
32
+ required: ["summary"],
33
+ additionalProperties: false,
34
+ },
35
+ reliability: { idempotent: true, timeoutMs: 1_000 },
36
+ async execute(input, context) {
37
+ return context.waitForHost({
38
+ instruction: input.instruction,
39
+ checkpoint: { waiting: true },
40
+ });
41
+ },
42
+ async resume(_input, resumeInput) {
43
+ if (resumeInput.type !== "host") {
44
+ throw new AtomExecutionError("HOST_RESUME_REQUIRED", "Host resume is required");
45
+ }
46
+ return resumeInput.value;
47
+ },
48
+ });
49
+ }
50
+ //# sourceMappingURL=fake-atoms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-atoms.js","sourceRoot":"","sources":["../../src/testing/fake-atoms.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAuB,MAAM,6BAA6B,CAAC;AAE9E,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAW,CAAC;AAE7E,MAAM,UAAU,cAAc,CAC5B,EAAE,GAAG,cAAc;IAEnB,OAAO,UAAU,CAAC;QAChB,EAAE;QACF,O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AChC,MAAM,IAAI,kBAAkB,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,CAAC;YAClF,CAAC;YACD,OAAO,WAAW,CAAC,KAA4B,CAAC;QAClD,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./fake-atoms.js";
2
+ export * from "./schema-descriptions.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./fake-atoms.js";
2
+ export * from "./schema-descriptions.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { JsonSchema } from "@atom-workflow-agent/contracts";
2
+ /** Returns named JSON Schema fields that do not explain their business meaning. */
3
+ export declare function findUndescribedSchemaFields(schema: JsonSchema, root?: string): string[];
4
+ //# sourceMappingURL=schema-descriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-descriptions.d.ts","sourceRoot":"","sources":["../../src/testing/schema-descriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,gCAAgC,CAAC;AAQ5E,mFAAmF;AACnF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,SAAM,GAAG,MAAM,EAAE,CAqBpF"}
@@ -0,0 +1,37 @@
1
+ function record(value) {
2
+ return value !== null && typeof value === "object" && !Array.isArray(value)
3
+ ? value
4
+ : undefined;
5
+ }
6
+ /** Returns named JSON Schema fields that do not explain their business meaning. */
7
+ export function findUndescribedSchemaFields(schema, root = "$") {
8
+ const missing = [];
9
+ const visit = (value, path, namedField) => {
10
+ const node = record(value);
11
+ if (!node) {
12
+ if (namedField)
13
+ missing.push(path);
14
+ return;
15
+ }
16
+ if (namedField && (typeof node.description !== "string" || node.description.trim().length === 0))
17
+ missing.push(path);
18
+ const properties = record(node.properties);
19
+ if (properties)
20
+ for (const [name, child] of Object.entries(properties))
21
+ visit(child, `${path}.${name}`, true);
22
+ if (node.items !== undefined)
23
+ visit(node.items, `${path}[]`, false);
24
+ for (const keyword of ["allOf", "anyOf", "oneOf"]) {
25
+ const alternatives = node[keyword];
26
+ if (Array.isArray(alternatives))
27
+ alternatives.forEach((child, index) => visit(child, `${path}.${keyword}[${index}]`, false));
28
+ }
29
+ const definitions = record(node.$defs) ?? record(node.definitions);
30
+ if (definitions)
31
+ for (const [name, child] of Object.entries(definitions))
32
+ visit(child, `${path}.$defs.${name}`, false);
33
+ };
34
+ visit(schema, root, false);
35
+ return missing;
36
+ }
37
+ //# sourceMappingURL=schema-descriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-descriptions.js","sourceRoot":"","sources":["../../src/testing/schema-descriptions.ts"],"names":[],"mappings":"AAEA,SAAS,MAAM,CAAC,KAA4B;IAC1C,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAC,KAAkC;QACpC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,2BAA2B,CAAC,MAAkB,EAAE,IAAI,GAAG,GAAG;IACxE,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,CAAC,KAAgB,EAAE,IAAY,EAAE,UAAmB,EAAQ,EAAE;QAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,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,CAAC;gBAAE,KAAK,CAAC,KAAK,EAAE,GAAG,IAAI,UAAU,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACzH,CAAC,CAAC;IACF,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@atom-workflow-agent/atom-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Authoring API for typed, lifecycle-based atom packages.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/joekbits/atom-workflow-agent.git",
9
+ "directory": "packages/atom-sdk"
10
+ },
11
+ "homepage": "https://github.com/joekbits/atom-workflow-agent/tree/main/packages/atom-sdk#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/joekbits/atom-workflow-agent/issues"
14
+ },
15
+ "keywords": [
16
+ "atom",
17
+ "workflow",
18
+ "sdk",
19
+ "typescript"
20
+ ],
21
+ "type": "module",
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "README.zh-CN.md"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./testing": {
33
+ "types": "./dist/testing/index.d.ts",
34
+ "default": "./dist/testing/index.js"
35
+ }
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "provenance": true
40
+ },
41
+ "engines": {
42
+ "node": ">=22"
43
+ },
44
+ "dependencies": {
45
+ "zod": "^4.0.0",
46
+ "@atom-workflow-agent/contracts": "0.1.0"
47
+ },
48
+ "scripts": {
49
+ "build": "tsc -p tsconfig.json",
50
+ "typecheck": "tsc -p tsconfig.json --noEmit",
51
+ "test": "vitest run"
52
+ }
53
+ }