@generacy-ai/generacy 0.3.3 → 0.4.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/README.md +153 -0
- package/dist/cli/commands/cluster/scaffolder.d.ts.map +1 -1
- package/dist/cli/commands/cluster/scaffolder.js +2 -0
- package/dist/cli/commands/cluster/scaffolder.js.map +1 -1
- package/dist/cli/commands/cockpit/advance.d.ts +42 -0
- package/dist/cli/commands/cockpit/advance.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/advance.js +136 -0
- package/dist/cli/commands/cockpit/advance.js.map +1 -0
- package/dist/cli/commands/cockpit/clarification-comment-finder.d.ts +13 -0
- package/dist/cli/commands/cockpit/clarification-comment-finder.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/clarification-comment-finder.js +31 -0
- package/dist/cli/commands/cockpit/clarification-comment-finder.js.map +1 -0
- package/dist/cli/commands/cockpit/code-references.d.ts +27 -0
- package/dist/cli/commands/cockpit/code-references.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/code-references.js +48 -0
- package/dist/cli/commands/cockpit/code-references.js.map +1 -0
- package/dist/cli/commands/cockpit/context.d.ts +90 -0
- package/dist/cli/commands/cockpit/context.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/context.js +280 -0
- package/dist/cli/commands/cockpit/context.js.map +1 -0
- package/dist/cli/commands/cockpit/exit.d.ts +12 -0
- package/dist/cli/commands/cockpit/exit.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/exit.js +18 -0
- package/dist/cli/commands/cockpit/exit.js.map +1 -0
- package/dist/cli/commands/cockpit/gate-vocabulary.d.ts +48 -0
- package/dist/cli/commands/cockpit/gate-vocabulary.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/gate-vocabulary.js +96 -0
- package/dist/cli/commands/cockpit/gate-vocabulary.js.map +1 -0
- package/dist/cli/commands/cockpit/index.d.ts +20 -0
- package/dist/cli/commands/cockpit/index.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/index.js +40 -0
- package/dist/cli/commands/cockpit/index.js.map +1 -0
- package/dist/cli/commands/cockpit/manual-advance-marker.d.ts +18 -0
- package/dist/cli/commands/cockpit/manual-advance-marker.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/manual-advance-marker.js +43 -0
- package/dist/cli/commands/cockpit/manual-advance-marker.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/errors.d.ts +54 -0
- package/dist/cli/commands/cockpit/mcp/errors.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/errors.js +190 -0
- package/dist/cli/commands/cockpit/mcp/errors.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/event-bus-registry.d.ts +59 -0
- package/dist/cli/commands/cockpit/mcp/event-bus-registry.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/event-bus-registry.js +305 -0
- package/dist/cli/commands/cockpit/mcp/event-bus-registry.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/event-bus.d.ts +82 -0
- package/dist/cli/commands/cockpit/mcp/event-bus.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/event-bus.js +230 -0
- package/dist/cli/commands/cockpit/mcp/event-bus.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/index.d.ts +17 -0
- package/dist/cli/commands/cockpit/mcp/index.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/index.js +37 -0
- package/dist/cli/commands/cockpit/mcp/index.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/ref-input.d.ts +52 -0
- package/dist/cli/commands/cockpit/mcp/ref-input.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/ref-input.js +132 -0
- package/dist/cli/commands/cockpit/mcp/ref-input.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/schemas.d.ts +287 -0
- package/dist/cli/commands/cockpit/mcp/schemas.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/schemas.js +84 -0
- package/dist/cli/commands/cockpit/mcp/schemas.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/server.d.ts +17 -0
- package/dist/cli/commands/cockpit/mcp/server.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/server.js +62 -0
- package/dist/cli/commands/cockpit/mcp/server.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_advance.d.ts +42 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_advance.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_advance.js +73 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_advance.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_await_events.d.ts +34 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_await_events.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_await_events.js +115 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_await_events.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_context.d.ts +21 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_context.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_context.js +35 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_context.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_merge.d.ts +43 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_merge.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_merge.js +99 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_merge.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_queue.d.ts +43 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_queue.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_queue.js +68 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_queue.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_resume.d.ts +38 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_resume.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_resume.js +79 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_resume.js.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_status.d.ts +21 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_status.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_status.js +59 -0
- package/dist/cli/commands/cockpit/mcp/tools/cockpit_status.js.map +1 -0
- package/dist/cli/commands/cockpit/merge.d.ts +42 -0
- package/dist/cli/commands/cockpit/merge.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/merge.js +360 -0
- package/dist/cli/commands/cockpit/merge.js.map +1 -0
- package/dist/cli/commands/cockpit/plan-dependency-extractor.d.ts +30 -0
- package/dist/cli/commands/cockpit/plan-dependency-extractor.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/plan-dependency-extractor.js +135 -0
- package/dist/cli/commands/cockpit/plan-dependency-extractor.js.map +1 -0
- package/dist/cli/commands/cockpit/queue.d.ts +85 -0
- package/dist/cli/commands/cockpit/queue.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/queue.js +438 -0
- package/dist/cli/commands/cockpit/queue.js.map +1 -0
- package/dist/cli/commands/cockpit/resolver.d.ts +70 -0
- package/dist/cli/commands/cockpit/resolver.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/resolver.js +117 -0
- package/dist/cli/commands/cockpit/resolver.js.map +1 -0
- package/dist/cli/commands/cockpit/resume.d.ts +38 -0
- package/dist/cli/commands/cockpit/resume.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/resume.js +167 -0
- package/dist/cli/commands/cockpit/resume.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/classify-issue.d.ts +12 -0
- package/dist/cli/commands/cockpit/shared/classify-issue.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/classify-issue.js +10 -0
- package/dist/cli/commands/cockpit/shared/classify-issue.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/failing-check-json.d.ts +53 -0
- package/dist/cli/commands/cockpit/shared/failing-check-json.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/failing-check-json.js +170 -0
- package/dist/cli/commands/cockpit/shared/failing-check-json.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/identity.d.ts +54 -0
- package/dist/cli/commands/cockpit/shared/identity.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/identity.js +65 -0
- package/dist/cli/commands/cockpit/shared/identity.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/is-done-snapshot.d.ts +16 -0
- package/dist/cli/commands/cockpit/shared/is-done-snapshot.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/is-done-snapshot.js +17 -0
- package/dist/cli/commands/cockpit/shared/is-done-snapshot.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/pagination.d.ts +17 -0
- package/dist/cli/commands/cockpit/shared/pagination.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/pagination.js +50 -0
- package/dist/cli/commands/cockpit/shared/pagination.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/pr-link.d.ts +8 -0
- package/dist/cli/commands/cockpit/shared/pr-link.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/pr-link.js +15 -0
- package/dist/cli/commands/cockpit/shared/pr-link.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/required-checks.d.ts +17 -0
- package/dist/cli/commands/cockpit/shared/required-checks.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/required-checks.js +38 -0
- package/dist/cli/commands/cockpit/shared/required-checks.js.map +1 -0
- package/dist/cli/commands/cockpit/shared/review-context-json.d.ts +29 -0
- package/dist/cli/commands/cockpit/shared/review-context-json.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/shared/review-context-json.js +28 -0
- package/dist/cli/commands/cockpit/shared/review-context-json.js.map +1 -0
- package/dist/cli/commands/cockpit/status/color.d.ts +11 -0
- package/dist/cli/commands/cockpit/status/color.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/status/color.js +33 -0
- package/dist/cli/commands/cockpit/status/color.js.map +1 -0
- package/dist/cli/commands/cockpit/status/group.d.ts +8 -0
- package/dist/cli/commands/cockpit/status/group.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/status/group.js +35 -0
- package/dist/cli/commands/cockpit/status/group.js.map +1 -0
- package/dist/cli/commands/cockpit/status/render-table.d.ts +24 -0
- package/dist/cli/commands/cockpit/status/render-table.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/status/render-table.js +71 -0
- package/dist/cli/commands/cockpit/status/render-table.js.map +1 -0
- package/dist/cli/commands/cockpit/status/row.d.ts +18 -0
- package/dist/cli/commands/cockpit/status/row.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/status/row.js +17 -0
- package/dist/cli/commands/cockpit/status/row.js.map +1 -0
- package/dist/cli/commands/cockpit/status.d.ts +18 -0
- package/dist/cli/commands/cockpit/status.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/status.js +138 -0
- package/dist/cli/commands/cockpit/status.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/actionable.d.ts +15 -0
- package/dist/cli/commands/cockpit/watch/actionable.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/actionable.js +32 -0
- package/dist/cli/commands/cockpit/watch/actionable.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/aggregate-emit.d.ts +107 -0
- package/dist/cli/commands/cockpit/watch/aggregate-emit.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/aggregate-emit.js +41 -0
- package/dist/cli/commands/cockpit/watch/aggregate-emit.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/aggregate.d.ts +25 -0
- package/dist/cli/commands/cockpit/watch/aggregate.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/aggregate.js +67 -0
- package/dist/cli/commands/cockpit/watch/aggregate.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/check-rollup.d.ts +9 -0
- package/dist/cli/commands/cockpit/watch/check-rollup.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/check-rollup.js +22 -0
- package/dist/cli/commands/cockpit/watch/check-rollup.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/diff.d.ts +29 -0
- package/dist/cli/commands/cockpit/watch/diff.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/diff.js +85 -0
- package/dist/cli/commands/cockpit/watch/diff.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/emit.d.ts +58 -0
- package/dist/cli/commands/cockpit/watch/emit.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/emit.js +30 -0
- package/dist/cli/commands/cockpit/watch/emit.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/poll-loop.d.ts +29 -0
- package/dist/cli/commands/cockpit/watch/poll-loop.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/poll-loop.js +81 -0
- package/dist/cli/commands/cockpit/watch/poll-loop.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/pr-state.d.ts +17 -0
- package/dist/cli/commands/cockpit/watch/pr-state.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/pr-state.js +33 -0
- package/dist/cli/commands/cockpit/watch/pr-state.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/snapshot.d.ts +33 -0
- package/dist/cli/commands/cockpit/watch/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/snapshot.js +30 -0
- package/dist/cli/commands/cockpit/watch/snapshot.js.map +1 -0
- package/dist/cli/commands/cockpit/watch/stream-event.d.ts +82 -0
- package/dist/cli/commands/cockpit/watch/stream-event.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch/stream-event.js +9 -0
- package/dist/cli/commands/cockpit/watch/stream-event.js.map +1 -0
- package/dist/cli/commands/cockpit/watch.d.ts +22 -0
- package/dist/cli/commands/cockpit/watch.d.ts.map +1 -0
- package/dist/cli/commands/cockpit/watch.js +186 -0
- package/dist/cli/commands/cockpit/watch.js.map +1 -0
- package/dist/cli/commands/setup/build.d.ts.map +1 -1
- package/dist/cli/commands/setup/build.js +59 -0
- package/dist/cli/commands/setup/build.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +11 -5
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `formatManualAdvanceComment` — renders the structured issue comment posted
|
|
3
|
+
* by `cockpit advance` per AD-1 / D-R5.
|
|
4
|
+
*
|
|
5
|
+
* Inputs are regex-validated before interpolation so a malformed `gate`,
|
|
6
|
+
* `actor`, or `ts` cannot inject HTML/markdown into the marker body.
|
|
7
|
+
*
|
|
8
|
+
* `actor` is optional: when `undefined` or empty, the `actor=` attribute is
|
|
9
|
+
* omitted from the HTML comment and the ` by **@<actor>**` clause is dropped
|
|
10
|
+
* from the sentence (contract: FR-003, `contracts/manual-advance-marker.md`).
|
|
11
|
+
*/
|
|
12
|
+
export interface ManualAdvanceMarker {
|
|
13
|
+
gate: string;
|
|
14
|
+
actor?: string;
|
|
15
|
+
ts: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function formatManualAdvanceComment(marker: ManualAdvanceMarker): string;
|
|
18
|
+
//# sourceMappingURL=manual-advance-marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manual-advance-marker.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/cockpit/manual-advance-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAW9E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `formatManualAdvanceComment` — renders the structured issue comment posted
|
|
3
|
+
* by `cockpit advance` per AD-1 / D-R5.
|
|
4
|
+
*
|
|
5
|
+
* Inputs are regex-validated before interpolation so a malformed `gate`,
|
|
6
|
+
* `actor`, or `ts` cannot inject HTML/markdown into the marker body.
|
|
7
|
+
*
|
|
8
|
+
* `actor` is optional: when `undefined` or empty, the `actor=` attribute is
|
|
9
|
+
* omitted from the HTML comment and the ` by **@<actor>**` clause is dropped
|
|
10
|
+
* from the sentence (contract: FR-003, `contracts/manual-advance-marker.md`).
|
|
11
|
+
*/
|
|
12
|
+
const GATE_REGEX = /^[a-z][a-z0-9-]*$/;
|
|
13
|
+
const ACTOR_REGEX = /^[A-Za-z0-9-]+$/;
|
|
14
|
+
export function formatManualAdvanceComment(marker) {
|
|
15
|
+
validate(marker);
|
|
16
|
+
const { gate, actor, ts } = marker;
|
|
17
|
+
const hasActor = typeof actor === 'string' && actor.length > 0;
|
|
18
|
+
const commentPrelude = hasActor
|
|
19
|
+
? `<!-- generacy-cockpit:manual-advance gate=${gate} actor=${actor} ts=${ts} -->`
|
|
20
|
+
: `<!-- generacy-cockpit:manual-advance gate=${gate} ts=${ts} -->`;
|
|
21
|
+
const sentence = hasActor
|
|
22
|
+
? `Marked \`completed:${gate}\` by **@${actor}** — \`waiting-for:${gate}\` left in place for the worker to clear on resume.`
|
|
23
|
+
: `Marked \`completed:${gate}\` — \`waiting-for:${gate}\` left in place for the worker to clear on resume.`;
|
|
24
|
+
return `${commentPrelude}\n\n${sentence}`;
|
|
25
|
+
}
|
|
26
|
+
function validate(marker) {
|
|
27
|
+
if (!GATE_REGEX.test(marker.gate)) {
|
|
28
|
+
throw new Error(`formatManualAdvanceComment: invalid gate name "${marker.gate}"`);
|
|
29
|
+
}
|
|
30
|
+
if (typeof marker.actor === 'string' && marker.actor.length > 0) {
|
|
31
|
+
if (!ACTOR_REGEX.test(marker.actor)) {
|
|
32
|
+
throw new Error(`formatManualAdvanceComment: invalid actor login "${marker.actor}"`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (typeof marker.ts !== 'string' || marker.ts === '') {
|
|
36
|
+
throw new Error('formatManualAdvanceComment: ts must be a non-empty ISO-8601 string');
|
|
37
|
+
}
|
|
38
|
+
const parsed = new Date(marker.ts);
|
|
39
|
+
if (Number.isNaN(parsed.getTime()) || parsed.toISOString() !== marker.ts) {
|
|
40
|
+
throw new Error(`formatManualAdvanceComment: ts "${marker.ts}" is not round-trip ISO-8601`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=manual-advance-marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manual-advance-marker.js","sourceRoot":"","sources":["../../../../src/cli/commands/cockpit/manual-advance-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,UAAU,GAAG,mBAAmB,CAAC;AACvC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAQtC,MAAM,UAAU,0BAA0B,CAAC,MAA2B;IACpE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;IACnC,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,QAAQ;QAC7B,CAAC,CAAC,6CAA6C,IAAI,UAAU,KAAK,OAAO,EAAE,MAAM;QACjF,CAAC,CAAC,6CAA6C,IAAI,OAAO,EAAE,MAAM,CAAC;IACrE,MAAM,QAAQ,GAAG,QAAQ;QACvB,CAAC,CAAC,sBAAsB,IAAI,YAAY,KAAK,sBAAsB,IAAI,qDAAqD;QAC5H,CAAC,CAAC,sBAAsB,IAAI,sBAAsB,IAAI,qDAAqD,CAAC;IAC9G,OAAO,GAAG,cAAc,OAAO,QAAQ,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,QAAQ,CAAC,MAA2B;IAC3C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,kDAAkD,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;IACpF,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,oDAAoD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,mCAAmC,MAAM,CAAC,EAAE,8BAA8B,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error results for the cockpit MCP tool boundary.
|
|
3
|
+
*
|
|
4
|
+
* Every tool returns `ToolResult<T>` — either `ToolOkResult<T>` (status: 'ok')
|
|
5
|
+
* or `ToolErrorResult` (status: 'error'). Bare thrown exceptions never reach
|
|
6
|
+
* the JSON-RPC transport; `wrapToolBoundary` converts them into an
|
|
7
|
+
* `internal`-class error result.
|
|
8
|
+
*
|
|
9
|
+
* `mapCockpitExitToToolError` translates the `CockpitExit` codes used by the
|
|
10
|
+
* CLI verbs (1 = transport, 2 = argument/parse, 3 = gate refusal) into
|
|
11
|
+
* discriminated tool-error classes.
|
|
12
|
+
*/
|
|
13
|
+
import { type CockpitExit } from '../exit.js';
|
|
14
|
+
export type ErrorClass = 'invalid-args' | 'wrong-kind' | 'unknown-gate' | 'not-an-epic' | 'gate-refusal' | 'transport' | 'invalid-cursor' | 'not-worker' | 'internal';
|
|
15
|
+
export interface ToolOkResult<T> {
|
|
16
|
+
status: 'ok';
|
|
17
|
+
data: T;
|
|
18
|
+
}
|
|
19
|
+
export interface ToolErrorResult {
|
|
20
|
+
status: 'error';
|
|
21
|
+
class: ErrorClass;
|
|
22
|
+
detail: string;
|
|
23
|
+
hint?: string;
|
|
24
|
+
}
|
|
25
|
+
export type ToolResult<T> = ToolOkResult<T> | ToolErrorResult;
|
|
26
|
+
/** Map a `CockpitExit` from the CLI verb into a typed tool-error result. */
|
|
27
|
+
export declare function mapCockpitExitToToolError(exit: CockpitExit): ToolErrorResult;
|
|
28
|
+
/**
|
|
29
|
+
* Wrap a tool handler so that any thrown Error (including `CockpitExit`)
|
|
30
|
+
* becomes a typed `ToolErrorResult`. The MCP transport never sees an
|
|
31
|
+
* uncaught throw from a wrapped handler.
|
|
32
|
+
*/
|
|
33
|
+
export declare function wrapToolBoundary<T>(fn: () => Promise<ToolResult<T>>): Promise<ToolResult<T>>;
|
|
34
|
+
/**
|
|
35
|
+
* #928 — Envelope-mapping helper.
|
|
36
|
+
*
|
|
37
|
+
* Translates the CLI verb's `RunMergeResult` (`{ exitCode, stdout }`) into the
|
|
38
|
+
* MCP `ToolResult<T>` envelope. THIS TABLE IS THE TRANSPORT CONTRACT (Q4 → B):
|
|
39
|
+
* any new `reason` string introduced in `runMerge` must appear here, or fall
|
|
40
|
+
* through to `class: 'invalid-args'` (which is loud enough for tests to catch).
|
|
41
|
+
*
|
|
42
|
+
* Mapping (see data-model.md §toMcpResult):
|
|
43
|
+
* exit=0 → ok, data: parsed
|
|
44
|
+
* exit=2 + reason='pr-number' → wrong-kind (with `hint`)
|
|
45
|
+
* exit=2 + reason∈{unresolved, ambiguous-resolution, pr-is-draft, checks-failing}
|
|
46
|
+
* → gate-refusal
|
|
47
|
+
* exit=2 + other/missing reason → invalid-args
|
|
48
|
+
* exit=3 → gate-refusal
|
|
49
|
+
* exit=1 → transport
|
|
50
|
+
* exit≥4 → internal
|
|
51
|
+
* non-JSON stdout → internal
|
|
52
|
+
*/
|
|
53
|
+
export declare function toMcpResult<T>(cliJsonStdout: string, exitCode: number): ToolResult<T>;
|
|
54
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/cockpit/mcp/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,YAAY,GACZ,cAAc,GACd,aAAa,GACb,cAAc,GACd,WAAW,GACX,gBAAgB,GAChB,YAAY,GACZ,UAAU,CAAC;AAEf,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,MAAM,EAAE,IAAI,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC;AAE9D,4EAA4E;AAC5E,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAY5E;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAUxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,UAAU,CAAC,CAAC,CAAC,CA8Ff"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error results for the cockpit MCP tool boundary.
|
|
3
|
+
*
|
|
4
|
+
* Every tool returns `ToolResult<T>` — either `ToolOkResult<T>` (status: 'ok')
|
|
5
|
+
* or `ToolErrorResult` (status: 'error'). Bare thrown exceptions never reach
|
|
6
|
+
* the JSON-RPC transport; `wrapToolBoundary` converts them into an
|
|
7
|
+
* `internal`-class error result.
|
|
8
|
+
*
|
|
9
|
+
* `mapCockpitExitToToolError` translates the `CockpitExit` codes used by the
|
|
10
|
+
* CLI verbs (1 = transport, 2 = argument/parse, 3 = gate refusal) into
|
|
11
|
+
* discriminated tool-error classes.
|
|
12
|
+
*/
|
|
13
|
+
import { isCockpitExit } from '../exit.js';
|
|
14
|
+
/** Map a `CockpitExit` from the CLI verb into a typed tool-error result. */
|
|
15
|
+
export function mapCockpitExitToToolError(exit) {
|
|
16
|
+
const detail = exit.message;
|
|
17
|
+
switch (exit.code) {
|
|
18
|
+
case 1:
|
|
19
|
+
return { status: 'error', class: 'transport', detail };
|
|
20
|
+
case 2:
|
|
21
|
+
return { status: 'error', class: 'invalid-args', detail };
|
|
22
|
+
case 3:
|
|
23
|
+
return { status: 'error', class: 'gate-refusal', detail };
|
|
24
|
+
default:
|
|
25
|
+
return { status: 'error', class: 'internal', detail };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wrap a tool handler so that any thrown Error (including `CockpitExit`)
|
|
30
|
+
* becomes a typed `ToolErrorResult`. The MCP transport never sees an
|
|
31
|
+
* uncaught throw from a wrapped handler.
|
|
32
|
+
*/
|
|
33
|
+
export async function wrapToolBoundary(fn) {
|
|
34
|
+
try {
|
|
35
|
+
return await fn();
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
if (isCockpitExit(err)) {
|
|
39
|
+
return mapCockpitExitToToolError(err);
|
|
40
|
+
}
|
|
41
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
42
|
+
return { status: 'error', class: 'internal', detail };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* #928 — Envelope-mapping helper.
|
|
47
|
+
*
|
|
48
|
+
* Translates the CLI verb's `RunMergeResult` (`{ exitCode, stdout }`) into the
|
|
49
|
+
* MCP `ToolResult<T>` envelope. THIS TABLE IS THE TRANSPORT CONTRACT (Q4 → B):
|
|
50
|
+
* any new `reason` string introduced in `runMerge` must appear here, or fall
|
|
51
|
+
* through to `class: 'invalid-args'` (which is loud enough for tests to catch).
|
|
52
|
+
*
|
|
53
|
+
* Mapping (see data-model.md §toMcpResult):
|
|
54
|
+
* exit=0 → ok, data: parsed
|
|
55
|
+
* exit=2 + reason='pr-number' → wrong-kind (with `hint`)
|
|
56
|
+
* exit=2 + reason∈{unresolved, ambiguous-resolution, pr-is-draft, checks-failing}
|
|
57
|
+
* → gate-refusal
|
|
58
|
+
* exit=2 + other/missing reason → invalid-args
|
|
59
|
+
* exit=3 → gate-refusal
|
|
60
|
+
* exit=1 → transport
|
|
61
|
+
* exit≥4 → internal
|
|
62
|
+
* non-JSON stdout → internal
|
|
63
|
+
*/
|
|
64
|
+
export function toMcpResult(cliJsonStdout, exitCode) {
|
|
65
|
+
let parsed = null;
|
|
66
|
+
let parseFailed = false;
|
|
67
|
+
try {
|
|
68
|
+
parsed = cliJsonStdout.trim().length === 0 ? null : JSON.parse(cliJsonStdout);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
parseFailed = true;
|
|
72
|
+
}
|
|
73
|
+
if (exitCode === 0) {
|
|
74
|
+
if (parseFailed) {
|
|
75
|
+
return {
|
|
76
|
+
status: 'error',
|
|
77
|
+
class: 'internal',
|
|
78
|
+
detail: 'CLI produced non-JSON stdout on success exit',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return { status: 'ok', data: parsed };
|
|
82
|
+
}
|
|
83
|
+
const detailFallback = firstLineOr(cliJsonStdout, 'CLI reported an error');
|
|
84
|
+
if (exitCode === 1) {
|
|
85
|
+
// Legacy: several cockpit verbs (notably `runMerge`) still use exit-1
|
|
86
|
+
// for resolver-driven gate refusals. Distinguish by the presence of a
|
|
87
|
+
// red-payload JSON with a known refusal `reason` — that's a gate
|
|
88
|
+
// refusal, not a transport error.
|
|
89
|
+
if (!parseFailed) {
|
|
90
|
+
const reason = extractString(parsed, 'reason');
|
|
91
|
+
if (reason !== null && isKnownGateRefusalReason(reason)) {
|
|
92
|
+
return {
|
|
93
|
+
status: 'error',
|
|
94
|
+
class: 'gate-refusal',
|
|
95
|
+
detail: describeGateRefusal(parsed, reason),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { status: 'error', class: 'transport', detail: detailFallback };
|
|
100
|
+
}
|
|
101
|
+
if (exitCode === 2) {
|
|
102
|
+
if (parseFailed) {
|
|
103
|
+
return {
|
|
104
|
+
status: 'error',
|
|
105
|
+
class: 'internal',
|
|
106
|
+
detail: 'CLI produced non-JSON stdout on error exit',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const reason = extractString(parsed, 'reason');
|
|
110
|
+
if (reason === 'pr-number') {
|
|
111
|
+
const hint = extractString(parsed, 'hint') ?? undefined;
|
|
112
|
+
const err = {
|
|
113
|
+
status: 'error',
|
|
114
|
+
class: 'wrong-kind',
|
|
115
|
+
detail: hint ?? `input is a pull request; pass the issue number`,
|
|
116
|
+
};
|
|
117
|
+
if (hint !== undefined)
|
|
118
|
+
err.hint = hint;
|
|
119
|
+
return err;
|
|
120
|
+
}
|
|
121
|
+
if (reason === 'unresolved' ||
|
|
122
|
+
reason === 'ambiguous-resolution' ||
|
|
123
|
+
reason === 'pr-is-draft' ||
|
|
124
|
+
reason === 'checks-failing' ||
|
|
125
|
+
reason === 'missing-label' ||
|
|
126
|
+
reason === 'pr-flag-linkage-refused' ||
|
|
127
|
+
reason === 'pr-flag-closed-unmerged') {
|
|
128
|
+
return {
|
|
129
|
+
status: 'error',
|
|
130
|
+
class: 'gate-refusal',
|
|
131
|
+
detail: describeGateRefusal(parsed, reason),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
status: 'error',
|
|
136
|
+
class: 'invalid-args',
|
|
137
|
+
detail: describeInvalidArgs(parsed, detailFallback),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (exitCode === 3) {
|
|
141
|
+
if (parseFailed) {
|
|
142
|
+
return { status: 'error', class: 'gate-refusal', detail: detailFallback };
|
|
143
|
+
}
|
|
144
|
+
const reason = extractString(parsed, 'reason');
|
|
145
|
+
return {
|
|
146
|
+
status: 'error',
|
|
147
|
+
class: 'gate-refusal',
|
|
148
|
+
detail: reason !== null ? describeGateRefusal(parsed, reason) : detailFallback,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return { status: 'error', class: 'internal', detail: detailFallback };
|
|
152
|
+
}
|
|
153
|
+
function firstLineOr(stdout, fallback) {
|
|
154
|
+
const trimmed = stdout.trim();
|
|
155
|
+
if (trimmed.length === 0)
|
|
156
|
+
return fallback;
|
|
157
|
+
const first = trimmed.split('\n')[0];
|
|
158
|
+
return first != null && first.length > 0 ? first : fallback;
|
|
159
|
+
}
|
|
160
|
+
function extractString(raw, field) {
|
|
161
|
+
if (raw == null || typeof raw !== 'object')
|
|
162
|
+
return null;
|
|
163
|
+
const value = raw[field];
|
|
164
|
+
return typeof value === 'string' ? value : null;
|
|
165
|
+
}
|
|
166
|
+
function describeGateRefusal(raw, reason) {
|
|
167
|
+
const message = extractString(raw, 'message');
|
|
168
|
+
if (message !== null)
|
|
169
|
+
return message;
|
|
170
|
+
return reason;
|
|
171
|
+
}
|
|
172
|
+
function isKnownGateRefusalReason(reason) {
|
|
173
|
+
return (reason === 'unresolved' ||
|
|
174
|
+
reason === 'ambiguous-resolution' ||
|
|
175
|
+
reason === 'pr-is-draft' ||
|
|
176
|
+
reason === 'checks-failing' ||
|
|
177
|
+
reason === 'missing-label' ||
|
|
178
|
+
reason === 'pr-flag-linkage-refused' ||
|
|
179
|
+
reason === 'pr-flag-closed-unmerged');
|
|
180
|
+
}
|
|
181
|
+
function describeInvalidArgs(raw, fallback) {
|
|
182
|
+
const detail = extractString(raw, 'detail');
|
|
183
|
+
if (detail !== null)
|
|
184
|
+
return detail;
|
|
185
|
+
const message = extractString(raw, 'message');
|
|
186
|
+
if (message !== null)
|
|
187
|
+
return message;
|
|
188
|
+
return fallback;
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../src/cli/commands/cockpit/mcp/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,aAAa,EAAoB,MAAM,YAAY,CAAC;AA2B7D,4EAA4E;AAC5E,MAAM,UAAU,yBAAyB,CAAC,IAAiB;IACzD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;IAC5B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;QACzD,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,K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AI;QAAE,OAAO,MAAM,CAAC;IACnC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC9C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IACrC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-orchestrator-process registry of `EpicEventBus` instances, keyed by
|
|
3
|
+
* epic-ref string (`"owner/repo#number"`).
|
|
4
|
+
*
|
|
5
|
+
* Each bus is driven by a private poller — mirrors `watch.ts` but emits into
|
|
6
|
+
* the bus instead of stdout NDJSON. Multiple concurrent `cockpit_await_events`
|
|
7
|
+
* callers against the same epic share the subscriber; refcounted via
|
|
8
|
+
* `acquire` / `release`.
|
|
9
|
+
*
|
|
10
|
+
* Bus lifetime is decoupled from call lifetime (#924): `release()` at
|
|
11
|
+
* refcount 0 pauses the poller and arms an idle-TTL timer instead of tearing
|
|
12
|
+
* down the bus. The next `acquire()` disarms the timer, resumes the poller,
|
|
13
|
+
* and runs a synchronous catch-up poll so between-call events are captured.
|
|
14
|
+
* A soft cap on live buses evicts the least-recently-active on overflow.
|
|
15
|
+
*
|
|
16
|
+
* Env knobs:
|
|
17
|
+
* `COCKPIT_MCP_BUS_IDLE_TTL_MS` — idle-TTL for refcount-0 buses (default 600_000).
|
|
18
|
+
* `COCKPIT_MCP_BUS_MAX` — soft cap on live buses (default 100).
|
|
19
|
+
*/
|
|
20
|
+
import { type CommandRunner, type GhWrapper } from '@generacy-ai/cockpit';
|
|
21
|
+
import { EpicEventBus } from './event-bus.js';
|
|
22
|
+
export interface AcquireOptions {
|
|
23
|
+
epicRef: string;
|
|
24
|
+
runner?: CommandRunner;
|
|
25
|
+
gh?: GhWrapper;
|
|
26
|
+
intervalMs?: number;
|
|
27
|
+
logger?: {
|
|
28
|
+
warn: (msg: string) => void;
|
|
29
|
+
info?: (msg: string) => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Injection seam for tests: build an event bus without starting a poll
|
|
33
|
+
* loop. Callers use the returned bus's `emit()` directly.
|
|
34
|
+
*/
|
|
35
|
+
noPoll?: boolean;
|
|
36
|
+
/** Test seam: wall-clock provider (drives `lastActiveAt`). */
|
|
37
|
+
now?: () => number;
|
|
38
|
+
/** Test seam: override the idle-TTL for this and subsequent acquires. */
|
|
39
|
+
idleTtlMs?: number;
|
|
40
|
+
/** Test seam: override the LRU soft cap for this and subsequent acquires. */
|
|
41
|
+
maxBuses?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Test seam: replace the entire poll cycle (resolveEpic + runOnePoll +
|
|
44
|
+
* computeAggregateEvents). Called from both the poll loop and
|
|
45
|
+
* `catchUpPoll()`. Used to drive between-call event emission
|
|
46
|
+
* deterministically in unit tests.
|
|
47
|
+
*/
|
|
48
|
+
runCycle?: (bus: EpicEventBus) => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface Acquired {
|
|
51
|
+
bus: EpicEventBus;
|
|
52
|
+
release: () => void;
|
|
53
|
+
}
|
|
54
|
+
export declare function acquireEpicBus(options: AcquireOptions): Promise<Acquired>;
|
|
55
|
+
/**
|
|
56
|
+
* Test-only: forcibly release all subscriptions. Use in test `afterEach`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function _resetRegistryForTests(): void;
|
|
59
|
+
//# sourceMappingURL=event-bus-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus-registry.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/cockpit/mcp/event-bus-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,sBAAsB,CAAC;AAU9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAgD9C,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;IACvE;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,YAAY,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkJ/E;AA2JD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAM7C"}
|