@generacy-ai/cockpit 0.0.0-preview-20260626164104-19e6344
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 +191 -0
- package/README.md +145 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +127 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +37 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +14 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/gh/command-runner.d.ts +17 -0
- package/dist/gh/command-runner.d.ts.map +1 -0
- package/dist/gh/command-runner.js +31 -0
- package/dist/gh/command-runner.js.map +1 -0
- package/dist/gh/wrapper.d.ts +38 -0
- package/dist/gh/wrapper.d.ts.map +1 -0
- package/dist/gh/wrapper.js +164 -0
- package/dist/gh/wrapper.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest/io.d.ts +18 -0
- package/dist/manifest/io.d.ts.map +1 -0
- package/dist/manifest/io.js +66 -0
- package/dist/manifest/io.js.map +1 -0
- package/dist/manifest/schema.d.ts +100 -0
- package/dist/manifest/schema.d.ts.map +1 -0
- package/dist/manifest/schema.js +21 -0
- package/dist/manifest/schema.js.map +1 -0
- package/dist/manifest/scoping.d.ts +20 -0
- package/dist/manifest/scoping.d.ts.map +1 -0
- package/dist/manifest/scoping.js +79 -0
- package/dist/manifest/scoping.js.map +1 -0
- package/dist/orchestrator/client.d.ts +62 -0
- package/dist/orchestrator/client.d.ts.map +1 -0
- package/dist/orchestrator/client.js +132 -0
- package/dist/orchestrator/client.js.map +1 -0
- package/dist/orchestrator/http.d.ts +27 -0
- package/dist/orchestrator/http.d.ts.map +1 -0
- package/dist/orchestrator/http.js +59 -0
- package/dist/orchestrator/http.js.map +1 -0
- package/dist/orchestrator/stub.d.ts +8 -0
- package/dist/orchestrator/stub.d.ts.map +1 -0
- package/dist/orchestrator/stub.js +23 -0
- package/dist/orchestrator/stub.js.map +1 -0
- package/dist/state/classifier.d.ts +7 -0
- package/dist/state/classifier.d.ts.map +1 -0
- package/dist/state/classifier.js +41 -0
- package/dist/state/classifier.js.map +1 -0
- package/dist/state/label-map.d.ts +8 -0
- package/dist/state/label-map.d.ts.map +1 -0
- package/dist/state/label-map.js +68 -0
- package/dist/state/label-map.js.map +1 -0
- package/dist/state/precedence.d.ts +27 -0
- package/dist/state/precedence.d.ts.map +1 -0
- package/dist/state/precedence.js +63 -0
- package/dist/state/precedence.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +20 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 The Generacy AI Authors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# @generacy-ai/cockpit
|
|
2
|
+
|
|
3
|
+
Foundation library for the Generacy **Epic Cockpit** — a set of pure,
|
|
4
|
+
testable primitives any cockpit consumer (UI, CLI, or service) can import
|
|
5
|
+
without depending on the orchestrator runtime.
|
|
6
|
+
|
|
7
|
+
This package is the foundation issue (#786) for the Epic Cockpit work; UI and
|
|
8
|
+
CLI surfaces ship in later G0.x issues.
|
|
9
|
+
|
|
10
|
+
## What's inside
|
|
11
|
+
|
|
12
|
+
- A curated `CockpitState` union (`pending | active | waiting | error |
|
|
13
|
+
terminal | unknown`) and a pure `classify(labels)` function that returns a
|
|
14
|
+
single `{ state, sourceLabel }` summary for any GitHub issue's label set.
|
|
15
|
+
- The precedence rule the cockpit renders by — `terminal > error > waiting >
|
|
16
|
+
active > pending` — with documented tie-breaks (pipeline order inside
|
|
17
|
+
`waiting`, `WORKFLOW_LABELS` index everywhere else).
|
|
18
|
+
- A Zod-validated `cockpit:` config block read from `.generacy/config.yaml`,
|
|
19
|
+
with a `MONITORED_REPOS` env-var fallback and warn-on-empty (not throw)
|
|
20
|
+
behaviour.
|
|
21
|
+
- Epic-manifest read / append / atomic-write helpers + a
|
|
22
|
+
`resolveEpicIssues(epic, owner, repo)` resolver that scans
|
|
23
|
+
`.generacy/epics/*.yaml` first and falls back to the `epic-child` label
|
|
24
|
+
graph via `gh search`.
|
|
25
|
+
- A thin, testable `gh` CLI wrapper (list issues, mutate labels, read PR
|
|
26
|
+
check runs) with an injectable `CommandRunner` so unit tests never spawn
|
|
27
|
+
real processes.
|
|
28
|
+
- A two-mode orchestrator client built on `node:http` / `node:https`. With
|
|
29
|
+
a token, it issues `GET /health`, `GET /queue`, `GET
|
|
30
|
+
/dispatch/queue/workers`. Without a token, it returns a stub whose every
|
|
31
|
+
method resolves to `{ available: false, reason: 'no-token' }`. The live
|
|
32
|
+
client never throws — HTTP errors map to `{ reason: 'http-error',
|
|
33
|
+
statusCode }`, network errors to `{ reason: 'cloud-unreachable' }`.
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm add @generacy-ai/cockpit
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
ESM only, Node ≥ 22.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Classify a GitHub issue's labels
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { classify } from '@generacy-ai/cockpit';
|
|
49
|
+
|
|
50
|
+
const { state, sourceLabel } = classify([
|
|
51
|
+
'phase:plan',
|
|
52
|
+
'waiting-for:plan-review',
|
|
53
|
+
]);
|
|
54
|
+
// → { state: 'waiting', sourceLabel: 'waiting-for:plan-review' }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Load the cockpit config block
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { loadCockpitConfig } from '@generacy-ai/cockpit';
|
|
61
|
+
|
|
62
|
+
const { config, source, warnings } = await loadCockpitConfig();
|
|
63
|
+
// config.owner, config.repos, config.orchestrator.{baseUrl, token}
|
|
64
|
+
// source: 'cockpit-block' | 'monitored-repos-env' | 'defaults'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The loader is non-throwing on the *absent-config* path — it logs a warning
|
|
68
|
+
and returns an empty `repos: []`. It throws on **malformed** YAML or
|
|
69
|
+
schema-invalid input.
|
|
70
|
+
|
|
71
|
+
### Resolve the children of an epic
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { resolveEpicIssues } from '@generacy-ai/cockpit';
|
|
75
|
+
|
|
76
|
+
const childIssueNumbers = await resolveEpicIssues(
|
|
77
|
+
786,
|
|
78
|
+
'generacy-ai',
|
|
79
|
+
'generacy',
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Reads `.generacy/epics/*.yaml` first; falls back to two `gh search` queries
|
|
84
|
+
(label + body reference) and merges the results.
|
|
85
|
+
|
|
86
|
+
### Talk to a running orchestrator
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { createOrchestratorClient } from '@generacy-ai/cockpit';
|
|
90
|
+
|
|
91
|
+
const client = createOrchestratorClient({
|
|
92
|
+
baseUrl: 'http://127.0.0.1:3100',
|
|
93
|
+
token: process.env.ORCHESTRATOR_API_TOKEN, // when undefined → stub
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (client.isAvailable()) {
|
|
97
|
+
const jobs = await client.getJobs();
|
|
98
|
+
if (jobs.available) {
|
|
99
|
+
for (const job of jobs.jobs) console.log(job.id, job.status);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Config schema (`.generacy/config.yaml`)
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
cockpit:
|
|
108
|
+
owner: alice # optional; defaults to `gh auth status` login
|
|
109
|
+
repos: # optional; falls back to MONITORED_REPOS env
|
|
110
|
+
- generacy-ai/generacy
|
|
111
|
+
- generacy-ai/generacy-extension
|
|
112
|
+
orchestrator: # optional
|
|
113
|
+
baseUrl: http://127.0.0.1:3100 # optional; falls back to ORCHESTRATOR_URL env
|
|
114
|
+
token: ******** # optional; falls back to ORCHESTRATOR_API_TOKEN env
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Environment variables
|
|
118
|
+
|
|
119
|
+
| Variable | Effect |
|
|
120
|
+
| ------------------------- | ----------------------------------------------------------------- |
|
|
121
|
+
| `MONITORED_REPOS` | Comma-separated `owner/repo` list used when `cockpit.repos` empty |
|
|
122
|
+
| `ORCHESTRATOR_URL` | Used when `cockpit.orchestrator.baseUrl` not set |
|
|
123
|
+
| `ORCHESTRATOR_API_TOKEN` | Used when `cockpit.orchestrator.token` not set |
|
|
124
|
+
|
|
125
|
+
## Degraded mode
|
|
126
|
+
|
|
127
|
+
The orchestrator client is designed to degrade silently:
|
|
128
|
+
|
|
129
|
+
- No token (config or env)? `createOrchestratorClient` returns a stub. Every
|
|
130
|
+
method resolves to `{ available: false, reason: 'no-token' }`. No HTTP
|
|
131
|
+
calls are made.
|
|
132
|
+
- Token present but the orchestrator is unreachable? The live client returns
|
|
133
|
+
`{ available: false, reason: 'cloud-unreachable' }`.
|
|
134
|
+
- Token present but the orchestrator returns 5xx / 4xx? The live client
|
|
135
|
+
returns `{ available: false, reason: 'http-error', statusCode }`.
|
|
136
|
+
|
|
137
|
+
The live client never throws — all error paths surface as result envelopes
|
|
138
|
+
so callers can render a degraded UI without try/catch noise.
|
|
139
|
+
|
|
140
|
+
## References
|
|
141
|
+
|
|
142
|
+
- Spec: [`specs/786-epic-generacy-ai-tetrad/spec.md`](../../specs/786-epic-generacy-ai-tetrad/spec.md)
|
|
143
|
+
- Plan: [`specs/786-epic-generacy-ai-tetrad/plan.md`](../../specs/786-epic-generacy-ai-tetrad/plan.md)
|
|
144
|
+
- Data model: [`specs/786-epic-generacy-ai-tetrad/data-model.md`](../../specs/786-epic-generacy-ai-tetrad/data-model.md)
|
|
145
|
+
- Contracts: [`specs/786-epic-generacy-ai-tetrad/contracts/`](../../specs/786-epic-generacy-ai-tetrad/contracts/)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type LoadedCockpitConfig } from './schema.js';
|
|
2
|
+
export interface LoadCockpitConfigOptions {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
env?: NodeJS.ProcessEnv;
|
|
5
|
+
whoami?: () => Promise<string | null>;
|
|
6
|
+
logger?: {
|
|
7
|
+
warn: (msg: string) => void;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function loadCockpitConfig(options?: LoadCockpitConfigOptions): Promise<LoadedCockpitConfig>;
|
|
11
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;CAC1C;AAyCD,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAuF9B"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { findWorkspaceConfigPath } from '@generacy-ai/config';
|
|
4
|
+
import { parse as parseYaml } from 'yaml';
|
|
5
|
+
import { CockpitConfigSchema, } from './schema.js';
|
|
6
|
+
const OWNER_REPO_REGEX = /^[^/]+\/[^/]+$/;
|
|
7
|
+
const DEFAULT_BASE_URL = 'http://127.0.0.1:3100';
|
|
8
|
+
const MISSING_REPOS_WARN = 'cockpit: no repos configured (set cockpit.repos in .generacy/config.yaml or MONITORED_REPOS env)';
|
|
9
|
+
function parseMonitoredReposEnv(raw) {
|
|
10
|
+
const entries = raw
|
|
11
|
+
.split(',')
|
|
12
|
+
.map((s) => s.trim())
|
|
13
|
+
.filter((s) => s.length > 0);
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
if (!OWNER_REPO_REGEX.test(entry)) {
|
|
16
|
+
throw new Error(`MONITORED_REPOS contains invalid entry "${entry}" — must be owner/repo`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return entries;
|
|
20
|
+
}
|
|
21
|
+
async function parseGhWhoami() {
|
|
22
|
+
// Lazy import — only runs when no explicit owner is configured.
|
|
23
|
+
const { execFile } = await import('node:child_process');
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
execFile('gh', ['auth', 'status'], { timeout: 5_000 }, (error, stdout, stderr) => {
|
|
26
|
+
const combined = `${stdout}\n${stderr}`;
|
|
27
|
+
if (error != null && combined.length === 0) {
|
|
28
|
+
resolve(null);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// gh auth status prints "Logged in to github.com as <login>" (newer versions)
|
|
32
|
+
// or "Logged in to github.com account <login>" depending on version.
|
|
33
|
+
const match = combined.match(/Logged in to [^\s]+ as ([A-Za-z0-9-]+)/) ??
|
|
34
|
+
combined.match(/account ([A-Za-z0-9-]+)/);
|
|
35
|
+
if (match?.[1] != null) {
|
|
36
|
+
resolve(match[1]);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
resolve(null);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export async function loadCockpitConfig(options = {}) {
|
|
44
|
+
const cwd = options.cwd ?? process.cwd();
|
|
45
|
+
const env = options.env ?? process.env;
|
|
46
|
+
const whoami = options.whoami ?? parseGhWhoami;
|
|
47
|
+
const logger = options.logger ?? console;
|
|
48
|
+
const warnings = [];
|
|
49
|
+
// 1. Locate workspace config file.
|
|
50
|
+
const configPath = findWorkspaceConfigPath(cwd);
|
|
51
|
+
let cockpitBlock = undefined;
|
|
52
|
+
if (configPath != null && existsSync(configPath)) {
|
|
53
|
+
let raw;
|
|
54
|
+
try {
|
|
55
|
+
raw = await readFile(configPath, 'utf-8');
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
59
|
+
throw new Error(`failed to read ${configPath}: ${msg}`);
|
|
60
|
+
}
|
|
61
|
+
let parsed;
|
|
62
|
+
try {
|
|
63
|
+
parsed = parseYaml(raw);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
67
|
+
throw new Error(`failed to parse YAML at ${configPath}: ${msg}`);
|
|
68
|
+
}
|
|
69
|
+
if (parsed != null && typeof parsed === 'object') {
|
|
70
|
+
const doc = parsed;
|
|
71
|
+
cockpitBlock = doc['cockpit'];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// 2. Validate the cockpit block (throws on malformed).
|
|
75
|
+
const parsedCockpit = CockpitConfigSchema.parse(cockpitBlock ?? {});
|
|
76
|
+
// 3. Resolve repos.
|
|
77
|
+
let repos = parsedCockpit.repos;
|
|
78
|
+
let source;
|
|
79
|
+
if (repos.length > 0) {
|
|
80
|
+
source = 'cockpit-block';
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const monitoredReposEnv = env['MONITORED_REPOS'];
|
|
84
|
+
if (monitoredReposEnv != null && monitoredReposEnv.trim().length > 0) {
|
|
85
|
+
repos = parseMonitoredReposEnv(monitoredReposEnv);
|
|
86
|
+
source = 'monitored-repos-env';
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
source = 'defaults';
|
|
90
|
+
warnings.push(MISSING_REPOS_WARN);
|
|
91
|
+
logger.warn(MISSING_REPOS_WARN);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// 4. Resolve owner.
|
|
95
|
+
let owner = parsedCockpit.owner;
|
|
96
|
+
if (owner == null) {
|
|
97
|
+
try {
|
|
98
|
+
const login = await whoami();
|
|
99
|
+
if (login != null && login.length > 0) {
|
|
100
|
+
owner = login;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// gh failure is non-fatal — leave owner undefined.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// 5. Resolve orchestrator.
|
|
108
|
+
const orchestratorBlock = parsedCockpit.orchestrator ?? {};
|
|
109
|
+
const token = orchestratorBlock.token ??
|
|
110
|
+
(env['ORCHESTRATOR_API_TOKEN'] != null && env['ORCHESTRATOR_API_TOKEN'].length > 0
|
|
111
|
+
? env['ORCHESTRATOR_API_TOKEN']
|
|
112
|
+
: undefined);
|
|
113
|
+
const baseUrl = orchestratorBlock.baseUrl ??
|
|
114
|
+
(env['ORCHESTRATOR_URL'] != null && env['ORCHESTRATOR_URL'].length > 0
|
|
115
|
+
? env['ORCHESTRATOR_URL']
|
|
116
|
+
: DEFAULT_BASE_URL);
|
|
117
|
+
const config = {
|
|
118
|
+
owner,
|
|
119
|
+
repos,
|
|
120
|
+
orchestrator: {
|
|
121
|
+
baseUrl,
|
|
122
|
+
...(token != null ? { token } : {}),
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
return { config, source, warnings };
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,KAAK,IAAI,SAA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tC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CockpitConfigSchema: z.ZodObject<{
|
|
3
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
4
|
+
repos: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
5
|
+
orchestrator: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
7
|
+
token: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
baseUrl?: string | undefined;
|
|
10
|
+
token?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
baseUrl?: string | undefined;
|
|
13
|
+
token?: string | undefined;
|
|
14
|
+
}>>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
repos: string[];
|
|
17
|
+
orchestrator: {
|
|
18
|
+
baseUrl?: string | undefined;
|
|
19
|
+
token?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
owner?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
owner?: string | undefined;
|
|
24
|
+
repos?: string[] | undefined;
|
|
25
|
+
orchestrator?: {
|
|
26
|
+
baseUrl?: string | undefined;
|
|
27
|
+
token?: string | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export type CockpitConfig = z.infer<typeof CockpitConfigSchema>;
|
|
31
|
+
export type CockpitConfigSource = 'cockpit-block' | 'monitored-repos-env' | 'defaults';
|
|
32
|
+
export interface LoadedCockpitConfig {
|
|
33
|
+
config: CockpitConfig;
|
|
34
|
+
source: CockpitConfigSource;
|
|
35
|
+
warnings: string[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG,qBAAqB,GAAG,UAAU,CAAC;AAEvF,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const OWNER_REPO_REGEX = /^[^/]+\/[^/]+$/;
|
|
3
|
+
export const CockpitConfigSchema = z.object({
|
|
4
|
+
owner: z.string().min(1).optional(),
|
|
5
|
+
repos: z.array(z.string().regex(OWNER_REPO_REGEX, 'must be owner/repo')).default([]),
|
|
6
|
+
orchestrator: z
|
|
7
|
+
.object({
|
|
8
|
+
baseUrl: z.string().url().optional(),
|
|
9
|
+
token: z.string().min(1).optional(),
|
|
10
|
+
})
|
|
11
|
+
.optional()
|
|
12
|
+
.default({}),
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACpF,YAAY,EAAE,CAAC;SACZ,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;QACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;KACpC,CAAC;SACD,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CommandRunnerOptions {
|
|
2
|
+
env?: Record<string, string>;
|
|
3
|
+
cwd?: string;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CommandResult {
|
|
7
|
+
stdout: string;
|
|
8
|
+
stderr: string;
|
|
9
|
+
exitCode: number;
|
|
10
|
+
}
|
|
11
|
+
export type CommandRunner = (cmd: string, args: string[], opts?: CommandRunnerOptions) => Promise<CommandResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Default runner using `node:child_process.execFile` with a 30s timeout.
|
|
14
|
+
* Does not throw on non-zero exit code — the wrapper inspects `exitCode`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const nodeChildProcessRunner: CommandRunner;
|
|
17
|
+
//# sourceMappingURL=command-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.d.ts","sourceRoot":"","sources":["../../src/gh/command-runner.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,CAC1B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,CAAC,EAAE,oBAAoB,KACxB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,aA8BpC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
/**
|
|
3
|
+
* Default runner using `node:child_process.execFile` with a 30s timeout.
|
|
4
|
+
* Does not throw on non-zero exit code — the wrapper inspects `exitCode`.
|
|
5
|
+
*/
|
|
6
|
+
export const nodeChildProcessRunner = (cmd, args, opts) => {
|
|
7
|
+
const timeoutMs = opts?.timeoutMs ?? 30_000;
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
execFile(cmd, args, {
|
|
10
|
+
env: opts?.env != null ? { ...process.env, ...opts.env } : process.env,
|
|
11
|
+
cwd: opts?.cwd,
|
|
12
|
+
timeout: timeoutMs,
|
|
13
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
14
|
+
}, (error, stdout, stderr) => {
|
|
15
|
+
const stdoutStr = typeof stdout === 'string' ? stdout : Buffer.from(stdout).toString('utf-8');
|
|
16
|
+
const stderrStr = typeof stderr === 'string' ? stderr : Buffer.from(stderr).toString('utf-8');
|
|
17
|
+
let exitCode = 0;
|
|
18
|
+
if (error) {
|
|
19
|
+
const errWithCode = error;
|
|
20
|
+
if (typeof errWithCode.code === 'number') {
|
|
21
|
+
exitCode = errWithCode.code;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
exitCode = 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
resolve({ stdout: stdoutStr, stderr: stderrStr, exitCode });
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
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AI,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACzC,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC;gBAC9B,CAAC;qBAAM,CAAC;oBACN,QAAQ,GAAG,CAAC,CAAC;gBACf,CAAC;YACH,CAAC;YACD,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type CommandRunner } from './command-runner.js';
|
|
2
|
+
export interface Issue {
|
|
3
|
+
number: number;
|
|
4
|
+
title: string;
|
|
5
|
+
state: 'OPEN' | 'CLOSED';
|
|
6
|
+
labels: string[];
|
|
7
|
+
url: string;
|
|
8
|
+
body: string;
|
|
9
|
+
author?: {
|
|
10
|
+
login: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface CheckRunSummary {
|
|
14
|
+
name: string;
|
|
15
|
+
state: 'SUCCESS' | 'FAILURE' | 'PENDING' | 'NEUTRAL' | 'SKIPPED' | 'CANCELLED';
|
|
16
|
+
conclusion?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ListIssuesOptions {
|
|
20
|
+
limit?: number;
|
|
21
|
+
repo?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GhWrapper {
|
|
24
|
+
listIssues(query: string, options?: ListIssuesOptions): Promise<Issue[]>;
|
|
25
|
+
addLabels(repo: string, issue: number, labels: string[]): Promise<void>;
|
|
26
|
+
removeLabels(repo: string, issue: number, labels: string[]): Promise<void>;
|
|
27
|
+
getPullRequestCheckRuns(repo: string, prNumber: number): Promise<CheckRunSummary[]>;
|
|
28
|
+
}
|
|
29
|
+
export declare class GhCliWrapper implements GhWrapper {
|
|
30
|
+
private readonly runner;
|
|
31
|
+
constructor(runner?: CommandRunner);
|
|
32
|
+
listIssues(query: string, options?: ListIssuesOptions): Promise<Issue[]>;
|
|
33
|
+
addLabels(repo: string, issue: number, labels: string[]): Promise<void>;
|
|
34
|
+
removeLabels(repo: string, issue: number, labels: string[]): Promise<void>;
|
|
35
|
+
getPullRequestCheckRuns(repo: string, prNumber: number): Promise<CheckRunSummary[]>;
|
|
36
|
+
}
|
|
37
|
+
export type { CommandRunner } from './command-runner.js';
|
|
38
|
+
//# sourceMappingURL=wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/gh/wrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACzE,SAAS,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