@kana-ai/edgar-contracts 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +86 -2
- package/dist/diagnostic.schema.d.ts +14 -0
- package/dist/js/schemas/ts/card.d.ts +55 -0
- package/dist/js/schemas/ts/card.js +33 -0
- package/dist/js/schemas/ts/end.d.ts +57 -0
- package/dist/js/schemas/ts/end.js +57 -0
- package/dist/limit.schema.d.ts +14 -0
- package/dist/manifest.schema.d.ts +213 -0
- package/dist/outcome.schema.d.ts +107 -0
- package/dist/provider.schema.d.ts +435 -0
- package/dist/rpc.schema.d.ts +711 -0
- package/package.json +48 -3
- package/schemas/json/diagnostic.schema.json +38 -0
- package/schemas/json/limit.schema.json +32 -0
- package/schemas/json/manifest.schema.json +273 -0
- package/schemas/json/outcome.schema.json +210 -0
- package/schemas/json/provider.schema.json +515 -0
- package/schemas/json/rpc.schema.json +1036 -0
- package/schemas/ts/card.ts +36 -0
- package/schemas/ts/end.ts +67 -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,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kana-ai/edgar-contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
JSON Schemas (2020-12) of what the EDGAR engine and its TypeScript side exchange, and the TypeScript types generated from them.
|
|
4
|
+
|
|
5
|
+
Use this package when you write code that reads or writes one of these messages: the SDK, the extension runtime, a provider runtime, or a program that reads `edgar check --json`. An extension author does not import it directly: the SDK gives the same types. For how the processes talk, see [architecture](/docs/concepts/architecture.md#the-processes).
|
|
6
|
+
|
|
7
|
+
> `schemas/json/diagnostic.schema.json` and `schemas/json/limit.schema.json` come from the Rust types `Diagnostic` and `Limit`. After you change one of these types, run `edgar contracts emit` from the repository root, and commit the files. A unit test in `edgar-core` fails when a committed file differs. The other four schemas are written by hand until their types derive `JsonSchema`. For them, the files in `schemas/` are the source, and the engine's Rust types in `edgar-core` must match them. See [logs, spans and contracts](/docs/reference/observability.md#make-the-contracts-from-the-rust-types).
|
|
8
|
+
|
|
9
|
+
## Schemas
|
|
10
|
+
|
|
11
|
+
The package has two folders: `schemas/json/` holds the JSON Schema files, and `schemas/ts/` holds the Zod schemas that the TypeScript side imports.
|
|
12
|
+
|
|
13
|
+
| Schema | What it describes |
|
|
14
|
+
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `schemas/json/outcome.schema.json` | The outcome union, the temporary and the permanent kinds; `retry_after` is in seconds and `timeout_at` in Unix milliseconds; `done` and both failures take an optional `limit` |
|
|
16
|
+
| `schemas/json/limit.schema.json` | One rate or usage limit, `{source, remaining?, limit?, resets_at?, window?}`, made from the Rust `Limit` type by `edgar contracts emit`; `resets_at` is in Unix milliseconds |
|
|
17
|
+
| `schemas/json/rpc.schema.json` | The JSON-RPC 2.0 lines between the engine and `edgar-runtime`, their params and results, and the 4 MiB line limit (`MaxMessageBytes`) |
|
|
18
|
+
| `schemas/json/provider.schema.json` | The JSON-RPC 2.0 lines between the engine and a provider runtime such as `edgar-provider-claude`: `hello`, `session.*`, `tool.request` and the `session.event` notifications, with the `limit` event |
|
|
19
|
+
| `schemas/json/manifest.schema.json` | `edgar-extension.json`, which the SDK build writes |
|
|
20
|
+
| `schemas/json/diagnostic.schema.json` | One record of `edgar check --json` |
|
|
21
|
+
|
|
22
|
+
`schemas/ts/` holds the Zod schemas. `end.ts` has `runEnded`, the part of a `run_outcome` event that a note at the end of a run reads. `card.ts` has `cardBlock` and `cardSpec`, whose output types are the `CardBlock` and `CardSpec` of `rpc.schema.json`. The tracker extensions import them from `@kana-ai/edgar-contracts/card`, so their `create_card` schemas stay the same. A card's block has a `kind` (`defect`, `request`, `question` or `investigation`) and optional facts such as `service`, `fingerprint` (16 lower-case hex characters) and `severity`. The intake refuses a card whose block does not match, and says why on the card.
|
|
23
|
+
|
|
24
|
+
## Imports
|
|
25
|
+
|
|
26
|
+
| Import | What you get |
|
|
27
|
+
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| `@kana-ai/edgar-contracts/<name>` | The generated types of `schemas/json/<name>.schema.json`, such as `import type { Outcome } from "@kana-ai/edgar-contracts/outcome"`. The default export is the schema file. |
|
|
29
|
+
| `@kana-ai/edgar-contracts/schemas/json/<file>` | A schema file by path, such as `@kana-ai/edgar-contracts/schemas/json/outcome.schema.json`. |
|
|
30
|
+
| `@kana-ai/edgar-contracts/card` | `cardBlock` and `cardSpec`. |
|
|
31
|
+
| `@kana-ai/edgar-contracts/end` | `runEnded`, the Zod schema of the part of a `run_outcome` payload that a note at the end of a run reads. |
|
|
32
|
+
|
|
33
|
+
This program type-checks an outcome and parses a card block:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import type { Outcome } from "@kana-ai/edgar-contracts/outcome";
|
|
37
|
+
import { cardBlock } from "@kana-ai/edgar-contracts/card";
|
|
38
|
+
|
|
39
|
+
const outcome: Outcome = {
|
|
40
|
+
outcome: "permanent_failure",
|
|
41
|
+
kind: "invalid_input",
|
|
42
|
+
message: "no such card",
|
|
43
|
+
};
|
|
44
|
+
const block = cardBlock.safeParse({ kind: "defect", service: "notes" });
|
|
45
|
+
console.log(JSON.stringify(outcome), block.success);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
{"outcome":"permanent_failure","kind":"invalid_input","message":"no such card"} true
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Build
|
|
53
|
+
|
|
54
|
+
`pnpm build` writes the types to `dist/` with `json-schema-to-typescript`. `dist/` is not committed. `check-types` runs the build first, so a type that the schemas no longer give fails the check.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pnpm --filter @kana-ai/edgar-contracts run build
|
|
58
|
+
pnpm --filter @kana-ai/edgar-contracts run test
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Change a schema
|
|
62
|
+
|
|
63
|
+
1. Change the schema in `schemas/json/`, and the Rust type of the same message in `edgar-core` (`model::outcome`, `model::rpc`, `project::manifest` or `project::diagnostic`).
|
|
64
|
+
1. Run `pnpm --filter @kana-ai/edgar-contracts run check-types`, and fix each type that changed.
|
|
65
|
+
1. Add a test in `tests/schemas.test.ts` with a message that the schema must accept, and one that it must refuse.
|
|
66
|
+
1. Run the Rust tests: the engine's own tests read and write the same JSON.
|
|
67
|
+
|
|
68
|
+
A schema and its Rust type that do not match is a defect: the engine refuses a message that the TypeScript side sends, or the other way.
|
|
69
|
+
|
|
70
|
+
## Tests
|
|
71
|
+
|
|
72
|
+
`tests/schemas.test.ts` checks the schemas with `ajv`: a full manifest is accepted, and an unknown capability or a half undo pair is refused; `executables` takes a program name and a path inside the extension, and refuses a path as a name, a missing reason and a path with `..`; each outcome word is accepted, and an unknown kind is refused; each failure takes only its own kinds; the JSON-RPC lines, a diagnostic and the provider lines match their schemas.
|
|
73
|
+
|
|
74
|
+
## Validation
|
|
75
|
+
|
|
76
|
+
These commands were run on 2026-11-10 on macOS with Node 26:
|
|
77
|
+
|
|
78
|
+
| Command | Exit code |
|
|
79
|
+
| --------------------------------------------------------------------------------- | ------------------- |
|
|
80
|
+
| `pnpm --filter @kana-ai/edgar-contracts run test` | 0, `pass 11` |
|
|
81
|
+
| `tsc --noEmit` on the program above, in a scratch package that links this package | 0 |
|
|
82
|
+
| `node` on the program above | 0, the output above |
|
|
83
|
+
|
|
84
|
+
## Where to read next
|
|
85
|
+
|
|
86
|
+
- [The SDK](/packages/sdk/README.md): the types that an extension author uses.
|
|
87
|
+
- [Events and outcomes](/docs/concepts/events-and-outcomes.md#outcomes): what each outcome and kind means.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Generated by json-schema-to-typescript from the schema of the same name. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One problem `edgar check` reports.
|
|
5
|
+
*/
|
|
6
|
+
export interface Diagnostic {
|
|
7
|
+
code: string;
|
|
8
|
+
column: number;
|
|
9
|
+
file: string;
|
|
10
|
+
help: string;
|
|
11
|
+
line: number;
|
|
12
|
+
message: string;
|
|
13
|
+
severity: "info" | "warning" | "error";
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The `edgar:v0` block of a card; its output type is the contract's `CardBlock`. */
|
|
3
|
+
export declare const cardBlock: z.ZodObject<{
|
|
4
|
+
kind: z.ZodEnum<{
|
|
5
|
+
defect: "defect";
|
|
6
|
+
investigation: "investigation";
|
|
7
|
+
question: "question";
|
|
8
|
+
request: "request";
|
|
9
|
+
}>;
|
|
10
|
+
service: z.ZodExactOptional<z.ZodString>;
|
|
11
|
+
environment: z.ZodExactOptional<z.ZodString>;
|
|
12
|
+
fingerprint: z.ZodExactOptional<z.ZodString>;
|
|
13
|
+
first_seen: z.ZodExactOptional<z.ZodISODateTime>;
|
|
14
|
+
last_seen: z.ZodExactOptional<z.ZodISODateTime>;
|
|
15
|
+
occurrences: z.ZodExactOptional<z.ZodNumber>;
|
|
16
|
+
severity: z.ZodExactOptional<z.ZodString>;
|
|
17
|
+
window: z.ZodExactOptional<z.ZodString>;
|
|
18
|
+
waits_for: z.ZodExactOptional<z.ZodString>;
|
|
19
|
+
decided: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
20
|
+
origin: z.ZodExactOptional<z.ZodObject<{
|
|
21
|
+
extension: z.ZodString;
|
|
22
|
+
channel: z.ZodString;
|
|
23
|
+
thread: z.ZodString;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
/** The card a tool files; its output type is the contract's `CardSpec`. */
|
|
27
|
+
export declare const cardSpec: z.ZodObject<{
|
|
28
|
+
title: z.ZodString;
|
|
29
|
+
description: z.ZodString;
|
|
30
|
+
column: z.ZodExactOptional<z.ZodString>;
|
|
31
|
+
labels: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
block: z.ZodObject<{
|
|
33
|
+
kind: z.ZodEnum<{
|
|
34
|
+
defect: "defect";
|
|
35
|
+
investigation: "investigation";
|
|
36
|
+
question: "question";
|
|
37
|
+
request: "request";
|
|
38
|
+
}>;
|
|
39
|
+
service: z.ZodExactOptional<z.ZodString>;
|
|
40
|
+
environment: z.ZodExactOptional<z.ZodString>;
|
|
41
|
+
fingerprint: z.ZodExactOptional<z.ZodString>;
|
|
42
|
+
first_seen: z.ZodExactOptional<z.ZodISODateTime>;
|
|
43
|
+
last_seen: z.ZodExactOptional<z.ZodISODateTime>;
|
|
44
|
+
occurrences: z.ZodExactOptional<z.ZodNumber>;
|
|
45
|
+
severity: z.ZodExactOptional<z.ZodString>;
|
|
46
|
+
window: z.ZodExactOptional<z.ZodString>;
|
|
47
|
+
waits_for: z.ZodExactOptional<z.ZodString>;
|
|
48
|
+
decided: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
49
|
+
origin: z.ZodExactOptional<z.ZodObject<{
|
|
50
|
+
extension: z.ZodString;
|
|
51
|
+
channel: z.ZodString;
|
|
52
|
+
thread: z.ZodString;
|
|
53
|
+
}, z.core.$strict>>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The `edgar:v0` block of a card; its output type is the contract's `CardBlock`. */
|
|
3
|
+
export const cardBlock = z.strictObject({
|
|
4
|
+
kind: z.enum(["defect", "request", "question", "investigation"]),
|
|
5
|
+
service: z.string().exactOptional(),
|
|
6
|
+
environment: z.string().exactOptional(),
|
|
7
|
+
fingerprint: z
|
|
8
|
+
.string()
|
|
9
|
+
.regex(/^[0-9a-f]{16}$/)
|
|
10
|
+
.exactOptional(),
|
|
11
|
+
first_seen: z.iso.datetime({ offset: true }).exactOptional(),
|
|
12
|
+
last_seen: z.iso.datetime({ offset: true }).exactOptional(),
|
|
13
|
+
occurrences: z.number().int().min(0).exactOptional(),
|
|
14
|
+
severity: z.string().exactOptional(),
|
|
15
|
+
window: z.string().exactOptional(),
|
|
16
|
+
waits_for: z.string().min(1).exactOptional(),
|
|
17
|
+
decided: z.record(z.string(), z.string()).exactOptional(),
|
|
18
|
+
origin: z
|
|
19
|
+
.strictObject({
|
|
20
|
+
extension: z.string().regex(/^[a-z][a-z0-9_]{0,63}$/),
|
|
21
|
+
channel: z.string().min(1),
|
|
22
|
+
thread: z.string().min(1),
|
|
23
|
+
})
|
|
24
|
+
.exactOptional(),
|
|
25
|
+
});
|
|
26
|
+
/** The card a tool files; its output type is the contract's `CardSpec`. */
|
|
27
|
+
export const cardSpec = z.strictObject({
|
|
28
|
+
title: z.string().min(1),
|
|
29
|
+
description: z.string(),
|
|
30
|
+
column: z.string().exactOptional(),
|
|
31
|
+
labels: z.array(z.string()).exactOptional(),
|
|
32
|
+
block: cardBlock,
|
|
33
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The card of a run, as its `run_created` payload and the `end` of its `run_outcome` name it. In `run_created`, `event` is the card event that started the run, such as `created` or `comment`, and `tracker` is the extension of the tracker that holds the card. */
|
|
3
|
+
export declare const runCard: z.ZodObject<{
|
|
4
|
+
event: z.ZodOptional<z.ZodString>;
|
|
5
|
+
card: z.ZodOptional<z.ZodString>;
|
|
6
|
+
tracker: z.ZodOptional<z.ZodString>;
|
|
7
|
+
title: z.ZodOptional<z.ZodString>;
|
|
8
|
+
service: z.ZodOptional<z.ZodString>;
|
|
9
|
+
card_url: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$loose>;
|
|
11
|
+
export type RunCard = z.infer<typeof runCard>;
|
|
12
|
+
/** The part of a `run_outcome` payload a note at the end of a run reads. */
|
|
13
|
+
export declare const runEnded: z.ZodObject<{
|
|
14
|
+
outcome: z.ZodObject<{
|
|
15
|
+
outcome: z.ZodString;
|
|
16
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
17
|
+
message: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$loose>;
|
|
19
|
+
totals: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
input_tokens: z.ZodNumber;
|
|
21
|
+
output_tokens: z.ZodNumber;
|
|
22
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, z.core.$loose>>;
|
|
24
|
+
end: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
event: z.ZodOptional<z.ZodString>;
|
|
26
|
+
card: z.ZodOptional<z.ZodString>;
|
|
27
|
+
tracker: z.ZodOptional<z.ZodString>;
|
|
28
|
+
title: z.ZodOptional<z.ZodString>;
|
|
29
|
+
service: z.ZodOptional<z.ZodString>;
|
|
30
|
+
card_url: z.ZodOptional<z.ZodString>;
|
|
31
|
+
assignee: z.ZodOptional<z.ZodString>;
|
|
32
|
+
started: z.ZodNumber;
|
|
33
|
+
workflow: z.ZodOptional<z.ZodString>;
|
|
34
|
+
failed_before: z.ZodDefault<z.ZodNumber>;
|
|
35
|
+
repeat: z.ZodDefault<z.ZodBoolean>;
|
|
36
|
+
pull_requests: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
37
|
+
url: z.ZodString;
|
|
38
|
+
number: z.ZodNumber;
|
|
39
|
+
referenced: z.ZodOptional<z.ZodLiteral<true>>;
|
|
40
|
+
}, z.core.$loose>>>;
|
|
41
|
+
reviewed: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
state: z.ZodString;
|
|
43
|
+
review_state: z.ZodString;
|
|
44
|
+
approved_by: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
45
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$loose>>;
|
|
47
|
+
decision: z.ZodOptional<z.ZodString>;
|
|
48
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
49
|
+
options: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
50
|
+
question: z.ZodOptional<z.ZodString>;
|
|
51
|
+
risk: z.ZodOptional<z.ZodString>;
|
|
52
|
+
risk_reason: z.ZodOptional<z.ZodString>;
|
|
53
|
+
failed_stage: z.ZodOptional<z.ZodString>;
|
|
54
|
+
failure: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$loose>>;
|
|
56
|
+
}, z.core.$loose>;
|
|
57
|
+
export type RunEnded = z.infer<typeof runEnded>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A pull request of a run: one that it opened, a stage output that has a `url` and a `number`, or with `referenced` one that it only worked on or found, such as the pull request that a revise pushed to. The store takes any text as the `url`, so a reader checks it. */
|
|
3
|
+
const pullRequest = z.looseObject({
|
|
4
|
+
url: z.string(),
|
|
5
|
+
number: z.number().int(),
|
|
6
|
+
referenced: z.literal(true).optional(),
|
|
7
|
+
});
|
|
8
|
+
/** What people decided on a run's pull request: its `state` (`open`, `merged` or `closed`), its `review_state` (`pending`, `approved` or `changes_requested`), the logins that approved, and the merge commit of a merged pull request, else the commit that was reviewed. */
|
|
9
|
+
const reviewed = z.looseObject({
|
|
10
|
+
state: z.string(),
|
|
11
|
+
review_state: z.string(),
|
|
12
|
+
approved_by: z.array(z.string()).default([]),
|
|
13
|
+
commit: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
/** What a run used; `cost` is in USD, when a model call reported one. */
|
|
16
|
+
const totals = z.looseObject({
|
|
17
|
+
input_tokens: z.number(),
|
|
18
|
+
output_tokens: z.number(),
|
|
19
|
+
cost: z.number().optional(),
|
|
20
|
+
});
|
|
21
|
+
/** The card of a run, as its `run_created` payload and the `end` of its `run_outcome` name it. In `run_created`, `event` is the card event that started the run, such as `created` or `comment`, and `tracker` is the extension of the tracker that holds the card. */
|
|
22
|
+
export const runCard = z.looseObject({
|
|
23
|
+
event: z.string().min(1).optional(),
|
|
24
|
+
card: z.string().min(1).optional(),
|
|
25
|
+
tracker: z.string().min(1).optional(),
|
|
26
|
+
title: z.string().optional(),
|
|
27
|
+
service: z.string().min(1).optional(),
|
|
28
|
+
card_url: z.string().min(1).optional(),
|
|
29
|
+
});
|
|
30
|
+
/** The `end` of a `run_outcome` payload: the run's card, when the run began in Unix milliseconds, its workflow, each pull request that it or its sub-runs opened or worked on, what people decided on it (`reviewed`), the `decision`, `summary` and `options` of its newest proposal, the `question` of its newest stage output that asks one, and the stage and message of its newest attempt that failed for good. `risk` is how likely the review thinks it that the change is not what its developers want, such as `low`, `moderate` or `high`, and `risk_reason` says why. For a run that a schedule started, `failed_before` counts the runs of that schedule that failed in a row just before it, and `repeat` says that the run just before it failed with the same failure kind. */
|
|
31
|
+
const runEnd = runCard.extend({
|
|
32
|
+
assignee: z.string().min(1).optional(),
|
|
33
|
+
started: z.number(),
|
|
34
|
+
workflow: z.string().min(1).optional(),
|
|
35
|
+
failed_before: z.number().int().nonnegative().default(0),
|
|
36
|
+
repeat: z.boolean().default(false),
|
|
37
|
+
pull_requests: z.array(pullRequest).default([]),
|
|
38
|
+
reviewed: reviewed.optional(),
|
|
39
|
+
decision: z.string().optional(),
|
|
40
|
+
summary: z.string().optional(),
|
|
41
|
+
options: z.array(z.string()).default([]),
|
|
42
|
+
question: z.string().optional(),
|
|
43
|
+
risk: z.string().optional(),
|
|
44
|
+
risk_reason: z.string().optional(),
|
|
45
|
+
failed_stage: z.string().optional(),
|
|
46
|
+
failure: z.string().optional(),
|
|
47
|
+
});
|
|
48
|
+
/** The part of a `run_outcome` payload a note at the end of a run reads. */
|
|
49
|
+
export const runEnded = z.looseObject({
|
|
50
|
+
outcome: z.looseObject({
|
|
51
|
+
outcome: z.string(),
|
|
52
|
+
kind: z.string().optional(),
|
|
53
|
+
message: z.string().optional(),
|
|
54
|
+
}),
|
|
55
|
+
totals: totals.optional(),
|
|
56
|
+
end: runEnd.optional(),
|
|
57
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Generated by json-schema-to-typescript from the schema of the same name. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a vendor or a provider said about one rate or usage limit of `source`, a host such as
|
|
5
|
+
* `api.github.com` or a provider name such as `claude`. It rides beside an outcome on the wire
|
|
6
|
+
* and is split off at the boundary, so stored outcomes never hold it.
|
|
7
|
+
*/
|
|
8
|
+
export interface Limit {
|
|
9
|
+
limit?: number | null;
|
|
10
|
+
remaining?: number | null;
|
|
11
|
+
resets_at?: number | null;
|
|
12
|
+
source: string;
|
|
13
|
+
window?: string | null;
|
|
14
|
+
}
|