@harnessforce/semconv 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +105 -2
  3. package/dist/attributes.d.ts +22 -0
  4. package/dist/attributes.js +27 -0
  5. package/dist/attributes.js.map +1 -0
  6. package/dist/index.d.ts +182 -0
  7. package/dist/index.js +28 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/redaction.d.ts +25 -0
  10. package/dist/redaction.js +70 -0
  11. package/dist/redaction.js.map +1 -0
  12. package/dist/repository.d.ts +1 -0
  13. package/dist/repository.js +46 -0
  14. package/dist/repository.js.map +1 -0
  15. package/dist/schemas/analysis-report.d.ts +47 -0
  16. package/dist/schemas/analysis-report.js +87 -0
  17. package/dist/schemas/analysis-report.js.map +1 -0
  18. package/dist/schemas/common.d.ts +14 -0
  19. package/dist/schemas/common.js +33 -0
  20. package/dist/schemas/common.js.map +1 -0
  21. package/dist/schemas/config-snapshot.d.ts +15 -0
  22. package/dist/schemas/config-snapshot.js +36 -0
  23. package/dist/schemas/config-snapshot.js.map +1 -0
  24. package/dist/schemas/ingest-items.d.ts +36 -0
  25. package/dist/schemas/ingest-items.js +73 -0
  26. package/dist/schemas/ingest-items.js.map +1 -0
  27. package/dist/schemas/session-import.d.ts +23 -0
  28. package/dist/schemas/session-import.js +15 -0
  29. package/dist/schemas/session-import.js.map +1 -0
  30. package/dist/schemas/session-registration.d.ts +25 -0
  31. package/dist/schemas/session-registration.js +19 -0
  32. package/dist/schemas/session-registration.js.map +1 -0
  33. package/dist/schemas/session-usage-summary.d.ts +57 -0
  34. package/dist/schemas/session-usage-summary.js +32 -0
  35. package/dist/schemas/session-usage-summary.js.map +1 -0
  36. package/dist/values.d.ts +4 -0
  37. package/dist/values.js +52 -0
  38. package/dist/values.js.map +1 -0
  39. package/package.json +53 -3
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,106 @@
1
- # Temporary Holding Version
1
+ # @harnessforce/semconv
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The semantic conventions of [Harnessforce](https://github.com/lambda-script/harnessforce-agent): the
4
+ `hf.*` OpenTelemetry resource attribute names and the JSON Schemas of the items sent to the
5
+ Harnessforce ingest API. The `harnessforce` CLI and the Claude Code plugin hook build what they send from this
6
+ package, and the Harnessforce service validates what it receives against the same schemas.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm install @harnessforce/semconv
12
+ ```
13
+
14
+ It is an ES module with no side effects and one runtime dependency,
15
+ [`@sinclair/typebox`](https://github.com/sinclairzx81/typebox). Node.js 18 or later.
16
+
17
+ ## Usage
18
+
19
+ ### Attributes
20
+
21
+ ```ts
22
+ import { ATTR, EXECUTION_MODES } from "@harnessforce/semconv";
23
+
24
+ const attributes = {
25
+ [ATTR.issueIdentifier]: "ENG-42", // "hf.issue.identifier"
26
+ [ATTR.vcsRepository]: "github.com/acme/web", // "hf.vcs.repository"
27
+ [ATTR.executionMode]: EXECUTION_MODES[1], // "ai"
28
+ };
29
+ ```
30
+
31
+ `ATTR` maps each attribute to its name (`hf.workspace.id`, `hf.issue.identifier`,
32
+ `hf.agent.config_version`, `hf.vcs.branch`, ...). `EXECUTION_MODES` and `EXECUTION_ACTOR_TYPES` list
33
+ the allowed values of `hf.execution.mode` and `hf.execution.actor_type`.
34
+
35
+ ### Schemas
36
+
37
+ Each schema is a plain JSON Schema object (built with TypeBox) with a static TypeScript type:
38
+
39
+ | Key in `SCHEMAS` | Schema | Type |
40
+ | --- | --- | --- |
41
+ | `session-registration` | `SessionRegistrationSchema` | `SessionRegistration` |
42
+ | `session-import` | `SessionImportSchema` | `SessionImport` |
43
+ | `config-snapshot` | `ConfigSnapshotSchema` | `ConfigSnapshot` |
44
+ | `analysis-report` | `AnalysisReportSchema` | `AnalysisReport` |
45
+ | `session-usage-summary` | `SessionUsageSummarySchema` | `SessionUsageSummary` |
46
+ | `ingest-issue` | `IngestIssueSchema` | `IngestIssue` |
47
+ | `ingest-event` | `IngestEventSchema` | `IngestEvent` |
48
+
49
+ Compile them with the JSON Schema validator of your choice. The schemas use the `date-time`, `date`
50
+ and `uri` formats, so enable format validation. On runtimes that forbid code generation, such as
51
+ Cloudflare Workers, pick a validator that does not generate code.
52
+
53
+ ```ts
54
+ import { Ajv } from "ajv";
55
+ import addFormats from "ajv-formats";
56
+ import { SCHEMAS, type SessionRegistration } from "@harnessforce/semconv";
57
+
58
+ const ajv = new Ajv({ strict: true });
59
+ addFormats(ajv);
60
+ const validate = ajv.compile<SessionRegistration>(SCHEMAS["session-registration"]);
61
+ ```
62
+
63
+ Every schema's `$id` is `urn:harnessforce:semconv:<major>:<name>` (`schemaId(name)`, with
64
+ `SEMCONV_MAJOR`), so a consumer can tell which major a schema belongs to.
65
+
66
+ ### Tokens and instants
67
+
68
+ A token is a string of 1 to 256 (or the stated maximum) Unicode code points with no character of the
69
+ Unicode `White_Space` property. `isToken(value, maxLength)` checks the same rule as the schemas.
70
+
71
+ An instant is an ISO 8601 date-time with `Z` or a `±hh:mm` offset (`hh` 00 to 23, `mm` 00 to 59) from
72
+ 1677-09-21T00:12:44Z to 2262-04-11T23:47:16Z. The schemas check the shape, the offset and the year;
73
+ JSON Schema cannot compare the instant after its offset, so use `isInstant(value)` for the exact range.
74
+
75
+ ### Repository names
76
+
77
+ `normalizeRepository(remoteUrl)` turns a git remote URL (HTTPS, SSH or scp-like) into the
78
+ lowercase `<host>/<owner>/<name>` form used by `hf.vcs.repository` (for example
79
+ `git@github.com:Acme/Web.git` becomes `github.com/acme/web`), and returns `undefined` for remotes that do
80
+ not have that shape, such as local paths, `file://` URLs and GitLab subgroups.
81
+
82
+ ### Secret patterns
83
+
84
+ ```ts
85
+ import { REDACTION_RULES, redactText } from "@harnessforce/semconv";
86
+
87
+ redactText("DATABASE_URL=postgres://app:pa55word@db.internal/main");
88
+ // { text: "DATABASE_URL=[REDACTED:connection_string]", count: 1 }
89
+ ```
90
+
91
+ `REDACTION_RULES` lists, in the order they are applied, the regular expressions that the Harnessforce
92
+ service uses to redact telemetry: `private_key`, `connection_string`, `jwt`, `api_key` (Anthropic,
93
+ OpenAI and Google API keys, GitHub tokens, AWS access key IDs, and Harnessforce ingest keys, access
94
+ tokens and refresh tokens), `bearer_token`, `email` and `phone` (E.164 and Japanese domestic numbers).
95
+ `redactText` replaces each match with `[REDACTED:<kind>]` and counts the replacements. Pass
96
+ `{ skipPhone: true }` for names, where digits are not phone numbers. The patterns are global
97
+ regular expressions; copy one before calling `test` or `exec` on it.
98
+
99
+ ## Versioning
100
+
101
+ This package follows semantic versioning from 0.1.0: adding attributes or vocabulary is a minor
102
+ release, and changing their meaning or removing them is a major release.
103
+
104
+ ## License
105
+
106
+ [Apache-2.0](https://github.com/lambda-script/harnessforce-agent/blob/main/LICENSE)
@@ -0,0 +1,22 @@
1
+ export declare const ATTR: {
2
+ readonly workspaceId: "hf.workspace.id";
3
+ readonly projectId: "hf.project.id";
4
+ readonly projectKey: "hf.project.key";
5
+ readonly milestoneId: "hf.milestone.id";
6
+ readonly issueId: "hf.issue.id";
7
+ readonly issueIdentifier: "hf.issue.identifier";
8
+ readonly planId: "hf.plan.id";
9
+ readonly planVersion: "hf.plan.version";
10
+ readonly agentConfigVersion: "hf.agent.config_version";
11
+ readonly executionMode: "hf.execution.mode";
12
+ readonly executionActorType: "hf.execution.actor_type";
13
+ readonly executionActorId: "hf.execution.actor_id";
14
+ readonly vcsRepository: "hf.vcs.repository";
15
+ readonly vcsBranch: "hf.vcs.branch";
16
+ readonly vcsCommit: "hf.vcs.commit";
17
+ readonly sdkName: "hf.sdk.name";
18
+ readonly sdkVersion: "hf.sdk.version";
19
+ };
20
+ export type AttributeName = (typeof ATTR)[keyof typeof ATTR];
21
+ export declare const EXECUTION_MODES: readonly ["human", "ai", "hybrid"];
22
+ export declare const EXECUTION_ACTOR_TYPES: readonly ["user", "agent", "integration", "system"];
@@ -0,0 +1,27 @@
1
+ export const ATTR = {
2
+ workspaceId: "hf.workspace.id",
3
+ projectId: "hf.project.id",
4
+ projectKey: "hf.project.key",
5
+ milestoneId: "hf.milestone.id",
6
+ issueId: "hf.issue.id",
7
+ issueIdentifier: "hf.issue.identifier",
8
+ planId: "hf.plan.id",
9
+ planVersion: "hf.plan.version",
10
+ agentConfigVersion: "hf.agent.config_version",
11
+ executionMode: "hf.execution.mode",
12
+ executionActorType: "hf.execution.actor_type",
13
+ executionActorId: "hf.execution.actor_id",
14
+ vcsRepository: "hf.vcs.repository",
15
+ vcsBranch: "hf.vcs.branch",
16
+ vcsCommit: "hf.vcs.commit",
17
+ sdkName: "hf.sdk.name",
18
+ sdkVersion: "hf.sdk.version",
19
+ };
20
+ export const EXECUTION_MODES = ["human", "ai", "hybrid"];
21
+ export const EXECUTION_ACTOR_TYPES = [
22
+ "user",
23
+ "agent",
24
+ "integration",
25
+ "system",
26
+ ];
27
+ //# sourceMappingURL=attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG;IACnB,WAAW,EAAE,iBAAiB;IAC9B,SAAS,EAAE,eAAe;IAC1B,UAAU,EAAE,gBAAgB;IAC5B,WAAW,EAAE,iBAAiB;IAC9B,OAAO,EAAE,aAAa;IACtB,eAAe,EAAE,qBAAqB;IACtC,MAAM,EAAE,YAAY;IACpB,WAAW,EAAE,iBAAiB;IAC9B,kBAAkB,EAAE,yBAAyB;IAC7C,aAAa,EAAE,mBAAmB;IAClC,kBAAkB,EAAE,yBAAyB;IAC7C,gBAAgB,EAAE,uBAAuB;IACzC,aAAa,EAAE,mBAAmB;IAClC,SAAS,EAAE,eAAe;IAC1B,SAAS,EAAE,eAAe;IAC1B,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,gBAAgB;CACnB,CAAC;AAIX,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAU,CAAC;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,MAAM;IACN,OAAO;IACP,aAAa;IACb,QAAQ;CACC,CAAC"}
@@ -0,0 +1,182 @@
1
+ export * from "./attributes.js";
2
+ export { REDACTION_KINDS, REDACTION_RULES, type RedactedText, type RedactionKind, type RedactionRule, type RedactOptions, redactText, } from "./redaction.js";
3
+ export { normalizeRepository } from "./repository.js";
4
+ export * from "./schemas/analysis-report.js";
5
+ export { SEMCONV_MAJOR, schemaId } from "./schemas/common.js";
6
+ export * from "./schemas/config-snapshot.js";
7
+ export * from "./schemas/ingest-items.js";
8
+ export * from "./schemas/session-import.js";
9
+ export { REGISTRATION_SOURCES, type SessionRegistration, SessionRegistrationSchema, } from "./schemas/session-registration.js";
10
+ export * from "./schemas/session-usage-summary.js";
11
+ export { isInstant, isToken } from "./values.js";
12
+ export declare const SCHEMAS: {
13
+ readonly "session-registration": import("@sinclair/typebox").TObject<{
14
+ agent: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"claude_code">, import("@sinclair/typebox").TLiteral<"codex">]>;
15
+ session_id: import("@sinclair/typebox").TString;
16
+ first_prompt_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
17
+ repository: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
18
+ branch: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
19
+ commit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
+ issue_identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
21
+ source: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"cli" | "hook" | "import" | "mcp">[]>;
22
+ started_at: import("@sinclair/typebox").TString;
23
+ }>;
24
+ readonly "session-import": import("@sinclair/typebox").TObject<{
25
+ agent: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"claude_code">, import("@sinclair/typebox").TLiteral<"codex">]>;
26
+ session_id: import("@sinclair/typebox").TString;
27
+ first_prompt_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
28
+ repository: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
29
+ branch: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
30
+ commit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
31
+ issue_identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
32
+ started_at: import("@sinclair/typebox").TString;
33
+ source: import("@sinclair/typebox").TLiteral<"import">;
34
+ ended_at: import("@sinclair/typebox").TString;
35
+ model: import("@sinclair/typebox").TString;
36
+ input_tokens: import("@sinclair/typebox").TInteger;
37
+ output_tokens: import("@sinclair/typebox").TInteger;
38
+ tool_calls: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
39
+ tool: import("@sinclair/typebox").TString;
40
+ calls: import("@sinclair/typebox").TInteger;
41
+ failures: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
42
+ }>>;
43
+ parser_version: import("@sinclair/typebox").TString;
44
+ }>;
45
+ readonly "config-snapshot": import("@sinclair/typebox").TObject<{
46
+ agent: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"claude_code">, import("@sinclair/typebox").TLiteral<"codex">]>;
47
+ session_id: import("@sinclair/typebox").TString;
48
+ components: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
49
+ kind: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"agent" | "command" | "hook" | "mcp_server" | "model" | "permissions" | "rule" | "skill" | "workflow">[]>;
50
+ id: import("@sinclair/typebox").TString;
51
+ version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
52
+ hash: import("@sinclair/typebox").TString;
53
+ source: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"local" | "managed" | "plugin" | "repository" | "user">[]>;
54
+ }>>;
55
+ }>;
56
+ readonly "analysis-report": import("@sinclair/typebox").TObject<{
57
+ agent: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"claude_code">, import("@sinclair/typebox").TLiteral<"codex">]>;
58
+ session_id: import("@sinclair/typebox").TString;
59
+ first_prompt_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
60
+ started_at: import("@sinclair/typebox").TString;
61
+ analyzer_version: import("@sinclair/typebox").TString;
62
+ parser_version: import("@sinclair/typebox").TString;
63
+ interventions: import("@sinclair/typebox").TObject<Record<"answer" | "approval" | "ci_relay" | "continue" | "other" | "review_relay", import("@sinclair/typebox").TSchema>>;
64
+ loops: import("@sinclair/typebox").TObject<Record<"ci_fix" | "dependency_update" | "issue_to_pr" | "lint_fix" | "review_response" | "test_fix", import("@sinclair/typebox").TSchema>>;
65
+ mcp_servers: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
66
+ server: import("@sinclair/typebox").TString;
67
+ configured: import("@sinclair/typebox").TBoolean;
68
+ measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
69
+ calls: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
70
+ failures_measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
71
+ failures: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
72
+ }>, import("@sinclair/typebox").TObject<{
73
+ server: import("@sinclair/typebox").TString;
74
+ configured: import("@sinclair/typebox").TBoolean;
75
+ measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
76
+ calls: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
77
+ failures_measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
78
+ failures: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
79
+ }>, import("@sinclair/typebox").TObject<{
80
+ server: import("@sinclair/typebox").TString;
81
+ configured: import("@sinclair/typebox").TBoolean;
82
+ measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
83
+ calls: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
84
+ failures_measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
85
+ failures: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
86
+ }>, import("@sinclair/typebox").TObject<{
87
+ server: import("@sinclair/typebox").TString;
88
+ configured: import("@sinclair/typebox").TBoolean;
89
+ measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
90
+ calls: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
91
+ failures_measurement: import("@sinclair/typebox").TLiteral<"measured" | "not_measured">;
92
+ failures: import("@sinclair/typebox").TInteger | import("@sinclair/typebox").TNull;
93
+ }>]>>;
94
+ proposals: import("@sinclair/typebox").TObject<Record<"agent" | "claude_md" | "command" | "hook" | "loop_prompt" | "mcp_config" | "permissions" | "rule" | "skill", import("@sinclair/typebox").TSchema>>;
95
+ records_skipped: import("@sinclair/typebox").TInteger;
96
+ }>;
97
+ readonly "session-usage-summary": import("@sinclair/typebox").TObject<{
98
+ agent: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"claude_code">, import("@sinclair/typebox").TLiteral<"codex">]>;
99
+ session_id: import("@sinclair/typebox").TString;
100
+ first_prompt_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
101
+ started_at: import("@sinclair/typebox").TString;
102
+ last_event_at: import("@sinclair/typebox").TString;
103
+ collector_version: import("@sinclair/typebox").TString;
104
+ skills: import("@sinclair/typebox").TObject<{
105
+ items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
106
+ name: import("@sinclair/typebox").TString;
107
+ calls: import("@sinclair/typebox").TInteger;
108
+ failures: import("@sinclair/typebox").TInteger;
109
+ }>>;
110
+ other: import("@sinclair/typebox").TObject<{
111
+ calls: import("@sinclair/typebox").TInteger;
112
+ failures: import("@sinclair/typebox").TInteger;
113
+ }>;
114
+ }>;
115
+ commands: import("@sinclair/typebox").TObject<{
116
+ items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
117
+ name: import("@sinclair/typebox").TString;
118
+ calls: import("@sinclair/typebox").TInteger;
119
+ }>>;
120
+ other: import("@sinclair/typebox").TObject<{
121
+ calls: import("@sinclair/typebox").TInteger;
122
+ }>;
123
+ }>;
124
+ subagents: import("@sinclair/typebox").TObject<{
125
+ items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
126
+ name: import("@sinclair/typebox").TString;
127
+ calls: import("@sinclair/typebox").TInteger;
128
+ failures: import("@sinclair/typebox").TInteger;
129
+ }>>;
130
+ other: import("@sinclair/typebox").TObject<{
131
+ calls: import("@sinclair/typebox").TInteger;
132
+ failures: import("@sinclair/typebox").TInteger;
133
+ }>;
134
+ }>;
135
+ mcp_servers: import("@sinclair/typebox").TObject<{
136
+ items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
137
+ name: import("@sinclair/typebox").TString;
138
+ calls: import("@sinclair/typebox").TInteger;
139
+ failures: import("@sinclair/typebox").TInteger;
140
+ }>>;
141
+ other: import("@sinclair/typebox").TObject<{
142
+ calls: import("@sinclair/typebox").TInteger;
143
+ failures: import("@sinclair/typebox").TInteger;
144
+ }>;
145
+ }>;
146
+ permission_requests: import("@sinclair/typebox").TInteger;
147
+ compactions: import("@sinclair/typebox").TObject<{
148
+ auto: import("@sinclair/typebox").TInteger;
149
+ manual: import("@sinclair/typebox").TInteger;
150
+ }>;
151
+ }>;
152
+ readonly "ingest-issue": import("@sinclair/typebox").TObject<{
153
+ external_id: import("@sinclair/typebox").TString;
154
+ project_key: import("@sinclair/typebox").TString;
155
+ identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
156
+ title: import("@sinclair/typebox").TString;
157
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
158
+ status_category: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<string>[]>;
159
+ raw_status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
160
+ is_blocked: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
161
+ assignee: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
162
+ priority: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
163
+ due_on: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
164
+ parent_external_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
165
+ url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
166
+ source_updated_at: import("@sinclair/typebox").TString;
167
+ }>;
168
+ readonly "ingest-event": import("@sinclair/typebox").TObject<{
169
+ event_id: import("@sinclair/typebox").TString;
170
+ event_type: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<string>[]>;
171
+ occurred_at: import("@sinclair/typebox").TString;
172
+ actor_type: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<string>[]>;
173
+ actor_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
174
+ entity: import("@sinclair/typebox").TObject<{
175
+ type: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<string>[]>;
176
+ id: import("@sinclair/typebox").TString;
177
+ }>;
178
+ payload: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
179
+ correlation_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
180
+ causation_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
181
+ }>;
182
+ };
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import { AnalysisReportSchema } from "./schemas/analysis-report.js";
2
+ import { ConfigSnapshotSchema } from "./schemas/config-snapshot.js";
3
+ import { IngestEventSchema, IngestIssueSchema, } from "./schemas/ingest-items.js";
4
+ import { SessionImportSchema } from "./schemas/session-import.js";
5
+ import { SessionRegistrationSchema } from "./schemas/session-registration.js";
6
+ import { SessionUsageSummarySchema } from "./schemas/session-usage-summary.js";
7
+ export * from "./attributes.js";
8
+ export { REDACTION_KINDS, REDACTION_RULES, redactText, } from "./redaction.js";
9
+ export { normalizeRepository } from "./repository.js";
10
+ export * from "./schemas/analysis-report.js";
11
+ export { SEMCONV_MAJOR, schemaId } from "./schemas/common.js";
12
+ export * from "./schemas/config-snapshot.js";
13
+ export * from "./schemas/ingest-items.js";
14
+ export * from "./schemas/session-import.js";
15
+ export { REGISTRATION_SOURCES, SessionRegistrationSchema, } from "./schemas/session-registration.js";
16
+ export * from "./schemas/session-usage-summary.js";
17
+ export { isInstant, isToken } from "./values.js";
18
+ // 利用側はこの一覧から、自分のvalidatorでschemaをcompileする。Workers上ではコード生成を伴わないvalidatorを選ぶ。
19
+ export const SCHEMAS = {
20
+ "session-registration": SessionRegistrationSchema,
21
+ "session-import": SessionImportSchema,
22
+ "config-snapshot": ConfigSnapshotSchema,
23
+ "analysis-report": AnalysisReportSchema,
24
+ "session-usage-summary": SessionUsageSummarySchema,
25
+ "ingest-issue": IngestIssueSchema,
26
+ "ingest-event": IngestEventSchema,
27
+ };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EACN,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACN,eAAe,EACf,eAAe,EAKf,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACN,oBAAoB,EAEpB,yBAAyB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,sBAAsB,EAAE,yBAAyB;IACjD,gBAAgB,EAAE,mBAAmB;IACrC,iBAAiB,EAAE,oBAAoB;IACvC,iBAAiB,EAAE,oBAAoB;IACvC,uBAAuB,EAAE,yBAAyB;IAClD,cAAc,EAAE,iBAAiB;IACjC,cAAc,EAAE,iBAAiB;CACxB,CAAC"}
@@ -0,0 +1,25 @@
1
+ export declare const REDACTION_KINDS: readonly ["private_key", "connection_string", "jwt", "api_key", "bearer_token", "email", "phone"];
2
+ export type RedactionKind = (typeof REDACTION_KINDS)[number];
3
+ export type RedactionRule = Readonly<{
4
+ kind: RedactionKind;
5
+ pattern: RegExp;
6
+ }>;
7
+ /**
8
+ * 正規表現の正本(privacy-and-retention.md「Redaction」)。上から順に当て、先に伏せた箇所を後の規則で
9
+ * 二重に数えない。接続文字列はemailより先、API keyはBearerより先に当てる。
10
+ * 電話番号は、UUIDと日付の区切りに一致しないよう、前後に`-`と英数字を許さない。
11
+ * 可変長の先頭を持つ規則は、直前が同じ文字種でない位置からだけ始める。途中の位置から何度も走査し直すと、
12
+ * 処理時間が長さの2乗になるためである。
13
+ * patternはglobalであり、`lastIndex`を持つ。`replace`以外(`test`、`exec`)で使う場合は写しを作る。
14
+ */
15
+ export declare const REDACTION_RULES: readonly RedactionRule[];
16
+ export type RedactedText = Readonly<{
17
+ text: string;
18
+ count: number;
19
+ }>;
20
+ export type RedactOptions = Readonly<{
21
+ /** 名前を表すfieldでは、数字を含む名前を電話番号と誤検知して識別子を書き換えないよう使う。 */
22
+ skipPhone?: boolean;
23
+ }>;
24
+ /** 一致した箇所を`[REDACTED:<種類>]`に置き換える。countは置き換えた箇所の数。 */
25
+ export declare function redactText(text: string, options?: RedactOptions): RedactedText;