@atom-workflow-agent/atom-catalog 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 +201 -0
- package/README.md +30 -0
- package/README.zh-CN.md +30 -0
- package/dist/config/atom-discovery-config.d.ts +20 -0
- package/dist/config/atom-discovery-config.d.ts.map +1 -0
- package/dist/config/atom-discovery-config.js +23 -0
- package/dist/config/atom-discovery-config.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/atom-package-loader.d.ts +23 -0
- package/dist/loader/atom-package-loader.d.ts.map +1 -0
- package/dist/loader/atom-package-loader.js +120 -0
- package/dist/loader/atom-package-loader.js.map +1 -0
- package/dist/registry/atom-registry.d.ts +56 -0
- package/dist/registry/atom-registry.d.ts.map +1 -0
- package/dist/registry/atom-registry.js +179 -0
- package/dist/registry/atom-registry.js.map +1 -0
- package/package.json +50 -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,30 @@
|
|
|
1
|
+
# @atom-workflow-agent/atom-catalog
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
The trusted catalog of enabled exact Atom definitions and reloadable module sources.
|
|
6
|
+
|
|
7
|
+
## Responsibilities
|
|
8
|
+
|
|
9
|
+
- Loads explicitly configured packages and project-local modules.
|
|
10
|
+
- Validates packages, exact id@version keys, schemas, projections, and duplicate conflicts.
|
|
11
|
+
- Tracks registered, enabled, draining, and disposed definitions with Attempt leases.
|
|
12
|
+
|
|
13
|
+
## Boundaries
|
|
14
|
+
|
|
15
|
+
- Does not execute lifecycle hooks, plan graphs, or choose branches.
|
|
16
|
+
|
|
17
|
+
## Main entry points
|
|
18
|
+
|
|
19
|
+
- `AtomRegistry`
|
|
20
|
+
- `loadAtomPackages`
|
|
21
|
+
- `loadAtomDiscoveryConfig`
|
|
22
|
+
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm --filter @atom-workflow-agent/atom-catalog typecheck
|
|
27
|
+
pnpm --filter @atom-workflow-agent/atom-catalog test
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See the project [documentation](../../docs/README.md) for shared concepts and complete flows.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @atom-workflow-agent/atom-catalog
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
已启用精确 Atom Definition 与可重载模块来源的可信目录。
|
|
6
|
+
|
|
7
|
+
## 职责
|
|
8
|
+
|
|
9
|
+
- 加载显式配置的 Package 与项目内模块。
|
|
10
|
+
- 校验 Package、精确 id@version、Schema、投影和重复冲突。
|
|
11
|
+
- 通过 Attempt lease 管理 registered、enabled、draining、disposed 状态。
|
|
12
|
+
|
|
13
|
+
## 边界
|
|
14
|
+
|
|
15
|
+
- 不执行生命周期 Hook、不规划图,也不选择分支。
|
|
16
|
+
|
|
17
|
+
## 主要入口
|
|
18
|
+
|
|
19
|
+
- `AtomRegistry`
|
|
20
|
+
- `loadAtomPackages`
|
|
21
|
+
- `loadAtomDiscoveryConfig`
|
|
22
|
+
|
|
23
|
+
## 开发
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm --filter @atom-workflow-agent/atom-catalog typecheck
|
|
27
|
+
pnpm --filter @atom-workflow-agent/atom-catalog test
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
通用概念与完整流程见项目[中文文档](../../docs/README.zh-CN.md)。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AtomSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
kind: z.ZodLiteral<"package">;
|
|
4
|
+
specifier: z.ZodString;
|
|
5
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"module">;
|
|
7
|
+
path: z.ZodString;
|
|
8
|
+
}, z.core.$strict>], "kind">;
|
|
9
|
+
export type AtomSource = z.infer<typeof AtomSourceSchema>;
|
|
10
|
+
export declare const AtomDiscoveryConfigSchema: z.ZodObject<{
|
|
11
|
+
sources: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
|
+
kind: z.ZodLiteral<"package">;
|
|
13
|
+
specifier: z.ZodString;
|
|
14
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
15
|
+
kind: z.ZodLiteral<"module">;
|
|
16
|
+
path: z.ZodString;
|
|
17
|
+
}, z.core.$strict>], "kind">>>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export type AtomDiscoveryConfig = z.infer<typeof AtomDiscoveryConfigSchema>;
|
|
20
|
+
//# sourceMappingURL=atom-discovery-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom-discovery-config.d.ts","sourceRoot":"","sources":["../../src/config/atom-discovery-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,gBAAgB;;;;;;4BAS3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,yBAAyB;;;;;;;;kBASpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const PackageSpecifierSchema = z.string().regex(/^(?:@[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*|[a-z0-9][a-z0-9._-]*)$/i, "Package Atom source must be a package root without a subpath");
|
|
3
|
+
export const AtomSourceSchema = z.discriminatedUnion("kind", [
|
|
4
|
+
z.object({
|
|
5
|
+
kind: z.literal("package"),
|
|
6
|
+
specifier: PackageSpecifierSchema,
|
|
7
|
+
}).strict(),
|
|
8
|
+
z.object({
|
|
9
|
+
kind: z.literal("module"),
|
|
10
|
+
path: z.string().trim().min(1),
|
|
11
|
+
}).strict(),
|
|
12
|
+
]);
|
|
13
|
+
export const AtomDiscoveryConfigSchema = z.object({
|
|
14
|
+
sources: z.array(AtomSourceSchema).default([]),
|
|
15
|
+
}).strict().superRefine((config, context) => {
|
|
16
|
+
const identities = config.sources.map((source) => source.kind === "package"
|
|
17
|
+
? `package:${source.specifier}`
|
|
18
|
+
: `module:${source.path}`);
|
|
19
|
+
if (new Set(identities).size !== identities.length) {
|
|
20
|
+
context.addIssue({ code: "custom", path: ["sources"], message: "Atom sources must be unique" });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=atom-discovery-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom-discovery-config.js","sourceRoot":"","sources":["../../src/config/atom-discovery-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAC7C,yEAAyE,EACzE,8DAA8D,CAC/D,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,kBAAkB,CAAC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cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AtomRegistry } from "../registry/atom-registry.js";
|
|
2
|
+
import { type AtomDiscoveryConfig } from "../config/atom-discovery-config.js";
|
|
3
|
+
interface ImportedAtomModule {
|
|
4
|
+
readonly atomPackage?: unknown;
|
|
5
|
+
readonly default?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface LoadedAtomPackage {
|
|
8
|
+
readonly sourceId: string;
|
|
9
|
+
readonly packageId: string;
|
|
10
|
+
readonly packageVersion: string;
|
|
11
|
+
readonly atomKeys: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface AtomPackageLoaderOptions {
|
|
14
|
+
readonly cwd: string;
|
|
15
|
+
readonly registry: AtomRegistry;
|
|
16
|
+
readonly config?: AtomDiscoveryConfig;
|
|
17
|
+
readonly importModule?: (url: string) => Promise<ImportedAtomModule>;
|
|
18
|
+
readonly resolvePackage?: (specifier: string, cwd: string) => string;
|
|
19
|
+
}
|
|
20
|
+
/** Loads configured Atom packages in two phases, then registers only exact declared Atoms. */
|
|
21
|
+
export declare function loadAtomPackages(options: AtomPackageLoaderOptions): Promise<readonly LoadedAtomPackage[]>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=atom-package-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom-package-loader.d.ts","sourceRoot":"","sources":["../../src/loader/atom-package-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAA6B,KAAK,mBAAmB,EAAmB,MAAM,oCAAoC,CAAC;AAE1H,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AASD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACtE;AA4ED,8FAA8F;AAC9F,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAqC/G"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { realpath } from "node:fs/promises";
|
|
3
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { AtomPackageManifestSchema, AtomWorkflowError, atomKey } from "@atom-workflow-agent/contracts";
|
|
6
|
+
import { AtomRegistry } from "../registry/atom-registry.js";
|
|
7
|
+
import { AtomDiscoveryConfigSchema } from "../config/atom-discovery-config.js";
|
|
8
|
+
function sourceError(code, message, cause) {
|
|
9
|
+
return new AtomWorkflowError(code, message, false, cause === undefined ? undefined : { cause });
|
|
10
|
+
}
|
|
11
|
+
function assertWithinProject(projectRoot, target) {
|
|
12
|
+
const nested = relative(projectRoot, target);
|
|
13
|
+
if (nested === "" || (!nested.startsWith("..") && !isAbsolute(nested)))
|
|
14
|
+
return;
|
|
15
|
+
throw sourceError("ATOM_MODULE_OUTSIDE_PROJECT", `Local Atom module must stay inside the project: ${target}`);
|
|
16
|
+
}
|
|
17
|
+
function normalizePackage(raw, sourceId) {
|
|
18
|
+
if (raw === null || typeof raw !== "object") {
|
|
19
|
+
throw sourceError("ATOM_PACKAGE_EXPORT_INVALID", `Atom source must export atomPackage or default: ${sourceId}`);
|
|
20
|
+
}
|
|
21
|
+
const candidate = raw;
|
|
22
|
+
const parsed = AtomPackageManifestSchema.safeParse(candidate.manifest);
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
throw sourceError("ATOM_PACKAGE_MANIFEST_INVALID", `Atom package manifest is invalid: ${sourceId}`, parsed.error);
|
|
25
|
+
}
|
|
26
|
+
if (!Array.isArray(candidate.atoms)) {
|
|
27
|
+
throw sourceError("ATOM_PACKAGE_ATOMS_MISSING", `Atom package must provide an atoms array: ${sourceId}`);
|
|
28
|
+
}
|
|
29
|
+
return { manifest: parsed.data, atoms: candidate.atoms };
|
|
30
|
+
}
|
|
31
|
+
function verifyAtoms(atoms, sourceId) {
|
|
32
|
+
if (!Array.isArray(atoms) || atoms.length === 0) {
|
|
33
|
+
throw sourceError("ATOM_PACKAGE_EMPTY", `Atom package returned no Atoms: ${sourceId}`);
|
|
34
|
+
}
|
|
35
|
+
const actual = atoms.map((atom) => {
|
|
36
|
+
if (atom === null || typeof atom !== "object" || !("manifest" in atom)) {
|
|
37
|
+
throw sourceError("ATOM_PACKAGE_FACTORY_INVALID", `Atom package returned a non-Atom value: ${sourceId}`);
|
|
38
|
+
}
|
|
39
|
+
const manifest = atom.manifest;
|
|
40
|
+
if (!manifest || typeof manifest.id !== "string" || typeof manifest.version !== "string") {
|
|
41
|
+
throw sourceError("ATOM_PACKAGE_FACTORY_INVALID", `Atom package returned an Atom without an exact id/version: ${sourceId}`);
|
|
42
|
+
}
|
|
43
|
+
return `${manifest.id}@${manifest.version}`;
|
|
44
|
+
}).sort();
|
|
45
|
+
if (new Set(actual).size !== actual.length) {
|
|
46
|
+
throw sourceError("ATOM_PACKAGE_DUPLICATE", `Atom package returned duplicate Atom keys: ${sourceId}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function defaultModuleImport(url) {
|
|
50
|
+
return import(url);
|
|
51
|
+
}
|
|
52
|
+
function defaultPackageResolver(specifier, cwd) {
|
|
53
|
+
const requireFromProject = createRequire(join(cwd, "package.json"));
|
|
54
|
+
return requireFromProject.resolve(specifier);
|
|
55
|
+
}
|
|
56
|
+
async function sourceUrl(source, cwd, resolvePackage) {
|
|
57
|
+
if (source.kind === "package") {
|
|
58
|
+
let entry;
|
|
59
|
+
try {
|
|
60
|
+
entry = resolvePackage(source.specifier, cwd);
|
|
61
|
+
}
|
|
62
|
+
catch (cause) {
|
|
63
|
+
throw sourceError("ATOM_PACKAGE_NOT_FOUND", `Cannot resolve Atom package: ${source.specifier}`, cause);
|
|
64
|
+
}
|
|
65
|
+
return { sourceId: `package:${source.specifier}`, url: pathToFileURL(entry).href };
|
|
66
|
+
}
|
|
67
|
+
const projectRoot = await realpath(cwd);
|
|
68
|
+
const requested = resolve(projectRoot, source.path);
|
|
69
|
+
assertWithinProject(projectRoot, requested);
|
|
70
|
+
let canonical;
|
|
71
|
+
try {
|
|
72
|
+
canonical = await realpath(requested);
|
|
73
|
+
}
|
|
74
|
+
catch (cause) {
|
|
75
|
+
throw sourceError("ATOM_MODULE_NOT_FOUND", `Cannot resolve local Atom module: ${source.path}`, cause);
|
|
76
|
+
}
|
|
77
|
+
assertWithinProject(projectRoot, canonical);
|
|
78
|
+
return { sourceId: `module:${relative(projectRoot, canonical)}`, url: pathToFileURL(canonical).href };
|
|
79
|
+
}
|
|
80
|
+
/** Loads configured Atom packages in two phases, then registers only exact declared Atoms. */
|
|
81
|
+
export async function loadAtomPackages(options) {
|
|
82
|
+
const config = AtomDiscoveryConfigSchema.parse(options.config ?? {});
|
|
83
|
+
const importer = options.importModule ?? defaultModuleImport;
|
|
84
|
+
const resolver = options.resolvePackage ?? defaultPackageResolver;
|
|
85
|
+
const prepared = [];
|
|
86
|
+
for (const source of config.sources) {
|
|
87
|
+
const resolved = await sourceUrl(source, options.cwd, resolver);
|
|
88
|
+
let module;
|
|
89
|
+
try {
|
|
90
|
+
module = await importer(resolved.url);
|
|
91
|
+
}
|
|
92
|
+
catch (cause) {
|
|
93
|
+
throw sourceError("ATOM_MODULE_IMPORT_FAILED", `Failed to import Atom source: ${resolved.sourceId}`, cause);
|
|
94
|
+
}
|
|
95
|
+
const packageDefinition = normalizePackage(module.atomPackage ?? module.default, resolved.sourceId);
|
|
96
|
+
const atoms = packageDefinition.atoms;
|
|
97
|
+
verifyAtoms(atoms, resolved.sourceId);
|
|
98
|
+
prepared.push({ sourceId: resolved.sourceId, moduleUrl: resolved.url, packageDefinition, atoms });
|
|
99
|
+
}
|
|
100
|
+
const packageIds = prepared.map((item) => `${item.packageDefinition.manifest.id}@${item.packageDefinition.manifest.version}`);
|
|
101
|
+
if (new Set(packageIds).size !== packageIds.length) {
|
|
102
|
+
throw sourceError("ATOM_PACKAGE_ID_DUPLICATE", "Multiple Atom sources resolved to the same package id/version");
|
|
103
|
+
}
|
|
104
|
+
const allAtomKeys = prepared.flatMap((item) => item.atoms.map((atom) => atomKey(atom.manifest)));
|
|
105
|
+
if (new Set(allAtomKeys).size !== allAtomKeys.length) {
|
|
106
|
+
throw sourceError("ATOM_SOURCE_DUPLICATE", "Multiple Atom packages export the same exact Atom key");
|
|
107
|
+
}
|
|
108
|
+
for (const item of prepared) {
|
|
109
|
+
for (const atom of item.atoms) {
|
|
110
|
+
await options.registry.register(atom, { kind: "module", sourceId: item.sourceId, moduleUrl: item.moduleUrl });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return prepared.map((item) => ({
|
|
114
|
+
sourceId: item.sourceId,
|
|
115
|
+
packageId: item.packageDefinition.manifest.id,
|
|
116
|
+
packageVersion: item.packageDefinition.manifest.version,
|
|
117
|
+
atomKeys: item.atoms.map((atom) => atomKey(atom.manifest)).sort(),
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=atom-package-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom-package-loader.js","sourceRoot":"","sources":["../../src/loader/atom-package-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAA6C,MAAM,oCAAoC,CAAC;AA6B1H,SAAS,WAAW,CAAC,IAAY,EAAE,OAAe,EAAE,KAAe;IACjE,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAClG,CAAC;AAED,SAAS,mBAAmB,CAAC,WAAmB,EAAE,MAAc;IAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,MAAM,KAAK,EAAE,IAA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annerAtomDescriptor, type PlannerCatalogIndexAtomDescriptor } from "@atom-workflow-agent/contracts";
|
|
2
|
+
import type { AtomDefinition } from "@atom-workflow-agent/atom-sdk";
|
|
3
|
+
type AnyAtomDefinition = AtomDefinition<any, any>;
|
|
4
|
+
/** Exact reloadable module used by process-backed Atom Attempt execution. */
|
|
5
|
+
export interface AtomExecutionSource {
|
|
6
|
+
readonly kind: "module";
|
|
7
|
+
readonly sourceId: string;
|
|
8
|
+
readonly moduleUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AtomRegistryQuery {
|
|
11
|
+
id?: string;
|
|
12
|
+
includeDisabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface AtomRegistryEntry {
|
|
15
|
+
readonly manifest: AtomManifest;
|
|
16
|
+
readonly capability: AtomCapability;
|
|
17
|
+
readonly catalogIndexDescriptor: PlannerCatalogIndexAtomDescriptor;
|
|
18
|
+
readonly plannerDescriptor: PlannerAtomDescriptor;
|
|
19
|
+
readonly state: AtomInstanceState;
|
|
20
|
+
readonly enabled: boolean;
|
|
21
|
+
readonly activeAttempts: number;
|
|
22
|
+
readonly executionSource?: AtomExecutionSource;
|
|
23
|
+
readonly disabledReason?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AtomLease<TInput = any, TOutput = any> {
|
|
26
|
+
readonly definition: AtomDefinition<TInput, TOutput>;
|
|
27
|
+
readonly executionSource?: AtomExecutionSource;
|
|
28
|
+
release(): void;
|
|
29
|
+
}
|
|
30
|
+
export interface AtomRegistryOptions {
|
|
31
|
+
onStateChange?: (event: {
|
|
32
|
+
key: string;
|
|
33
|
+
previous?: AtomInstanceState;
|
|
34
|
+
state: AtomInstanceState;
|
|
35
|
+
}) => void;
|
|
36
|
+
}
|
|
37
|
+
/** Runtime-owned, fail-closed catalog of exact Atom versions. */
|
|
38
|
+
export declare class AtomRegistry {
|
|
39
|
+
private readonly options;
|
|
40
|
+
private readonly atoms;
|
|
41
|
+
constructor(options?: AtomRegistryOptions);
|
|
42
|
+
register<TInput, TOutput>(definition: AtomDefinition<TInput, TOutput>, executionSource?: AtomExecutionSource): Promise<void>;
|
|
43
|
+
has(id: string, version: string): boolean;
|
|
44
|
+
isEnabled(id: string, version: string): boolean;
|
|
45
|
+
get(id: string, version: string): AnyAtomDefinition;
|
|
46
|
+
acquire<TInput = any, TOutput = any>(id: string, version: string): AtomLease<TInput, TOutput>;
|
|
47
|
+
disable(id: string, version: string, reason?: string): Promise<void>;
|
|
48
|
+
disposeAll(reason?: string): Promise<void>;
|
|
49
|
+
list(query?: AtomRegistryQuery): AtomRegistryEntry[];
|
|
50
|
+
private requireEnabled;
|
|
51
|
+
private requireEntry;
|
|
52
|
+
private startDraining;
|
|
53
|
+
private emit;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=atom-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom-registry.d.ts","sourceRoot":"","sources":["../../src/registry/atom-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,iCAAiC,EACvC,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,KAAK,iBAAiB,GAAG,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAYlD,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAAG,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE;AAE7E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CA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AAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAC/C,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAEnD,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAmB7F,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,UAAU,CAAC,MAAM,SAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D,IAAI,CAAC,KAAK,GAAE,iBAAsB,GAAG,iBAAiB,EAAE;IAkBxD,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { AtomCapabilitySchema, AtomManifestSchema, AtomWorkflowError, PlannerAtomDescriptorSchema, PlannerCatalogIndexAtomDescriptorSchema, atomKey, } from "@atom-workflow-agent/contracts";
|
|
2
|
+
function freezeDeep(value) {
|
|
3
|
+
if (value === null || typeof value !== "object" || Object.isFrozen(value))
|
|
4
|
+
return value;
|
|
5
|
+
for (const nested of Object.values(value))
|
|
6
|
+
freezeDeep(nested);
|
|
7
|
+
return Object.freeze(value);
|
|
8
|
+
}
|
|
9
|
+
function invalidAtom(message, cause) {
|
|
10
|
+
return new AtomWorkflowError("INVALID_ATOM", message, false, cause === undefined ? undefined : { cause });
|
|
11
|
+
}
|
|
12
|
+
function validateDefinition(rawDefinition) {
|
|
13
|
+
if (rawDefinition === null || typeof rawDefinition !== "object") {
|
|
14
|
+
throw invalidAtom("Atom Definition must be an object");
|
|
15
|
+
}
|
|
16
|
+
const candidate = rawDefinition;
|
|
17
|
+
const manifestResult = AtomManifestSchema.safeParse(candidate.manifest);
|
|
18
|
+
if (!manifestResult.success)
|
|
19
|
+
throw invalidAtom("Atom Definition has an invalid manifest", manifestResult.error);
|
|
20
|
+
const key = atomKey(manifestResult.data);
|
|
21
|
+
const capabilityResult = AtomCapabilitySchema.safeParse(candidate.capability);
|
|
22
|
+
if (!capabilityResult.success)
|
|
23
|
+
throw invalidAtom(`Atom Definition has an invalid capability: ${key}`, capabilityResult.error);
|
|
24
|
+
const indexResult = PlannerCatalogIndexAtomDescriptorSchema.safeParse(candidate.catalogIndexDescriptor);
|
|
25
|
+
if (!indexResult.success)
|
|
26
|
+
throw invalidAtom(`Atom Definition has an invalid catalog index descriptor: ${key}`, indexResult.error);
|
|
27
|
+
const plannerResult = PlannerAtomDescriptorSchema.safeParse(candidate.plannerDescriptor);
|
|
28
|
+
if (!plannerResult.success)
|
|
29
|
+
throw invalidAtom(`Atom Definition has an invalid Planner descriptor: ${key}`, plannerResult.error);
|
|
30
|
+
for (const [name, descriptorKey] of [
|
|
31
|
+
["capability", capabilityResult.data.key],
|
|
32
|
+
["catalog index descriptor", indexResult.data.key],
|
|
33
|
+
["Planner descriptor", plannerResult.data.key],
|
|
34
|
+
]) {
|
|
35
|
+
if (descriptorKey !== key)
|
|
36
|
+
throw invalidAtom(`Atom ${name} key '${descriptorKey}' does not match manifest key '${key}'`);
|
|
37
|
+
}
|
|
38
|
+
if (typeof candidate.execute !== "function")
|
|
39
|
+
throw invalidAtom(`Atom Definition must provide execute(): ${key}`);
|
|
40
|
+
for (const hook of ["initialize", "resume", "dispose"]) {
|
|
41
|
+
if (candidate[hook] !== undefined && typeof candidate[hook] !== "function") {
|
|
42
|
+
throw invalidAtom(`Atom Definition ${hook} must be a function: ${key}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Object.freeze({
|
|
46
|
+
manifest: freezeDeep(manifestResult.data),
|
|
47
|
+
capability: freezeDeep(capabilityResult.data),
|
|
48
|
+
catalogIndexDescriptor: freezeDeep(indexResult.data),
|
|
49
|
+
plannerDescriptor: freezeDeep(plannerResult.data),
|
|
50
|
+
inheritsPackageVersion: candidate.inheritsPackageVersion === true,
|
|
51
|
+
...(typeof candidate.initialize === "function" ? { initialize: candidate.initialize.bind(rawDefinition) } : {}),
|
|
52
|
+
execute: candidate.execute.bind(rawDefinition),
|
|
53
|
+
...(typeof candidate.resume === "function" ? { resume: candidate.resume.bind(rawDefinition) } : {}),
|
|
54
|
+
...(typeof candidate.dispose === "function" ? { dispose: candidate.dispose.bind(rawDefinition) } : {}),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Runtime-owned, fail-closed catalog of exact Atom versions. */
|
|
58
|
+
export class AtomRegistry {
|
|
59
|
+
options;
|
|
60
|
+
atoms = new Map();
|
|
61
|
+
constructor(options = {}) {
|
|
62
|
+
this.options = options;
|
|
63
|
+
}
|
|
64
|
+
async register(definition, executionSource) {
|
|
65
|
+
const rawManifest = definition.manifest;
|
|
66
|
+
const provisionalKey = rawManifest && typeof rawManifest.id === "string" && typeof rawManifest.version === "string"
|
|
67
|
+
? `${rawManifest.id}@${rawManifest.version}` : "unknown@unknown";
|
|
68
|
+
this.emit(provisionalKey, "discovered");
|
|
69
|
+
this.emit(provisionalKey, "loading", "discovered");
|
|
70
|
+
const validated = validateDefinition(definition);
|
|
71
|
+
const key = atomKey(validated.manifest);
|
|
72
|
+
this.emit(key, "validated", "loading");
|
|
73
|
+
if (this.atoms.has(key))
|
|
74
|
+
throw new AtomWorkflowError("DUPLICATE_ATOM", `Atom already registered: ${key}`);
|
|
75
|
+
const entry = {
|
|
76
|
+
definition: validated,
|
|
77
|
+
...(executionSource ? { executionSource: Object.freeze({ ...executionSource }) } : {}),
|
|
78
|
+
state: "registered",
|
|
79
|
+
activeAttempts: 0,
|
|
80
|
+
};
|
|
81
|
+
this.atoms.set(key, entry);
|
|
82
|
+
this.emit(key, "registered", "validated");
|
|
83
|
+
entry.state = "enabled";
|
|
84
|
+
this.emit(key, "enabled", "registered");
|
|
85
|
+
}
|
|
86
|
+
has(id, version) { return this.atoms.has(atomKey({ id, version })); }
|
|
87
|
+
isEnabled(id, version) { return this.atoms.get(atomKey({ id, version }))?.state === "enabled"; }
|
|
88
|
+
get(id, version) { return this.requireEnabled(id, version).definition; }
|
|
89
|
+
acquire(id, version) {
|
|
90
|
+
const entry = this.requireEnabled(id, version);
|
|
91
|
+
entry.activeAttempts += 1;
|
|
92
|
+
let released = false;
|
|
93
|
+
return {
|
|
94
|
+
definition: entry.definition,
|
|
95
|
+
...(entry.executionSource ? { executionSource: entry.executionSource } : {}),
|
|
96
|
+
release: () => {
|
|
97
|
+
if (released)
|
|
98
|
+
return;
|
|
99
|
+
released = true;
|
|
100
|
+
entry.activeAttempts -= 1;
|
|
101
|
+
if (entry.activeAttempts === 0 && entry.state === "draining") {
|
|
102
|
+
entry.resolveDrained?.();
|
|
103
|
+
delete entry.resolveDrained;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
disable(id, version, reason) {
|
|
109
|
+
const entry = this.requireEntry(id, version);
|
|
110
|
+
const normalizedReason = reason?.trim();
|
|
111
|
+
if (normalizedReason)
|
|
112
|
+
entry.disabledReason = normalizedReason;
|
|
113
|
+
return this.startDraining(atomKey({ id, version }), entry);
|
|
114
|
+
}
|
|
115
|
+
async disposeAll(reason = "runtime shutdown") {
|
|
116
|
+
const results = await Promise.allSettled([...this.atoms.entries()].map(([key, entry]) => {
|
|
117
|
+
if (!entry.disabledReason)
|
|
118
|
+
entry.disabledReason = reason;
|
|
119
|
+
return this.startDraining(key, entry);
|
|
120
|
+
}));
|
|
121
|
+
const failures = results.filter((result) => result.status === "rejected");
|
|
122
|
+
if (failures.length > 0)
|
|
123
|
+
throw new AggregateError(failures.map((failure) => failure.reason), "One or more Atom instances failed to dispose");
|
|
124
|
+
}
|
|
125
|
+
list(query = {}) {
|
|
126
|
+
return [...this.atoms.values()]
|
|
127
|
+
.filter((entry) => query.includeDisabled === true || entry.state === "enabled")
|
|
128
|
+
.filter((entry) => query.id === undefined || entry.definition.manifest.id === query.id)
|
|
129
|
+
.sort((left, right) => atomKey(left.definition.manifest).localeCompare(atomKey(right.definition.manifest)))
|
|
130
|
+
.map((entry) => ({
|
|
131
|
+
manifest: entry.definition.manifest,
|
|
132
|
+
capability: entry.definition.capability,
|
|
133
|
+
catalogIndexDescriptor: entry.definition.catalogIndexDescriptor,
|
|
134
|
+
plannerDescriptor: entry.definition.plannerDescriptor,
|
|
135
|
+
state: entry.state,
|
|
136
|
+
enabled: entry.state === "enabled",
|
|
137
|
+
activeAttempts: entry.activeAttempts,
|
|
138
|
+
...(entry.executionSource ? { executionSource: entry.executionSource } : {}),
|
|
139
|
+
...(entry.disabledReason ? { disabledReason: entry.disabledReason } : {}),
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
requireEnabled(id, version) {
|
|
143
|
+
const key = atomKey({ id, version });
|
|
144
|
+
const entry = this.requireEntry(id, version);
|
|
145
|
+
if (entry.state !== "enabled") {
|
|
146
|
+
const suffix = entry.disabledReason ? ` (${entry.disabledReason})` : "";
|
|
147
|
+
throw new AtomWorkflowError("ATOM_UNAVAILABLE", `Atom is ${entry.state}: ${key}${suffix}`);
|
|
148
|
+
}
|
|
149
|
+
return entry;
|
|
150
|
+
}
|
|
151
|
+
requireEntry(id, version) {
|
|
152
|
+
const key = atomKey({ id, version });
|
|
153
|
+
const entry = this.atoms.get(key);
|
|
154
|
+
if (!entry)
|
|
155
|
+
throw new AtomWorkflowError("ATOM_NOT_FOUND", `Atom not found: ${key}`);
|
|
156
|
+
return entry;
|
|
157
|
+
}
|
|
158
|
+
startDraining(key, entry) {
|
|
159
|
+
if (entry.shutdownPromise)
|
|
160
|
+
return entry.shutdownPromise;
|
|
161
|
+
if (entry.state === "disposed")
|
|
162
|
+
return Promise.resolve();
|
|
163
|
+
const previous = entry.state;
|
|
164
|
+
entry.state = "draining";
|
|
165
|
+
this.emit(key, "draining", previous);
|
|
166
|
+
entry.shutdownPromise = (async () => {
|
|
167
|
+
if (entry.activeAttempts > 0)
|
|
168
|
+
await new Promise((resolve) => { entry.resolveDrained = resolve; });
|
|
169
|
+
const current = entry.state;
|
|
170
|
+
entry.state = "disposed";
|
|
171
|
+
this.emit(key, "disposed", current);
|
|
172
|
+
})();
|
|
173
|
+
return entry.shutdownPromise;
|
|
174
|
+
}
|
|
175
|
+
emit(key, state, previous) {
|
|
176
|
+
this.options.onStateChange?.({ key, state, ...(previous ? { previous } : {}) });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=atom-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom-registry.js","sourceRoot":"","sources":["../../src/registry/atom-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,uCAAuC,EACvC,OAAO,GAMR,MAAM,gCAAgC,CAAC;AA8CxC,SAAS,UAAU,CAAI,KAAQ;IAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxF,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;QAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,WAAW,CAAC,OAAe,EAAE,KAAe;IACnD,OAAO,IAAI,iBAAiB,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5G,CAAC;AAED,SAAS,kBAAk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IACf,CAAC;IACO,aAAa,CAAC,GAAW,EAAE,KAAiB;QAClD,IAAI,KAAK,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC,eAAe,CAAC;QACxD,IAAI,KAAK,CAAC,KAAK,KAAK,UAAU;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QACzD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;QAC7B,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QACrC,KAAK,CAAC,eAAe,GAAG,CAAC,KAAK,IAAI,EAAE;YAClC,IAAI,KAAK,CAAC,cAAc,GAAG,CAAC;gBAAE,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YACxG,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC;YAC5B,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,KAAK,CAAC,eAAe,CAAC;IAC/B,CAAC;IACO,IAAI,CAAC,GAAW,EAAE,KAAwB,EAAE,QAA4B;QAC9E,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atom-workflow-agent/atom-catalog",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Discovery, validation, loading, and leasing of exact atom definitions.",
|
|
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-catalog"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/joekbits/atom-workflow-agent/tree/main/packages/atom-catalog#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/joekbits/atom-workflow-agent/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"atom",
|
|
17
|
+
"workflow",
|
|
18
|
+
"catalog",
|
|
19
|
+
"registry"
|
|
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
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"provenance": true
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=22"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"zod": "^4.0.0",
|
|
42
|
+
"@atom-workflow-agent/contracts": "0.1.0",
|
|
43
|
+
"@atom-workflow-agent/atom-sdk": "0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -p tsconfig.json",
|
|
47
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
48
|
+
"test": "vitest run"
|
|
49
|
+
}
|
|
50
|
+
}
|