@open-everywhere/provider-github 0.0.0-stage → 0.1.1
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/NOTICE +21 -0
- package/README.md +50 -2
- package/agent/channels/github-catch-up.ts +134 -0
- package/agent/channels/github-engagement.ts +381 -0
- package/agent/channels/github-identity.ts +376 -0
- package/agent/channels/github-installations.ts +152 -0
- package/agent/channels/github-message-ops.ts +62 -0
- package/agent/channels/github-origin-codec.ts +42 -0
- package/agent/channels/github-post-arm.ts +422 -0
- package/agent/channels/github-reaction-feedback.ts +489 -0
- package/agent/channels/github-reaction-scope.ts +312 -0
- package/agent/channels/github-read.ts +471 -0
- package/agent/channels/github-stop.ts +175 -0
- package/agent/channels/github-supervisor.ts +645 -0
- package/agent/channels/github-webhook-verifier.ts +56 -0
- package/agent/channels/github.ts +1458 -0
- package/agent/contributions.ts +31 -0
- package/agent/docs-generated.ts +15 -0
- package/agent/memory/memory.ts +265 -0
- package/agent/ops.ts +17 -0
- package/agent/provider-events.ts +114 -0
- package/agent/register.ts +130 -0
- package/agent/surface-parity.ts +116 -0
- package/dist/agent/channels/github-catch-up.d.ts +29 -0
- package/dist/agent/channels/github-catch-up.d.ts.map +1 -0
- package/dist/agent/channels/github-catch-up.js +105 -0
- package/dist/agent/channels/github-catch-up.js.map +1 -0
- package/dist/agent/channels/github-engagement.d.ts +223 -0
- package/dist/agent/channels/github-engagement.d.ts.map +1 -0
- package/dist/agent/channels/github-engagement.js +317 -0
- package/dist/agent/channels/github-engagement.js.map +1 -0
- package/dist/agent/channels/github-identity.d.ts +164 -0
- package/dist/agent/channels/github-identity.d.ts.map +1 -0
- package/dist/agent/channels/github-identity.js +295 -0
- package/dist/agent/channels/github-identity.js.map +1 -0
- package/dist/agent/channels/github-installations.d.ts +49 -0
- package/dist/agent/channels/github-installations.d.ts.map +1 -0
- package/dist/agent/channels/github-installations.js +114 -0
- package/dist/agent/channels/github-installations.js.map +1 -0
- package/dist/agent/channels/github-message-ops.d.ts +3 -0
- package/dist/agent/channels/github-message-ops.d.ts.map +1 -0
- package/dist/agent/channels/github-message-ops.js +58 -0
- package/dist/agent/channels/github-message-ops.js.map +1 -0
- package/dist/agent/channels/github-origin-codec.d.ts +7 -0
- package/dist/agent/channels/github-origin-codec.d.ts.map +1 -0
- package/dist/agent/channels/github-origin-codec.js +36 -0
- package/dist/agent/channels/github-origin-codec.js.map +1 -0
- package/dist/agent/channels/github-post-arm.d.ts +54 -0
- package/dist/agent/channels/github-post-arm.d.ts.map +1 -0
- package/dist/agent/channels/github-post-arm.js +339 -0
- package/dist/agent/channels/github-post-arm.js.map +1 -0
- package/dist/agent/channels/github-reaction-feedback.d.ts +97 -0
- package/dist/agent/channels/github-reaction-feedback.d.ts.map +1 -0
- package/dist/agent/channels/github-reaction-feedback.js +380 -0
- package/dist/agent/channels/github-reaction-feedback.js.map +1 -0
- package/dist/agent/channels/github-reaction-scope.d.ts +102 -0
- package/dist/agent/channels/github-reaction-scope.d.ts.map +1 -0
- package/dist/agent/channels/github-reaction-scope.js +296 -0
- package/dist/agent/channels/github-reaction-scope.js.map +1 -0
- package/dist/agent/channels/github-read.d.ts +135 -0
- package/dist/agent/channels/github-read.d.ts.map +1 -0
- package/dist/agent/channels/github-read.js +371 -0
- package/dist/agent/channels/github-read.js.map +1 -0
- package/dist/agent/channels/github-stop.d.ts +52 -0
- package/dist/agent/channels/github-stop.d.ts.map +1 -0
- package/dist/agent/channels/github-stop.js +145 -0
- package/dist/agent/channels/github-stop.js.map +1 -0
- package/dist/agent/channels/github-supervisor.d.ts +308 -0
- package/dist/agent/channels/github-supervisor.d.ts.map +1 -0
- package/dist/agent/channels/github-supervisor.js +339 -0
- package/dist/agent/channels/github-supervisor.js.map +1 -0
- package/dist/agent/channels/github-webhook-verifier.d.ts +5 -0
- package/dist/agent/channels/github-webhook-verifier.d.ts.map +1 -0
- package/dist/agent/channels/github-webhook-verifier.js +55 -0
- package/dist/agent/channels/github-webhook-verifier.js.map +1 -0
- package/dist/agent/channels/github.d.ts +139 -0
- package/dist/agent/channels/github.d.ts.map +1 -0
- package/dist/agent/channels/github.js +1232 -0
- package/dist/agent/channels/github.js.map +1 -0
- package/dist/agent/contributions.d.ts +12 -0
- package/dist/agent/contributions.d.ts.map +1 -0
- package/dist/agent/contributions.js +31 -0
- package/dist/agent/contributions.js.map +1 -0
- package/dist/agent/docs-generated.d.ts +3 -0
- package/dist/agent/docs-generated.d.ts.map +1 -0
- package/dist/agent/docs-generated.js +13 -0
- package/dist/agent/docs-generated.js.map +1 -0
- package/dist/agent/memory/memory.d.ts +54 -0
- package/dist/agent/memory/memory.d.ts.map +1 -0
- package/dist/agent/memory/memory.js +224 -0
- package/dist/agent/memory/memory.js.map +1 -0
- package/dist/agent/ops.d.ts +3 -0
- package/dist/agent/ops.d.ts.map +1 -0
- package/dist/agent/ops.js +16 -0
- package/dist/agent/ops.js.map +1 -0
- package/dist/agent/provider-events.d.ts +3 -0
- package/dist/agent/provider-events.d.ts.map +1 -0
- package/dist/agent/provider-events.js +112 -0
- package/dist/agent/provider-events.js.map +1 -0
- package/dist/agent/register.d.ts +4 -0
- package/dist/agent/register.d.ts.map +1 -0
- package/dist/agent/register.js +116 -0
- package/dist/agent/register.js.map +1 -0
- package/dist/agent/surface-parity.d.ts +3 -0
- package/dist/agent/surface-parity.d.ts.map +1 -0
- package/dist/agent/surface-parity.js +110 -0
- package/dist/agent/surface-parity.js.map +1 -0
- package/package.json +156 -4
- package/tsconfig.build.json +22 -0
- package/tsconfig.json +15 -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 2026 Tommy Long
|
|
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/NOTICE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Open Everywhere
|
|
2
|
+
Copyright 2026 Tommy Long
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Built on Vercel Eve (https://github.com/vercel/eve), licensed under the
|
|
9
|
+
Apache License, Version 2.0.
|
|
10
|
+
|
|
11
|
+
@open-everywhere/core also ships a patch that modifies Vercel Eve (the file in
|
|
12
|
+
its patches/ directory), with the oe-eve-patch command that applies it to a
|
|
13
|
+
consumer's own installed copy. The patch is licensed under the Apache License,
|
|
14
|
+
Version 2.0. No modified Vercel Eve files are distributed.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
Open Everywhere is an independent, open-source project. It is NOT affiliated
|
|
19
|
+
with, endorsed by, or sponsored by Anthropic. "Claude", "Claude Code", and
|
|
20
|
+
"Claude Tag" are referenced only to describe the prior art Open Everywhere is
|
|
21
|
+
inspired by, and are trademarks of their respective owner.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @open-everywhere/provider-github
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
GitHub issues and pull requests as a wake surface for Open Everywhere.
|
|
4
|
+
|
|
5
|
+
Part of [Open Everywhere](https://github.com/open-everywhere/open-everywhere) — an open, self-hostable autonomous teammate you tag where your
|
|
6
|
+
team works. This package is the GitHub provider. It supplies the identity mapper, the capability manifest, the post arm, the wake-origin codec, the timeline read adapter, the reaction feedback arm and the App installation lifecycle.
|
|
7
|
+
|
|
8
|
+
`@open-everywhere/core` owns the runtime — access and approvals, identity, memory, spend, the
|
|
9
|
+
audit chain. This package holds the GitHub half. The boundary between them is a vendor-coupling
|
|
10
|
+
one, and `packages/core/scripts/boundary-test.ts` checks it per provider: it names one or more
|
|
11
|
+
vendor fingerprint strings, asserts that **at least one** of them appears under this package, and
|
|
12
|
+
asserts that **every** one of them is absent from `packages/core/agent`. For GitHub those strings are
|
|
13
|
+
the webhook signature header `x-hub-signature-256`. Core's registries refuse a provider the deployment has not selected.
|
|
14
|
+
|
|
15
|
+
This package is the GitHub **chat surface** only. The source-control plane stays in core and uses
|
|
16
|
+
`api.github.com` and the GitHub App credentials from there, which is why the fingerprint above is the
|
|
17
|
+
webhook signature header rather than the API host.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm i @open-everywhere/core @open-everywhere/provider-github eve@0.54.3
|
|
23
|
+
npx oe-eve-patch
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Both commands are required.** Core refuses to boot on an unpatched `eve`. A registry `eve` carries
|
|
27
|
+
no patch, so `npx oe-eve-patch` applies the copy `@open-everywhere/core` ships.
|
|
28
|
+
|
|
29
|
+
`eve` is a peer dependency, pinned to the exact version above, which is the pin
|
|
30
|
+
`@open-everywhere/core` declares as `peerDependencies.eve`. Node 24 or newer.
|
|
31
|
+
|
|
32
|
+
## Use
|
|
33
|
+
|
|
34
|
+
One call registers the bundle:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { registerGithubProvider } from "@open-everywhere/provider-github/agent/register.js";
|
|
38
|
+
|
|
39
|
+
registerGithubProvider();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Credentials, the webhook and the GitHub app setup are in the runbook below.
|
|
43
|
+
|
|
44
|
+
## Docs
|
|
45
|
+
|
|
46
|
+
- [GitHub runbook](https://github.com/open-everywhere/open-everywhere/blob/main/docs/deploy/surfaces/github.md)
|
|
47
|
+
- [Documentation index](https://github.com/open-everywhere/open-everywhere/blob/main/docs/README.md)
|
|
48
|
+
|
|
49
|
+
## Licence
|
|
50
|
+
|
|
51
|
+
Apache 2.0. The tarball carries `LICENSE` and `NOTICE`.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// github-catch-up — GitHub's registered SEAT CATCH-UP FETCH (OPE-1726): the seat's own conversation
|
|
2
|
+
// since its last wake, normalized for core's shared catch-up path (channels/seat-catch-up.ts).
|
|
3
|
+
//
|
|
4
|
+
// WHAT "THE SEAT'S CONTAINER" IS HERE. A GitHub seat is bound to a repo and every wake arrives on ONE
|
|
5
|
+
// issue or pull request, so the history a catch-up owes is that conversation's timeline comments —
|
|
6
|
+
// the same container `read_channel` reads and the same one the reply lands in. The request's
|
|
7
|
+
// `container` is therefore the conversation key `owner/repo#number` the read adapter already mints.
|
|
8
|
+
//
|
|
9
|
+
// WHY A STANDALONE CALLER, not `githubReadAdapter.readChannel`: that method takes a live
|
|
10
|
+
// {@link BindableContext} and runs the turn-time domain-scope fence over it. A catch-up fires from a
|
|
11
|
+
// webhook route with no turn, and its container is the one the wake itself already admitted — the
|
|
12
|
+
// seat is bound to it — so there is no second scope question to ask. The CREDENTIAL is the same
|
|
13
|
+
// brokered conversation-read token the adapter uses, and the transport is the same `getJson` seam,
|
|
14
|
+
// so this read inherits the 429 backoff rather than opening a second, unretried path.
|
|
15
|
+
//
|
|
16
|
+
// `since` IS A VENDOR FILTER, and it is why this leg is cheap: GitHub's issue-comments endpoint takes
|
|
17
|
+
// an ISO timestamp and returns only what changed after it, so a seat that woke a minute ago pays for
|
|
18
|
+
// a near-empty page instead of walking the conversation. The shared path re-applies the same bound on
|
|
19
|
+
// its own side, so a vendor that returned more is trimmed there.
|
|
20
|
+
//
|
|
21
|
+
// An unparseable container yields `[]`. A credential/transport/read error propagates to core's
|
|
22
|
+
// shared seatCatchUp boundary, which keeps the wake alive and records `failed` (OPE-1842).
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
catchUpSender,
|
|
26
|
+
resolveConversationReadToken,
|
|
27
|
+
type NormalizedMessage,
|
|
28
|
+
type PrFetchFn,
|
|
29
|
+
type SeatCatchUpFetch,
|
|
30
|
+
} from "@open-everywhere/core/agent/adapter-api.js";
|
|
31
|
+
import { getJson, liveGithubReadFetch, parseGithubContainer } from "./github-read.js";
|
|
32
|
+
|
|
33
|
+
const API_BASE = "https://api.github.com";
|
|
34
|
+
|
|
35
|
+
/** GitHub's page ceiling for the comments endpoint. ONE page: the catch-up window is "since the seat
|
|
36
|
+
* last woke", and a conversation that produced more than 100 comments in that window is one the cap
|
|
37
|
+
* in core would trim anyway. */
|
|
38
|
+
const CATCH_UP_PAGE_LIMIT = 100;
|
|
39
|
+
|
|
40
|
+
/** The raw comment fields this fetch reads. Everything else on the payload is ignored. */
|
|
41
|
+
interface RawTimelineComment {
|
|
42
|
+
readonly id?: number;
|
|
43
|
+
readonly body?: string | null;
|
|
44
|
+
readonly created_at?: string;
|
|
45
|
+
readonly user?: { readonly login?: string; readonly type?: string };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Normalize ONE timeline comment, applying the VISIBILITY GATE every fetch adapter owes core: a
|
|
50
|
+
* comment whose author GitHub does not name is dropped, because an unattributable body must never
|
|
51
|
+
* reach a seat. An `App`/`Bot` actor is KEPT and tagged `bot` — attributable machine awareness, which
|
|
52
|
+
* the domain's admission policy then accepts or refuses — and the bot's own login is what lets the
|
|
53
|
+
* seat recognise its own prior posts as `self`.
|
|
54
|
+
* Returns undefined for a dropped (unattributed, empty, or undateable) comment.
|
|
55
|
+
*/
|
|
56
|
+
function normalizeComment(c: RawTimelineComment, selfLogin: string | undefined): NormalizedMessage | undefined {
|
|
57
|
+
const login = c.user?.login;
|
|
58
|
+
if (!login) return undefined; // unattributable ⇒ fail closed
|
|
59
|
+
const text = (c.body ?? "").trim();
|
|
60
|
+
if (text.length === 0) return undefined;
|
|
61
|
+
const ms = Date.parse(c.created_at ?? "");
|
|
62
|
+
if (!Number.isFinite(ms)) return undefined;
|
|
63
|
+
const isBot = c.user?.type === "Bot";
|
|
64
|
+
const isSelf = selfLogin !== undefined && login.toLowerCase() === selfLogin.toLowerCase();
|
|
65
|
+
return {
|
|
66
|
+
id: String(c.id ?? `${login}@${c.created_at ?? ms}`),
|
|
67
|
+
ms,
|
|
68
|
+
// The bot's OWN posts carry no author id, matching every other surface's normalized shape.
|
|
69
|
+
...(isSelf ? {} : { authorId: login }),
|
|
70
|
+
// THE SHARED SENDER RULE (OPE-1857): this surface contributes the vendor's own signal —
|
|
71
|
+
// GitHub's `user.type` is `Bot` for an app — and core decides what it means.
|
|
72
|
+
sender: catchUpSender({ self: isSelf, bot: isBot }),
|
|
73
|
+
// A timeline comment sits at the top level of its conversation — the same answer
|
|
74
|
+
// `githubReadAdapter.wakeAddress` gives (only an inline review comment is thread-scoped).
|
|
75
|
+
type: "channel",
|
|
76
|
+
text,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Injected seam so the fetch drives offline in tests; defaults to the package's one read transport. */
|
|
81
|
+
export interface GitHubCatchUpDeps {
|
|
82
|
+
readonly fetchFn: PrFetchFn;
|
|
83
|
+
/** Resolve the brokered conversation-read token for a repo. Injected so the fetch drives with no
|
|
84
|
+
* credential store; the live default is the same resolver `githubReadAdapter` uses. */
|
|
85
|
+
readonly resolveToken?: (repoFull: string) => Promise<string>;
|
|
86
|
+
/** The bot's own login, so its prior comments read as `self` rather than as a foreign bot. Absent ⇒
|
|
87
|
+
* the seat's own posts arrive tagged `bot`, which is visible and honest, never a crash. */
|
|
88
|
+
readonly selfLogin?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const liveDeps: GitHubCatchUpDeps = {
|
|
92
|
+
fetchFn: liveGithubReadFetch,
|
|
93
|
+
// The GitHub App's comment author is `<app-slug>[bot]`; the deployment states its own slug, and an
|
|
94
|
+
// unset one degrades to "our posts look like a bot's", which the admission policy still admits
|
|
95
|
+
// under `wide`.
|
|
96
|
+
selfLogin: process.env.GITHUB_APP_SLUG ? `${process.env.GITHUB_APP_SLUG}[bot]` : undefined,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** The fetch, with its seams exposed so the contract test drives it with no network. */
|
|
100
|
+
export async function fetchGitHubCatchUpWindow(
|
|
101
|
+
req: { container: string; sinceMs: number },
|
|
102
|
+
deps: GitHubCatchUpDeps = liveDeps,
|
|
103
|
+
): Promise<readonly NormalizedMessage[]> {
|
|
104
|
+
const target = parseGithubContainer(req.container);
|
|
105
|
+
if (!target) return []; // not a conversation key ⇒ nothing addressable to read
|
|
106
|
+
const token = await (deps.resolveToken ?? resolveConversationReadToken)(target.repoFull);
|
|
107
|
+
const since = new Date(req.sinceMs).toISOString();
|
|
108
|
+
const url = `${API_BASE}/repos/${target.repoFull}/issues/${target.number}/comments?per_page=${CATCH_UP_PAGE_LIMIT}&since=${encodeURIComponent(since)}`;
|
|
109
|
+
const raw = await getJson<readonly RawTimelineComment[]>(deps.fetchFn, url, token, "issues.listComments");
|
|
110
|
+
// A successful HTTP status with the wrong body shape is an attempted read failure, not evidence
|
|
111
|
+
// that the conversation was quiet. Keep the error fixed and content-free: the vendor body can
|
|
112
|
+
// contain arbitrary text and the shared audit row records only the error class/status.
|
|
113
|
+
if (!Array.isArray(raw)) throw new Error("GitHub catch-up returned a malformed response");
|
|
114
|
+
const out: NormalizedMessage[] = [];
|
|
115
|
+
for (const c of raw) {
|
|
116
|
+
const n = normalizeComment(c, deps.selfLogin);
|
|
117
|
+
if (n) out.push(n);
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 🔴 GITHUB STAMPS A COMMENT'S `created_at` TO THE SECOND, and this is the number the shared catch-up
|
|
124
|
+
* road widens both of its bounds by (OPE-1847, `core/agent/channels/seat-catch-up.ts`
|
|
125
|
+
* {@link SeatCatchUpDeclaration.timestampPrecisionMs}).
|
|
126
|
+
* It is the VENDOR'S UNIT, not a margin. Two comments posted inside one wall-clock second — which two
|
|
127
|
+
* API round trips easily are — come back carrying the SAME instant, so a window that ends strictly at
|
|
128
|
+
* the trigger's stamp drops the comment the seat woke to read. That is why this leg used to owe a
|
|
129
|
+
* two-second sleep (`core/scripts/e2e/scenarios.ts`, J-ENGAGED-github).
|
|
130
|
+
*/
|
|
131
|
+
export const GITHUB_TIMESTAMP_PRECISION_MS = 1_000;
|
|
132
|
+
|
|
133
|
+
/** GitHub's registered {@link SeatCatchUpFetch} — the one thing this surface contributes to the shared path. */
|
|
134
|
+
export const githubSeatCatchUpFetch: SeatCatchUpFetch = (req) => fetchGitHubCatchUpWindow({ container: req.container, sinceMs: req.sinceMs });
|