@harnesskit/shared 0.1.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.
@@ -0,0 +1,2 @@
1
+ export { costSummarySchema, dailyCostSchema, projectCostSchema, sessionDetailSchema, sessionListSchema, sessionSummarySchema, timelineActionSchema, } from './schemas.js';
2
+ export type { CostSummary, DailyCost, ProjectCost, SessionDetail, SessionList, SessionSummary, TimelineAction, } from './schemas.js';
@@ -0,0 +1,2 @@
1
+ export { costSummarySchema, dailyCostSchema, projectCostSchema, sessionDetailSchema, sessionListSchema, sessionSummarySchema, timelineActionSchema, } from './schemas.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,174 @@
1
+ import { z } from 'zod';
2
+ export declare const sessionSummarySchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ toolSource: z.ZodEnum<{
5
+ claude_code: "claude_code";
6
+ codex: "codex";
7
+ opencode: "opencode";
8
+ }>;
9
+ status: z.ZodEnum<{
10
+ success: "success";
11
+ failed: "failed";
12
+ cancelled: "cancelled";
13
+ unknown: "unknown";
14
+ }>;
15
+ startedAt: z.ZodString;
16
+ endedAt: z.ZodNullable<z.ZodString>;
17
+ durationMs: z.ZodNullable<z.ZodNumber>;
18
+ inputTokens: z.ZodNullable<z.ZodNumber>;
19
+ outputTokens: z.ZodNullable<z.ZodNumber>;
20
+ costUsd: z.ZodNullable<z.ZodNumber>;
21
+ costEstimated: z.ZodBoolean;
22
+ outcomeReason: z.ZodNullable<z.ZodString>;
23
+ totalActions: z.ZodNumber;
24
+ }, z.core.$strip>;
25
+ export declare const sessionListSchema: z.ZodObject<{
26
+ sessions: z.ZodArray<z.ZodObject<{
27
+ id: z.ZodString;
28
+ toolSource: z.ZodEnum<{
29
+ claude_code: "claude_code";
30
+ codex: "codex";
31
+ opencode: "opencode";
32
+ }>;
33
+ status: z.ZodEnum<{
34
+ success: "success";
35
+ failed: "failed";
36
+ cancelled: "cancelled";
37
+ unknown: "unknown";
38
+ }>;
39
+ startedAt: z.ZodString;
40
+ endedAt: z.ZodNullable<z.ZodString>;
41
+ durationMs: z.ZodNullable<z.ZodNumber>;
42
+ inputTokens: z.ZodNullable<z.ZodNumber>;
43
+ outputTokens: z.ZodNullable<z.ZodNumber>;
44
+ costUsd: z.ZodNullable<z.ZodNumber>;
45
+ costEstimated: z.ZodBoolean;
46
+ outcomeReason: z.ZodNullable<z.ZodString>;
47
+ totalActions: z.ZodNumber;
48
+ }, z.core.$strip>>;
49
+ }, z.core.$strip>;
50
+ export declare const timelineActionSchema: z.ZodObject<{
51
+ id: z.ZodString;
52
+ seq: z.ZodNumber;
53
+ type: z.ZodEnum<{
54
+ llm_call: "llm_call";
55
+ tool_call: "tool_call";
56
+ mcp: "mcp";
57
+ file_edit: "file_edit";
58
+ system: "system";
59
+ error: "error";
60
+ }>;
61
+ name: z.ZodString;
62
+ status: z.ZodEnum<{
63
+ success: "success";
64
+ cancelled: "cancelled";
65
+ error: "error";
66
+ timeout: "timeout";
67
+ }>;
68
+ startedAt: z.ZodString;
69
+ endedAt: z.ZodNullable<z.ZodString>;
70
+ durationMs: z.ZodNullable<z.ZodNumber>;
71
+ inputTokens: z.ZodNullable<z.ZodNumber>;
72
+ outputTokens: z.ZodNullable<z.ZodNumber>;
73
+ costUsd: z.ZodNullable<z.ZodNumber>;
74
+ costEstimated: z.ZodBoolean;
75
+ errorCode: z.ZodNullable<z.ZodString>;
76
+ errorMessage: z.ZodNullable<z.ZodString>;
77
+ filePath: z.ZodNullable<z.ZodString>;
78
+ fileOp: z.ZodNullable<z.ZodEnum<{
79
+ read: "read";
80
+ write: "write";
81
+ edit: "edit";
82
+ delete: "delete";
83
+ }>>;
84
+ }, z.core.$strip>;
85
+ export declare const sessionDetailSchema: z.ZodObject<{
86
+ session: z.ZodObject<{
87
+ id: z.ZodString;
88
+ toolSource: z.ZodEnum<{
89
+ claude_code: "claude_code";
90
+ codex: "codex";
91
+ opencode: "opencode";
92
+ }>;
93
+ status: z.ZodEnum<{
94
+ success: "success";
95
+ failed: "failed";
96
+ cancelled: "cancelled";
97
+ unknown: "unknown";
98
+ }>;
99
+ startedAt: z.ZodString;
100
+ endedAt: z.ZodNullable<z.ZodString>;
101
+ durationMs: z.ZodNullable<z.ZodNumber>;
102
+ inputTokens: z.ZodNullable<z.ZodNumber>;
103
+ outputTokens: z.ZodNullable<z.ZodNumber>;
104
+ costUsd: z.ZodNullable<z.ZodNumber>;
105
+ costEstimated: z.ZodBoolean;
106
+ outcomeReason: z.ZodNullable<z.ZodString>;
107
+ totalActions: z.ZodNumber;
108
+ }, z.core.$strip>;
109
+ actions: z.ZodArray<z.ZodObject<{
110
+ id: z.ZodString;
111
+ seq: z.ZodNumber;
112
+ type: z.ZodEnum<{
113
+ llm_call: "llm_call";
114
+ tool_call: "tool_call";
115
+ mcp: "mcp";
116
+ file_edit: "file_edit";
117
+ system: "system";
118
+ error: "error";
119
+ }>;
120
+ name: z.ZodString;
121
+ status: z.ZodEnum<{
122
+ success: "success";
123
+ cancelled: "cancelled";
124
+ error: "error";
125
+ timeout: "timeout";
126
+ }>;
127
+ startedAt: z.ZodString;
128
+ endedAt: z.ZodNullable<z.ZodString>;
129
+ durationMs: z.ZodNullable<z.ZodNumber>;
130
+ inputTokens: z.ZodNullable<z.ZodNumber>;
131
+ outputTokens: z.ZodNullable<z.ZodNumber>;
132
+ costUsd: z.ZodNullable<z.ZodNumber>;
133
+ costEstimated: z.ZodBoolean;
134
+ errorCode: z.ZodNullable<z.ZodString>;
135
+ errorMessage: z.ZodNullable<z.ZodString>;
136
+ filePath: z.ZodNullable<z.ZodString>;
137
+ fileOp: z.ZodNullable<z.ZodEnum<{
138
+ read: "read";
139
+ write: "write";
140
+ edit: "edit";
141
+ delete: "delete";
142
+ }>>;
143
+ }, z.core.$strip>>;
144
+ }, z.core.$strip>;
145
+ export declare const dailyCostSchema: z.ZodObject<{
146
+ date: z.ZodString;
147
+ costUsd: z.ZodNumber;
148
+ }, z.core.$strip>;
149
+ export declare const projectCostSchema: z.ZodObject<{
150
+ projectId: z.ZodString;
151
+ projectName: z.ZodString;
152
+ costUsd: z.ZodNumber;
153
+ }, z.core.$strip>;
154
+ export declare const costSummarySchema: z.ZodObject<{
155
+ from: z.ZodString;
156
+ to: z.ZodString;
157
+ currency: z.ZodLiteral<"USD">;
158
+ daily: z.ZodArray<z.ZodObject<{
159
+ date: z.ZodString;
160
+ costUsd: z.ZodNumber;
161
+ }, z.core.$strip>>;
162
+ byProject: z.ZodArray<z.ZodObject<{
163
+ projectId: z.ZodString;
164
+ projectName: z.ZodString;
165
+ costUsd: z.ZodNumber;
166
+ }, z.core.$strip>>;
167
+ }, z.core.$strip>;
168
+ export type SessionSummary = z.infer<typeof sessionSummarySchema>;
169
+ export type SessionList = z.infer<typeof sessionListSchema>;
170
+ export type TimelineAction = z.infer<typeof timelineActionSchema>;
171
+ export type SessionDetail = z.infer<typeof sessionDetailSchema>;
172
+ export type DailyCost = z.infer<typeof dailyCostSchema>;
173
+ export type ProjectCost = z.infer<typeof projectCostSchema>;
174
+ export type CostSummary = z.infer<typeof costSummarySchema>;
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ import { actionStatusSchema, actionTypeSchema, fileOpSchema, sessionStatusSchema, toolSourceSchema, } from '../ingestion/schemas.js';
3
+ export const sessionSummarySchema = z.object({
4
+ id: z.string().uuid(),
5
+ toolSource: toolSourceSchema,
6
+ status: sessionStatusSchema,
7
+ startedAt: z.string().datetime(),
8
+ endedAt: z.string().datetime().nullable(),
9
+ durationMs: z.number().int().nonnegative().nullable(),
10
+ inputTokens: z.number().int().nonnegative().nullable(),
11
+ outputTokens: z.number().int().nonnegative().nullable(),
12
+ costUsd: z.number().nonnegative().nullable(),
13
+ costEstimated: z.boolean(),
14
+ outcomeReason: z.string().nullable(),
15
+ totalActions: z.number().int().nonnegative(),
16
+ });
17
+ export const sessionListSchema = z.object({
18
+ sessions: z.array(sessionSummarySchema),
19
+ });
20
+ export const timelineActionSchema = z.object({
21
+ id: z.string().uuid(),
22
+ seq: z.number().int().nonnegative(),
23
+ type: actionTypeSchema,
24
+ name: z.string(),
25
+ status: actionStatusSchema,
26
+ startedAt: z.string().datetime(),
27
+ endedAt: z.string().datetime().nullable(),
28
+ durationMs: z.number().int().nonnegative().nullable(),
29
+ inputTokens: z.number().int().nonnegative().nullable(),
30
+ outputTokens: z.number().int().nonnegative().nullable(),
31
+ costUsd: z.number().nonnegative().nullable(),
32
+ costEstimated: z.boolean(),
33
+ errorCode: z.string().nullable(),
34
+ errorMessage: z.string().nullable(),
35
+ filePath: z.string().nullable(),
36
+ fileOp: fileOpSchema.nullable(),
37
+ });
38
+ export const sessionDetailSchema = z.object({
39
+ session: sessionSummarySchema,
40
+ actions: z.array(timelineActionSchema),
41
+ });
42
+ export const dailyCostSchema = z.object({
43
+ date: z.string(),
44
+ costUsd: z.number().nonnegative(),
45
+ });
46
+ export const projectCostSchema = z.object({
47
+ projectId: z.string().uuid(),
48
+ projectName: z.string(),
49
+ costUsd: z.number().nonnegative(),
50
+ });
51
+ export const costSummarySchema = z.object({
52
+ from: z.string(),
53
+ to: z.string(),
54
+ currency: z.literal('USD'),
55
+ daily: z.array(dailyCostSchema),
56
+ byProject: z.array(projectCostSchema),
57
+ });
58
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/dashboard/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,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OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;CAClC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;CAClC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC1B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IAC/B,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;CACtC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ingestion/index.js';
2
+ export * from './dashboard/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './ingestion/index.js';
2
+ export * from './dashboard/index.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { actionPayloadSchema, actionStatusSchema, actionTypeSchema, errorPayloadSchema, eventTypeSchema, fileOpSchema, ingestionBatchSchema, ingestionEventSchema, sessionEndPayloadSchema, sessionStartPayloadSchema, sessionStatusSchema, toolSourceSchema, } from './schemas.js';
2
+ export type { IngestionBatch, IngestionEvent } from './schemas.js';
@@ -0,0 +1,2 @@
1
+ export { actionPayloadSchema, actionStatusSchema, actionTypeSchema, errorPayloadSchema, eventTypeSchema, fileOpSchema, ingestionBatchSchema, ingestionEventSchema, sessionEndPayloadSchema, sessionStartPayloadSchema, sessionStatusSchema, toolSourceSchema, } from './schemas.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ingestion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,334 @@
1
+ import { z } from 'zod';
2
+ export declare const toolSourceSchema: z.ZodEnum<{
3
+ claude_code: "claude_code";
4
+ codex: "codex";
5
+ opencode: "opencode";
6
+ }>;
7
+ export declare const sessionStatusSchema: z.ZodEnum<{
8
+ success: "success";
9
+ failed: "failed";
10
+ cancelled: "cancelled";
11
+ unknown: "unknown";
12
+ }>;
13
+ export declare const actionTypeSchema: z.ZodEnum<{
14
+ llm_call: "llm_call";
15
+ tool_call: "tool_call";
16
+ mcp: "mcp";
17
+ file_edit: "file_edit";
18
+ system: "system";
19
+ error: "error";
20
+ }>;
21
+ export declare const actionStatusSchema: z.ZodEnum<{
22
+ success: "success";
23
+ cancelled: "cancelled";
24
+ error: "error";
25
+ timeout: "timeout";
26
+ }>;
27
+ export declare const fileOpSchema: z.ZodEnum<{
28
+ read: "read";
29
+ write: "write";
30
+ edit: "edit";
31
+ delete: "delete";
32
+ }>;
33
+ export declare const eventTypeSchema: z.ZodEnum<{
34
+ error: "error";
35
+ session_start: "session_start";
36
+ session_end: "session_end";
37
+ action: "action";
38
+ }>;
39
+ export declare const sessionStartPayloadSchema: z.ZodObject<{
40
+ started_at: z.ZodString;
41
+ sample_rate: z.ZodOptional<z.ZodNumber>;
42
+ capture_config_id: z.ZodOptional<z.ZodString>;
43
+ user_ref: z.ZodOptional<z.ZodString>;
44
+ machine_ref: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strip>;
46
+ export declare const sessionEndPayloadSchema: z.ZodObject<{
47
+ ended_at: z.ZodString;
48
+ status: z.ZodEnum<{
49
+ success: "success";
50
+ failed: "failed";
51
+ cancelled: "cancelled";
52
+ unknown: "unknown";
53
+ }>;
54
+ outcome_reason: z.ZodOptional<z.ZodString>;
55
+ input_tokens: z.ZodOptional<z.ZodNumber>;
56
+ output_tokens: z.ZodOptional<z.ZodNumber>;
57
+ cost_usd: z.ZodOptional<z.ZodNumber>;
58
+ cost_estimated: z.ZodOptional<z.ZodBoolean>;
59
+ }, z.core.$strip>;
60
+ export declare const actionPayloadSchema: z.ZodObject<{
61
+ id: z.ZodString;
62
+ seq: z.ZodNumber;
63
+ type: z.ZodEnum<{
64
+ llm_call: "llm_call";
65
+ tool_call: "tool_call";
66
+ mcp: "mcp";
67
+ file_edit: "file_edit";
68
+ system: "system";
69
+ error: "error";
70
+ }>;
71
+ name: z.ZodString;
72
+ status: z.ZodEnum<{
73
+ success: "success";
74
+ cancelled: "cancelled";
75
+ error: "error";
76
+ timeout: "timeout";
77
+ }>;
78
+ started_at: z.ZodString;
79
+ ended_at: z.ZodOptional<z.ZodString>;
80
+ input_tokens: z.ZodOptional<z.ZodNumber>;
81
+ output_tokens: z.ZodOptional<z.ZodNumber>;
82
+ cost_usd: z.ZodOptional<z.ZodNumber>;
83
+ cost_estimated: z.ZodOptional<z.ZodBoolean>;
84
+ request_payload: z.ZodOptional<z.ZodUnknown>;
85
+ response_payload: z.ZodOptional<z.ZodUnknown>;
86
+ payload_truncated: z.ZodOptional<z.ZodBoolean>;
87
+ error_code: z.ZodOptional<z.ZodString>;
88
+ error_message: z.ZodOptional<z.ZodString>;
89
+ file_path: z.ZodOptional<z.ZodString>;
90
+ file_op: z.ZodOptional<z.ZodEnum<{
91
+ read: "read";
92
+ write: "write";
93
+ edit: "edit";
94
+ delete: "delete";
95
+ }>>;
96
+ }, z.core.$strip>;
97
+ export declare const errorPayloadSchema: z.ZodObject<{
98
+ error_code: z.ZodString;
99
+ error_message: z.ZodString;
100
+ action_id: z.ZodOptional<z.ZodString>;
101
+ severity: z.ZodOptional<z.ZodEnum<{
102
+ error: "error";
103
+ info: "info";
104
+ warn: "warn";
105
+ }>>;
106
+ }, z.core.$strip>;
107
+ export declare const ingestionEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
108
+ version: z.ZodString;
109
+ project_id: z.ZodString;
110
+ session_id: z.ZodString;
111
+ tool_source: z.ZodEnum<{
112
+ claude_code: "claude_code";
113
+ codex: "codex";
114
+ opencode: "opencode";
115
+ }>;
116
+ timestamp: z.ZodString;
117
+ event_type: z.ZodLiteral<"session_start">;
118
+ payload: z.ZodObject<{
119
+ started_at: z.ZodString;
120
+ sample_rate: z.ZodOptional<z.ZodNumber>;
121
+ capture_config_id: z.ZodOptional<z.ZodString>;
122
+ user_ref: z.ZodOptional<z.ZodString>;
123
+ machine_ref: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>;
125
+ }, z.core.$strip>, z.ZodObject<{
126
+ version: z.ZodString;
127
+ project_id: z.ZodString;
128
+ session_id: z.ZodString;
129
+ tool_source: z.ZodEnum<{
130
+ claude_code: "claude_code";
131
+ codex: "codex";
132
+ opencode: "opencode";
133
+ }>;
134
+ timestamp: z.ZodString;
135
+ event_type: z.ZodLiteral<"session_end">;
136
+ payload: z.ZodObject<{
137
+ ended_at: z.ZodString;
138
+ status: z.ZodEnum<{
139
+ success: "success";
140
+ failed: "failed";
141
+ cancelled: "cancelled";
142
+ unknown: "unknown";
143
+ }>;
144
+ outcome_reason: z.ZodOptional<z.ZodString>;
145
+ input_tokens: z.ZodOptional<z.ZodNumber>;
146
+ output_tokens: z.ZodOptional<z.ZodNumber>;
147
+ cost_usd: z.ZodOptional<z.ZodNumber>;
148
+ cost_estimated: z.ZodOptional<z.ZodBoolean>;
149
+ }, z.core.$strip>;
150
+ }, z.core.$strip>, z.ZodObject<{
151
+ version: z.ZodString;
152
+ project_id: z.ZodString;
153
+ session_id: z.ZodString;
154
+ tool_source: z.ZodEnum<{
155
+ claude_code: "claude_code";
156
+ codex: "codex";
157
+ opencode: "opencode";
158
+ }>;
159
+ timestamp: z.ZodString;
160
+ event_type: z.ZodLiteral<"action">;
161
+ payload: z.ZodObject<{
162
+ id: z.ZodString;
163
+ seq: z.ZodNumber;
164
+ type: z.ZodEnum<{
165
+ llm_call: "llm_call";
166
+ tool_call: "tool_call";
167
+ mcp: "mcp";
168
+ file_edit: "file_edit";
169
+ system: "system";
170
+ error: "error";
171
+ }>;
172
+ name: z.ZodString;
173
+ status: z.ZodEnum<{
174
+ success: "success";
175
+ cancelled: "cancelled";
176
+ error: "error";
177
+ timeout: "timeout";
178
+ }>;
179
+ started_at: z.ZodString;
180
+ ended_at: z.ZodOptional<z.ZodString>;
181
+ input_tokens: z.ZodOptional<z.ZodNumber>;
182
+ output_tokens: z.ZodOptional<z.ZodNumber>;
183
+ cost_usd: z.ZodOptional<z.ZodNumber>;
184
+ cost_estimated: z.ZodOptional<z.ZodBoolean>;
185
+ request_payload: z.ZodOptional<z.ZodUnknown>;
186
+ response_payload: z.ZodOptional<z.ZodUnknown>;
187
+ payload_truncated: z.ZodOptional<z.ZodBoolean>;
188
+ error_code: z.ZodOptional<z.ZodString>;
189
+ error_message: z.ZodOptional<z.ZodString>;
190
+ file_path: z.ZodOptional<z.ZodString>;
191
+ file_op: z.ZodOptional<z.ZodEnum<{
192
+ read: "read";
193
+ write: "write";
194
+ edit: "edit";
195
+ delete: "delete";
196
+ }>>;
197
+ }, z.core.$strip>;
198
+ }, z.core.$strip>, z.ZodObject<{
199
+ version: z.ZodString;
200
+ project_id: z.ZodString;
201
+ session_id: z.ZodString;
202
+ tool_source: z.ZodEnum<{
203
+ claude_code: "claude_code";
204
+ codex: "codex";
205
+ opencode: "opencode";
206
+ }>;
207
+ timestamp: z.ZodString;
208
+ event_type: z.ZodLiteral<"error">;
209
+ payload: z.ZodObject<{
210
+ error_code: z.ZodString;
211
+ error_message: z.ZodString;
212
+ action_id: z.ZodOptional<z.ZodString>;
213
+ severity: z.ZodOptional<z.ZodEnum<{
214
+ error: "error";
215
+ info: "info";
216
+ warn: "warn";
217
+ }>>;
218
+ }, z.core.$strip>;
219
+ }, z.core.$strip>], "event_type">;
220
+ export declare const ingestionBatchSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
221
+ version: z.ZodString;
222
+ project_id: z.ZodString;
223
+ session_id: z.ZodString;
224
+ tool_source: z.ZodEnum<{
225
+ claude_code: "claude_code";
226
+ codex: "codex";
227
+ opencode: "opencode";
228
+ }>;
229
+ timestamp: z.ZodString;
230
+ event_type: z.ZodLiteral<"session_start">;
231
+ payload: z.ZodObject<{
232
+ started_at: z.ZodString;
233
+ sample_rate: z.ZodOptional<z.ZodNumber>;
234
+ capture_config_id: z.ZodOptional<z.ZodString>;
235
+ user_ref: z.ZodOptional<z.ZodString>;
236
+ machine_ref: z.ZodOptional<z.ZodString>;
237
+ }, z.core.$strip>;
238
+ }, z.core.$strip>, z.ZodObject<{
239
+ version: z.ZodString;
240
+ project_id: z.ZodString;
241
+ session_id: z.ZodString;
242
+ tool_source: z.ZodEnum<{
243
+ claude_code: "claude_code";
244
+ codex: "codex";
245
+ opencode: "opencode";
246
+ }>;
247
+ timestamp: z.ZodString;
248
+ event_type: z.ZodLiteral<"session_end">;
249
+ payload: z.ZodObject<{
250
+ ended_at: z.ZodString;
251
+ status: z.ZodEnum<{
252
+ success: "success";
253
+ failed: "failed";
254
+ cancelled: "cancelled";
255
+ unknown: "unknown";
256
+ }>;
257
+ outcome_reason: z.ZodOptional<z.ZodString>;
258
+ input_tokens: z.ZodOptional<z.ZodNumber>;
259
+ output_tokens: z.ZodOptional<z.ZodNumber>;
260
+ cost_usd: z.ZodOptional<z.ZodNumber>;
261
+ cost_estimated: z.ZodOptional<z.ZodBoolean>;
262
+ }, z.core.$strip>;
263
+ }, z.core.$strip>, z.ZodObject<{
264
+ version: z.ZodString;
265
+ project_id: z.ZodString;
266
+ session_id: z.ZodString;
267
+ tool_source: z.ZodEnum<{
268
+ claude_code: "claude_code";
269
+ codex: "codex";
270
+ opencode: "opencode";
271
+ }>;
272
+ timestamp: z.ZodString;
273
+ event_type: z.ZodLiteral<"action">;
274
+ payload: z.ZodObject<{
275
+ id: z.ZodString;
276
+ seq: z.ZodNumber;
277
+ type: z.ZodEnum<{
278
+ llm_call: "llm_call";
279
+ tool_call: "tool_call";
280
+ mcp: "mcp";
281
+ file_edit: "file_edit";
282
+ system: "system";
283
+ error: "error";
284
+ }>;
285
+ name: z.ZodString;
286
+ status: z.ZodEnum<{
287
+ success: "success";
288
+ cancelled: "cancelled";
289
+ error: "error";
290
+ timeout: "timeout";
291
+ }>;
292
+ started_at: z.ZodString;
293
+ ended_at: z.ZodOptional<z.ZodString>;
294
+ input_tokens: z.ZodOptional<z.ZodNumber>;
295
+ output_tokens: z.ZodOptional<z.ZodNumber>;
296
+ cost_usd: z.ZodOptional<z.ZodNumber>;
297
+ cost_estimated: z.ZodOptional<z.ZodBoolean>;
298
+ request_payload: z.ZodOptional<z.ZodUnknown>;
299
+ response_payload: z.ZodOptional<z.ZodUnknown>;
300
+ payload_truncated: z.ZodOptional<z.ZodBoolean>;
301
+ error_code: z.ZodOptional<z.ZodString>;
302
+ error_message: z.ZodOptional<z.ZodString>;
303
+ file_path: z.ZodOptional<z.ZodString>;
304
+ file_op: z.ZodOptional<z.ZodEnum<{
305
+ read: "read";
306
+ write: "write";
307
+ edit: "edit";
308
+ delete: "delete";
309
+ }>>;
310
+ }, z.core.$strip>;
311
+ }, z.core.$strip>, z.ZodObject<{
312
+ version: z.ZodString;
313
+ project_id: z.ZodString;
314
+ session_id: z.ZodString;
315
+ tool_source: z.ZodEnum<{
316
+ claude_code: "claude_code";
317
+ codex: "codex";
318
+ opencode: "opencode";
319
+ }>;
320
+ timestamp: z.ZodString;
321
+ event_type: z.ZodLiteral<"error">;
322
+ payload: z.ZodObject<{
323
+ error_code: z.ZodString;
324
+ error_message: z.ZodString;
325
+ action_id: z.ZodOptional<z.ZodString>;
326
+ severity: z.ZodOptional<z.ZodEnum<{
327
+ error: "error";
328
+ info: "info";
329
+ warn: "warn";
330
+ }>>;
331
+ }, z.core.$strip>;
332
+ }, z.core.$strip>], "event_type">>;
333
+ export type IngestionEvent = z.infer<typeof ingestionEventSchema>;
334
+ export type IngestionBatch = z.infer<typeof ingestionBatchSchema>;
@@ -0,0 +1,83 @@
1
+ import { z } from 'zod';
2
+ export const toolSourceSchema = z.enum(['claude_code', 'codex', 'opencode']);
3
+ export const sessionStatusSchema = z.enum(['success', 'failed', 'cancelled', 'unknown']);
4
+ export const actionTypeSchema = z.enum([
5
+ 'llm_call',
6
+ 'tool_call',
7
+ 'mcp',
8
+ 'file_edit',
9
+ 'system',
10
+ 'error',
11
+ ]);
12
+ export const actionStatusSchema = z.enum(['success', 'error', 'timeout', 'cancelled']);
13
+ export const fileOpSchema = z.enum(['read', 'write', 'edit', 'delete']);
14
+ export const eventTypeSchema = z.enum(['session_start', 'session_end', 'action', 'error']);
15
+ const baseEventSchema = z.object({
16
+ version: z.string(),
17
+ project_id: z.string(),
18
+ session_id: z.string().uuid(),
19
+ tool_source: toolSourceSchema,
20
+ timestamp: z.string().datetime(),
21
+ });
22
+ export const sessionStartPayloadSchema = z.object({
23
+ started_at: z.string().datetime(),
24
+ sample_rate: z.number().min(0).max(1).optional(),
25
+ capture_config_id: z.string().optional(),
26
+ user_ref: z.string().optional(),
27
+ machine_ref: z.string().optional(),
28
+ });
29
+ export const sessionEndPayloadSchema = z.object({
30
+ ended_at: z.string().datetime(),
31
+ status: sessionStatusSchema,
32
+ outcome_reason: z.string().optional(),
33
+ input_tokens: z.number().int().nonnegative().optional(),
34
+ output_tokens: z.number().int().nonnegative().optional(),
35
+ cost_usd: z.number().nonnegative().optional(),
36
+ cost_estimated: z.boolean().optional(),
37
+ });
38
+ export const actionPayloadSchema = z.object({
39
+ id: z.string().uuid(),
40
+ seq: z.number().int().nonnegative(),
41
+ type: actionTypeSchema,
42
+ name: z.string(),
43
+ status: actionStatusSchema,
44
+ started_at: z.string().datetime(),
45
+ ended_at: z.string().datetime().optional(),
46
+ input_tokens: z.number().int().nonnegative().optional(),
47
+ output_tokens: z.number().int().nonnegative().optional(),
48
+ cost_usd: z.number().nonnegative().optional(),
49
+ cost_estimated: z.boolean().optional(),
50
+ request_payload: z.unknown().optional(),
51
+ response_payload: z.unknown().optional(),
52
+ payload_truncated: z.boolean().optional(),
53
+ error_code: z.string().optional(),
54
+ error_message: z.string().optional(),
55
+ file_path: z.string().optional(),
56
+ file_op: fileOpSchema.optional(),
57
+ });
58
+ export const errorPayloadSchema = z.object({
59
+ error_code: z.string(),
60
+ error_message: z.string(),
61
+ action_id: z.string().uuid().optional(),
62
+ severity: z.enum(['info', 'warn', 'error']).optional(),
63
+ });
64
+ export const ingestionEventSchema = z.discriminatedUnion('event_type', [
65
+ baseEventSchema.extend({
66
+ event_type: z.literal('session_start'),
67
+ payload: sessionStartPayloadSchema,
68
+ }),
69
+ baseEventSchema.extend({
70
+ event_type: z.literal('session_end'),
71
+ payload: sessionEndPayloadSchema,
72
+ }),
73
+ baseEventSchema.extend({
74
+ event_type: z.literal('action'),
75
+ payload: actionPayloadSchema,
76
+ }),
77
+ baseEventSchema.extend({
78
+ event_type: z.literal('error'),
79
+ payload: errorPayloadSchema,
80
+ }),
81
+ ]);
82
+ export const ingestionBatchSchema = z.array(ingestionEventSchema).min(1);
83
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/ingestion/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EA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AM,CAAC;QACrB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;QACtC,OAAO,EAAE,yBAAyB;KACnC,CAAC;IACF,eAAe,CAAC,MAAM,CAAC;QACrB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;QACpC,OAAO,EAAE,uBAAuB;KACjC,CAAC;IACF,eAAe,CAAC,MAAM,CAAC;QACrB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC/B,OAAO,EAAE,mBAAmB;KAC7B,CAAC;IACF,eAAe,CAAC,MAAM,CAAC;QACrB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QAC9B,OAAO,EAAE,kBAAkB;KAC5B,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@harnesskit/shared",
3
+ "private": false,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "types": "./dist/index.d.ts",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "zod": "^4.3.6"
21
+ },
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "test": "node -e \"\""
27
+ }
28
+ }