@kana-ai/edgar-ext-gcp 0.0.0-stage → 0.1.4
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 +202 -0
- package/README.md +46 -2
- package/dist/src/api/auth.d.ts +17 -0
- package/dist/src/api/auth.js +66 -0
- package/dist/src/api/client.d.ts +7 -0
- package/dist/src/api/client.js +31 -0
- package/dist/src/api/failures.d.ts +8 -0
- package/dist/src/api/failures.js +52 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +18 -0
- package/dist/src/schemas/config.d.ts +11 -0
- package/dist/src/schemas/config.js +23 -0
- package/dist/src/schemas/google.d.ts +79 -0
- package/dist/src/schemas/google.js +55 -0
- package/dist/src/schemas/tools.d.ts +35 -0
- package/dist/src/schemas/tools.js +52 -0
- package/dist/src/tools/alerts.d.ts +14 -0
- package/dist/src/tools/alerts.js +44 -0
- package/dist/src/tools/logs.d.ts +21 -0
- package/dist/src/tools/logs.js +66 -0
- package/edgar-extension.json +57 -0
- package/package.json +41 -3
- package/schemas/alerts.in.json +12 -0
- package/schemas/alerts.out.json +41 -0
- package/schemas/config.json +26 -0
- package/schemas/read_logs.in.json +30 -0
- package/schemas/read_logs.out.json +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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 Kana.ai
|
|
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.
|
|
202
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kana-ai/edgar-ext-gcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Google Cloud extension of EDGAR. Many services run on Google Cloud, and their logs and alerts live there. The extension's tools read the entries of a Cloud Logging filter that the project names, and the open alerts of Cloud Monitoring. They only read; a service account with the Logs Viewer and Monitoring Viewer roles is enough.
|
|
4
|
+
|
|
5
|
+
## Set up
|
|
6
|
+
|
|
7
|
+
```toml
|
|
8
|
+
[extensions]
|
|
9
|
+
enabled = ["gcp"]
|
|
10
|
+
|
|
11
|
+
[extensions.gcp]
|
|
12
|
+
project = "shop-prod-1"
|
|
13
|
+
logs = { api = 'resource.type="cloud_run_revision" AND resource.labels.service_name="api"' }
|
|
14
|
+
|
|
15
|
+
[secrets]
|
|
16
|
+
GOOGLE_CLOUD_KEY = { env = "GOOGLE_CLOUD_KEY" }
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`GOOGLE_CLOUD_KEY` holds the JSON key file of the service account. Each call signs a request for a read-only access token with it, at `oauth2.googleapis.com`, and never at the address the key file names.
|
|
20
|
+
|
|
21
|
+
## Tools
|
|
22
|
+
|
|
23
|
+
| Tool | Input | Output | Notes |
|
|
24
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `read_logs` | `log`: a name of `logs`; optional `since` (an hour ago when absent), `until`, `lines` (1 to 1000, 200 when absent) | `log`: each entry as its time, its severity and its text, oldest first; `truncated` | Reads at most `lines` entries and 32 KiB. The text of an entry is its text payload, else the `message` of its JSON payload, else the payload as JSON. A name that `logs` does not hold is `refused`, with the names it holds, and no request is sent. EDGAR redacts each secret it holds from the answer. |
|
|
26
|
+
| `alerts` | optional `limit` (1 to 100, 50 when absent) | `alerts`: `id`, `policy`, `severity`, `opened_at`, `resource`, `metric`; `complete` | The open alerts, newest first. `complete` is false when more are open than `limit`. |
|
|
27
|
+
|
|
28
|
+
The built-in `investigate` role gets `read_logs` when the extension is enabled, as it gets `docker__read_logs`.
|
|
29
|
+
|
|
30
|
+
A role names a filter and never writes one, so it reads only what the project chose. A log can hold personal data that no redaction removes, so keep each filter narrow.
|
|
31
|
+
|
|
32
|
+
## Failures
|
|
33
|
+
|
|
34
|
+
One table maps Google's error code (`error.status` of an API, `error` of the token endpoint) to a kind, then the HTTP status when the code is not in it:
|
|
35
|
+
|
|
36
|
+
| Code | Kind | Retried |
|
|
37
|
+
| --------------------------------------------------------- | ---------------------- | ------------------------------------ |
|
|
38
|
+
| `INVALID_ARGUMENT`, `FAILED_PRECONDITION`, `OUT_OF_RANGE` | `invalid` | no |
|
|
39
|
+
| `UNAUTHENTICATED`, `invalid_grant`, `invalid_client` | `unauthenticated` | no |
|
|
40
|
+
| `PERMISSION_DENIED`, `unauthorized_client` | `forbidden` | no |
|
|
41
|
+
| `NOT_FOUND` | `not_found` | no |
|
|
42
|
+
| `RESOURCE_EXHAUSTED` | `rate_limited` | yes, after `Retry-After` or a minute |
|
|
43
|
+
| `UNAVAILABLE`, `INTERNAL`, or a 5xx with no code | `provider_unavailable` | yes |
|
|
44
|
+
| `DEADLINE_EXCEEDED` | `timeout` | yes |
|
|
45
|
+
| any other | `tool_error` | no |
|
|
46
|
+
|
|
47
|
+
Every call only reads, so a retry repeats nothing. `cause` keeps the status and the code, never Google's message, which can quote the request.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Ctx, type Failure, type Result } from "@kana-ai/edgar-sdk";
|
|
2
|
+
/** The secret that holds the JSON key of a service account with the Logs Viewer and Monitoring Viewer roles. */
|
|
3
|
+
export declare const KEY = "GOOGLE_CLOUD_KEY";
|
|
4
|
+
export declare const TOKEN_HOST = "oauth2.googleapis.com";
|
|
5
|
+
export declare const LOGGING_HOST = "logging.googleapis.com";
|
|
6
|
+
export declare const MONITORING_HOST = "monitoring.googleapis.com";
|
|
7
|
+
/** The secret and the capabilities of each tool. */
|
|
8
|
+
export declare const apiAccess: {
|
|
9
|
+
readonly secrets: readonly ["GOOGLE_CLOUD_KEY"];
|
|
10
|
+
readonly capabilities: readonly ["network:oauth2.googleapis.com", "network:logging.googleapis.com", "network:monitoring.googleapis.com"];
|
|
11
|
+
};
|
|
12
|
+
/** A context that holds the key. */
|
|
13
|
+
export type GoogleCtx = Ctx<typeof KEY>;
|
|
14
|
+
/** The signed JWT that asks the token endpoint for an access token of the service account, valid for an hour from `nowSeconds`. */
|
|
15
|
+
export declare function assertion(key: string, nowSeconds: number): Result<string, Failure>;
|
|
16
|
+
/** An access token for one call. shortcut: each call asks for a new token, two requests a call; keep one until it expires if a busy role makes the token endpoint a limit. */
|
|
17
|
+
export declare function accessToken(ctx: GoogleCtx, now?: number): Promise<Result<string, Failure>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { sign } from "node:crypto";
|
|
2
|
+
import { attempt, attemptAsync, err, fetchFailure, ok, permanentFailure, unwrapOr, } from "@kana-ai/edgar-sdk";
|
|
3
|
+
import { mapFailure } from "#api/failures";
|
|
4
|
+
import { serviceAccountKey, tokenAnswer } from "#schemas/google";
|
|
5
|
+
/** The secret that holds the JSON key of a service account with the Logs Viewer and Monitoring Viewer roles. */
|
|
6
|
+
export const KEY = "GOOGLE_CLOUD_KEY";
|
|
7
|
+
export const TOKEN_HOST = "oauth2.googleapis.com";
|
|
8
|
+
export const LOGGING_HOST = "logging.googleapis.com";
|
|
9
|
+
export const MONITORING_HOST = "monitoring.googleapis.com";
|
|
10
|
+
/** The token endpoint is fixed here, never read from the key file, so a key cannot send the assertion elsewhere. */
|
|
11
|
+
const TOKEN_URL = `https://${TOKEN_HOST}/token`;
|
|
12
|
+
/** Read-only scopes: the token can read logs and alerts and change nothing. */
|
|
13
|
+
const SCOPES = [
|
|
14
|
+
"https://www.googleapis.com/auth/logging.read",
|
|
15
|
+
"https://www.googleapis.com/auth/monitoring.read",
|
|
16
|
+
].join(" ");
|
|
17
|
+
/** The secret and the capabilities of each tool. */
|
|
18
|
+
export const apiAccess = {
|
|
19
|
+
secrets: [KEY],
|
|
20
|
+
capabilities: [`network:${TOKEN_HOST}`, `network:${LOGGING_HOST}`, `network:${MONITORING_HOST}`],
|
|
21
|
+
};
|
|
22
|
+
const base64url = (text) => Buffer.from(text).toString("base64url");
|
|
23
|
+
/** The signed JWT that asks the token endpoint for an access token of the service account, valid for an hour from `nowSeconds`. */
|
|
24
|
+
export function assertion(key, nowSeconds) {
|
|
25
|
+
const parsed = attempt(() => JSON.parse(key), () => undefined);
|
|
26
|
+
const account = serviceAccountKey.safeParse(unwrapOr(parsed, undefined));
|
|
27
|
+
if (!account.success)
|
|
28
|
+
return err(permanentFailure("unauthenticated", `${KEY} is not the JSON key of a service account`));
|
|
29
|
+
const head = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
|
30
|
+
const claims = base64url(JSON.stringify({
|
|
31
|
+
iss: account.data.client_email,
|
|
32
|
+
scope: SCOPES,
|
|
33
|
+
aud: TOKEN_URL,
|
|
34
|
+
iat: nowSeconds,
|
|
35
|
+
exp: nowSeconds + 3600,
|
|
36
|
+
}));
|
|
37
|
+
const signed = attempt(() => sign("RSA-SHA256", Buffer.from(`${head}.${claims}`), account.data.private_key), () => undefined);
|
|
38
|
+
if (!signed.ok)
|
|
39
|
+
return err(permanentFailure("unauthenticated", `the private key of ${KEY} cannot sign`));
|
|
40
|
+
return ok(`${head}.${claims}.${base64url(signed.value)}`);
|
|
41
|
+
}
|
|
42
|
+
/** An access token for one call. shortcut: each call asks for a new token, two requests a call; keep one until it expires if a busy role makes the token endpoint a limit. */
|
|
43
|
+
export async function accessToken(ctx, now = Date.now()) {
|
|
44
|
+
const jwt = assertion(ctx.secrets.get(KEY), Math.floor(now / 1000));
|
|
45
|
+
if (!jwt.ok)
|
|
46
|
+
return jwt;
|
|
47
|
+
const context = "gcp POST /token";
|
|
48
|
+
const sent = await attemptAsync(async () => await fetch(TOKEN_URL, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
signal: ctx.signal,
|
|
51
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
52
|
+
body: new URLSearchParams({
|
|
53
|
+
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
54
|
+
assertion: jwt.value,
|
|
55
|
+
}).toString(),
|
|
56
|
+
}), (caught) => fetchFailure(caught, ctx.signal, context));
|
|
57
|
+
if (!sent.ok)
|
|
58
|
+
return sent;
|
|
59
|
+
const body = unwrapOr(await attemptAsync(async () => await sent.value.json(), () => null), null);
|
|
60
|
+
if (!sent.value.ok)
|
|
61
|
+
return err(mapFailure(sent.value.status, sent.value.headers, body, context, now));
|
|
62
|
+
const token = tokenAnswer.safeParse(body);
|
|
63
|
+
return token.success
|
|
64
|
+
? ok(token.data.access_token)
|
|
65
|
+
: err(permanentFailure("tool_error", `${context}: unexpected answer`));
|
|
66
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Failure, type Result } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import { type GoogleCtx } from "#api/auth";
|
|
4
|
+
/** The answer of one call: the parsed body, or the failure it maps to. */
|
|
5
|
+
export type Reply<T> = Result<T, Failure>;
|
|
6
|
+
/** Calls one Google API `url` with a fresh access token, sends `body` as JSON when given, and parses the answer with `schema`. */
|
|
7
|
+
export declare function google<T>(ctx: GoogleCtx, url: URL, body: unknown, schema: z.ZodType<T>, now?: number): Promise<Reply<T>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { attemptAsync, err, failure, fetchFailure, ok, unwrapOr, } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { accessToken } from "#api/auth";
|
|
3
|
+
import { mapFailure } from "#api/failures";
|
|
4
|
+
/** Calls one Google API `url` with a fresh access token, sends `body` as JSON when given, and parses the answer with `schema`. */
|
|
5
|
+
export async function google(ctx, url, body, schema, now = Date.now()) {
|
|
6
|
+
const token = await accessToken(ctx, now);
|
|
7
|
+
if (!token.ok)
|
|
8
|
+
return token;
|
|
9
|
+
const method = body === undefined ? "GET" : "POST";
|
|
10
|
+
const context = `gcp ${method} ${url.host}${url.pathname}`;
|
|
11
|
+
const sent = await attemptAsync(async () => await fetch(url, {
|
|
12
|
+
method,
|
|
13
|
+
signal: ctx.signal,
|
|
14
|
+
headers: {
|
|
15
|
+
authorization: `Bearer ${token.value}`,
|
|
16
|
+
accept: "application/json",
|
|
17
|
+
...(body === undefined ? {} : { "content-type": "application/json" }),
|
|
18
|
+
},
|
|
19
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
20
|
+
}), (caught) => fetchFailure(caught, ctx.signal, context));
|
|
21
|
+
if (!sent.ok)
|
|
22
|
+
return sent;
|
|
23
|
+
const json = unwrapOr(await attemptAsync(async () => await sent.value.json(), () => null), null);
|
|
24
|
+
if (!sent.value.ok)
|
|
25
|
+
return err(mapFailure(sent.value.status, sent.value.headers, json, context, now));
|
|
26
|
+
const read = schema.safeParse(json);
|
|
27
|
+
if (read.success)
|
|
28
|
+
return ok(read.data);
|
|
29
|
+
const fields = read.error.issues.map((i) => i.path.join(".") || "(root)").join(", ");
|
|
30
|
+
return err(failure("tool_error", `${context}: unexpected answer`, { cause: `fields: ${fields}` }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Failure } from "@kana-ai/edgar-sdk";
|
|
2
|
+
/** Google reports a quota hit as `RESOURCE_EXHAUSTED`, sometimes with `Retry-After`. */
|
|
3
|
+
export declare const limits: {
|
|
4
|
+
readonly scheme: "retry_after";
|
|
5
|
+
readonly source: "googleapis.com";
|
|
6
|
+
};
|
|
7
|
+
/** Maps an error answer of Google to a failure: the vendor code first, then the HTTP status. `cause` keeps the status and the raw code, never the message, which can quote the request. */
|
|
8
|
+
export declare function mapFailure(status: number, headers: Headers, body: unknown, context: string, now?: number): Failure;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { vendorFailure } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { apiError, tokenError } from "#schemas/google";
|
|
3
|
+
/** Google reports a quota hit as `RESOURCE_EXHAUSTED`, sometimes with `Retry-After`. */
|
|
4
|
+
export const limits = {
|
|
5
|
+
scheme: "retry_after",
|
|
6
|
+
source: "googleapis.com",
|
|
7
|
+
};
|
|
8
|
+
/** The kind of each Google error code. Only a row of a temporary kind retries, and every call is a read, so a retry repeats nothing; a code that is not here is `tool_error`, a permanent failure. */
|
|
9
|
+
const vendorKinds = new Map([
|
|
10
|
+
["INVALID_ARGUMENT", "invalid"],
|
|
11
|
+
["FAILED_PRECONDITION", "invalid"],
|
|
12
|
+
["OUT_OF_RANGE", "invalid"],
|
|
13
|
+
["UNAUTHENTICATED", "unauthenticated"],
|
|
14
|
+
["PERMISSION_DENIED", "forbidden"],
|
|
15
|
+
["NOT_FOUND", "not_found"],
|
|
16
|
+
["RESOURCE_EXHAUSTED", "rate_limited"],
|
|
17
|
+
["UNAVAILABLE", "provider_unavailable"],
|
|
18
|
+
["INTERNAL", "provider_unavailable"],
|
|
19
|
+
["DEADLINE_EXCEEDED", "timeout"],
|
|
20
|
+
["invalid_grant", "unauthenticated"],
|
|
21
|
+
["invalid_client", "unauthenticated"],
|
|
22
|
+
["unauthorized_client", "forbidden"],
|
|
23
|
+
]);
|
|
24
|
+
/** The kind of an answer with no code that the table knows, by its HTTP status. */
|
|
25
|
+
function statusKind(status) {
|
|
26
|
+
if (status >= 500)
|
|
27
|
+
return "provider_unavailable";
|
|
28
|
+
if (status === 429)
|
|
29
|
+
return "rate_limited";
|
|
30
|
+
if (status === 401)
|
|
31
|
+
return "unauthenticated";
|
|
32
|
+
if (status === 403)
|
|
33
|
+
return "forbidden";
|
|
34
|
+
if (status === 404)
|
|
35
|
+
return "not_found";
|
|
36
|
+
return "tool_error";
|
|
37
|
+
}
|
|
38
|
+
/** Google's code of an error answer: `error.status` of an API, or `error` of the token endpoint. */
|
|
39
|
+
function codeOf(body) {
|
|
40
|
+
const api = apiError.safeParse(body);
|
|
41
|
+
if (api.success)
|
|
42
|
+
return api.data.error.status;
|
|
43
|
+
const token = tokenError.safeParse(body);
|
|
44
|
+
return token.success ? token.data.error : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** Maps an error answer of Google to a failure: the vendor code first, then the HTTP status. `cause` keeps the status and the raw code, never the message, which can quote the request. */
|
|
47
|
+
export function mapFailure(status, headers, body, context, now = Date.now()) {
|
|
48
|
+
const code = codeOf(body);
|
|
49
|
+
const kind = (code === undefined ? undefined : vendorKinds.get(code)) ?? statusKind(status);
|
|
50
|
+
const cause = code === undefined ? `status:${String(status)}` : `status:${String(status)} ${code}`;
|
|
51
|
+
return vendorFailure(kind, context, cause, headers, limits, now);
|
|
52
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** The Google Cloud extension: `read_logs` reads the entries of a Cloud Logging filter the project names, and `alerts` the open alerts of Cloud Monitoring, both with a read-only service-account key. */
|
|
2
|
+
declare const _default: import("@kana-ai/edgar-sdk").Extension;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineExtension } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { KEY, LOGGING_HOST, MONITORING_HOST, TOKEN_HOST, apiAccess } from "#api/auth";
|
|
3
|
+
import { config } from "#schemas/config";
|
|
4
|
+
import { alerts } from "#tools/alerts";
|
|
5
|
+
import { readLogs } from "#tools/logs";
|
|
6
|
+
/** The Google Cloud extension: `read_logs` reads the entries of a Cloud Logging filter the project names, and `alerts` the open alerts of Cloud Monitoring, both with a read-only service-account key. */
|
|
7
|
+
export default defineExtension({
|
|
8
|
+
name: "gcp",
|
|
9
|
+
config,
|
|
10
|
+
secrets: {
|
|
11
|
+
[KEY]: {
|
|
12
|
+
hosts: [TOKEN_HOST, LOGGING_HOST, MONITORING_HOST],
|
|
13
|
+
help: "The JSON key of a Google Cloud service account with the Logs Viewer and Monitoring Viewer roles.",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
capabilities: apiAccess.capabilities,
|
|
17
|
+
tools: { read_logs: readLogs, alerts },
|
|
18
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Failure, type Result } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** The `[extensions.gcp]` table: the project to read, and the Cloud Logging filters `read_logs` may read, by name. A role names a filter and never writes one, so it reads only what the project chose; keep each filter narrow, since a log can hold personal data that no redaction removes. */
|
|
4
|
+
export declare const config: z.ZodObject<{
|
|
5
|
+
project: z.ZodString;
|
|
6
|
+
logs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
/** The parsed `[extensions.gcp]` table. */
|
|
9
|
+
export type Config = z.output<typeof config>;
|
|
10
|
+
/** The `[extensions.gcp]` table a call receives, or the failure when it does not match its schema. */
|
|
11
|
+
export declare function readConfig(raw: unknown): Result<Config, Failure>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { err, ok, permanentFailure } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** A Google Cloud project id: 6 to 30 lowercase letters, digits and hyphens, starting with a letter. */
|
|
4
|
+
const projectId = z.string().regex(/^[a-z][a-z0-9-]{4,28}[a-z0-9]$/);
|
|
5
|
+
/** A name of `logs`, as a role writes it in a call. */
|
|
6
|
+
const logName = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
|
|
7
|
+
/** The `[extensions.gcp]` table: the project to read, and the Cloud Logging filters `read_logs` may read, by name. A role names a filter and never writes one, so it reads only what the project chose; keep each filter narrow, since a log can hold personal data that no redaction removes. */
|
|
8
|
+
export const config = z.strictObject({
|
|
9
|
+
project: projectId.describe("the Google Cloud project whose logs and alerts the tools read"),
|
|
10
|
+
logs: z
|
|
11
|
+
.record(logName, z.string().min(1))
|
|
12
|
+
.default({})
|
|
13
|
+
.describe('each Cloud Logging filter that read_logs may read, by name, such as api = \'resource.type="cloud_run_revision" AND resource.labels.service_name="api"\''),
|
|
14
|
+
});
|
|
15
|
+
/** The `[extensions.gcp]` table a call receives, or the failure when it does not match its schema. */
|
|
16
|
+
export function readConfig(raw) {
|
|
17
|
+
const settings = config.safeParse(raw ?? {});
|
|
18
|
+
if (settings.success)
|
|
19
|
+
return ok(settings.data);
|
|
20
|
+
return err(permanentFailure("invalid", "the [extensions.gcp] table does not match its schema", {
|
|
21
|
+
cause: settings.error.issues.map((issue) => issue.message).join("; "),
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The fields of a service-account key file that the token request needs. */
|
|
3
|
+
export declare const serviceAccountKey: z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"service_account">;
|
|
5
|
+
client_email: z.ZodString;
|
|
6
|
+
private_key: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
/** The answer of the token endpoint to a signed assertion. */
|
|
9
|
+
export declare const tokenAnswer: z.ZodObject<{
|
|
10
|
+
access_token: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/** An error answer of a Google API: `status` is the vendor code, such as `PERMISSION_DENIED`. */
|
|
13
|
+
export declare const apiError: z.ZodObject<{
|
|
14
|
+
error: z.ZodObject<{
|
|
15
|
+
status: z.ZodOptional<z.ZodString>;
|
|
16
|
+
message: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** An error answer of the token endpoint, such as `invalid_grant`. */
|
|
20
|
+
export declare const tokenError: z.ZodObject<{
|
|
21
|
+
error: z.ZodString;
|
|
22
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
/** One entry of `entries:list`, with the payload in one of its three forms. */
|
|
25
|
+
export declare const logEntry: z.ZodObject<{
|
|
26
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
27
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
28
|
+
textPayload: z.ZodOptional<z.ZodString>;
|
|
29
|
+
jsonPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
+
protoPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/** The answer of `entries:list`; an empty page has no `entries`. */
|
|
33
|
+
export declare const logEntries: z.ZodObject<{
|
|
34
|
+
entries: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
35
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
36
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
37
|
+
textPayload: z.ZodOptional<z.ZodString>;
|
|
38
|
+
jsonPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
|
+
protoPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
40
|
+
}, z.core.$strip>>>;
|
|
41
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
/** One alert of the Cloud Monitoring alerts API. */
|
|
44
|
+
export declare const alert: z.ZodObject<{
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
state: z.ZodOptional<z.ZodString>;
|
|
47
|
+
openTime: z.ZodOptional<z.ZodString>;
|
|
48
|
+
policy: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
50
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
resource: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
type: z.ZodOptional<z.ZodString>;
|
|
54
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
metric: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
type: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
/** The answer of `alerts.list`; an empty page has no `alerts`. */
|
|
61
|
+
export declare const alerts: z.ZodObject<{
|
|
62
|
+
alerts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
state: z.ZodOptional<z.ZodString>;
|
|
65
|
+
openTime: z.ZodOptional<z.ZodString>;
|
|
66
|
+
policy: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
68
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
resource: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
type: z.ZodOptional<z.ZodString>;
|
|
72
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
metric: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
type: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>>;
|
|
77
|
+
}, z.core.$strip>>>;
|
|
78
|
+
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The fields of a service-account key file that the token request needs. */
|
|
3
|
+
export const serviceAccountKey = z.object({
|
|
4
|
+
type: z.literal("service_account"),
|
|
5
|
+
client_email: z.string().min(1),
|
|
6
|
+
private_key: z.string().min(1),
|
|
7
|
+
});
|
|
8
|
+
/** The answer of the token endpoint to a signed assertion. */
|
|
9
|
+
export const tokenAnswer = z.object({ access_token: z.string().min(1) });
|
|
10
|
+
/** An error answer of a Google API: `status` is the vendor code, such as `PERMISSION_DENIED`. */
|
|
11
|
+
export const apiError = z.object({
|
|
12
|
+
error: z.object({ status: z.string().optional(), message: z.string().optional() }),
|
|
13
|
+
});
|
|
14
|
+
/** An error answer of the token endpoint, such as `invalid_grant`. */
|
|
15
|
+
export const tokenError = z.object({
|
|
16
|
+
error: z.string(),
|
|
17
|
+
error_description: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
/** One entry of `entries:list`, with the payload in one of its three forms. */
|
|
20
|
+
export const logEntry = z.object({
|
|
21
|
+
timestamp: z.string().optional(),
|
|
22
|
+
severity: z.string().optional(),
|
|
23
|
+
textPayload: z.string().optional(),
|
|
24
|
+
jsonPayload: z.record(z.string(), z.unknown()).optional(),
|
|
25
|
+
protoPayload: z.record(z.string(), z.unknown()).optional(),
|
|
26
|
+
});
|
|
27
|
+
/** The answer of `entries:list`; an empty page has no `entries`. */
|
|
28
|
+
export const logEntries = z.object({
|
|
29
|
+
entries: z.array(logEntry).optional(),
|
|
30
|
+
nextPageToken: z.string().optional(),
|
|
31
|
+
});
|
|
32
|
+
/** One alert of the Cloud Monitoring alerts API. */
|
|
33
|
+
export const alert = z.object({
|
|
34
|
+
name: z.string(),
|
|
35
|
+
state: z.string().optional(),
|
|
36
|
+
openTime: z.string().optional(),
|
|
37
|
+
policy: z
|
|
38
|
+
.object({
|
|
39
|
+
displayName: z.string().optional(),
|
|
40
|
+
severity: z.string().optional(),
|
|
41
|
+
})
|
|
42
|
+
.optional(),
|
|
43
|
+
resource: z
|
|
44
|
+
.object({
|
|
45
|
+
type: z.string().optional(),
|
|
46
|
+
labels: z.record(z.string(), z.string()).optional(),
|
|
47
|
+
})
|
|
48
|
+
.optional(),
|
|
49
|
+
metric: z.object({ type: z.string().optional() }).optional(),
|
|
50
|
+
});
|
|
51
|
+
/** The answer of `alerts.list`; an empty page has no `alerts`. */
|
|
52
|
+
export const alerts = z.object({
|
|
53
|
+
alerts: z.array(alert).optional(),
|
|
54
|
+
nextPageToken: z.string().optional(),
|
|
55
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The entries `read_logs` reads when the call names no number. */
|
|
3
|
+
export declare const LINES = 200;
|
|
4
|
+
/** The alerts `alerts` reads when the call names no number. */
|
|
5
|
+
export declare const ALERTS = 50;
|
|
6
|
+
/** The input and output of `read_logs`: the newest entries of one named filter in a window. */
|
|
7
|
+
export declare const readLogsTool: {
|
|
8
|
+
input: z.ZodObject<{
|
|
9
|
+
log: z.ZodString;
|
|
10
|
+
since: z.ZodOptional<z.ZodISODateTime>;
|
|
11
|
+
until: z.ZodOptional<z.ZodISODateTime>;
|
|
12
|
+
lines: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
output: z.ZodObject<{
|
|
15
|
+
log: z.ZodString;
|
|
16
|
+
truncated: z.ZodBoolean;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
};
|
|
19
|
+
/** The input and output of `alerts`: the open alerts of the project, newest first. */
|
|
20
|
+
export declare const alertsTool: {
|
|
21
|
+
input: z.ZodObject<{
|
|
22
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
output: z.ZodObject<{
|
|
25
|
+
alerts: z.ZodArray<z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
policy: z.ZodString;
|
|
28
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
29
|
+
opened_at: z.ZodOptional<z.ZodString>;
|
|
30
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
31
|
+
metric: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
complete: z.ZodBoolean;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The entries `read_logs` reads when the call names no number. */
|
|
3
|
+
export const LINES = 200;
|
|
4
|
+
/** The alerts `alerts` reads when the call names no number. */
|
|
5
|
+
export const ALERTS = 50;
|
|
6
|
+
/** The input and output of `read_logs`: the newest entries of one named filter in a window. */
|
|
7
|
+
export const readLogsTool = {
|
|
8
|
+
input: z.object({
|
|
9
|
+
log: z.string().min(1).describe("a filter that [extensions.gcp] logs names"),
|
|
10
|
+
since: z.iso
|
|
11
|
+
.datetime({ offset: true })
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("the time of the first entry; the last hour when absent"),
|
|
14
|
+
until: z.iso.datetime({ offset: true }).optional().describe("now when absent"),
|
|
15
|
+
lines: z
|
|
16
|
+
.number()
|
|
17
|
+
.int()
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(1000)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(`${String(LINES)} when absent`),
|
|
22
|
+
}),
|
|
23
|
+
output: z.object({
|
|
24
|
+
log: z.string().describe("each entry as its time, its severity and its text, oldest first"),
|
|
25
|
+
truncated: z
|
|
26
|
+
.boolean()
|
|
27
|
+
.describe("true when the entry count or the byte cap was reached, so older entries may be left out"),
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
/** The input and output of `alerts`: the open alerts of the project, newest first. */
|
|
31
|
+
export const alertsTool = {
|
|
32
|
+
input: z.object({
|
|
33
|
+
limit: z
|
|
34
|
+
.number()
|
|
35
|
+
.int()
|
|
36
|
+
.min(1)
|
|
37
|
+
.max(100)
|
|
38
|
+
.optional()
|
|
39
|
+
.describe(`${String(ALERTS)} when absent`),
|
|
40
|
+
}),
|
|
41
|
+
output: z.object({
|
|
42
|
+
alerts: z.array(z.object({
|
|
43
|
+
id: z.string().describe("the alert's resource name, stable while it is open"),
|
|
44
|
+
policy: z.string().describe("the name of the alerting policy that opened it"),
|
|
45
|
+
severity: z.string().optional(),
|
|
46
|
+
opened_at: z.string().optional(),
|
|
47
|
+
resource: z.string().optional().describe("the monitored resource's type and labels"),
|
|
48
|
+
metric: z.string().optional(),
|
|
49
|
+
})),
|
|
50
|
+
complete: z.boolean().describe("false when more open alerts exist than `limit`"),
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** `alerts`: the open alerts of the project's Cloud Monitoring, newest first, so a role or a feeder can tell what fires now. */
|
|
2
|
+
export declare const alerts: import("@kana-ai/edgar-sdk").Tool<{
|
|
3
|
+
limit?: number | undefined;
|
|
4
|
+
}, {
|
|
5
|
+
alerts: {
|
|
6
|
+
id: string;
|
|
7
|
+
policy: string;
|
|
8
|
+
severity?: string | undefined;
|
|
9
|
+
opened_at?: string | undefined;
|
|
10
|
+
resource?: string | undefined;
|
|
11
|
+
metric?: string | undefined;
|
|
12
|
+
}[];
|
|
13
|
+
complete: boolean;
|
|
14
|
+
}, "GOOGLE_CLOUD_KEY">;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineTool, done } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { MONITORING_HOST, apiAccess } from "#api/auth";
|
|
3
|
+
import { google } from "#api/client";
|
|
4
|
+
import { readConfig } from "#schemas/config";
|
|
5
|
+
import { alerts as alertList } from "#schemas/google";
|
|
6
|
+
import { ALERTS, alertsTool } from "#schemas/tools";
|
|
7
|
+
/** `alerts`: the open alerts of the project's Cloud Monitoring, newest first, so a role or a feeder can tell what fires now. */
|
|
8
|
+
export const alerts = defineTool({
|
|
9
|
+
description: `The open alerts of the project's Cloud Monitoring, newest first: at most \`limit\` (${String(ALERTS)} when absent), each with its policy, severity, the time it opened, and the resource and metric it is about; \`complete\` is false when more are open`,
|
|
10
|
+
input: alertsTool.input,
|
|
11
|
+
output: alertsTool.output,
|
|
12
|
+
...apiAccess,
|
|
13
|
+
execute: async (input, ctx) => {
|
|
14
|
+
const settings = readConfig(ctx.config);
|
|
15
|
+
if (!settings.ok)
|
|
16
|
+
return settings.error;
|
|
17
|
+
const url = new URL(`https://${MONITORING_HOST}/v3/projects/${settings.value.project}/alerts`);
|
|
18
|
+
url.searchParams.set("filter", 'state = "OPEN"');
|
|
19
|
+
url.searchParams.set("orderBy", "open_time desc");
|
|
20
|
+
url.searchParams.set("pageSize", String(input.limit ?? ALERTS));
|
|
21
|
+
const read = await google(ctx, url, undefined, alertList);
|
|
22
|
+
if (!read.ok)
|
|
23
|
+
return read.error;
|
|
24
|
+
return done({
|
|
25
|
+
alerts: (read.value.alerts ?? []).map((a) => {
|
|
26
|
+
const labels = Object.entries(a.resource?.labels ?? {})
|
|
27
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
28
|
+
.join(", ");
|
|
29
|
+
const resource = a.resource?.type === undefined
|
|
30
|
+
? undefined
|
|
31
|
+
: `${a.resource.type}${labels === "" ? "" : ` (${labels})`}`;
|
|
32
|
+
return {
|
|
33
|
+
id: a.name,
|
|
34
|
+
policy: a.policy?.displayName ?? "an unnamed policy",
|
|
35
|
+
...(a.policy?.severity === undefined ? {} : { severity: a.policy.severity }),
|
|
36
|
+
...(a.openTime === undefined ? {} : { opened_at: a.openTime }),
|
|
37
|
+
...(resource === undefined ? {} : { resource }),
|
|
38
|
+
...(a.metric?.type === undefined ? {} : { metric: a.metric.type }),
|
|
39
|
+
};
|
|
40
|
+
}),
|
|
41
|
+
complete: read.value.nextPageToken === undefined,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { type logEntry } from "#schemas/google";
|
|
3
|
+
/** The most bytes of log one answer holds, so a few reads fit in a session's context. */
|
|
4
|
+
export declare const MAX_BYTES = 32768;
|
|
5
|
+
/** One entry as one line: its time, its severity and its text, the text of a JSON payload being its `message` when it has one. */
|
|
6
|
+
export declare function lineOf(entry: z.infer<typeof logEntry>): string;
|
|
7
|
+
/** The newest whole lines that fit in `max` bytes, oldest first, and whether older ones were cut. */
|
|
8
|
+
export declare function newest(lines: readonly string[], max: number): {
|
|
9
|
+
readonly log: string;
|
|
10
|
+
readonly truncated: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** `read_logs`: the newest entries of a Cloud Logging filter that the project names. Only the filters of `[extensions.gcp] logs`, since a log can hold what other services must keep to themselves. */
|
|
13
|
+
export declare const readLogs: import("@kana-ai/edgar-sdk").Tool<{
|
|
14
|
+
log: string;
|
|
15
|
+
since?: string | undefined;
|
|
16
|
+
until?: string | undefined;
|
|
17
|
+
lines?: number | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
log: string;
|
|
20
|
+
truncated: boolean;
|
|
21
|
+
}, "GOOGLE_CLOUD_KEY">;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { defineTool, done, permanentFailure } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { LOGGING_HOST, apiAccess } from "#api/auth";
|
|
3
|
+
import { google } from "#api/client";
|
|
4
|
+
import { readConfig } from "#schemas/config";
|
|
5
|
+
import { logEntries } from "#schemas/google";
|
|
6
|
+
import { LINES, readLogsTool } from "#schemas/tools";
|
|
7
|
+
/** The most bytes of log one answer holds, so a few reads fit in a session's context. */
|
|
8
|
+
export const MAX_BYTES = 32_768;
|
|
9
|
+
/** The window a call with no `since` reads. */
|
|
10
|
+
const HOUR_MS = 3_600_000;
|
|
11
|
+
/** One entry as one line: its time, its severity and its text, the text of a JSON payload being its `message` when it has one. */
|
|
12
|
+
export function lineOf(entry) {
|
|
13
|
+
const json = entry.jsonPayload;
|
|
14
|
+
const text = entry.textPayload ??
|
|
15
|
+
(typeof json?.["message"] === "string" ? json["message"] : undefined) ??
|
|
16
|
+
JSON.stringify(json ?? entry.protoPayload ?? {});
|
|
17
|
+
return `${entry.timestamp ?? ""} ${entry.severity ?? "DEFAULT"} ${text.replaceAll(/\r?\n/g, "\\n")}`;
|
|
18
|
+
}
|
|
19
|
+
/** The newest whole lines that fit in `max` bytes, oldest first, and whether older ones were cut. */
|
|
20
|
+
export function newest(lines, max) {
|
|
21
|
+
let from = lines.length;
|
|
22
|
+
let bytes = 0;
|
|
23
|
+
for (let at = lines.length - 1; at >= 0; at -= 1) {
|
|
24
|
+
bytes += Buffer.byteLength(lines[at] ?? "") + (at === lines.length - 1 ? 0 : 1);
|
|
25
|
+
if (bytes > max)
|
|
26
|
+
break;
|
|
27
|
+
from = at;
|
|
28
|
+
}
|
|
29
|
+
return { log: lines.slice(from).join("\n"), truncated: from > 0 };
|
|
30
|
+
}
|
|
31
|
+
/** `read_logs`: the newest entries of a Cloud Logging filter that the project names. Only the filters of `[extensions.gcp] logs`, since a log can hold what other services must keep to themselves. */
|
|
32
|
+
export const readLogs = defineTool({
|
|
33
|
+
description: `The newest entries of a Cloud Logging filter that [extensions.gcp] logs names, each as its time, severity and text: at most \`lines\` (${String(LINES)} when absent) between \`since\` (an hour ago when absent) and \`until\`, and at most 32 KiB; \`truncated\` says older entries may be left out. EDGAR redacts each secret it holds from the answer`,
|
|
34
|
+
input: readLogsTool.input,
|
|
35
|
+
output: readLogsTool.output,
|
|
36
|
+
...apiAccess,
|
|
37
|
+
execute: async (input, ctx) => {
|
|
38
|
+
const settings = readConfig(ctx.config);
|
|
39
|
+
if (!settings.ok)
|
|
40
|
+
return settings.error;
|
|
41
|
+
const { project, logs } = settings.value;
|
|
42
|
+
const filter = logs[input.log];
|
|
43
|
+
if (filter === undefined)
|
|
44
|
+
return permanentFailure("refused", `[extensions.gcp] logs does not name the filter \`${input.log}\`; it names: ${Object.keys(logs).join(", ") || "none"}`);
|
|
45
|
+
const lines = input.lines ?? LINES;
|
|
46
|
+
const since = input.since ?? new Date(Date.now() - HOUR_MS).toISOString();
|
|
47
|
+
const window = [
|
|
48
|
+
`timestamp>="${since}"`,
|
|
49
|
+
...(input.until === undefined ? [] : [`timestamp<="${input.until}"`]),
|
|
50
|
+
];
|
|
51
|
+
const read = await google(ctx, new URL(`https://${LOGGING_HOST}/v2/entries:list`), {
|
|
52
|
+
resourceNames: [`projects/${project}`],
|
|
53
|
+
filter: [`(${filter})`, ...window].join(" AND "),
|
|
54
|
+
orderBy: "timestamp desc",
|
|
55
|
+
pageSize: lines,
|
|
56
|
+
}, logEntries);
|
|
57
|
+
if (!read.ok)
|
|
58
|
+
return read.error;
|
|
59
|
+
const entries = read.value.entries ?? [];
|
|
60
|
+
const kept = newest(entries.map(lineOf).toReversed(), MAX_BYTES);
|
|
61
|
+
return done({
|
|
62
|
+
log: kept.log,
|
|
63
|
+
truncated: kept.truncated || read.value.nextPageToken !== undefined,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": 1,
|
|
3
|
+
"name": "gcp",
|
|
4
|
+
"version": "0.1.4",
|
|
5
|
+
"config_schema": "schemas/config.json",
|
|
6
|
+
"secrets": [
|
|
7
|
+
{
|
|
8
|
+
"name": "GOOGLE_CLOUD_KEY",
|
|
9
|
+
"hosts": ["oauth2.googleapis.com", "logging.googleapis.com", "monitoring.googleapis.com"],
|
|
10
|
+
"help": "The JSON key of a Google Cloud service account with the Logs Viewer and Monitoring Viewer roles."
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"capabilities": [
|
|
14
|
+
"network:oauth2.googleapis.com",
|
|
15
|
+
"network:logging.googleapis.com",
|
|
16
|
+
"network:monitoring.googleapis.com"
|
|
17
|
+
],
|
|
18
|
+
"tools": [
|
|
19
|
+
{
|
|
20
|
+
"name": "read_logs",
|
|
21
|
+
"description": "The newest entries of a Cloud Logging filter that [extensions.gcp] logs names, each as its time, severity and text: at most `lines` (200 when absent) between `since` (an hour ago when absent) and `until`, and at most 32 KiB; `truncated` says older entries may be left out. EDGAR redacts each secret it holds from the answer",
|
|
22
|
+
"input_schema": "schemas/read_logs.in.json",
|
|
23
|
+
"output_schema": "schemas/read_logs.out.json",
|
|
24
|
+
"secrets": ["GOOGLE_CLOUD_KEY"],
|
|
25
|
+
"capabilities": [
|
|
26
|
+
"network:oauth2.googleapis.com",
|
|
27
|
+
"network:logging.googleapis.com",
|
|
28
|
+
"network:monitoring.googleapis.com"
|
|
29
|
+
],
|
|
30
|
+
"side_effect": false,
|
|
31
|
+
"approval": "never",
|
|
32
|
+
"disabled": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "alerts",
|
|
36
|
+
"description": "The open alerts of the project's Cloud Monitoring, newest first: at most `limit` (50 when absent), each with its policy, severity, the time it opened, and the resource and metric it is about; `complete` is false when more are open",
|
|
37
|
+
"input_schema": "schemas/alerts.in.json",
|
|
38
|
+
"output_schema": "schemas/alerts.out.json",
|
|
39
|
+
"secrets": ["GOOGLE_CLOUD_KEY"],
|
|
40
|
+
"capabilities": [
|
|
41
|
+
"network:oauth2.googleapis.com",
|
|
42
|
+
"network:logging.googleapis.com",
|
|
43
|
+
"network:monitoring.googleapis.com"
|
|
44
|
+
],
|
|
45
|
+
"side_effect": false,
|
|
46
|
+
"approval": "never",
|
|
47
|
+
"disabled": false
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"webhooks": [],
|
|
51
|
+
"workflows": [],
|
|
52
|
+
"roles": [],
|
|
53
|
+
"skills": [],
|
|
54
|
+
"tracker": null,
|
|
55
|
+
"environments": [],
|
|
56
|
+
"hooks": []
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kana-ai/edgar-ext-gcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "EDGAR extension for Google Cloud: tools that read log entries from Cloud Logging through the filters a project names, and the open alerts of Cloud Monitoring.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/kana-ai/edgar",
|
|
9
|
+
"directory": "packages/extensions/ext-gcp"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/src",
|
|
13
|
+
"edgar-extension.json",
|
|
14
|
+
"schemas"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"imports": {
|
|
18
|
+
"#*": "./dist/src/*.js"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/src/index.js"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@kana-ai/edgar-contracts": "0.1.4",
|
|
25
|
+
"@kana-ai/edgar-sdk": "0.1.4",
|
|
26
|
+
"zod": "4.6.7"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "24.19.2",
|
|
30
|
+
"ajv": "8.20.0",
|
|
31
|
+
"oxfmt": "0.76.0",
|
|
32
|
+
"oxlint": "1.91.0",
|
|
33
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
34
|
+
"typescript": "7.0.2",
|
|
35
|
+
"undici": "7.30.2"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "edgar-extension-build src/index.ts",
|
|
39
|
+
"check-types": "tsc --noEmit",
|
|
40
|
+
"lint": "oxlint --type-aware --deny-warnings",
|
|
41
|
+
"format:check": "oxfmt --check",
|
|
42
|
+
"test": "node --test"
|
|
43
|
+
}
|
|
6
44
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"alerts": {
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"id": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "the alert's resource name, stable while it is open"
|
|
13
|
+
},
|
|
14
|
+
"policy": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "the name of the alerting policy that opened it"
|
|
17
|
+
},
|
|
18
|
+
"severity": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"opened_at": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"resource": {
|
|
25
|
+
"description": "the monitored resource's type and labels",
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"metric": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": ["id", "policy"]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"complete": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"description": "false when more open alerts exist than `limit`"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["alerts", "complete"]
|
|
41
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"project": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"pattern": "^[a-z][a-z0-9-]{4,28}[a-z0-9]$",
|
|
8
|
+
"description": "the Google Cloud project whose logs and alerts the tools read"
|
|
9
|
+
},
|
|
10
|
+
"logs": {
|
|
11
|
+
"default": {},
|
|
12
|
+
"description": "each Cloud Logging filter that read_logs may read, by name, such as api = 'resource.type=\"cloud_run_revision\" AND resource.labels.service_name=\"api\"'",
|
|
13
|
+
"type": "object",
|
|
14
|
+
"propertyNames": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"pattern": "^[a-z][a-z0-9_]{0,63}$"
|
|
17
|
+
},
|
|
18
|
+
"additionalProperties": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"minLength": 1
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": ["project"],
|
|
25
|
+
"additionalProperties": false
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"log": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"minLength": 1,
|
|
8
|
+
"description": "a filter that [extensions.gcp] logs names"
|
|
9
|
+
},
|
|
10
|
+
"since": {
|
|
11
|
+
"description": "the time of the first entry; the last hour when absent",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"format": "date-time",
|
|
14
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
15
|
+
},
|
|
16
|
+
"until": {
|
|
17
|
+
"description": "now when absent",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"format": "date-time",
|
|
20
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
|
|
21
|
+
},
|
|
22
|
+
"lines": {
|
|
23
|
+
"description": "200 when absent",
|
|
24
|
+
"type": "integer",
|
|
25
|
+
"minimum": 1,
|
|
26
|
+
"maximum": 1000
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": ["log"]
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"log": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "each entry as its time, its severity and its text, oldest first"
|
|
8
|
+
},
|
|
9
|
+
"truncated": {
|
|
10
|
+
"type": "boolean",
|
|
11
|
+
"description": "true when the entry count or the byte cap was reached, so older entries may be left out"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": ["log", "truncated"]
|
|
15
|
+
}
|