@framers/agentos-ext-github 0.2.2 → 0.3.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/README.md +48 -12
- package/dist/__tests__/app.test.js +229 -1
- package/dist/__tests__/app.test.js.map +1 -1
- package/dist/__tests__/documents.test.js +86 -1
- package/dist/__tests__/documents.test.js.map +1 -1
- package/dist/__tests__/entry.test.d.ts +2 -1
- package/dist/__tests__/entry.test.d.ts.map +1 -1
- package/dist/__tests__/entry.test.js +19 -2
- package/dist/__tests__/entry.test.js.map +1 -1
- package/dist/__tests__/events.test.d.ts +8 -0
- package/dist/__tests__/events.test.d.ts.map +1 -0
- package/dist/__tests__/events.test.js +304 -0
- package/dist/__tests__/events.test.js.map +1 -0
- package/dist/app/credential.d.ts +11 -2
- package/dist/app/credential.d.ts.map +1 -1
- package/dist/app/credential.js +6 -2
- package/dist/app/credential.js.map +1 -1
- package/dist/app/events.d.ts +142 -0
- package/dist/app/events.d.ts.map +1 -0
- package/dist/app/events.js +182 -0
- package/dist/app/events.js.map +1 -0
- package/dist/app/http.d.ts +83 -13
- package/dist/app/http.d.ts.map +1 -1
- package/dist/app/http.js +169 -23
- package/dist/app/http.js.map +1 -1
- package/dist/app/installations.d.ts +8 -6
- package/dist/app/installations.d.ts.map +1 -1
- package/dist/app/installations.js +21 -15
- package/dist/app/installations.js.map +1 -1
- package/dist/app/reconcile.d.ts +3 -2
- package/dist/app/reconcile.d.ts.map +1 -1
- package/dist/app/reconcile.js +11 -9
- package/dist/app/reconcile.js.map +1 -1
- package/dist/app/userFlow.d.ts +32 -7
- package/dist/app/userFlow.d.ts.map +1 -1
- package/dist/app/userFlow.js +80 -9
- package/dist/app/userFlow.js.map +1 -1
- package/dist/documents/GitHubDocumentsConnector.d.ts +9 -4
- package/dist/documents/GitHubDocumentsConnector.d.ts.map +1 -1
- package/dist/documents/GitHubDocumentsConnector.js +47 -22
- package/dist/documents/GitHubDocumentsConnector.js.map +1 -1
- package/dist/documents/index.d.ts +12 -7
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +11 -6
- package/dist/documents/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/manifest.json +30 -28
- package/package.json +5 -4
package/dist/app/userFlow.js
CHANGED
|
@@ -1,36 +1,80 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview A GitHub App's user authorization on a web server: GitHub's authorize address with `state` and PKCE,
|
|
3
3
|
* and the code exchanged for a user access token, on the auth module's `RedirectOAuthFlow`. The token proves who the
|
|
4
|
-
* person is and which installations and repositories they can reach; it is used once
|
|
5
|
-
* store.
|
|
4
|
+
* person is and which installations and repositories they can reach; it is used once, then revoked at GitHub and
|
|
5
|
+
* dropped, so the flow has no store. The exchange and the revocation run under a deadline, and each answer is read
|
|
6
|
+
* whole under a cap before it is read.
|
|
6
7
|
* @module agentos-ext-github/app/userFlow
|
|
7
8
|
*/
|
|
8
|
-
import {
|
|
9
|
+
import { readCapped, ReadCapExceeded } from '@framers/agentos-ext-account-sources';
|
|
10
|
+
import { OAuthGrantRefused, RedirectOAuthFlow } from '@framers/agentos/auth';
|
|
11
|
+
import { callDeadline, GITHUB_API_BASE, GITHUB_API_VERSION } from './http.js';
|
|
9
12
|
/** github.com's own authorize and token addresses. */
|
|
10
13
|
export const GITHUB_OAUTH_ENDPOINTS = {
|
|
11
14
|
authorize: 'https://github.com/login/oauth/authorize',
|
|
12
15
|
token: 'https://github.com/login/oauth/access_token',
|
|
13
16
|
};
|
|
17
|
+
/** The largest token answer read: 64 KiB, far above GitHub's few hundred bytes. */
|
|
18
|
+
const TOKEN_ANSWER_BYTES = 65_536;
|
|
19
|
+
/**
|
|
20
|
+
* A fetch that ends each call at its deadline and hands on the answer only once its whole body is read under
|
|
21
|
+
* {@link TOKEN_ANSWER_BYTES}, so the auth module never waits on GitHub past the deadline. A redirect is answered as
|
|
22
|
+
* it came and never followed: a 307 or 308 would send the code and the client secret on to its target, and the auth
|
|
23
|
+
* module refuses the redirect's status. A call that gets no answer, or whose body stops before its end, throws
|
|
24
|
+
* `GitHubNoAnswer`; a body past the cap throws an error that names the cap.
|
|
25
|
+
*/
|
|
26
|
+
function boundedFetch(fetchImpl, timeoutMs) {
|
|
27
|
+
return async (input, init) => {
|
|
28
|
+
const deadline = callDeadline(init?.signal ?? undefined, timeoutMs);
|
|
29
|
+
let response;
|
|
30
|
+
try {
|
|
31
|
+
response = await fetchImpl(input, { ...init, redirect: 'manual', signal: deadline.signal });
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw deadline.noAnswer();
|
|
35
|
+
}
|
|
36
|
+
let bytes;
|
|
37
|
+
try {
|
|
38
|
+
bytes = await readCapped(response, TOKEN_ANSWER_BYTES);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof ReadCapExceeded)
|
|
42
|
+
throw new Error('GitHub answered a body past the size cap');
|
|
43
|
+
throw deadline.noAnswer();
|
|
44
|
+
}
|
|
45
|
+
return new Response(bytes.byteLength === 0 ? null : new TextDecoder().decode(bytes), {
|
|
46
|
+
status: response.status,
|
|
47
|
+
statusText: response.statusText,
|
|
48
|
+
headers: response.headers,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
14
52
|
/**
|
|
15
53
|
* The user's web flow for a GitHub App: `begin` answers the authorize address with the state and the PKCE verifier
|
|
16
|
-
* for the caller to keep,
|
|
17
|
-
*
|
|
18
|
-
* no `scope`.
|
|
54
|
+
* for the caller to keep, `complete` checks the state and exchanges the code (with `code_verifier`, asking for a JSON
|
|
55
|
+
* answer) for the user's token, and `revoke` deletes that token at GitHub once the caller is done with it. A GitHub
|
|
56
|
+
* App's permissions are the app's, not the token's, so the address carries no `scope`. The exchange and a revocation
|
|
57
|
+
* end at their deadline with `GitHubNoAnswer`, and a redirect from either address is refused with `OAuthGrantRefused`
|
|
58
|
+
* (reason `exchange` or `revoke`, the redirect's status), never followed.
|
|
19
59
|
*/
|
|
20
60
|
export class GitHubAppUserFlow extends RedirectOAuthFlow {
|
|
21
61
|
client;
|
|
22
62
|
endpoints;
|
|
23
63
|
/** The provider's id. */
|
|
24
64
|
providerId = 'github';
|
|
65
|
+
/** GitHub's REST API, where `revoke` deletes a token. */
|
|
66
|
+
apiBase;
|
|
25
67
|
/**
|
|
26
68
|
* @param client The app's client id and client secret.
|
|
27
|
-
* @param fetchImpl The fetch the code is exchanged with.
|
|
69
|
+
* @param fetchImpl The fetch the code is exchanged and a token revoked with.
|
|
28
70
|
* @param endpoints GitHub's authorize and token addresses.
|
|
71
|
+
* @param options The deadline of the exchange and of a revocation, and GitHub's REST API.
|
|
29
72
|
*/
|
|
30
|
-
constructor(client, fetchImpl = fetch, endpoints = GITHUB_OAUTH_ENDPOINTS) {
|
|
31
|
-
super(null, fetchImpl);
|
|
73
|
+
constructor(client, fetchImpl = fetch, endpoints = GITHUB_OAUTH_ENDPOINTS, options = {}) {
|
|
74
|
+
super(null, boundedFetch(fetchImpl, options.timeoutMs));
|
|
32
75
|
this.client = client;
|
|
33
76
|
this.endpoints = endpoints;
|
|
77
|
+
this.apiBase = options.apiBase ?? GITHUB_API_BASE;
|
|
34
78
|
}
|
|
35
79
|
/** GitHub's addresses and the app's client, with no scopes. */
|
|
36
80
|
getConfig() {
|
|
@@ -50,5 +94,32 @@ export class GitHubAppUserFlow extends RedirectOAuthFlow {
|
|
|
50
94
|
address.searchParams.delete('scope');
|
|
51
95
|
return { ...begun, url: address.toString() };
|
|
52
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Deletes a user access token at GitHub, so a token the caller is done with stops working at once instead of at its
|
|
99
|
+
* expiry: GitHub's "Delete an app token" (`DELETE /applications/{client_id}/token` with the token in a JSON body),
|
|
100
|
+
* authenticated as the app with Basic authentication, its client id and client secret
|
|
101
|
+
* (https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-token). GitHub answers 204. Any other answer
|
|
102
|
+
* throws `OAuthGrantRefused` (reason `revoke`, its status) without its body, a redirect is refused rather than
|
|
103
|
+
* followed so the client secret reaches GitHub's API alone, and a call that gets no answer by the flow's deadline
|
|
104
|
+
* throws `GitHubNoAnswer`.
|
|
105
|
+
*
|
|
106
|
+
* @param token The user access token to delete.
|
|
107
|
+
*/
|
|
108
|
+
async revoke(token) {
|
|
109
|
+
const credentials = Buffer.from(`${this.client.clientId}:${this.client.clientSecret}`).toString('base64');
|
|
110
|
+
const response = await this.fetchImpl(`${this.apiBase}/applications/${encodeURIComponent(this.client.clientId)}/token`, {
|
|
111
|
+
method: 'DELETE',
|
|
112
|
+
headers: {
|
|
113
|
+
authorization: `Basic ${credentials}`,
|
|
114
|
+
accept: 'application/vnd.github+json',
|
|
115
|
+
'content-type': 'application/json',
|
|
116
|
+
'x-github-api-version': GITHUB_API_VERSION,
|
|
117
|
+
'user-agent': 'agentos-ext-github',
|
|
118
|
+
},
|
|
119
|
+
body: JSON.stringify({ access_token: token }),
|
|
120
|
+
});
|
|
121
|
+
if (!response.ok)
|
|
122
|
+
throw new OAuthGrantRefused('revoke', response.status);
|
|
123
|
+
}
|
|
53
124
|
}
|
|
54
125
|
//# sourceMappingURL=userFlow.js.map
|
package/dist/app/userFlow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userFlow.js","sourceRoot":"","sources":["../../src/app/userFlow.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"userFlow.js","sourceRoot":"","sources":["../../src/app/userFlow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAgD,MAAM,uBAAuB,CAAC;AAC3H,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAqB,MAAM,WAAW,CAAC;AAsBjG,sDAAsD;AACt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C,MAAM,CAAC,KAAa;QACjC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1G,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,iBAAiB,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACtH,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,WAAW,EAAE;gBACrC,MAAM,EAAE,6BAA6B;gBACrC,cAAc,EAAE,kBAAkB;gBAClC,sBAAsB,EAAE,kBAAkB;gBAC1C,YAAY,EAAE,oBAAoB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;SAC9C,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,IAAI,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -48,6 +48,7 @@ export declare class GitHubDocumentsConnector implements AccountSourceConnector
|
|
|
48
48
|
*/
|
|
49
49
|
constructor(credential: GitHubAppCredential, installationId: number, repositories: readonly LinkedRepository[], filter?: TreeFilter, fetchImpl?: typeof fetch, apiBase?: string);
|
|
50
50
|
private repository;
|
|
51
|
+
/** An installation token narrowed to one repository, its request ended by the caller's signal. */
|
|
51
52
|
private token;
|
|
52
53
|
/** The head commit of a repository's default branch. */
|
|
53
54
|
head(repositoryId: number, signal?: AbortSignal): Promise<string>;
|
|
@@ -62,15 +63,19 @@ export declare class GitHubDocumentsConnector implements AccountSourceConnector
|
|
|
62
63
|
gone: SourceGone[];
|
|
63
64
|
}>;
|
|
64
65
|
/**
|
|
65
|
-
* A file's raw bytes at the commit of its version, read as a stream
|
|
66
|
-
* as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
67
|
-
* commit. A file GitHub no longer has
|
|
66
|
+
* A file's raw bytes at the commit of its version, read as a stream under the call's deadline and cut at
|
|
67
|
+
* `maxFileBytes`: PDF, Word and HTML as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
68
|
+
* attribution linking the file at that commit. A file GitHub no longer has (the contents read answers 404), or one
|
|
69
|
+
* past the cap, is answered gone with reason `removed`; any other refusal throws `GitHubApiError`, a rate limit with
|
|
70
|
+
* its `retryAt`, so a read GitHub held back is never taken for a file gone. So does a refusal of the installation
|
|
71
|
+
* token (404 for an installation GitHub no longer has): a lost installation never reads as every file gone.
|
|
68
72
|
*/
|
|
69
73
|
read(item: SourceItem, signal?: AbortSignal): Promise<SourceRead | SourceGone>;
|
|
70
74
|
/**
|
|
71
75
|
* What a push to `after` changed, from the listing at `after` (read here when the caller holds none) against the
|
|
72
76
|
* blobs read before (`cursor`: the JSON of each path's blob). A push's own commit lists are never read, so a force
|
|
73
|
-
* push, or a push of more commits than its event lists, is read like any other. A
|
|
77
|
+
* push, or a push of more commits than its event lists, is read like any other. A cursor this connector did not
|
|
78
|
+
* answer throws a `TypeError` before any request, whatever the push's branch. A push to another branch than the
|
|
74
79
|
* default answers no change and the cursor it was given.
|
|
75
80
|
*/
|
|
76
81
|
changesSince(cursor: string | null, selection: GitHubChangesSelection, signal?: AbortSignal): Promise<SourceChanges>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubDocumentsConnector.d.ts","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"GitHubDocumentsConnector.d.ts","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,K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AY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAOvE;;;OAGG;IACG,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAS9F,oGAAoG;IAC9F,IAAI,CAAC,SAAS,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QAAC,IAAI,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IAWlH;;;;;;;OAOG;IACG,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;IAkCpF;;;;;;OAMG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAiB1H,uGAAuG;IACjG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* raw bytes under a cap, and a push compared by the tree at its `after` commit.
|
|
5
5
|
* @module agentos-ext-github/documents/GitHubDocumentsConnector
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { ReadCapExceeded, } from '@framers/agentos-ext-account-sources';
|
|
8
|
+
import { GITHUB_API_BASE, GitHubApiError, githubFetch, githubSend, objectOf, stringIn } from '../app/http.js';
|
|
9
9
|
import { DEFAULT_MAX_FILE_BYTES, extensionOf, pathFilter, readTree, SKIPPED_FOLDERS } from './tree.js';
|
|
10
10
|
/** The files answered as bytes with their media type; every other kept file is answered as text. */
|
|
11
11
|
const MEDIA_TYPES = {
|
|
@@ -18,6 +18,26 @@ const MEDIA_TYPES = {
|
|
|
18
18
|
function encodedPath(path) {
|
|
19
19
|
return path.split('/').map(encodeURIComponent).join('/');
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The blobs a cursor holds by path. A cursor this connector did not answer (not the JSON of an object of path to
|
|
23
|
+
* blob) throws a `TypeError` that quotes none of it, since a cursor's text is a repository's paths.
|
|
24
|
+
*/
|
|
25
|
+
function blobsOf(cursor) {
|
|
26
|
+
if (cursor === null)
|
|
27
|
+
return new Map();
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = JSON.parse(cursor);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// The parser's message would quote the cursor.
|
|
34
|
+
parsed = undefined;
|
|
35
|
+
}
|
|
36
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed) || Object.values(parsed).some((blob) => typeof blob !== 'string')) {
|
|
37
|
+
throw new TypeError('the cursor is not one this connector answered');
|
|
38
|
+
}
|
|
39
|
+
return new Map(Object.entries(parsed));
|
|
40
|
+
}
|
|
21
41
|
/**
|
|
22
42
|
* A repository's documentation as account sources: an item's id is `<repositoryId>:<path>`, its version
|
|
23
43
|
* `<blob>@<commit>`, and the cursor of `changesSince` the JSON of each documentation path's blob at the commit last
|
|
@@ -53,14 +73,15 @@ export class GitHubDocumentsConnector {
|
|
|
53
73
|
throw new Error(`repository ${id} is not part of this link`);
|
|
54
74
|
return found;
|
|
55
75
|
}
|
|
56
|
-
token
|
|
57
|
-
|
|
76
|
+
/** An installation token narrowed to one repository, its request ended by the caller's signal. */
|
|
77
|
+
token(id, signal) {
|
|
78
|
+
return this.credential.installationToken(this.installationId, [id], { signal });
|
|
58
79
|
}
|
|
59
80
|
/** The head commit of a repository's default branch. */
|
|
60
81
|
async head(repositoryId, signal) {
|
|
61
82
|
const repository = this.repository(repositoryId);
|
|
62
83
|
const url = `${this.apiBase}/repos/${repository.fullName}/branches/${encodeURIComponent(repository.defaultBranch)}`;
|
|
63
|
-
const branch = objectOf(await githubFetch(this.fetchImpl, url, { token: await this.token(repositoryId), signal }), 'a branch');
|
|
84
|
+
const branch = objectOf(await githubFetch(this.fetchImpl, url, { token: await this.token(repositoryId, signal), signal }), 'a branch');
|
|
64
85
|
return stringIn(objectOf(branch.commit, "a branch's commit"), 'sha', "a branch's commit");
|
|
65
86
|
}
|
|
66
87
|
/**
|
|
@@ -68,7 +89,7 @@ export class GitHubDocumentsConnector {
|
|
|
68
89
|
* a skipped folder, then filtered. A caller keeps it for that commit and hands it to `changesSince`.
|
|
69
90
|
*/
|
|
70
91
|
async listing(repositoryId, commit, signal) {
|
|
71
|
-
const tree = await readTree(this.fetchImpl, await this.token(repositoryId), this.repository(repositoryId).fullName, commit, this.apiBase, {
|
|
92
|
+
const tree = await readTree(this.fetchImpl, await this.token(repositoryId, signal), this.repository(repositoryId).fullName, commit, this.apiBase, {
|
|
72
93
|
maxRequests: this.filter.maxTreeRequests,
|
|
73
94
|
skipFolders: this.filter.skipFolders ?? SKIPPED_FOLDERS,
|
|
74
95
|
signal,
|
|
@@ -87,30 +108,33 @@ export class GitHubDocumentsConnector {
|
|
|
87
108
|
return { items, gone: [] };
|
|
88
109
|
}
|
|
89
110
|
/**
|
|
90
|
-
* A file's raw bytes at the commit of its version, read as a stream
|
|
91
|
-
* as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
92
|
-
* commit. A file GitHub no longer has
|
|
111
|
+
* A file's raw bytes at the commit of its version, read as a stream under the call's deadline and cut at
|
|
112
|
+
* `maxFileBytes`: PDF, Word and HTML as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
113
|
+
* attribution linking the file at that commit. A file GitHub no longer has (the contents read answers 404), or one
|
|
114
|
+
* past the cap, is answered gone with reason `removed`; any other refusal throws `GitHubApiError`, a rate limit with
|
|
115
|
+
* its `retryAt`, so a read GitHub held back is never taken for a file gone. So does a refusal of the installation
|
|
116
|
+
* token (404 for an installation GitHub no longer has): a lost installation never reads as every file gone.
|
|
93
117
|
*/
|
|
94
118
|
async read(item, signal) {
|
|
95
119
|
const [repositoryId, ...rest] = item.id.split(':');
|
|
96
120
|
const path = rest.join(':');
|
|
97
121
|
const repository = this.repository(Number(repositoryId));
|
|
98
122
|
const commit = (item.version ?? '').split('@')[1] ?? repository.defaultBranch;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await
|
|
105
|
-
return { id: item.id, reason: 'removed' };
|
|
123
|
+
const url = `${this.apiBase}/repos/${repository.fullName}/contents/${encodedPath(path)}?ref=${encodeURIComponent(commit)}`;
|
|
124
|
+
// Minted outside the try below: a 404 there is the file's, and the token's own refusal must reach the caller.
|
|
125
|
+
const token = await this.token(repository.id, signal);
|
|
126
|
+
let answer;
|
|
127
|
+
try {
|
|
128
|
+
answer = await githubSend(this.fetchImpl, url, { token, accept: 'application/vnd.github.raw+json', signal });
|
|
106
129
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (error instanceof GitHubApiError && error.status === 404)
|
|
132
|
+
return { id: item.id, reason: 'removed' };
|
|
133
|
+
throw error;
|
|
110
134
|
}
|
|
111
135
|
let bytes;
|
|
112
136
|
try {
|
|
113
|
-
bytes = await
|
|
137
|
+
bytes = await answer.bytes(this.filter.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES);
|
|
114
138
|
}
|
|
115
139
|
catch (error) {
|
|
116
140
|
if (error instanceof ReadCapExceeded)
|
|
@@ -131,16 +155,17 @@ export class GitHubDocumentsConnector {
|
|
|
131
155
|
/**
|
|
132
156
|
* What a push to `after` changed, from the listing at `after` (read here when the caller holds none) against the
|
|
133
157
|
* blobs read before (`cursor`: the JSON of each path's blob). A push's own commit lists are never read, so a force
|
|
134
|
-
* push, or a push of more commits than its event lists, is read like any other. A
|
|
158
|
+
* push, or a push of more commits than its event lists, is read like any other. A cursor this connector did not
|
|
159
|
+
* answer throws a `TypeError` before any request, whatever the push's branch. A push to another branch than the
|
|
135
160
|
* default answers no change and the cursor it was given.
|
|
136
161
|
*/
|
|
137
162
|
async changesSince(cursor, selection, signal) {
|
|
138
163
|
const id = Number(selection.ids[0]);
|
|
139
164
|
const repository = this.repository(id);
|
|
165
|
+
const before = blobsOf(cursor);
|
|
140
166
|
if (selection.ref !== undefined && selection.ref !== `refs/heads/${repository.defaultBranch}`) {
|
|
141
167
|
return { changed: [], gone: [], cursor: cursor ?? '{}' };
|
|
142
168
|
}
|
|
143
|
-
const before = new Map(Object.entries(cursor === null ? {} : JSON.parse(cursor)));
|
|
144
169
|
const after = selection.after ?? (await this.head(id, signal));
|
|
145
170
|
const blobs = selection.listing ?? (await this.listing(id, after, signal));
|
|
146
171
|
const now = new Map(blobs.map((blob) => [blob.path, blob.sha]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubDocumentsConnector.js","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"GitHubDocumentsConnector.js","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,eAAe,GAQhB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAqB,MAAM,gBAAgB,CAAC;AACjI,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAkC,MAAM,WAAW,CAAC;AAsBvI,oGAAoG;AACpG,MAAM,WAAW,GAAqC;IACpD,MAAM,EAAE,iBAAiB;IACzB,OAAO,EAAE,yEAAyE;IAClF,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,WAAW;CACpB,CAAC;AAEF,+DAA+D;AAC/D,SAAS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I,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAC5E,CAAC;IAED,uGAAuG;IACvG,KAAK,CAAC,MAAM;QACV,8FAA8F;IAChG,CAAC;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview The `./documents` entry: a GitHub App's installation mode (its JWT and installation tokens, the user's
|
|
3
|
-
* web flow, what a user token reaches, the webhook signature
|
|
4
|
-
* `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
-
* over an injected `fetch
|
|
3
|
+
* web flow, what a user token reaches, the webhook signature and its deliveries read as typed events, the daily
|
|
4
|
+
* reconcile, the uninstall) and `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
+
* call goes to GitHub's REST API over an injected `fetch`, under a deadline, its answer read under a cap.
|
|
6
6
|
* @module agentos-ext-github/documents
|
|
7
7
|
*/
|
|
8
8
|
/** The documentation connector and the shape of a push it compares. */
|
|
@@ -10,15 +10,20 @@ export { GitHubDocumentsConnector, type GitHubChangesSelection, type LinkedRepos
|
|
|
10
10
|
/** A repository's tree within a request budget, and the filter that keeps its documentation. */
|
|
11
11
|
export { readTree, pathFilter, extensionOf, TreeTooLarge, DOCUMENT_EXTENSIONS, SKIPPED_FOLDERS, DEFAULT_MAX_FILES, DEFAULT_MAX_FILE_BYTES, DEFAULT_MAX_TREE_REQUESTS, type ReadTreeOptions, type TreeBlob, type TreeFilter, } from './tree.js';
|
|
12
12
|
/** The app's JWT and installation tokens. */
|
|
13
|
-
export { appJwt, GitHubAppCredential, type GitHubAppIdentity } from '../app/credential.js';
|
|
13
|
+
export { appJwt, GitHubAppCredential, type GitHubAppIdentity, type InstallationTokenOptions } from '../app/credential.js';
|
|
14
14
|
/** The user's web flow on the auth module's redirect flow. */
|
|
15
|
-
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS, type GitHubAppClient, type GitHubOAuthEndpoints } from '../app/userFlow.js';
|
|
15
|
+
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS, type GitHubAppClient, type GitHubAppUserFlowOptions, type GitHubOAuthEndpoints, } from '../app/userFlow.js';
|
|
16
16
|
/** What a user token reaches, and the app's own installations. */
|
|
17
17
|
export { userOfToken, installationsOfUser, repositoriesOfUser, listInstallations, uninstallInstallation, type GitHubAccount, type GitHubInstallation, type GitHubUser, type UserRepository, } from '../app/installations.js';
|
|
18
18
|
/** A webhook delivery's signature. */
|
|
19
19
|
export { verifyWebhookSignature } from '../app/webhook.js';
|
|
20
|
+
/** A webhook delivery read as a typed event once its signature holds. */
|
|
21
|
+
export { readWebhookDelivery, readWebhookRequest, WebhookDeliveryRefused, DEFAULT_MAX_DELIVERY_BYTES, type GitHubDelivery, type GitHubEvent, type GitHubEventRepository, type GitHubInstallationEvent, type GitHubInstallationRepositoriesEvent, type GitHubInstallationTargetEvent, type GitHubOtherEvent, type GitHubPingEvent, type GitHubPushEvent, type ReadWebhookOptions, type WebhookDeliveryInput, type WebhookRefusalReason, type WebhookRequestInput, } from '../app/events.js';
|
|
20
22
|
/** The daily reconcile. */
|
|
21
23
|
export { reconcileInstallations, type DeliveriesOutcome, type MovedRepository, type ReconcileLink, type ReconcileOptions, type ReconcileOutcome, type ReconcileRepository, type RefusedRedelivery, type UnreadableRepository, } from '../app/reconcile.js';
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The API version every call pins, GitHub's address, a call's deadline and an answer's cap, the error of an answer
|
|
26
|
+
* outside 2xx with its rate limit timing, and the error of a call that got no answer.
|
|
27
|
+
*/
|
|
28
|
+
export { GITHUB_API_BASE, GITHUB_API_VERSION, GITHUB_MAX_ANSWER_BYTES, GITHUB_TIMEOUT_MS, GitHubApiError, GitHubNoAnswer, type GitHubApiOptions, type GitHubNoAnswerReason, type GitHubRefusalTiming, } from '../app/http.js';
|
|
24
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uEAAuE;AACvE,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC7H,gGAAgG;AAChG,OAAO,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,6CAA6C;AAC7C,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uEAAuE;AACvE,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC7H,gGAAgG;AAChG,OAAO,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,6CAA6C;AAC7C,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC1H,8DAA8D;AAC9D,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,kEAAkE;AAClE,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AACjC,sCAAsC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,yEAAyE;AACzE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,mCAAmC,EACxC,KAAK,6BAA6B,EAClC,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,2BAA2B;AAC3B,OAAO,EACL,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B;;;GAGG;AACH,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC"}
|
package/dist/documents/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview The `./documents` entry: a GitHub App's installation mode (its JWT and installation tokens, the user's
|
|
3
|
-
* web flow, what a user token reaches, the webhook signature
|
|
4
|
-
* `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
-
* over an injected `fetch
|
|
3
|
+
* web flow, what a user token reaches, the webhook signature and its deliveries read as typed events, the daily
|
|
4
|
+
* reconcile, the uninstall) and `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
+
* call goes to GitHub's REST API over an injected `fetch`, under a deadline, its answer read under a cap.
|
|
6
6
|
* @module agentos-ext-github/documents
|
|
7
7
|
*/
|
|
8
8
|
/** The documentation connector and the shape of a push it compares. */
|
|
@@ -12,13 +12,18 @@ export { readTree, pathFilter, extensionOf, TreeTooLarge, DOCUMENT_EXTENSIONS, S
|
|
|
12
12
|
/** The app's JWT and installation tokens. */
|
|
13
13
|
export { appJwt, GitHubAppCredential } from '../app/credential.js';
|
|
14
14
|
/** The user's web flow on the auth module's redirect flow. */
|
|
15
|
-
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS } from '../app/userFlow.js';
|
|
15
|
+
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS, } from '../app/userFlow.js';
|
|
16
16
|
/** What a user token reaches, and the app's own installations. */
|
|
17
17
|
export { userOfToken, installationsOfUser, repositoriesOfUser, listInstallations, uninstallInstallation, } from '../app/installations.js';
|
|
18
18
|
/** A webhook delivery's signature. */
|
|
19
19
|
export { verifyWebhookSignature } from '../app/webhook.js';
|
|
20
|
+
/** A webhook delivery read as a typed event once its signature holds. */
|
|
21
|
+
export { readWebhookDelivery, readWebhookRequest, WebhookDeliveryRefused, DEFAULT_MAX_DELIVERY_BYTES, } from '../app/events.js';
|
|
20
22
|
/** The daily reconcile. */
|
|
21
23
|
export { reconcileInstallations, } from '../app/reconcile.js';
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The API version every call pins, GitHub's address, a call's deadline and an answer's cap, the error of an answer
|
|
26
|
+
* outside 2xx with its rate limit timing, and the error of a call that got no answer.
|
|
27
|
+
*/
|
|
28
|
+
export { GITHUB_API_BASE, GITHUB_API_VERSION, GITHUB_MAX_ANSWER_BYTES, GITHUB_TIMEOUT_MS, GitHubApiError, GitHubNoAnswer, } from '../app/http.js';
|
|
24
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uEAAuE;AACvE,OAAO,EAAE,wBAAwB,EAAsD,MAAM,+BAA+B,CAAC;AAC7H,gGAAgG;AAChG,OAAO,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,GAI1B,MAAM,WAAW,CAAC;AACnB,6CAA6C;AAC7C,OAAO,EAAE,MAAM,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uEAAuE;AACvE,OAAO,EAAE,wBAAwB,EAAsD,MAAM,+BAA+B,CAAC;AAC7H,gGAAgG;AAChG,OAAO,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,GAI1B,MAAM,WAAW,CAAC;AACnB,6CAA6C;AAC7C,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAyD,MAAM,sBAAsB,CAAC;AAC1H,8DAA8D;AAC9D,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GAIvB,MAAM,oBAAoB,CAAC;AAC5B,kEAAkE;AAClE,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GAKtB,MAAM,yBAAyB,CAAC;AACjC,sCAAsC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,yEAAyE;AACzE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,GAc3B,MAAM,kBAAkB,CAAC;AAC1B,2BAA2B;AAC3B,OAAO,EACL,sBAAsB,GASvB,MAAM,qBAAqB,CAAC;AAC7B;;;GAGG;AACH,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,cAAc,GAIf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE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AuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,oGAAoG;AACpG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,KAAK,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACnI,eAAe,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module @framers/agentos-ext-github
|
|
9
9
|
*/
|
|
10
10
|
import { execSync } from 'node:child_process';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
11
12
|
import { GitHubService } from './GitHubService.js';
|
|
12
13
|
import { GitHubSearchTool } from './tools/search.js';
|
|
13
14
|
import { GitHubIssueListTool } from './tools/issueList.js';
|
|
@@ -35,6 +36,11 @@ import { GitHubFileWriteTool } from './tools/fileWrite.js';
|
|
|
35
36
|
import { GitHubBranchListTool } from './tools/branchList.js';
|
|
36
37
|
import { GitHubBranchCreateTool } from './tools/branchCreate.js';
|
|
37
38
|
import { GitHubCommitListTool } from './tools/commitList.js';
|
|
39
|
+
/**
|
|
40
|
+
* The package's own version, which the pack reports to its host: read from the package.json one folder above this
|
|
41
|
+
* file, the package's root both from `dist/` and from `src/`.
|
|
42
|
+
*/
|
|
43
|
+
const PACKAGE_VERSION = createRequire(import.meta.url)('../package.json').version;
|
|
38
44
|
function resolveToken(options, secrets) {
|
|
39
45
|
if (options.token)
|
|
40
46
|
return options.token;
|
|
@@ -95,7 +101,8 @@ export function createExtensionPack(context) {
|
|
|
95
101
|
];
|
|
96
102
|
return {
|
|
97
103
|
name: '@framers/agentos-ext-github',
|
|
98
|
-
version:
|
|
104
|
+
version: PACKAGE_VERSION,
|
|
105
|
+
// Each id is the tool's own name, the id manifest.json lists it under.
|
|
99
106
|
descriptors: tools.map((tool) => ({
|
|
100
107
|
id: tool.name,
|
|
101
108
|
kind: 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O,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,oGAAoG;AACpG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAyD,MAAM,wBAAwB,CAAC;AACnI,eAAe,mBAAmB,CAAC"}
|
package/manifest.json
CHANGED
|
@@ -2,36 +2,36 @@
|
|
|
2
2
|
"$schema": "https://agentos.sh/schemas/extension-manifest-v1.json",
|
|
3
3
|
"id": "com.framers.integrations.github",
|
|
4
4
|
"name": "GitHub Extension",
|
|
5
|
-
"version": "0.
|
|
6
|
-
"description": "GitHub API tools: 26 tools for repos, issues, PRs, branches, commits, releases, Actions, files, gists, and codebase indexing. Its ./documents entry adds a GitHub App's installation mode (the app's JWT, installation tokens, the user's web flow, webhook
|
|
5
|
+
"version": "0.3.1",
|
|
6
|
+
"description": "GitHub API tools: 26 tools for repos, issues, PRs, branches, commits, releases, Actions, files, gists, and codebase indexing. Its ./documents entry adds a GitHub App's installation mode (the app's JWT, installation tokens, the user's web flow, webhook deliveries checked and read as typed events, a daily reconcile, every call under a deadline with rate limit timing) and a connector that reads a repository's documentation as account sources.",
|
|
7
7
|
"categories": ["tool", "developer"],
|
|
8
8
|
"extensions": [
|
|
9
|
-
{ "kind": "tool", "id": "
|
|
10
|
-
{ "kind": "tool", "id": "
|
|
11
|
-
{ "kind": "tool", "id": "
|
|
12
|
-
{ "kind": "tool", "id": "
|
|
13
|
-
{ "kind": "tool", "id": "
|
|
14
|
-
{ "kind": "tool", "id": "
|
|
15
|
-
{ "kind": "tool", "id": "
|
|
16
|
-
{ "kind": "tool", "id": "
|
|
17
|
-
{ "kind": "tool", "id": "
|
|
18
|
-
{ "kind": "tool", "id": "
|
|
19
|
-
{ "kind": "tool", "id": "
|
|
20
|
-
{ "kind": "tool", "id": "
|
|
21
|
-
{ "kind": "tool", "id": "
|
|
22
|
-
{ "kind": "tool", "id": "
|
|
23
|
-
{ "kind": "tool", "id": "
|
|
24
|
-
{ "kind": "tool", "id": "
|
|
25
|
-
{ "kind": "tool", "id": "
|
|
26
|
-
{ "kind": "tool", "id": "
|
|
27
|
-
{ "kind": "tool", "id": "
|
|
28
|
-
{ "kind": "tool", "id": "
|
|
29
|
-
{ "kind": "tool", "id": "
|
|
30
|
-
{ "kind": "tool", "id": "
|
|
31
|
-
{ "kind": "tool", "id": "
|
|
32
|
-
{ "kind": "tool", "id": "
|
|
33
|
-
{ "kind": "tool", "id": "
|
|
34
|
-
{ "kind": "tool", "id": "
|
|
9
|
+
{ "kind": "tool", "id": "github_search", "displayName": "GitHub Search" },
|
|
10
|
+
{ "kind": "tool", "id": "github_issue_list", "displayName": "List GitHub Issues" },
|
|
11
|
+
{ "kind": "tool", "id": "github_issue_create", "displayName": "Create GitHub Issue" },
|
|
12
|
+
{ "kind": "tool", "id": "github_pr_list", "displayName": "List GitHub PRs" },
|
|
13
|
+
{ "kind": "tool", "id": "github_pr_create", "displayName": "Create GitHub PR" },
|
|
14
|
+
{ "kind": "tool", "id": "github_file_read", "displayName": "Read GitHub File" },
|
|
15
|
+
{ "kind": "tool", "id": "github_gist_create", "displayName": "Create GitHub Gist" },
|
|
16
|
+
{ "kind": "tool", "id": "github_repo_list", "displayName": "GitHub Repo List" },
|
|
17
|
+
{ "kind": "tool", "id": "github_repo_info", "displayName": "GitHub Repo Info" },
|
|
18
|
+
{ "kind": "tool", "id": "github_repo_create", "displayName": "GitHub Repo Create" },
|
|
19
|
+
{ "kind": "tool", "id": "github_repo_index", "displayName": "GitHub Repo Index" },
|
|
20
|
+
{ "kind": "tool", "id": "github_file_write", "displayName": "GitHub File Write" },
|
|
21
|
+
{ "kind": "tool", "id": "github_branch_list", "displayName": "GitHub Branch List" },
|
|
22
|
+
{ "kind": "tool", "id": "github_branch_create", "displayName": "GitHub Branch Create" },
|
|
23
|
+
{ "kind": "tool", "id": "github_commit_list", "displayName": "GitHub Commit List" },
|
|
24
|
+
{ "kind": "tool", "id": "github_issue_update", "displayName": "GitHub Issue Update" },
|
|
25
|
+
{ "kind": "tool", "id": "github_comment_list", "displayName": "GitHub Comment List" },
|
|
26
|
+
{ "kind": "tool", "id": "github_pr_diff", "displayName": "GitHub PR Diff" },
|
|
27
|
+
{ "kind": "tool", "id": "github_pr_review", "displayName": "GitHub PR Review" },
|
|
28
|
+
{ "kind": "tool", "id": "github_pr_merge", "displayName": "GitHub PR Merge" },
|
|
29
|
+
{ "kind": "tool", "id": "github_pr_comment_list", "displayName": "GitHub PR Comment List" },
|
|
30
|
+
{ "kind": "tool", "id": "github_pr_comment_create", "displayName": "GitHub PR Comment Create" },
|
|
31
|
+
{ "kind": "tool", "id": "github_release_list", "displayName": "GitHub Release List" },
|
|
32
|
+
{ "kind": "tool", "id": "github_release_create", "displayName": "GitHub Release Create" },
|
|
33
|
+
{ "kind": "tool", "id": "github_actions_list", "displayName": "GitHub Actions List" },
|
|
34
|
+
{ "kind": "tool", "id": "github_actions_trigger", "displayName": "GitHub Actions Trigger" }
|
|
35
35
|
],
|
|
36
36
|
"requiredSecrets": ["github.token"],
|
|
37
37
|
"features": [
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"GitHub Actions workflow listing and triggering",
|
|
47
47
|
"Gist creation",
|
|
48
48
|
"GitHub App installation mode: app JWT, installation tokens, the user's web flow, installations and repositories a user can reach, webhook signatures, daily reconcile",
|
|
49
|
+
"Webhook deliveries read as typed events: pushes, installation actions, repositories added and removed, accounts renamed",
|
|
50
|
+
"Every REST call under a deadline, answers read under a cap, rate limits answered with the time to try again",
|
|
49
51
|
"Repository documentation as account sources, read by tree with raw file reads and compared by tree on a push"
|
|
50
52
|
]
|
|
51
53
|
}
|